summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/files.rb
Commit message (Collapse)AuthorAgeFilesLines
* [#4344] Fix for failing templates when module name matches file in local dir.Paul Berry2010-08-031-1/+1
| | | | | | | | | When the name of a module matches the name of a file in the local directory, puppet agent would sometimes try to read that file and interpret it as puppet code. This happened because files.rb was unintentionally permitting puppet files without an extension. Fixed by changing the glob pattern to only permit ".pp" and ".rb" extensions.
* Fix #4206 - import "path/*" tries to import files twiceBrice Figureau2010-07-111-1/+1
| | | | | | | | | Due to the glob pattern used, we are trying to import manifests twice. Since it isn't possible (see #4205), it is not possible to use a pattern in an import statement. This patch makes sure manifests are returned only once. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* Code smell: Two space indentationMarkus Roberts2010-07-091-65/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replaced 106806 occurances of ^( +)(.*$) with The ruby community almost universally (i.e. everyone but Luke, Markus, and the other eleven people who learned ruby in the 1900s) uses two-space indentation. 3 Examples: The code: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") becomes: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") The code: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object becomes: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object The code: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end becomes: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end
* Code smell: Avoid explicit returnsMarkus Roberts2010-07-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replaced 583 occurances of (DEF) (LINES) return (.*) end with 3 Examples: The code: def consolidate_failures(failed) filters = Hash.new { |h,k| h[k] = [] } failed.each do |spec, failed_trace| if f = test_files_for(failed).find { |f| failed_trace =~ Regexp.new(f) } filters[f] << spec break end end return filters end becomes: def consolidate_failures(failed) filters = Hash.new { |h,k| h[k] = [] } failed.each do |spec, failed_trace| if f = test_files_for(failed).find { |f| failed_trace =~ Regexp.new(f) } filters[f] << spec break end end filters end The code: def retrieve return_value = super return_value = return_value[0] if return_value && return_value.is_a?(Array) return return_value end becomes: def retrieve return_value = super return_value = return_value[0] if return_value && return_value.is_a?(Array) return_value end The code: def fake_fstab os = Facter['operatingsystem'] if os == "Solaris" name = "solaris.fstab" elsif os == "FreeBSD" name = "freebsd.fstab" else # Catchall for other fstabs name = "linux.fstab" end oldpath = @provider_class.default_target return fakefile(File::join("data/types/mount", name)) end becomes: def fake_fstab os = Facter['operatingsystem'] if os == "Solaris" name = "solaris.fstab" elsif os == "FreeBSD" name = "freebsd.fstab" else # Catchall for other fstabs name = "linux.fstab" end oldpath = @provider_class.default_target fakefile(File::join("data/types/mount", name)) end
* Fix for #4178 - generalize autoloading to include .rbLuke Kanies2010-07-091-5/+1
| | | | | | | | | | This mostly modifies autoloading to look for files ending in either 'pp' or 'rb' using Dir globing with {,.pp,.rb} or .{pp,rb} as appropriate. It could easily be extended to add support for other formats (e.g. xml) by adding them to the globs (though, if this were to be done often, having a centralized list of supported extensions would be a good (and easy) refactor). Signed-off-by: Luke Kanies <luke@puppetlabs.com>
* Fixing #1545 - module_name is now a variableLuke Kanies2010-02-171-2/+2
| | | | | | | | | | | | | This is only true for resource types (e.g., classes and defines) of course. The actual variable is 'module_name': class mymod { notify { "in mymod '$module_name'": } } Signed-off-by: Luke Kanies <luke@puppetlabs.com>
* Make specs work on win32David Schmitt2010-02-171-3/+3
| | | | | | | | | | | | | | | | | | | | lib/: * Fix Puppet::Parser::Files * Fix Puppet::Util::Settings spec/: * unit/application/kick.rb: only run on posix * unit/application.rb * unit/parser/compiler.rb * unit/parser/files.rb * unit/resource.rb * unit/resource/catalog.rb * unit/resource/type_collection.rb * unit/transaction.rb * unit/type/tidy.rb * unit/util/settings.rb * unit/util/settings/file_setting.rb * unit/application.rb
* Ticket #2525 don't fail find_manifest on invalid module namesMarkus Roberts2009-09-051-13/+11
| | | | | | | | | The patch that put validity assertions in for module names broke find_manifest because rather than returning a failure it now rasies an exception. This patch catches the exception and treats it as a negative result. Signed-off-by: Markus Roberts <Markus@reality.com>
* Fixing #2250 - Missing templates throw a helpful errorLuke Kanies2009-05-181-5/+5
| | | | | | | | | | | This changes the behaviour of template searching a bit - we previously usually returned a file name, whether the template existed or not. Now we only return a path if it exists. Refactoring a few of the the tests for TemplateWrapper, also. Signed-off-by: Luke Kanies <luke@madstop.com>
* Modules now can find their own pathsLuke Kanies2009-05-151-8/+8
| | | | | | | | | | | | Previously, when you created a module you had to specify the path. Now Module instances can use the module path to look up their paths, and there are methods for determining whether the module is present (if the path is present). Also cleaned up the methods for figuring out what's in the module (plugins, etc.). Signed-off-by: Luke Kanies <luke@madstop.com>
* Moving file-searching code out of Puppet::ModuleLuke Kanies2009-05-151-0/+94
The Module class had a bunch of code for finding manifests and templates even when not in a module, and it complicated the class unnecessarily. This moves that code to a new, hackish-but-sufficient module for just that purpose. Signed-off-by: Luke Kanies <luke@madstop.com>