Class: Sinatra::CLI::Generator
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Sinatra::CLI::Generator
- Includes:
- Thor::Actions
- Defined in:
- lib/sinatra/cli/generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #bundle_install ⇒ Object
- #create_app_file ⇒ Object
- #create_assets ⇒ Object
- #create_database_config ⇒ Object
- #create_gemfile ⇒ Object
- #create_gitignore ⇒ Object
- #create_models_dir ⇒ Object
- #create_rakefile ⇒ Object
- #create_readme ⇒ Object
- #create_seeds_file ⇒ Object
- #create_views_dir ⇒ Object
- #setup_capybara ⇒ Object
- #setup_rspec ⇒ Object
Class Method Details
.source_root ⇒ Object
10 11 12 |
# File 'lib/sinatra/cli/generator.rb', line 10 def self.source_root File.join(File.dirname(__FILE__), "../../../", "templates") end |
Instance Method Details
#bundle_install ⇒ Object
84 85 86 |
# File 'lib/sinatra/cli/generator.rb', line 84 def bundle_install system "cd #{app_name} && bundle install && cd ../" end |
#create_app_file ⇒ Object
41 42 43 |
# File 'lib/sinatra/cli/generator.rb', line 41 def create_app_file copy_file "app.rb", "#{app_name}/app.rb" end |
#create_assets ⇒ Object
31 32 33 34 35 |
# File 'lib/sinatra/cli/generator.rb', line 31 def create_assets create_file "#{app_name}/public/javascripts/app.js" create_file "#{app_name}/public/stylesheets/app.css" keep_file "#{app_name}/public/images/" end |
#create_database_config ⇒ Object
23 24 25 |
# File 'lib/sinatra/cli/generator.rb', line 23 def create_database_config template "config/database.yml.erb", "#{app_name}/config/database.yml" end |
#create_gemfile ⇒ Object
45 46 47 |
# File 'lib/sinatra/cli/generator.rb', line 45 def create_gemfile copy_file "Gemfile", "#{app_name}/Gemfile" end |
#create_gitignore ⇒ Object
37 38 39 |
# File 'lib/sinatra/cli/generator.rb', line 37 def create_gitignore copy_file ".gitignore", "#{app_name}/.gitignore" end |
#create_models_dir ⇒ Object
14 15 16 |
# File 'lib/sinatra/cli/generator.rb', line 14 def create_models_dir keep_file "#{app_name}/app/models" end |
#create_rakefile ⇒ Object
49 50 51 |
# File 'lib/sinatra/cli/generator.rb', line 49 def create_rakefile copy_file "Rakefile", "#{app_name}/Rakefile" end |
#create_readme ⇒ Object
53 54 55 |
# File 'lib/sinatra/cli/generator.rb', line 53 def create_readme template "README.md.erb", "#{app_name}/README.md" end |
#create_seeds_file ⇒ Object
27 28 29 |
# File 'lib/sinatra/cli/generator.rb', line 27 def create_seeds_file copy_file "db/seeds.rb", "#{app_name}/db/seeds.rb" end |
#create_views_dir ⇒ Object
18 19 20 21 |
# File 'lib/sinatra/cli/generator.rb', line 18 def create_views_dir template "app/views/index.erb", "#{app_name}/app/views/index.erb" template "app/views/layout.erb", "#{app_name}/app/views/layout.erb" end |
#setup_capybara ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/sinatra/cli/generator.rb', line 68 def insert_into_file( "#{app_name}/Gemfile", "gem 'capybara'", after: "group :test, :development do" ) insert_into_file( "#{app_name}/spec/spec_helper.rb", "require 'capybara/rspec'", after: "require 'rspec'" ) append_to_file "#{app_name}/spec/spec_helper.rb", "\n\nCapybara.app = Sinatra::Application" end |
#setup_rspec ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/sinatra/cli/generator.rb', line 57 def setup_rspec insert_into_file( "#{app_name}/Gemfile", "gem 'rspec'", after: "group :test, :development do" ) copy_file ".rspec", "#{app_name}/.rspec" copy_file "spec/spec_helper.rb", "#{app_name}/spec/spec_helper.rb" end |