summaryrefslogtreecommitdiffstats
path: root/lib/puppet/rails/param_value.rb
Commit message (Collapse)AuthorAgeFilesLines
* Code smell: Two space indentationMarkus Roberts2010-07-091-55/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Use string interpolationMarkus Roberts2010-07-091-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Replaced 83 occurances of (.*)" *[+] *([$@]?[\w_0-9.:]+?)(.to_s\b)?(?! *[*(%\w_0-9.:{\[]) with \1#{\2}" 3 Examples: The code: puts "PUPPET " + status + ": " + process + ", " + state becomes: puts "PUPPET " + status + ": " + process + ", #{state}" The code: puts "PUPPET " + status + ": #{process}" + ", #{state}" becomes: puts "PUPPET #{status}" + ": #{process}" + ", #{state}" The code: }.compact.join( "\n" ) + "\n" + t + "]\n" becomes: }.compact.join( "\n" ) + "\n#{t}" + "]\n" * Replaced 21 occurances of (.*)" *[+] *" with \1 3 Examples: The code: puts "PUPPET #{status}" + ": #{process}" + ", #{state}" becomes: puts "PUPPET #{status}" + ": #{process}, #{state}" The code: puts "PUPPET #{status}" + ": #{process}, #{state}" becomes: puts "PUPPET #{status}: #{process}, #{state}" The code: res = self.class.name + ": #{@name}" + "\n" becomes: res = self.class.name + ": #{@name}\n" * Don't use string concatenation to split lines unless they would be very long. Replaced 11 occurances of (.*)(['"]) *[+] *(['"])(.*) with 3 Examples: The code: o.define_head "The check_puppet Nagios plug-in checks that specified " + "Puppet process is running and the state file is no " + becomes: o.define_head "The check_puppet Nagios plug-in checks that specified Puppet process is running and the state file is no " + The code: o.separator "Mandatory arguments to long options are mandatory for " + "short options too." becomes: o.separator "Mandatory arguments to long options are mandatory for short options too." The code: o.define_head "The check_puppet Nagios plug-in checks that specified Puppet process is running and the state file is no " + "older than specified interval." becomes: o.define_head "The check_puppet Nagios plug-in checks that specified Puppet process is running and the state file is no older than specified interval." * Replaced no occurances of do (.*?) end with {\1} * Replaced 1488 occurances of "([^"\n]*%s[^"\n]*)" *% *(.+?)(?=$| *\b(do|if|while|until|unless|#)\b) with 20 Examples: The code: args[0].split(/\./).map do |s| "dc=%s"%[s] end.join(",") becomes: args[0].split(/\./).map do |s| "dc=#{s}" end.join(",") The code: puts "%s" % Puppet.version becomes: puts "#{Puppet.version}" The code: raise "Could not find information for %s" % node becomes: raise "Could not find information for #{node}" The code: raise Puppet::Error, "Cannot create %s: basedir %s is a file" % [dir, File.join(path)] becomes: raise Puppet::Error, "Cannot create #{dir}: basedir #{File.join(path)} is a file" The code: Puppet.err "Could not run %s: %s" % [client_class, detail] becomes: Puppet.err "Could not run #{client_class}: #{detail}" The code: raise "Could not find handler for %s" % arg becomes: raise "Could not find handler for #{arg}" The code: Puppet.err "Will not start without authorization file %s" % Puppet[:authconfig] becomes: Puppet.err "Will not start without authorization file #{Puppet[:authconfig]}" The code: raise Puppet::Error, "Could not deserialize catalog from pson: %s" % detail becomes: raise Puppet::Error, "Could not deserialize catalog from pson: #{detail}" The code: raise "Could not find facts for %s" % Puppet[:certname] becomes: raise "Could not find facts for #{Puppet[:certname]}" The code: raise ArgumentError, "%s is not readable" % path becomes: raise ArgumentError, "#{path} is not readable" The code: raise ArgumentError, "Invalid handler %s" % name becomes: raise ArgumentError, "Invalid handler #{name}" The code: debug "Executing '%s' in zone %s with '%s'" % [command, @resource[:name], str] becomes: debug "Executing '#{command}' in zone #{@resource[:name]} with '#{str}'" The code: raise Puppet::Error, "unknown cert type '%s'" % hash[:type] becomes: raise Puppet::Error, "unknown cert type '#{hash[:type]}'" The code: Puppet.info "Creating a new certificate request for %s" % Puppet[:certname] becomes: Puppet.info "Creating a new certificate request for #{Puppet[:certname]}" The code: "Cannot create alias %s: object already exists" % [name] becomes: "Cannot create alias #{name}: object already exists" The code: return "replacing from source %s with contents %s" % [metadata.source, metadata.checksum] becomes: return "replacing from source #{metadata.source} with contents #{metadata.checksum}" The code: it "should have a %s parameter" % param do becomes: it "should have a #{param} parameter" do The code: describe "when registring '%s' messages" % log do becomes: describe "when registring '#{log}' messages" do The code: paths = %w{a b c d e f g h}.collect { |l| "/tmp/iteration%stest" % l } becomes: paths = %w{a b c d e f g h}.collect { |l| "/tmp/iteration#{l}test" } The code: assert_raise(Puppet::Error, "Check '%s' did not fail on false" % check) do becomes: assert_raise(Puppet::Error, "Check '#{check}' did not fail on false") do
* Removing Resource::Reference classesLuke Kanies2010-02-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit is hopefully less messy than it first appears, but it's certainly cross-cutting. The reason for all of this is that we previously only looked up builtin resource types from outside the parser, but now that the defined resource types are available globally via environments, we can push that lookup code to Resource. Once we do that, however, we have to have environment and namespace information in every resource. Here I remove the Resource::Reference classes (except the AST class), and use Resource instances instead. I did this because the shared code between the two classes got incredibly complicated, such that they should have had a hierarchical relationship disallowed by their constants. This complexity convinced me just to get rid of References entirely. I also make Puppet::Parser::Resource a subclass of Puppet::Resource. There are still broken tests in test/, but this was a big enough commit I wanted to get it in. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
* Patch to address feature #2571 to add Oracle support to PuppetAvi Miller2009-10-241-2/+2
| | | | | | Adapter requires specifying database, username and password. Signed-off-by: Avi Miller <avi.miller@gmail.com>
* Removed extra whitespace from end of linesIan Taylor2009-06-061-1/+1
|
* Fixing #2187 - Puppet::Resource is expected by Rails supportLuke Kanies2009-04-241-6/+5
| | | | | | | | | | | | | We previously used and expected Puppet::Parser::Resource instances, but 0.25 converts them all to Puppet::Resource instances before they're passed out of the compiler, so the Rails integration had to be changed to expect that. There's still some muddling, because the rails resources only generate parser resources, but that works for now because that's what we expect when collecting resources. Signed-off-by: Luke Kanies <luke@madstop.com>
* Refactoring the Rails integrationLuke Kanies2009-04-221-3/+31
| | | | | | | | This moves all code from the Parser class into the ActiveRecord classes, and gets rid of 'ar_hash_merge'. Signed-off-by: Luke Kanies <luke@madstop.com>
* Add methods to return hash instead of objects to params and tagsBrice Figureau2009-02-061-12/+31
| | | | Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
* * Tweaks for puppetshow UI cleanupBlake Barnett2008-02-281-0/+4
|
* Removing the Id tags from all of the filesLuke Kanies2007-10-031-1/+0
|
* Fixing #695 -- resource references will correctly serialize and unserialize ↵luke2007-07-181-0/+19
| | | | | | in the db git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2706 980ebf18-57e1-0310-9a29-db15c13687c0
* Major rework of the rails feature. Changed the relationship between ballman2007-06-121-0/+1
| | | | | | | | | | | | | | | | host and facts (now many-to-many with fact_name through fact_values). Also changed the relationship between resource and params (similarly many-to-many with param_names through param_values). Added the resource_tags and puppet_tags. The latter has the tag names and the former is the man-to-many link with resources. There is a little clean up left but the schema is in order. Also a test for the tags stuff is required. git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2565 980ebf18-57e1-0310-9a29-db15c13687c0
* Re-add the filesshadoi2007-02-171-0/+5
| | | | git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2210 980ebf18-57e1-0310-9a29-db15c13687c0
* Merge fact_names & fact_values, and param_names & param_values.shadoi2007-02-151-5/+0
| | | | git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2191 980ebf18-57e1-0310-9a29-db15c13687c0
* Fixing most of the rails stuff. I think everything basically works now, and ↵luke2006-12-191-2/+2
| | | | | | now I am just going through and making sure things get deleted when they are supposed (i.e., you remove a resource and it gets deleted from the host's config). git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1950 980ebf18-57e1-0310-9a29-db15c13687c0
* New rails stuff redux.shadoi2006-12-141-0/+5
| | | | git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1925 980ebf18-57e1-0310-9a29-db15c13687c0
* Temporarily reverting all of the recent rails work so that I can release 0.20.1luke2006-11-131-5/+0
| | | | git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1873 980ebf18-57e1-0310-9a29-db15c13687c0
* The new rails files.shadoi2006-11-091-0/+5
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1838 980ebf18-57e1-0310-9a29-db15c13687c0