previous changes were made to Dsl that built on the options hash that was passed to it.
Except the options hash is actually a Thor::CoreExt::HashWithIndifferentAccess so, i reorganized the internal access and storage to read original data from the passed hash, but stores it into a local hash. No tests changed since no external behavior changed. All tests passed. This fixes the issue when the binary is run and results in a can't modify frozen hash (RuntimeError) small change to fix specs to run and always have @@orig_options be locked.
This commit is contained in:
parent
2a834e1228
commit
6b35e96e8d
@ -4,8 +4,9 @@ module Guard
|
|||||||
def evaluate_guardfile(options = {})
|
def evaluate_guardfile(options = {})
|
||||||
options.is_a?(Hash) or raise ArgumentError.new("evaluate_guardfile not passed a hash")
|
options.is_a?(Hash) or raise ArgumentError.new("evaluate_guardfile not passed a hash")
|
||||||
|
|
||||||
@@orig_options = options
|
@@orig_options = options.dup.freeze
|
||||||
@@options = {}
|
@@options = {}
|
||||||
|
@@groups = {}
|
||||||
prep_guardfile_contents
|
prep_guardfile_contents
|
||||||
instance_eval_guardfile(guardfile_contents, actual_guardfile(), 1)
|
instance_eval_guardfile(guardfile_contents, actual_guardfile(), 1)
|
||||||
end
|
end
|
||||||
@ -68,11 +69,11 @@ module Guard
|
|||||||
end
|
end
|
||||||
|
|
||||||
def guardfile_file
|
def guardfile_file
|
||||||
@@options[:guardfile]
|
@@options[:guardfile] || @@orig_options[:guardfile]
|
||||||
end
|
end
|
||||||
|
|
||||||
def actual_guardfile
|
def actual_guardfile
|
||||||
@@options[:actual_guardfile]
|
@@options[:actual_guardfile] || @@orig_options[:actual_guardfile]
|
||||||
end
|
end
|
||||||
|
|
||||||
def guardfile_contents_usable?
|
def guardfile_contents_usable?
|
||||||
@ -89,6 +90,7 @@ module Guard
|
|||||||
end
|
end
|
||||||
|
|
||||||
def group(name, &guard_definition)
|
def group(name, &guard_definition)
|
||||||
|
|
||||||
guard_definition.call if guard_definition && (@@orig_options[:group].empty? || @@orig_options[:group].include?(name))
|
guard_definition.call if guard_definition && (@@orig_options[:group].empty? || @@orig_options[:group].include?(name))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user