lib/hem/plugins.rb in hem-1.1.1 vs lib/hem/plugins.rb in hem-1.1.2
- old
+ new
@@ -6,10 +6,11 @@
class Plugins
def initialize(path, gemfile, lockfile = nil)
@is_setup = false
@gemfile = gemfile
+ @definitionBlocks = []
if lockfile.nil?
@lockfile = "#{gemfile}.lock"
else
@lockfile = lockfile
end
@@ -19,15 +20,10 @@
@root = Pathname.new(path) if path
@root
end
Bundler.root path
- @builder = Class.new(Bundler::Dsl) do
- define_method(:gemfile_root) do
- Bundler.root
- end
- end.new
@definition = nil
end
def setup
raise Hem::PluginsAlreadySetupError if @is_setup
@@ -40,11 +36,11 @@
@is_setup
end
def define(&block)
raise Hem::PluginsAlreadySetupError if @is_setup
- @builder.instance_eval &block
+ @definitionBlocks << block
self
end
def check
@@ -108,11 +104,21 @@
def definition(unlock = nil)
@definition = nil if unlock
return @definition unless @definition.nil?
+ builder = Class.new(Bundler::Dsl) do
+ define_method(:gemfile_root) do
+ Bundler.root
+ end
+ end.new
+
+ @definitionBlocks.each do |block|
+ builder.instance_eval &block
+ end
+
unlock = {} if unlock.nil?
- @definition = @builder.to_definition(@lockfile, unlock)
+ @definition = builder.to_definition(@lockfile, unlock)
@definition.validate_ruby!
@definition
end
end