Permalink
Browse files

Update generator to default to the running version of ruby

  • Loading branch information...
1 parent 940fdde commit a8e367ba4b5c50199c1b04150cb584bfcd8e82d5 @technicalpickles technicalpickles committed Feb 2, 2012
@@ -8,7 +8,7 @@ class MoonshineGenerator < Rails::Generator::Base
default_options :user => 'rails',
:domain => 'yourapp.com',
- :ruby => 'ree187',
+ :ruby => default_ruby,
:multistage => false
def initialize(runtime_args, runtime_options = {})
@@ -3,8 +3,15 @@
# and in `app/manifest/<%= file_name%>.rb` via `configuration`
# ruby to install at `cap deploy:setup` time. If you change this value, you
-# need to run `cap ruby:upgrade`. Currently allowed values include: mri,
-# src187, ree, ree187
+# need to run `cap ruby:upgrade`.
+#
+# As of time of generating, these are valid values:
+# * mri (as installed by Ubuntu)
+# * src187
+# * ree
+# * ree187
+# * src192
+# * src193
:ruby: <%= ruby %>
# Name of your application. Should be something with only alphanumerics, hypens
@@ -10,7 +10,8 @@ class MoonshineGenerator < Rails::Generators::Base
class_option :user, :default => 'rails', :desc => 'User to use on remote server', :type => :string
class_option :domain, :default => 'yourapp.com', :desc => 'Domain name of your application', :type => :string
class_option :repository, :default => 'git@github.com:username/your_app_name.git', :desc => 'git or subversion repository to deploy from', :type => :string
- class_option :ruby, :default => 'ree187', :desc => 'Ruby version to install. Currently supports: mri, ree, ree187, src187', :type => :string
+
+ class_option :ruby, :default => default_ruby, :desc => 'Ruby version to install. Currently supports: mri, ree, ree187, src187, src192, src193', :type => :string
class_option :multistage, :default => false, :desc => 'setup multistage deployment environment', :type => :boolean
def self.source_root
@@ -1,5 +1,31 @@
module MoonshineGeneratorHelpers
+
+ def self.included(base)
+ base.class_eval do
+ extend ClassMethods
+ end
+ end
+
def rails_root_path
RAILS_ROOT rescue Rails.root
end
-end
+
+ module ClassMethods
+ def ruby_version
+ RUBY_VERSION
+ end
+
+ def default_ruby
+ case ruby_version
+ when /^1\.8/
+ 'ree187'
+ when "1.9.2"
+ 'src192'
+ when "1.9.3"
+ 'src193'
+ else
+ end
+ end
+ end
+
+end
@@ -133,7 +133,7 @@ def run(*args)
end
end
- context "run with --ruby ree187" do
+ context "run with --ruby ree" do
before do
run %w(--ruby ree)
end
@@ -152,6 +152,32 @@ def run(*args)
configuration[:ruby].should == 'ree187'
end
end
+
+ context "run on 1.9.2" do
+ before do
+ MoonshineGenerator.stub!(:ruby_version).and_return("1.9.2")
+ run
+ end
+
+ it "configures src192 as the ruby vm" do
+ pending "stubbing doesn't seem to take effect"
+ configuration[:ruby].should == 'src192'
+ end
+
+ end
+
+ context "run on 1.9.3" do
+ before do
+ MoonshineGenerator.stub!(:ruby_version).and_return("1.9.3")
+ run
+ end
+
+ it "configures src193 as the ruby vm" do
+ pending "stubbing doesn't seem to take effect"
+ configuration[:ruby].should == 'src193'
+ end
+
+ end
end
private
View
@@ -1,3 +1,2 @@
--colour
---debugger
--format progress

0 comments on commit a8e367b

Please sign in to comment.