Skip to content

Commit

Permalink
Update generator to default to the running version of ruby
Browse files Browse the repository at this point in the history
  • Loading branch information
technicalpickles committed Feb 2, 2012
1 parent 940fdde commit a8e367b
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 7 deletions.
2 changes: 1 addition & 1 deletion generators/moonshine/moonshine_generator.rb
Expand Up @@ -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 = {})
Expand Down
11 changes: 9 additions & 2 deletions generators/moonshine/templates/moonshine.yml
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/generators/moonshine/moonshine_generator.rb
Expand Up @@ -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
Expand Down
28 changes: 27 additions & 1 deletion lib/generators/moonshine_helper.rb
@@ -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
28 changes: 27 additions & 1 deletion spec/moonshine_generator_spec.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion spec/spec.opts
@@ -1,3 +1,2 @@
--colour
--debugger
--format progress

0 comments on commit a8e367b

Please sign in to comment.