Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added option for creating app at Heroku

Signed-off-by: Vann Ek <vann@innerfusion.net>
  • Loading branch information...
commit e6900455af8897dda169e1cb43f6fd08368d91ed 1 parent 944118d
@citizen428 citizen428 authored committed
View
1  README.rdoc
@@ -56,6 +56,7 @@ It will also generate test skeletons in the test framework of your choosing.
-d, --vendor Extract the latest sinatra to vendor/sinatra
--tiny Only create the minimal files.
--init Initialize a git repository
+ --heroku=app_name Creates a Heroku app (also does 'git init'
--cap Adds config directory with basic capistrano deploy.rb
--scripts Install the rubigen scripts (script/generate, script/destroy)
--git /path/to/git Specify a different path for 'git'
View
9 app_generators/sinatra_app/sinatra_app_generator.rb
@@ -18,7 +18,7 @@ class SinatraAppGenerator < RubiGen::Base
default_options :author => nil
- attr_accessor :app_name, :vendor, :tiny, :git, :git_init, :test_framework, :view_framework, :install_scripts, :cap, :actions
+ attr_accessor :app_name, :vendor, :tiny, :git, :git_init, :heroku, :test_framework, :view_framework, :install_scripts, :cap, :actions
def initialize(runtime_args, runtime_options = {})
super
@@ -38,6 +38,11 @@ def manifest
m.run("#{git} init")
end
+ if heroku
+ m.run("#{git} init")
+ m.run("heroku create #{heroku}")
+ end
+
m.template 'config.ru.erb', 'config.ru'
m.template 'app.rb.erb' , "#{app_name}.rb"
m.template 'Rakefile.erb' , 'Rakefile'
@@ -92,6 +97,7 @@ def add_options!(opts)
opts.on("-d", "--vendor", "Extract the latest sinatra to vendor/sinatra") {|o| options[:vendor] = o }
opts.on("--tiny", "Only create the minimal files.") {|o| options[:tiny] = o }
opts.on("--init", "Initialize a git repository") {|o| options[:init] = o }
+ opts.on("--heroku=app_name", "Creates a Heroku app (also does 'git init')") { |o| options[:heroku] = o }
opts.on("--cap", "Adds config directory with basic capistrano deploy.rb") {|o| options[:cap] = o }
opts.on("--scripts", "Install the rubigen scripts (script/generate, script/destroy)") {|o| options[:scripts] = o }
opts.on("--git /path/to/git", "Specify a different path for 'git'") {|o| options[:git] = o }
@@ -108,6 +114,7 @@ def extract_options
self.cap = options[:cap]
self.git = options[:git] || `which git`.strip
self.git_init = options[:init] || false
+ self.heroku = options[:heroku]
self.test_framework = options[:test_framework] || 'unit'
self.view_framework = options[:view_framework] || 'erb'
self.install_scripts = options[:scripts] || false
View
9 test/test_sinatra_app_generator.rb
@@ -39,6 +39,15 @@ def test_generate_app_with_init_option
assert_basic_paths_and_files
assert_directory_exists '.git'
end
+
+ def test_generate_app_with_heroku_option
+ run_generator('sinatra_app', [APP_ROOT, "--heroku=#{Time.now.strftime("%Y%m%d_%H%M")+'test'}"], sources)
+ assert_basic_paths_and_files
+ assert_directory_exists '.git'
+ assert_generated_file '.git/config' do |config_contents|
+ assert_match(/[remote "heroku"]/, config_contents)
+ end
+ end
def test_generate_app_with_cap_option
run_generator('sinatra_app', [APP_ROOT, '--cap'], sources)
Please sign in to comment.
Something went wrong with that request. Please try again.