class SinatraGenerator::Generator

Public Class Methods

source_root() click to toggle source
# File lib/sinatra_generator/generator.rb, line 16
def self.source_root
  File.dirname(__FILE__)
end

Public Instance Methods

config_ru() click to toggle source
# File lib/sinatra_generator/generator.rb, line 33
def config_ru
  template "#{Generator.source_root}/templates/config.ru", "#{folder_name}/config.ru"
end
create_root() click to toggle source
# File lib/sinatra_generator/generator.rb, line 20
def create_root
  empty_directory folder_name
  #FileUtils.cd destination_root
end
gemfile() click to toggle source
# File lib/sinatra_generator/generator.rb, line 29
def gemfile
  template "#{Generator.source_root}/templates/Gemfile", "#{folder_name}/Gemfile"
end
main_rb() click to toggle source
# File lib/sinatra_generator/generator.rb, line 25
def main_rb
  template "#{Generator.source_root}/templates/main.rb", "#{folder_name}/main.rb"
end
procfile() click to toggle source
# File lib/sinatra_generator/generator.rb, line 37
def procfile
  template "#{Generator.source_root}/templates/Procfile", "#{folder_name}/Procfile" if options[:procfile]
end
public() click to toggle source
# File lib/sinatra_generator/generator.rb, line 55
def public
  if options[:assets] 
    directory "#{Generator.source_root}/templates/public", "#{folder_name}/public"

    if options[:views]
      insert_into_file "#{folder_name}/views/layout.erb", "\n  <link rel='stylesheet' href='/stylesheets/main.css'>",
        :after => '<title>Hello World</title>'
    end
  end
end
views() click to toggle source
# File lib/sinatra_generator/generator.rb, line 41
def views
  if options[:views]
    inside folder_name do

      empty_directory 'views'

      inside 'views' do
        copy_file "#{Generator.source_root}/templates/layout.erb", "layout.erb"
        copy_file "#{Generator.source_root}/templates/index.erb", "index.erb"     
      end
    end
  end
end