Class: SinatraGenerator::Generator
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- SinatraGenerator::Generator
- Includes:
- Thor::Actions
- Defined in:
- lib/sinatra_generator/generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #config_ru ⇒ Object
- #create_root ⇒ Object
- #gemfile ⇒ Object
- #main_rb ⇒ Object
- #procfile ⇒ Object
- #public ⇒ Object
- #views ⇒ Object
Class Method Details
.source_root ⇒ Object
16 17 18 |
# File 'lib/sinatra_generator/generator.rb', line 16 def self.source_root File.dirname(__FILE__) end |
Instance Method Details
#config_ru ⇒ Object
33 34 35 |
# 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 ⇒ Object
20 21 22 23 |
# File 'lib/sinatra_generator/generator.rb', line 20 def create_root empty_directory folder_name #FileUtils.cd destination_root end |
#gemfile ⇒ Object
29 30 31 |
# File 'lib/sinatra_generator/generator.rb', line 29 def gemfile template "#{Generator.source_root}/templates/Gemfile", "#{folder_name}/Gemfile" end |
#main_rb ⇒ Object
25 26 27 |
# File 'lib/sinatra_generator/generator.rb', line 25 def main_rb template "#{Generator.source_root}/templates/main.rb", "#{folder_name}/main.rb" end |
#procfile ⇒ Object
37 38 39 |
# File 'lib/sinatra_generator/generator.rb', line 37 def procfile template "#{Generator.source_root}/templates/Procfile", "#{folder_name}/Procfile" if [:procfile] end |
#public ⇒ Object
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/sinatra_generator/generator.rb', line 55 def public if [:assets] directory "#{Generator.source_root}/templates/public", "#{folder_name}/public" if [: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 ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/sinatra_generator/generator.rb', line 41 def views if [: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 |