On Aug 22, 2008, at 1:12 AM, Andrew Shafer wrote:
> @@ -216,7 +215,7 @@ class Puppet::Parser::Parser
> # Initialize or reset all of our variables.
> def initvars
> @lexer = Puppet::Parser::Lexer.new()
> - @files = []
> + @files = {}
> @loaded = []
> end
You've wisely got a hash here, but...
> +
> + def check_and_add_to_watched_files(filename)
> + unless @files.detect { |name, f| f.file == filename }
> + @files[filename] = Puppet::Util::LoadedFile.new(filename)
> + return true
> + else
> + return false
> end
> end
...you still use f.file == filename. You can instead just do this:
unless @files.include?(filename)
...
end
I'm also not entirely sure the extra check_and... method is necessary,
but I'm fine with it.
>
> end
> diff --git a/test/language/parser.rb b/test/language/parser.rb
> index cdd1329..fc8452b 100755
> --- a/test/language/parser.rb
> +++ b/test/language/parser.rb
> @@ -1208,5 +1208,13 @@ file { "/tmp/yayness":
> parser.import("test")
> end
> end
> +
> + def test_watch_file_only_once
> + FileTest.stubs(:exists?).returns(true)
> + parser = mkparser
> + parser.watch_file("doh")
> + parser.watch_file("doh")
> + assert_equal(1, parser.files.select { |name, file|
> file.file == "doh" }.length, "Length of watched 'doh' files was not
> 1")
> + end
> end
>
> --
> 1.5.3.7
>
>
> >
--
Whenever I hear anyone arguing for slavery, I feel a strong impulse to
see it tried on him personally. -- Abraham Lincoln
---------------------------------------------------------------------
Luke Kanies | http://reductivelabs.com | http://madstop.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---