Class: Sinatra::Rider::Generator
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Sinatra::Rider::Generator
- Includes:
- Thor::Actions
- Defined in:
- lib/sinatra/rider/command.rb
Class Method Summary collapse
Instance Method Summary collapse
- #new ⇒ Object
- #prepare_app ⇒ Object
- #prepare_assets ⇒ Object
- #prepare_database ⇒ Object
- #prepare_dokku ⇒ Object
- #prepare_dotenv ⇒ Object
- #prepare_rack ⇒ Object
- #prepare_ruby_version ⇒ Object
- #prepare_working_directory ⇒ Object
Class Method Details
.source_root ⇒ Object
74 75 76 |
# File 'lib/sinatra/rider/command.rb', line 74 def self.source_root File.dirname(__FILE__) end |
Instance Method Details
#new ⇒ Object
9 10 11 |
# File 'lib/sinatra/rider/command.rb', line 9 def new # generate application end |
#prepare_app ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/sinatra/rider/command.rb', line 40 def prepare_app template('templates/console.tt', "#{path}/bin/console") system('chmod', '+x', "#{path}/bin/console") template('templates/user.tt', "#{path}/app/user.rb") template('templates/layout.erb', "#{path}/views/layout.erb") template('templates/navigation.erb', "#{path}/views/_navigation.erb") template('templates/index.erb', "#{path}/views/index.erb") create_file("#{path}/README.md") { "# #{path.capitalize}\n" } end |
#prepare_assets ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/sinatra/rider/command.rb', line 51 def prepare_assets create_file "#{path}/assets/javascripts/application.js" create_file "#{path}/assets/stylesheets/vendor/.keep" create_file("#{path}/assets/stylesheets/base.scss") { "body {}" } template('templates/css.tt', "#{path}/assets/stylesheets/application.scss") end |
#prepare_database ⇒ Object
27 28 29 30 |
# File 'lib/sinatra/rider/command.rb', line 27 def prepare_database template('templates/database.erb', "#{path}/config/database.yml") template('templates/users_migration.erb', "#{path}/db/migrate/1_create_users.rb") end |
#prepare_dokku ⇒ Object
13 14 15 16 |
# File 'lib/sinatra/rider/command.rb', line 13 def prepare_dokku create_file("#{path}/CHECKS") { "/ #{path.capitalize}\n" } create_file("#{path}/DOKKU_SCALE") { "web=1\n" } end |
#prepare_dotenv ⇒ Object
22 23 24 25 |
# File 'lib/sinatra/rider/command.rb', line 22 def prepare_dotenv create_file("#{path}/.env") { "SESSION_SECRET=super secret shh\n" } create_file("#{path}/.gitignore") { ".env\ntmp/\n" } end |
#prepare_rack ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/sinatra/rider/command.rb', line 32 def prepare_rack template('templates/gemfile.tt', "#{path}/Gemfile") template('templates/procfile.tt', "#{path}/Procfile") template('templates/rakefile.tt', "#{path}/Rakefile") template('templates/rackup.tt', "#{path}/config.ru") template('templates/server.tt', "#{path}/server.rb") end |
#prepare_ruby_version ⇒ Object
18 19 20 |
# File 'lib/sinatra/rider/command.rb', line 18 def prepare_ruby_version create_file("#{path}/.ruby-version") { "#{RUBY_VERSION}\n" } end |
#prepare_working_directory ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/sinatra/rider/command.rb', line 59 def prepare_working_directory inside(path) do run('bundle install') run('bundle exec rake db:create db:migrate') run('git init') run('git add .') run('git commit -m "Initial Commit"') end run("cd #{path}") puts "You're all set up! Start your server like this:" puts " bundle exec rackup config.ru" puts "\nYou can get setup with a user at http://localhost:9292/signup" end |