Permalink
Browse files

extract ruby method in Dsl into its own module

  • Loading branch information...
hone committed Dec 26, 2012
1 parent 69c5d8b commit 9db6c216b2ad0a11e53734a12972c7f6c389bd42
Showing with 14 additions and 8 deletions.
  1. +1 −0 lib/bundler.rb
  2. +2 −8 lib/bundler/dsl.rb
  3. +11 −0 lib/bundler/ruby_dsl.rb
View
@@ -31,6 +31,7 @@ module Bundler
autoload :RemoteSpecification, 'bundler/remote_specification'
autoload :Resolver, 'bundler/resolver'
autoload :RubyVersion, 'bundler/ruby_version'
+ autoload :RubyDsl, 'bundler/ruby_dsl'
autoload :Runtime, 'bundler/runtime'
autoload :Settings, 'bundler/settings'
autoload :SharedHelpers, 'bundler/shared_helpers'
View
@@ -2,6 +2,8 @@
module Bundler
class Dsl
+ include RubyDsl
+
def self.evaluate(gemfile, lockfile, unlock)
builder = new
builder.eval_gemfile(gemfile)
@@ -171,14 +173,6 @@ def env(name)
@env = old
end
- def ruby(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?
-
- raise GemfileError, "ruby_version must match the :engine_version for MRI" if options[:engine] == "ruby" && options[:engine_version] && ruby_version != options[:engine_version]
- @ruby_version = RubyVersion.new(ruby_version, options[:engine], options[:engine_version])
- end
-
def method_missing(name, *args)
location = caller[0].split(':')[0..1].join(':')
raise GemfileError, "Undefined local variable or method `#{name}' for Gemfile\n" \
View
@@ -0,0 +1,11 @@
+module Bundler
+ module RubyDsl
+ def ruby(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?
+
+ raise GemfileError, "ruby_version must match the :engine_version for MRI" if options[:engine] == "ruby" && options[:engine_version] && ruby_version != options[:engine_version]
+ @ruby_version = RubyVersion.new(ruby_version, options[:engine], options[:engine_version])
+ end
+ end
+end

0 comments on commit 9db6c21

Please sign in to comment.