Permalink
Browse files

refactor ruby version into it's own class

  • Loading branch information...
1 parent e97ae7a commit 384c72c62ddf721ae2bc85c05fa6e1fdf367e81f @hone hone committed Mar 25, 2012
Showing with 17 additions and 3 deletions.
  1. +1 −0 lib/bundler.rb
  2. +1 −3 lib/bundler/dsl.rb
  3. +15 −0 lib/bundler/ruby_version.rb
View
@@ -27,6 +27,7 @@ module Bundler
autoload :MatchPlatform, 'bundler/match_platform'
autoload :RemoteSpecification, 'bundler/remote_specification'
autoload :Resolver, 'bundler/resolver'
+ autoload :RubyVersion, 'bundler/ruby_version'
autoload :Runtime, 'bundler/runtime'
autoload :Settings, 'bundler/settings'
autoload :SharedHelpers, 'bundler/shared_helpers'
View
@@ -174,10 +174,8 @@ def ruby_version(ruby_version, options = {})
raise GemfileError, "Please define :engine_version" if options[:engine] && options[:engine_version].nil?
raise GemfileError, "Please define :engine" if options[:engine_version] && options[:engine].nil?
- engine = options[:engine] || "ruby"
raise GemfileError, "ruby_version must match the :engine_version for MRI" if options[:engine] == "ruby" && options[:engine_version] && ruby_version != options[:engine_version]
- engine_version = engine == "ruby" ? ruby_version : options[:engine_version]
- @ruby_version = "ruby #{ruby_version} (#{engine} #{engine_version})"
+ @ruby_version = RubyVersion.new(ruby_version, options[:engine], options[:engine_version])
end
def method_missing(name, *args)
@@ -0,0 +1,15 @@
+module Bundler
+ class RubyVersion
+ attr_reader :version, :engine, :engine_version
+
+ def initialize(version, engine, engine_version)
+ @version = version
+ @engine = engine || "ruby"
+ @engine_version = @engine == "ruby" ? version : engine_version
+ end
+
+ def to_s
+ "ruby #{@version} (#{@engine} #{@engine_version})"
+ end
+ end
+end

0 comments on commit 384c72c

Please sign in to comment.