diff options
373 files changed, 1575 insertions, 1586 deletions
diff --git a/examples/modules/sample-module/lib/puppet/parser/functions/hostname_to_dn.rb b/examples/modules/sample-module/lib/puppet/parser/functions/hostname_to_dn.rb index d7ad7d22e..fdeeff1dc 100644 --- a/examples/modules/sample-module/lib/puppet/parser/functions/hostname_to_dn.rb +++ b/examples/modules/sample-module/lib/puppet/parser/functions/hostname_to_dn.rb @@ -31,6 +31,6 @@ module Puppet::Parser::Functions newfunction(:hostname_to_dn, :type => :rvalue, :doc => "Given 'foo.bar.com', return 'dc=foo,dc=bar,dc=com'.") do |args| - args[0].split(/\./).map do |s| "dc=%s"%[s] end.join(",") + args[0].split(/\./).map do |s| "dc=#{s}" end.join(",") end end diff --git a/ext/nagios/check_puppet.rb b/ext/nagios/check_puppet.rb index 5d448b6fc..4873c033b 100755 --- a/ext/nagios/check_puppet.rb +++ b/ext/nagios/check_puppet.rb @@ -19,12 +19,9 @@ class CheckPuppet o = OptionParser.new do |o| o.set_summary_indent(' ') o.banner = "Usage: #{script_name} [OPTIONS]" - 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." + 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." o.separator "" - o.separator "Mandatory arguments to long options are mandatory for " + - "short options too." + o.separator "Mandatory arguments to long options are mandatory for short options too." o.on( @@ -114,7 +111,7 @@ class CheckPuppet exitcide = 3 end - puts "PUPPET " + status + ": " + process + ", " + state + puts "PUPPET #{status}: #{process}, #{state}" exit(exitcode) end end diff --git a/ext/puppetlisten/puppetlisten.rb b/ext/puppetlisten/puppetlisten.rb index 23e9f65d5..b86f4d822 100755 --- a/ext/puppetlisten/puppetlisten.rb +++ b/ext/puppetlisten/puppetlisten.rb @@ -37,7 +37,7 @@ File.open(Puppet[:authconfig]).each do |line| when "allow": value.split(/\s*,\s*/).each { |val| allowed_servers << val - puts "allowing %s access" % val + puts "allowing #{val} access" } if runner==true end else diff --git a/ext/puppetstoredconfigclean.rb b/ext/puppetstoredconfigclean.rb index 6f4aa7230..4d7350ca4 100644 --- a/ext/puppetstoredconfigclean.rb +++ b/ext/puppetstoredconfigclean.rb @@ -40,7 +40,7 @@ begin printusage(0) when "--version" - puts "%s" % Puppet.version + puts "#{Puppet.version}" exit end end @@ -73,7 +73,7 @@ case adapter connections = pm_conf[:dbconnections].to_i args[:pool] = connections if connections > 0 else - raise ArgumentError, "Invalid db adapter %s" % adapter + raise ArgumentError, "Invalid db adapter #{adapter}" end args[:database] = "puppet" unless not args[:database].to_s.empty? diff --git a/ext/regexp_nodes/regexp_nodes.rb b/ext/regexp_nodes/regexp_nodes.rb index 92607eac7..ff851bc4a 100644 --- a/ext/regexp_nodes/regexp_nodes.rb +++ b/ext/regexp_nodes/regexp_nodes.rb @@ -74,8 +74,8 @@ class ExternalNode @parameters = Hash.new("unknown") # sets a default value of "unknown" self.parse_argv(hostname) - self.match_classes(WORKINGDIR + "/" + classdir) - self.match_parameters(WORKINGDIR + "/" + parameterdir) + self.match_classes(WORKINGDIR + "/#{classdir}") + self.match_parameters(WORKINGDIR + "/#{parameterdir}") end # private method called by initialize() which sanity-checks our hostname. diff --git a/ext/yaml_nodes.rb b/ext/yaml_nodes.rb index 107e57aa2..b6c191a73 100755 --- a/ext/yaml_nodes.rb +++ b/ext/yaml_nodes.rb @@ -58,7 +58,7 @@ def read_node(node) if FileTest.exist?(nodefile) return YAML.load_file(nodefile) else - raise "Could not find information for %s" % node + raise "Could not find information for #{node}" end end @@ -69,7 +69,7 @@ info = read_node(node) # Iterate over any provided parents, merging in there information. parents_seen = [] while parent = info["parent"] - raise "Found inheritance loop with parent %s" % parent if parents_seen.include?(parent) + raise "Found inheritance loop with parent #{parent}" if parents_seen.include?(parent) parents_seen << parent diff --git a/install.rb b/install.rb index a95ef7616..466b856f1 100755 --- a/install.rb +++ b/install.rb @@ -139,12 +139,12 @@ def check_prereqs # enough for this purpose. facter_version = Facter.version.to_f if facter_version < MIN_FACTER_VERSION - puts "Facter version: %s; minimum required: %s; cannot install" % [facter_version, MIN_FACTER_VERSION] + puts "Facter version: #{facter_version}; minimum required: #{MIN_FACTER_VERSION}; cannot install" exit -1 end end rescue LoadError - puts "Could not load %s; cannot install" % pre + puts "Could not load #{pre}; cannot install" exit -1 end } diff --git a/lib/puppet.rb b/lib/puppet.rb index d09c81801..7293ce2fb 100644 --- a/lib/puppet.rb +++ b/lib/puppet.rb @@ -132,13 +132,13 @@ module Puppet Puppet.err detail.to_s return false rescue => detail - Puppet.err "Could not create %s: %s" % [path, detail.to_s] + Puppet.err "Could not create #{path}: #{detail}" return false end elsif FileTest.directory?(File.join(path)) next else FileTest.exist?(File.join(path)) - raise Puppet::Error, "Cannot create %s: basedir %s is a file" % [dir, File.join(path)] + raise Puppet::Error, "Cannot create #{dir}: basedir #{File.join(path)} is a file" end } return true diff --git a/lib/puppet/agent.rb b/lib/puppet/agent.rb index 84bda6756..3c8a2af67 100644 --- a/lib/puppet/agent.rb +++ b/lib/puppet/agent.rb @@ -28,7 +28,7 @@ class Puppet::Agent # Perform a run with our client. def run(*args) if running? - Puppet.notice "Run of %s already in progress; skipping" % client_class + Puppet.notice "Run of #{client_class} already in progress; skipping" return end result = nil @@ -39,7 +39,7 @@ class Puppet::Agent sync.synchronize { lock { result = client.run(*args) } } rescue => detail puts detail.backtrace if Puppet[:trace] - Puppet.err "Could not run %s: %s" % [client_class, detail] + Puppet.err "Could not run #{client_class}: #{detail}" end end true @@ -63,7 +63,7 @@ class Puppet::Agent return if splayed? time = rand(Integer(Puppet[:splaylimit]) + 1) - Puppet.info "Sleeping for %s seconds (splay is enabled)" % time + Puppet.info "Sleeping for #{time} seconds (splay is enabled)" sleep(time) @splayed = true end @@ -98,7 +98,7 @@ class Puppet::Agent raise rescue Exception => detail puts detail.backtrace if Puppet[:trace] - Puppet.err "Could not create instance of %s: %s" % [client_class, detail] + Puppet.err "Could not create instance of #{client_class}: #{detail}" return end yield @client diff --git a/lib/puppet/application.rb b/lib/puppet/application.rb index 7e7a2a962..db297e073 100644 --- a/lib/puppet/application.rb +++ b/lib/puppet/application.rb @@ -241,7 +241,7 @@ class Application # Every app responds to --version option("--version", "-V") do |arg| - puts "%s" % Puppet.version + puts "#{Puppet.version}" exit end @@ -405,7 +405,7 @@ class Application yield rescue RuntimeError, NotImplementedError => detail puts detail.backtrace if Puppet[:trace] - $stderr.puts "Could not %s: %s" % [message, detail] + $stderr.puts "Could not #{message}: #{detail}" exit(code) end end diff --git a/lib/puppet/application/agent.rb b/lib/puppet/application/agent.rb index ab47abc38..fce978d88 100644 --- a/lib/puppet/application/agent.rb +++ b/lib/puppet/application/agent.rb @@ -54,7 +54,7 @@ class Puppet::Application::Agent < Puppet::Application if Puppet::Network::Handler.handler(arg) options[:serve] << arg.to_sym else - raise "Could not find handler for %s" % arg + raise "Could not find handler for #{arg}" end end @@ -138,7 +138,7 @@ class Puppet::Application::Agent < Puppet::Application end def main - Puppet.notice "Starting Puppet client version %s" % [Puppet.version] + Puppet.notice "Starting Puppet client version #{Puppet.version}" @daemon.start end @@ -183,7 +183,7 @@ class Puppet::Application::Agent < Puppet::Application def setup_listen unless FileTest.exists?(Puppet[:authconfig]) - Puppet.err "Will not start without authorization file %s" % Puppet[:authconfig] + Puppet.err "Will not start without authorization file #{Puppet[:authconfig]}" exit(14) end diff --git a/lib/puppet/application/apply.rb b/lib/puppet/application/apply.rb index 1814858b0..07ce36736 100644 --- a/lib/puppet/application/apply.rb +++ b/lib/puppet/application/apply.rb @@ -49,7 +49,7 @@ class Puppet::Application::Apply < Puppet::Application catalog = Puppet::Resource::Catalog.pson_create(catalog) end rescue => detail - raise Puppet::Error, "Could not deserialize catalog from pson: %s" % detail + raise Puppet::Error, "Could not deserialize catalog from pson: #{detail}" end catalog = catalog.to_ral @@ -85,12 +85,12 @@ class Puppet::Application::Apply < Puppet::Application # Collect our facts. unless facts = Puppet::Node::Facts.find(Puppet[:certname]) - raise "Could not find facts for %s" % Puppet[:certname] + raise "Could not find facts for #{Puppet[:certname]}" end # Find our Node unless node = Puppet::Node.find(Puppet[:certname]) - raise "Could not find node %s" % Puppet[:certname] + raise "Could not find node #{Puppet[:certname]}" end # Merge in the facts. @@ -101,7 +101,7 @@ class Puppet::Application::Apply < Puppet::Application file = Puppet[:classfile] if FileTest.exists?(file) unless FileTest.readable?(file) - $stderr.puts "%s is not readable" % file + $stderr.puts "#{file} is not readable" exit(63) end node.classes = File.read(file).split(/[\s\n]+/) diff --git a/lib/puppet/application/cert.rb b/lib/puppet/application/cert.rb index b2b788201..a85f6a02b 100644 --- a/lib/puppet/application/cert.rb +++ b/lib/puppet/application/cert.rb @@ -36,7 +36,7 @@ class Puppet::Application::Cert < Puppet::Application require 'puppet/ssl/certificate_authority/interface' Puppet::SSL::CertificateAuthority::Interface::INTERFACE_METHODS.reject {|m| m == :destroy }.each do |method| - option("--#{method}", "-%s" % method.to_s[0,1] ) do + option("--#{method}", "-#{method.to_s[0,1]}") do find_mode("--#{method}") end end diff --git a/lib/puppet/application/describe.rb b/lib/puppet/application/describe.rb index b9c05c0e5..e696f1613 100644 --- a/lib/puppet/application/describe.rb +++ b/lib/puppet/application/describe.rb @@ -25,7 +25,7 @@ class Formatter end end res << work if work.length.nonzero? - return prefix + res.join("\n" + prefix) + return prefix + res.join("\n#{prefix}") end def header(txt, sep = "-") @@ -133,7 +133,7 @@ class TypeDoc docs.sort { |a,b| a[0].to_s <=> b[0].to_s }.each { |name, doc| - print "\n- **%s**" % name + print "\n- **#{name}**" if type.namevar == name and name != :name puts " (*namevar*)" else @@ -159,7 +159,7 @@ class TypeDoc type.providers.sort { |a,b| a.to_s <=> b.to_s }.each { |prov| - puts "\n- **%s**" % prov + puts "\n- **#{prov}**" puts @format.wrap(type.provider(prov).doc, :indent => 4, :scrub => true) } end diff --git a/lib/puppet/application/doc.rb b/lib/puppet/application/doc.rb index ae4c871cd..8dd116233 100644 --- a/lib/puppet/application/doc.rb +++ b/lib/puppet/application/doc.rb @@ -22,12 +22,12 @@ class Puppet::Application::Doc < Puppet::Application option("--charset CHARSET") option("--format FORMAT", "-f") do |arg| - method = "to_%s" % arg + method = "to_#{arg}" require 'puppet/util/reference' if Puppet::Util::Reference.method_defined?(method) options[:format] = method else - raise "Invalid output format %s" % arg + raise "Invalid output format #{arg}" end end @@ -36,7 +36,7 @@ class Puppet::Application::Doc < Puppet::Application if Puppet::Util::Reference.modes.include?(arg) or arg.intern==:rdoc options[:mode] = arg.intern else - raise "Invalid output mode %s" % arg + raise "Invalid output mode #{arg}" end end @@ -69,7 +69,7 @@ class Puppet::Application::Doc < Puppet::Application files << File.dirname(env[:manifest]) end files += command_line.args - Puppet.info "scanning: %s" % files.inspect + Puppet.info "scanning: #{files.inspect}" Puppet.settings.setdefaults( "puppetdoc", @@ -89,7 +89,7 @@ class Puppet::Application::Doc < Puppet::Application if Puppet[:trace] puts detail.backtrace end - $stderr.puts "Could not generate documentation: %s" % detail + $stderr.puts "Could not generate documentation: #{detail}" exit_code = 1 end exit exit_code @@ -98,7 +98,7 @@ class Puppet::Application::Doc < Puppet::Application def trac require 'puppet/util/reference' options[:references].each do |name| - section = Puppet::Util::Reference.reference(name) or raise "Could not find section %s" % name + section = Puppet::Util::Reference.reference(name) or raise "Could not find section #{name}" unless options[:mode] == :pdf section.trac end @@ -111,7 +111,7 @@ class Puppet::Application::Doc < Puppet::Application exit_code = 0 require 'puppet/util/reference' options[:references].sort { |a,b| a.to_s <=> b.to_s }.each do |name| - raise "Could not find reference %s" % name unless section = Puppet::Util::Reference.reference(name) + raise "Could not find reference #{name}" unless section = Puppet::Util::Reference.reference(name) begin # Add the per-section text, but with no ToC @@ -122,7 +122,7 @@ class Puppet::Application::Doc < Puppet::Application text = "" rescue => detail puts detail.backtrace - $stderr.puts "Could not generate reference %s: %s" % [name, detail] + $stderr.puts "Could not generate reference #{name}: #{detail}" exit_code = 1 next end @@ -141,14 +141,14 @@ class Puppet::Application::Doc < Puppet::Application exit_code = 0 require 'puppet/util/reference' options[:references].sort { |a,b| a.to_s <=> b.to_s }.each do |name| - raise "Could not find reference %s" % name unless section = Puppet::Util::Reference.reference(name) + raise "Could not find reference #{name}" unless section = Puppet::Util::Reference.reference(name) begin # Add the per-section text, but with no ToC text += section.send(options[:format], with_contents) rescue => detail puts detail.backtrace - $stderr.puts "Could not generate reference %s: %s" % [name, detail] + $stderr.puts "Could not generate reference #{name}: #{detail}" exit_code = 1 next end diff --git a/lib/puppet/application/filebucket.rb b/lib/puppet/application/filebucket.rb index 842e172c1..095a413a7 100644 --- a/lib/puppet/application/filebucket.rb +++ b/lib/puppet/application/filebucket.rb @@ -28,15 +28,15 @@ class Puppet::Application::Filebucket < Puppet::Application def backup args.each do |file| unless FileTest.exists?(file) - $stderr.puts "%s: no such file" % file + $stderr.puts "#{file}: no such file" next end unless FileTest.readable?(file) - $stderr.puts "%s: cannot read file" % file + $stderr.puts "#{file}: cannot read file" next end md5 = @client.backup(file) - puts "%s: %s" % [file, md5] + puts "#{file}: #{md5}" end end diff --git a/lib/puppet/application/kick.rb b/lib/puppet/application/kick.rb index e6cbed6c8..eaafc0935 100644 --- a/lib/puppet/application/kick.rb +++ b/lib/puppet/application/kick.rb @@ -32,7 +32,7 @@ class Puppet::Application::Kick < Puppet::Application begin options[:parallel] = Integer(arg) rescue - $stderr.puts "Could not convert %s to an integer" % arg.inspect + $stderr.puts "Could not convert #{arg.inspect} to an integer" exit(23) end end @@ -80,9 +80,9 @@ class Puppet::Application::Kick < Puppet::Application if $CHILD_STATUS.exitstatus != 0 failures << host end - print "%s finished with exit code %s\n" % [host, $CHILD_STATUS.exitstatus] + print "#{host} finished with exit code #{$CHILD_STATUS.exitstatus}\n" else - $stderr.puts "Could not find host for PID %s with status %s" % [pid, $CHILD_STATUS.exitstatus] + $stderr.puts "Could not find host for PID #{pid} with status #{$CHILD_STATUS.exitstatus}" end rescue Errno::ECHILD # There are no children left, so just exit unless there are still @@ -93,7 +93,7 @@ class Puppet::Application::Kick < Puppet::Application puts "Finished" exit(0) else - puts "Failed: %s" % failures.join(", ") + puts "Failed: #{failures.join(", ")}" exit(3) end end @@ -105,7 +105,7 @@ class Puppet::Application::Kick < Puppet::Application if options[:ping] out = %x{ping -c 1 #{host}} unless $CHILD_STATUS == 0 - $stderr.print "Could not contact %s\n" % host + $stderr.print "Could not contact #{host}\n" next end end @@ -115,7 +115,7 @@ class Puppet::Application::Kick < Puppet::Application port = Puppet[:puppetport] url = ["https://#{host}:#{port}", "production", "run", host].join('/') - print "Triggering %s\n" % host + print "Triggering #{host}\n" begin run_options = { :tags => @tags, @@ -128,7 +128,7 @@ class Puppet::Application::Kick < Puppet::Application puts "status is #{result}" rescue => detail puts detail.backtrace if Puppet[:trace] - $stderr.puts "Host %s failed: %s\n" % [host, detail] + $stderr.puts "Host #{host} failed: #{detail}\n" exit(2) end @@ -136,10 +136,10 @@ class Puppet::Application::Kick < Puppet::Application when "success"; exit(0) when "running" - $stderr.puts "Host %s is already running" % host + $stderr.puts "Host #{host} is already running" exit(3) else - $stderr.puts "Host %s returned unknown answer '%s'" % [host, result] + $stderr.puts "Host #{host} returned unknown answer '#{result}'" exit(12) end end @@ -178,12 +178,12 @@ class Puppet::Application::Kick < Puppet::Application if Puppet[:node_terminus] == "ldap" and (options[:all] or @classes) if options[:all] @hosts = Puppet::Node.search("whatever", :fqdn => options[:fqdn]).collect { |node| node.name } - puts "all: %s" % @hosts.join(", ") + puts "all: #{@hosts.join(", ")}" else @hosts = [] @classes.each do |klass| list = Puppet::Node.search("whatever", :fqdn => options[:fqdn], :class => klass).collect { |node| node.name } - puts "%s: %s" % [klass, list.join(", ")] + puts "#{klass}: #{list.join(", ")}" @hosts += list end diff --git a/lib/puppet/application/master.rb b/lib/puppet/application/master.rb index a8ed27c42..7ea3f3a83 100644 --- a/lib/puppet/application/master.rb +++ b/lib/puppet/application/master.rb @@ -54,7 +54,7 @@ class Puppet::Application::Master < Puppet::Application raise ArgumentError, "Cannot render compiled catalogs without pson support" unless Puppet.features.pson? begin unless catalog = Puppet::Resource::Catalog.find(options[:node]) - raise "Could not compile catalog for %s" % options[:node] + raise "Could not compile catalog for #{options[:node]}" end jj catalog.to_resource @@ -100,7 +100,7 @@ class Puppet::Application::Master < Puppet::Application Puppet::Util.chuser rescue => detail puts detail.backtrace if Puppet[:trace] - $stderr.puts "Could not change user to %s: %s" % [Puppet[:user], detail] + $stderr.puts "Could not change user to #{Puppet[:user]}: #{detail}" exit(39) end end @@ -114,7 +114,7 @@ class Puppet::Application::Master < Puppet::Application @app = Puppet::Network::HTTP::Rack.new(:xmlrpc_handlers => xmlrpc_handlers, :protocols => [:rest, :xmlrpc]) end - Puppet.notice "Starting Puppet master version %s" % [Puppet.version] + Puppet.notice "Starting Puppet master version #{Puppet.version}" unless options[:rack] @daemon.start diff --git a/lib/puppet/application/queue.rb b/lib/puppet/application/queue.rb index ce5323505..8e830b39e 100644 --- a/lib/puppet/application/queue.rb +++ b/lib/puppet/application/queue.rb @@ -38,17 +38,17 @@ class Puppet::Application::Queue < Puppet::Application option("--verbose","-v") def main - Puppet.notice "Starting puppetqd %s" % Puppet.version + Puppet.notice "Starting puppetqd #{Puppet.version}" Puppet::Resource::Catalog::Queue.subscribe do |catalog| # Once you have a Puppet::Resource::Catalog instance, calling save() on it should suffice # to put it through to the database via its active_record indirector (which is determined # by the terminus_class = :active_record setting above) - Puppet::Util.benchmark(:notice, "Processing queued catalog for %s" % catalog.name) do + Puppet::Util.benchmark(:notice, "Processing queued catalog for #{catalog.name}") do begin catalog.save rescue => detail puts detail.backtrace if Puppet[:trace] - Puppet.err "Could not save queued catalog for %s: %s" % [catalog.name, detail] + Puppet.err "Could not save queued catalog for #{catalog.name}: #{detail}" end end end diff --git a/lib/puppet/application/resource.rb b/lib/puppet/application/resource.rb index df18cb5c7..a6cc99302 100644 --- a/lib/puppet/application/resource.rb +++ b/lib/puppet/application/resource.rb @@ -45,7 +45,7 @@ class Puppet::Application::Resource < Puppet::Application if setting =~ /^(\w+)=(.+)$/ params[$1] = $2 else - raise "Invalid parameter setting %s" % setting + raise "Invalid parameter setting #{setting}" end end @@ -96,7 +96,7 @@ class Puppet::Application::Resource < Puppet::Application end ENV["EDITOR"] ||= "vi" system(ENV["EDITOR"], file) - system("puppet -v " + file) + system("puppet -v #{file}") ensure #if FileTest.exists? file # File.unlink(file) diff --git a/lib/puppet/configurer.rb b/lib/puppet/configurer.rb index dc2b99cfe..832205f5f 100644 --- a/lib/puppet/configurer.rb +++ b/lib/puppet/configurer.rb @@ -57,12 +57,12 @@ class Puppet::Configurer if Puppet[:trace] puts detail.backtrace end - Puppet.err "Corrupt state file %s: %s" % [Puppet[:statefile], detail] + Puppet.err "Corrupt state file #{Puppet[:statefile]}: #{detail}" begin ::File.unlink(Puppet[:statefile]) retry rescue => detail - raise Puppet::Error.new("Cannot remove %s: %s" % [Puppet[:statefile], detail]) + raise Puppet::Error.new("Cannot remove #{Puppet[:statefile]}: #{detail}") end end end @@ -135,7 +135,7 @@ class Puppet::Configurer raise rescue Exception => detail puts detail.backtrace if Puppet[:trace] - Puppet.err "Failed to prepare catalog: %s" % detail + Puppet.err "Failed to prepare catalog: #{detail}" end options[:report] ||= initialize_report() @@ -158,7 +158,7 @@ class Puppet::Configurer report rescue => detail puts detail.backtrace if Puppet[:trace] - Puppet.err "Failed to apply catalog: %s" % detail + Puppet.err "Failed to apply catalog: #{detail}" return end ensure @@ -219,7 +219,7 @@ class Puppet::Configurer result rescue => detail puts detail.backtrace if Puppet[:trace] - Puppet.err "Could not retrieve catalog from cache: %s" % detail + Puppet.err "Could not retrieve catalog from cache: #{detail}" return nil end @@ -233,7 +233,7 @@ class Puppet::Configurer raise rescue Exception => detail puts detail.backtrace if Puppet[:trace] - Puppet.err "Could not retrieve catalog from remote server: %s" % detail + Puppet.err "Could not retrieve catalog from remote server: #{detail}" return nil end end diff --git a/lib/puppet/configurer/downloader.rb b/lib/puppet/configurer/downloader.rb index 7409fca64..5daea295b 100644 --- a/lib/puppet/configurer/downloader.rb +++ b/lib/puppet/configurer/downloader.rb @@ -38,7 +38,7 @@ class Puppet::Configurer::Downloader end rescue Puppet::Error, Timeout::Error => detail puts detail.backtrace if Puppet[:debug] - Puppet.err "Could not retrieve #{name}: %s" % detail + Puppet.err "Could not retrieve #{name}: #{detail}" end return files diff --git a/lib/puppet/configurer/fact_handler.rb b/lib/puppet/configurer/fact_handler.rb index 5ff202002..9710681d4 100644 --- a/lib/puppet/configurer/fact_handler.rb +++ b/lib/puppet/configurer/fact_handler.rb @@ -21,7 +21,7 @@ module Puppet::Configurer::FactHandler raise rescue Exception => detail puts detail.backtrace if Puppet[:trace] - raise Puppet::Error, "Could not retrieve local facts: %s" % detail + raise Puppet::Error, "Could not retrieve local facts: #{detail}" end end diff --git a/lib/puppet/configurer/plugin_handler.rb b/lib/puppet/configurer/plugin_handler.rb index 9e1c113f9..98c8de367 100644 --- a/lib/puppet/configurer/plugin_handler.rb +++ b/lib/puppet/configurer/plugin_handler.rb @@ -17,12 +17,12 @@ module Puppet::Configurer::PluginHandler return if FileTest.directory?(file) begin - Puppet.info "Loading downloaded plugin %s" % file + Puppet.info "Loading downloaded plugin #{file}" load file rescue SystemExit,NoMemoryError raise rescue Exception => detail - Puppet.err "Could not load downloaded file %s: %s" % [file, detail] + Puppet.err "Could not load downloaded file #{file}: #{detail}" end end end diff --git a/lib/puppet/daemon.rb b/lib/puppet/daemon.rb index 5d5c4631f..ed06ea6c8 100755 --- a/lib/puppet/daemon.rb +++ b/lib/puppet/daemon.rb @@ -32,9 +32,9 @@ class Puppet::Daemon $stderr.reopen $stdout Puppet::Util::Log.reopen rescue => detail - Puppet.err "Could not start %s: %s" % [Puppet[:name], detail] + Puppet.err "Could not start #{Puppet[:name]}: #{detail}" Puppet::Util::secure_open("/tmp/daemonout", "w") { |f| - f.puts "Could not start %s: %s" % [Puppet[:name], detail] + f.puts "Could not start #{Puppet[:name]}: #{detail}" } exit(12) end @@ -45,7 +45,7 @@ class Puppet::Daemon def create_pidfile Puppet::Util.sync(Puppet[:name]).synchronize(Sync::EX) do unless Puppet::Util::Pidlock.new(pidfile).lock - raise "Could not create PID file: %s" % [pidfile] + raise "Could not create PID file: #{pidfile}" end end end @@ -58,7 +58,7 @@ class Puppet::Daemon def reexec raise Puppet::DevError, "Cannot reexec unless ARGV arguments are set" unless argv command = $0 + " " + argv.join(" ") - Puppet.notice "Restarting with '%s'" % command + Puppet.notice "Restarting with '#{command}'" stop(:exit => false) exec(command) end @@ -78,7 +78,7 @@ class Puppet::Daemon Puppet::Util.sync(Puppet[:name]).synchronize(Sync::EX) do locker = Puppet::Util::Pidlock.new(pidfile) if locker.locked? - locker.unlock or Puppet.err "Could not remove PID file %s" % [pidfile] + locker.unlock or Puppet.err "Could not remove PID file #{pidfile}" end end end diff --git a/lib/puppet/error.rb b/lib/puppet/error.rb index 66c4f19a6..040a6c4b2 100644 --- a/lib/puppet/error.rb +++ b/lib/puppet/error.rb @@ -23,11 +23,11 @@ module Puppet # :nodoc: def to_s str = nil if self.file and self.line - str = "%s at %s:%s" % [@message.to_s, @file, @line] + str = "#{@message} at #{@file}:#{@line}" elsif self.line - str = "%s at line %s" % [@message.to_s, @line] + str = "#{@message} at line #{@line}" elsif self.file - str = "%s in %s" % [@message.to_s, self.file] + str = "#{@message} in #{self.file}" else str = @message.to_s end diff --git a/lib/puppet/external/dot.rb b/lib/puppet/external/dot.rb index b0d542891..77d66e92e 100644 --- a/lib/puppet/external/dot.rb +++ b/lib/puppet/external/dot.rb @@ -311,7 +311,7 @@ module DOT i[1] && i[0] != 'label' ? t + $tab + "#{i[0]} = #{i[1]}" : i[1] ? t + $tab + "#{i[0]} = \"#{i[1]}\"" : nil - }.compact.join( "\n" ) + "\n" + t + "]\n" + }.compact.join( "\n" ) + "\n#{t}]\n" end end # class DOTEdge diff --git a/lib/puppet/external/nagios/base.rb b/lib/puppet/external/nagios/base.rb index 1b49459a4..d3766e6f5 100755 --- a/lib/puppet/external/nagios/base.rb +++ b/lib/puppet/external/nagios/base.rb @@ -32,7 +32,7 @@ class Nagios::Base # Uncamelcase a parameter. def self.decamelcase(param) param.gsub(/[A-Z]/) do |match| - "_" + match.downcase + "_#{match.downcase}" end end @@ -43,7 +43,7 @@ class Nagios::Base if @types.include?(name) @types[name].new(args) else - raise UnknownNagiosType, "Unknown type %s" % name + raise UnknownNagiosType, "Unknown type #{name}" end end @@ -81,7 +81,7 @@ class Nagios::Base @namevar = tmp return @namevar else - raise "Type %s has no name var" % self.name + raise "Type #{self.name} has no name var" end end end @@ -287,14 +287,14 @@ class Nagios::Base oc.sub!(/::/,'') ocs.push oc ocs.each { |oc| - str += "objectclass: " + oc + "\n" + str += "objectclass: #{oc}\n" } @parameters.each { |name,value| if self.class.suppress.include?(name) next end ldapname = self.parammap(name) - str += ldapname + ": " + value + "\n" + str += ldapname + ": #{value}\n" } str += "\n" str diff --git a/lib/puppet/external/nagios/parser.rb b/lib/puppet/external/nagios/parser.rb index 4a1f4c98d..80b912bc0 100644 --- a/lib/puppet/external/nagios/parser.rb +++ b/lib/puppet/external/nagios/parser.rb @@ -537,10 +537,10 @@ def token if yytext =~ /\W/ giveback = yytext.dup giveback.sub!(/^\w+/,'') - #puts "giveback " + giveback - #puts "yytext " + yytext + #puts "giveback #{giveback}" + #puts "yytext #{yytext}" yytext.sub!(/\W.*$/,'') - #puts "yytext " + yytext + #puts "yytext #{yytext}" #puts "all [#{giveback} #{yytext} #{orig}]" @src = giveback + @src end diff --git a/lib/puppet/file_bucket/dipper.rb b/lib/puppet/file_bucket/dipper.rb index d9239e865..714f4f9cd 100644 --- a/lib/puppet/file_bucket/dipper.rb +++ b/lib/puppet/file_bucket/dipper.rb @@ -31,7 +31,7 @@ class Puppet::FileBucket::Dipper # Back up a file to our bucket def backup(file) unless ::File.exist?(file) - raise(ArgumentError, "File %s does not exist" % file) + raise(ArgumentError, "File #{file} does not exist") end contents = ::File.read(file) begin @@ -42,7 +42,7 @@ class Puppet::FileBucket::Dipper return file_bucket_file.checksum_data rescue => detail puts detail.backtrace if Puppet[:trace] - raise Puppet::Error, "Could not back up %s: %s" % [file, detail] + raise Puppet::Error, "Could not back up #{file}: #{detail}" end end @@ -84,7 +84,7 @@ class Puppet::FileBucket::Dipper ::File.chmod(changed, file) end else - Puppet.err "Could not find file with checksum %s" % sum + Puppet.err "Could not find file with checksum #{sum}" return nil end return newsum diff --git a/lib/puppet/file_serving/base.rb b/lib/puppet/file_serving/base.rb index 3543df8d7..8e55f742a 100644 --- a/lib/puppet/file_serving/base.rb +++ b/lib/puppet/file_serving/base.rb @@ -38,7 +38,7 @@ class Puppet::FileServing::Base begin send param.to_s + "=", value rescue NoMethodError - raise ArgumentError, "Invalid option %s for %s" % [param, self.class] + raise ArgumentError, "Invalid option #{param} for #{self.class}" end end end diff --git a/lib/puppet/file_serving/configuration.rb b/lib/puppet/file_serving/configuration.rb index 9034caed1..69b1f9329 100644 --- a/lib/puppet/file_serving/configuration.rb +++ b/lib/puppet/file_serving/configuration.rb @@ -41,7 +41,7 @@ class Puppet::FileServing::Configuration end if environment.module(mount_name) - Puppet::Util::Warnings.notice_once "DEPRECATION NOTICE: Files found in modules without specifying 'modules' in file path will be deprecated in the next major release. Please fix module '%s' when no 0.24.x clients are present" % mount_name + Puppet::Util::Warnings.notice_once "DEPRECATION NOTICE: Files found in modules without specifying 'modules' in file path will be deprecated in the next major release. Please fix module '#{mount_name}' when no 0.24.x clients are present" return mounts["modules"] end @@ -70,12 +70,12 @@ class Puppet::FileServing::Configuration mount_name, path = request.key.split(File::Separator, 2) - raise(ArgumentError, "Cannot find file: Invalid path '%s'" % mount_name) unless mount_name =~ %r{^[-\w]+$} + raise(ArgumentError, "Cannot find file: Invalid path '#{mount_name}'") unless mount_name =~ %r{^[-\w]+$} return nil unless mount = find_mount(mount_name, request.environment) if mount.name == "modules" and mount_name != "modules" # yay backward-compatibility - path = "%s/%s" % [mount_name, path] + path = "#{mount_name}/#{path}" end if path == "" @@ -119,7 +119,7 @@ class Puppet::FileServing::Configuration @mounts = newmounts rescue => detail puts detail.backtrace if Puppet[:trace] - Puppet.err "Error parsing fileserver configuration: %s; using old configuration" % detail + Puppet.err "Error parsing fileserver configuration: #{detail}; using old configuration" end ensure diff --git a/lib/puppet/file_serving/configuration/parser.rb b/lib/puppet/file_serving/configuration/parser.rb index d8bf30477..f40a554e3 100644 --- a/lib/puppet/file_serving/configuration/parser.rb +++ b/lib/puppet/file_serving/configuration/parser.rb @@ -7,8 +7,8 @@ class Puppet::FileServing::Configuration::Parser < Puppet::Util::LoadedFile # Parse our configuration file. def parse - raise("File server configuration %s does not exist" % self.file) unless FileTest.exists?(self.file) - raise("Cannot read file server configuration %s" % self.file) unless FileTest.readable?(self.file) + raise("File server configuration #{self.file} does not exist") unless FileTest.exists?(self.file) + raise("Cannot read file server configuration #{self.file}") unless FileTest.readable?(self.file) @mounts = {} @count = 0 @@ -36,10 +36,10 @@ class Puppet::FileServing::Configuration::Parser < Puppet::Util::LoadedFile when "deny" deny(mount, value) else - raise ArgumentError.new("Invalid argument '%s'" % var, @count, file) + raise ArgumentError.new("Invalid argument '#{var}'", @count, file) end else - raise ArgumentError.new("Invalid line '%s'" % line.chomp, @count, file) + raise ArgumentError.new("Invalid line '#{line.chomp}'", @count, file) end } } @@ -56,7 +56,7 @@ class Puppet::FileServing::Configuration::Parser < Puppet::Util::LoadedFile # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] x = value.split(/\s*,\s*/).each { |val| begin - mount.info "allowing %s access" % val + mount.info "allowing #{val} access" mount.allow(val) rescue AuthStoreError => detail @@ -73,7 +73,7 @@ class Puppet::FileServing::Configuration::Parser < Puppet::Util::LoadedFile # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com] x = value.split(/\s*,\s*/).each { |val| begin - mount.info "denying %s access" % val + mount.info "denying #{val} access" mount.deny(val) rescue AuthStoreError => detail @@ -88,7 +88,7 @@ class Puppet::FileServing::Configuration::Parser < Puppet::Util::LoadedFile # Create a new mount. def newmount(name) if @mounts.include?(name) - raise ArgumentError, "%s is already mounted at %s" % [@mounts[name], name], @count, file + raise ArgumentError, "#{@mounts[name]} is already mounted at #{name}", @count, file end case name when "modules" @@ -108,7 +108,7 @@ class Puppet::FileServing::Configuration::Parser < Puppet::Util::LoadedFile begin mount.path = value rescue ArgumentError => detail - Puppet.err "Removing mount %s: %s" % [mount.name, detail] + Puppet.err "Removing mount #{mount.name}: #{detail}" @mounts.delete(mount.name) end else diff --git a/lib/puppet/file_serving/fileset.rb b/lib/puppet/file_serving/fileset.rb index 41765164e..4155685d6 100644 --- a/lib/puppet/file_serving/fileset.rb +++ b/lib/puppet/file_serving/fileset.rb @@ -81,7 +81,7 @@ class Puppet::FileServing::Fileset def links=(links) links = links.to_sym - raise(ArgumentError, "Invalid :links value '%s'" % links) unless [:manage, :follow].include?(links) + raise(ArgumentError, "Invalid :links value '#{links}'") unless [:manage, :follow].include?(links) @links = links @stat_method = links == :manage ? :lstat : :stat end @@ -99,7 +99,7 @@ class Puppet::FileServing::Fileset begin send(method, value) rescue NoMethodError - raise ArgumentError, "Invalid option '%s'" % option + raise ArgumentError, "Invalid option '#{option}'" end end end diff --git a/lib/puppet/file_serving/indirection_hooks.rb b/lib/puppet/file_serving/indirection_hooks.rb index 5fd7985e7..d1219f0c1 100644 --- a/lib/puppet/file_serving/indirection_hooks.rb +++ b/lib/puppet/file_serving/indirection_hooks.rb @@ -25,7 +25,7 @@ module Puppet::FileServing::IndirectionHooks end if request.protocol and PROTOCOL_MAP[request.protocol].nil? - raise(ArgumentError, "URI protocol '%s' is not currently supported for file serving" % request.protocol) + raise(ArgumentError, "URI protocol '#{request.protocol}' is not currently supported for file serving") end # If we're still here, we're using the file_server or modules. diff --git a/lib/puppet/file_serving/metadata.rb b/lib/puppet/file_serving/metadata.rb index 848a5f963..697de1055 100644 --- a/lib/puppet/file_serving/metadata.rb +++ b/lib/puppet/file_serving/metadata.rb @@ -36,7 +36,7 @@ class Puppet::FileServing::Metadata < Puppet::FileServing::Base end def checksum_type=(type) - raise(ArgumentError, "Unsupported checksum type %s" % type) unless respond_to?("%s_file" % type) + raise(ArgumentError, "Unsupported checksum type #{type}") unless respond_to?("#{type}_file") @checksum_type = type end @@ -57,15 +57,15 @@ class Puppet::FileServing::Metadata < Puppet::FileServing::Base case stat.ftype when "file" - @checksum = ("{%s}" % @checksum_type) + send("%s_file" % @checksum_type, real_path).to_s + @checksum = ("{#{@checksum_type}}") + send("#{@checksum_type}_file", real_path).to_s when "directory" # Always just timestamp the directory. @checksum_type = "ctime" - @checksum = ("{%s}" % @checksum_type) + send("%s_file" % @checksum_type, path).to_s + @checksum = ("{#{@checksum_type}}") + send("#{@checksum_type}_file", path).to_s when "link" @destination = File.readlink(real_path) - @checksum = ("{%s}" % @checksum_type) + send("%s_file" % @checksum_type, real_path).to_s rescue nil + @checksum = ("{#{@checksum_type}}") + send("#{@checksum_type}_file", real_path).to_s rescue nil else - raise ArgumentError, "Cannot manage files of type %s" % stat.ftype + raise ArgumentError, "Cannot manage files of type #{stat.ftype}" end end diff --git a/lib/puppet/file_serving/mount.rb b/lib/puppet/file_serving/mount.rb index 7ee11a99b..420b6f73e 100644 --- a/lib/puppet/file_serving/mount.rb +++ b/lib/puppet/file_serving/mount.rb @@ -23,7 +23,7 @@ class Puppet::FileServing::Mount < Puppet::Network::AuthStore # Create our object. It must have a name. def initialize(name) unless name =~ %r{^[-\w]+$} - raise ArgumentError, "Invalid mount name format '%s'" % name + raise ArgumentError, "Invalid mount name format '#{name}'" end @name = name @@ -35,7 +35,7 @@ class Puppet::FileServing::Mount < Puppet::Network::AuthStore end def to_s - "mount[%s]" % @name + "mount[#{@name}]" end # A noop. diff --git a/lib/puppet/file_serving/mount/file.rb b/lib/puppet/file_serving/mount/file.rb index 8a619e962..c876cc2c0 100644 --- a/lib/puppet/file_serving/mount/file.rb +++ b/lib/puppet/file_serving/mount/file.rb @@ -56,10 +56,10 @@ class Puppet::FileServing::Mount::File < Puppet::FileServing::Mount @expandable = true else unless FileTest.directory?(path) - raise ArgumentError, "%s does not exist or is not a directory" % path + raise ArgumentError, "#{path} does not exist or is not a directory" end unless FileTest.readable?(path) - raise ArgumentError, "%s is not readable" % path + raise ArgumentError, "#{path} is not readable" end @expandable = false end @@ -96,7 +96,7 @@ class Puppet::FileServing::Mount::File < Puppet::FileServing::Mount if node map = clientmap(node) else - Puppet.notice "No client; expanding '%s' with local host" % path + Puppet.notice "No client; expanding '#{path}' with local host" # Else, use the local information map = localmap() end diff --git a/lib/puppet/indirector.rb b/lib/puppet/indirector.rb index 4f56b2fc4..97892d99a 100644 --- a/lib/puppet/indirector.rb +++ b/lib/puppet/indirector.rb @@ -18,7 +18,7 @@ module Puppet::Indirector # evaluated at parse time, which is before the user has had a chance # to override it. def indirects(indirection, options = {}) - raise(ArgumentError, "Already handling indirection for %s; cannot also handle %s" % [@indirection.name, indirection]) if defined?(@indirection) and @indirection + raise(ArgumentError, "Already handling indirection for #{@indirection.name}; cannot also handle #{indirection}") if defined?(@indirection) and @indirection # populate this class with the various new methods extend ClassMethods include InstanceMethods diff --git a/lib/puppet/indirector/catalog/compiler.rb b/lib/puppet/indirector/catalog/compiler.rb index b1c9df7c4..a689eff2d 100644 --- a/lib/puppet/indirector/catalog/compiler.rb +++ b/lib/puppet/indirector/catalog/compiler.rb @@ -13,7 +13,7 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code def extract_facts_from_request(request) return unless text_facts = request.options[:facts] - raise ArgumentError, "Facts but no fact format provided for %s" % request.name unless format = request.options[:facts_format] + raise ArgumentError, "Facts but no fact format provided for #{request.name}" unless format = request.options[:facts_format] # If the facts were encoded as yaml, then the param reconstitution system # in Network::HTTP::Handler will automagically deserialize the value. @@ -66,15 +66,15 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code # Compile the actual catalog. def compile(node) - str = "Compiled catalog for %s" % node.name + str = "Compiled catalog for #{node.name}" if node.environment - str += " in environment %s" % node.environment + str += " in environment #{node.environment}" end config = nil loglevel = networked? ? :notice : :none - benchmark(loglevel, "Compiled catalog for %s" % node.name) do + benchmark(loglevel, "Compiled catalog for #{node.name}") do begin return Puppet::Parser::Compiler.compile(node) rescue Puppet::Error => detail @@ -92,7 +92,7 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code return nil unless node = Puppet::Node.find(name) rescue => detail puts detail.backtrace if Puppet[:trace] - raise Puppet::Error, "Failed when searching for node %s: %s" % [name, detail] + raise Puppet::Error, "Failed when searching for node #{name}: #{detail}" end @@ -117,7 +117,7 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code return node end - raise ArgumentError, "Could not find node '%s'; cannot compile" % name + raise ArgumentError, "Could not find node '#{name}'; cannot compile" end # Initialize our server fact hash; we add these to each client, and they @@ -135,7 +135,7 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code if value = Facter.value(fact) @server_facts[var] = value else - Puppet.warning "Could not retrieve fact %s" % fact + Puppet.warning "Could not retrieve fact #{fact}" end end diff --git a/lib/puppet/indirector/certificate_request/ca.rb b/lib/puppet/indirector/certificate_request/ca.rb index e90f43a03..25680fb9b 100644 --- a/lib/puppet/indirector/certificate_request/ca.rb +++ b/lib/puppet/indirector/certificate_request/ca.rb @@ -8,7 +8,7 @@ class Puppet::SSL::CertificateRequest::Ca < Puppet::Indirector::SslFile def save(request) result = super - Puppet.notice "%s has a waiting certificate request" % request.key + Puppet.notice "#{request.key} has a waiting certificate request" result end end diff --git a/lib/puppet/indirector/exec.rb b/lib/puppet/indirector/exec.rb index 022ec5324..f8d863562 100644 --- a/lib/puppet/indirector/exec.rb +++ b/lib/puppet/indirector/exec.rb @@ -39,12 +39,12 @@ class Puppet::Indirector::Exec < Puppet::Indirector::Terminus begin output = execute(external_command) rescue Puppet::ExecutionFailure => detail - Puppet.err "Failed to find %s via exec: %s" % [name, detail] + Puppet.err "Failed to find #{name} via exec: #{detail}" return nil end if output =~ /\A\s*\Z/ # all whitespace - Puppet.debug "Empty response for %s from exec %s terminus" % [name, self.name] + Puppet.debug "Empty response for #{name} from exec #{self.name} terminus" return nil else return output diff --git a/lib/puppet/indirector/facts/facter.rb b/lib/puppet/indirector/facts/facter.rb index 9d181706c..e1d910247 100644 --- a/lib/puppet/indirector/facts/facter.rb +++ b/lib/puppet/indirector/facts/facter.rb @@ -11,7 +11,7 @@ class Puppet::Node::Facts::Facter < Puppet::Indirector::Code # Add any per-module fact directories to the factpath module_fact_dirs = Puppet[:modulepath].split(":").collect do |d| ["lib", "plugins"].map do |subdirectory| - Dir.glob("%s/*/#{subdirectory}/facter" % d) + Dir.glob("#{d}/*/#{subdirectory}/facter") end end.flatten dirs = module_fact_dirs + Puppet[:factpath].split(":") @@ -27,14 +27,14 @@ class Puppet::Node::Facts::Facter < Puppet::Indirector::Code Dir.glob("*.rb").each do |file| fqfile = ::File.join(dir, file) begin - Puppet.info "Loading facts in %s" % [::File.basename(file.sub(".rb",''))] + Puppet.info "Loading facts in #{::File.basename(file.sub(".rb",''))}" Timeout::timeout(self.timeout) do load file end rescue SystemExit,NoMemoryError raise rescue Exception => detail - Puppet.warning "Could not load fact file %s: %s" % [fqfile, detail] + Puppet.warning "Could not load fact file #{fqfile}: #{detail}" end end end diff --git a/lib/puppet/indirector/file.rb b/lib/puppet/indirector/file.rb index a035f0dac..dab8fc720 100644 --- a/lib/puppet/indirector/file.rb +++ b/lib/puppet/indirector/file.rb @@ -14,7 +14,7 @@ class Puppet::Indirector::File < Puppet::Indirector::Terminus end def file_path(request) - File.join(data_directory, request.key + "." + serialization_format) + File.join(data_directory, request.key + ".#{serialization_format}") end def latest_path(request) diff --git a/lib/puppet/indirector/file_server.rb b/lib/puppet/indirector/file_server.rb index 18ac20824..bf101d490 100644 --- a/lib/puppet/indirector/file_server.rb +++ b/lib/puppet/indirector/file_server.rb @@ -43,7 +43,7 @@ class Puppet::Indirector::FileServer < Puppet::Indirector::Terminus mount, relative_path = configuration.split_path(request) unless mount and paths = mount.search(relative_path, request) - Puppet.info "Could not find filesystem info for file '%s' in environment %s" % [request.key, request.environment] + Puppet.info "Could not find filesystem info for file '#{request.key}' in environment #{request.environment}" return nil end diff --git a/lib/puppet/indirector/indirection.rb b/lib/puppet/indirector/indirection.rb index 85890f24c..95a022e38 100644 --- a/lib/puppet/indirector/indirection.rb +++ b/lib/puppet/indirector/indirection.rb @@ -84,7 +84,7 @@ class Puppet::Indirector::Indirection end if s = terminus_setting() - text += "* **Terminus Setting**: %s" % terminus_setting + text += "* **Terminus Setting**: #{terminus_setting}" end text @@ -97,7 +97,7 @@ class Puppet::Indirector::Indirection @cache_class = nil @terminus_class = nil - raise(ArgumentError, "Indirection %s is already defined" % @name) if @@indirections.find { |i| i.name == @name } + raise(ArgumentError, "Indirection #{@name} is already defined") if @@indirections.find { |i| i.name == @name } @@indirections << self if mod = options[:extend] @@ -110,7 +110,7 @@ class Puppet::Indirector::Indirection begin send(name.to_s + "=", value) rescue NoMethodError - raise ArgumentError, "%s is not a valid Indirection parameter" % name + raise ArgumentError, "#{name} is not a valid Indirection parameter" end end end @@ -124,7 +124,7 @@ class Puppet::Indirector::Indirection def terminus(terminus_name = nil) # Get the name of the terminus. unless terminus_name ||= terminus_class - raise Puppet::DevError, "No terminus specified for %s; cannot redirect" % self.name + raise Puppet::DevError, "No terminus specified for #{self.name}; cannot redirect" end return termini[terminus_name] ||= make_terminus(terminus_name) @@ -139,7 +139,7 @@ class Puppet::Indirector::Indirection if setting = self.terminus_setting self.terminus_class = Puppet.settings[setting].to_sym else - raise Puppet::DevError, "No terminus class nor terminus setting was provided for indirection %s" % self.name + raise Puppet::DevError, "No terminus class nor terminus setting was provided for indirection #{self.name}" end end @terminus_class @@ -158,10 +158,10 @@ class Puppet::Indirector::Indirection # This is used by terminus_class= and cache=. def validate_terminus_class(terminus_class) unless terminus_class and terminus_class.to_s != "" - raise ArgumentError, "Invalid terminus name %s" % terminus_class.inspect + raise ArgumentError, "Invalid terminus name #{terminus_class.inspect}" end unless Puppet::Indirector::Terminus.terminus_class(self.name, terminus_class) - raise ArgumentError, "Could not find terminus %s for indirection %s" % [terminus_class, self.name] + raise ArgumentError, "Could not find terminus #{terminus_class} for indirection #{self.name}" end end @@ -175,7 +175,7 @@ class Puppet::Indirector::Indirection return nil unless instance = cache.find(request(:find, key, *args)) - Puppet.info "Expiring the %s cache of %s" % [self.name, instance.name] + Puppet.info "Expiring the #{self.name} cache of #{instance.name}" # Set an expiration date in the past instance.expiration = Time.now - 60 @@ -195,14 +195,14 @@ class Puppet::Indirector::Indirection end rescue => detail puts detail.backtrace if Puppet[:trace] - Puppet.err "Cached %s for %s failed: %s" % [self.name, request.key, detail] + Puppet.err "Cached #{self.name} for #{request.key} failed: #{detail}" end # Otherwise, return the result from the terminus, caching if appropriate. if ! request.ignore_terminus? and result = terminus.find(request) result.expiration ||= self.expiration if cache? and request.use_cache? - Puppet.info "Caching %s for %s" % [self.name, request.key] + Puppet.info "Caching #{self.name} for #{request.key}" cache.save request(:save, result, *args) end @@ -216,11 +216,11 @@ class Puppet::Indirector::Indirection # See if our instance is in the cache and up to date. return nil unless cache? and ! request.ignore_cache? and cached = cache.find(request) if cached.expired? - Puppet.info "Not using expired %s for %s from cache; expired at %s" % [self.name, request.key, cached.expiration] + Puppet.info "Not using expired #{self.name} for #{request.key} from cache; expired at #{cached.expiration}" return nil end - Puppet.debug "Using cached %s for %s" % [self.name, request.key] + Puppet.debug "Using cached #{self.name} for #{request.key}" return cached end @@ -245,7 +245,7 @@ class Puppet::Indirector::Indirection terminus = prepare(request) if result = terminus.search(request) - raise Puppet::DevError, "Search results from terminus %s are not an array" % terminus.name unless result.is_a?(Array) + raise Puppet::DevError, "Search results from terminus #{terminus.name} are not an array" unless result.is_a?(Array) result.each do |instance| instance.expiration ||= self.expiration end @@ -280,9 +280,9 @@ class Puppet::Indirector::Indirection return unless terminus.respond_to?(:authorized?) unless terminus.authorized?(request) - msg = "Not authorized to call %s on %s" % [request.method, request.to_s] + msg = "Not authorized to call #{request.method} on #{request}" unless request.options.empty? - msg += " with %s" % request.options.inspect + msg += " with #{request.options.inspect}" end raise ArgumentError, msg end @@ -293,7 +293,7 @@ class Puppet::Indirector::Indirection # Pick our terminus. if respond_to?(:select_terminus) unless terminus_name = select_terminus(request) - raise ArgumentError, "Could not determine appropriate terminus for %s" % request + raise ArgumentError, "Could not determine appropriate terminus for #{request}" end else terminus_name = terminus_class @@ -309,7 +309,7 @@ class Puppet::Indirector::Indirection def make_terminus(terminus_class) # Load our terminus class. unless klass = Puppet::Indirector::Terminus.terminus_class(self.name, terminus_class) - raise ArgumentError, "Could not find terminus %s for indirection %s" % [terminus_class, self.name] + raise ArgumentError, "Could not find terminus #{terminus_class} for indirection #{self.name}" end return klass.new end diff --git a/lib/puppet/indirector/key/file.rb b/lib/puppet/indirector/key/file.rb index a413ccf63..51b5cfd3d 100644 --- a/lib/puppet/indirector/key/file.rb +++ b/lib/puppet/indirector/key/file.rb @@ -25,7 +25,7 @@ class Puppet::SSL::Key::File < Puppet::Indirector::SslFile begin File.unlink(public_key_path(request.key)) rescue => detail - raise Puppet::Error, "Could not remove %s public key: %s" % [request.key, detail] + raise Puppet::Error, "Could not remove #{request.key} public key: #{detail}" end end @@ -36,7 +36,7 @@ class Puppet::SSL::Key::File < Puppet::Indirector::SslFile begin Puppet.settings.writesub(:publickeydir, public_key_path(request.key)) { |f| f.print request.instance.content.public_key.to_pem } rescue => detail - raise Puppet::Error, "Could not write %s: %s" % [request.key, detail] + raise Puppet::Error, "Could not write #{request.key}: #{detail}" end end end diff --git a/lib/puppet/indirector/ldap.rb b/lib/puppet/indirector/ldap.rb index 390fe6793..5888418ee 100644 --- a/lib/puppet/indirector/ldap.rb +++ b/lib/puppet/indirector/ldap.rb @@ -10,7 +10,7 @@ class Puppet::Indirector::Ldap < Puppet::Indirector::Terminus # Process the found entry. We assume that we don't just want the # ldap object. def process(entry) - raise Puppet::DevError, "The 'process' method has not been overridden for the LDAP terminus for %s" % self.name + raise Puppet::DevError, "The 'process' method has not been overridden for the LDAP terminus for #{self.name}" end # Default to all attributes. @@ -24,7 +24,7 @@ class Puppet::Indirector::Ldap < Puppet::Indirector::Terminus # The ldap search filter to use. def search_filter(name) - raise Puppet::DevError, "No search string set for LDAP terminus for %s" % self.name + raise Puppet::DevError, "No search string set for LDAP terminus for #{self.name}" end # Find the ldap node, return the class list and parent node specially, @@ -71,7 +71,7 @@ class Puppet::Indirector::Ldap < Puppet::Indirector::Terminus @connection = conn.connection rescue => detail puts detail.backtrace if Puppet[:trace] - raise Puppet::Error, "Could not connect to LDAP: %s" % detail + raise Puppet::Error, "Could not connect to LDAP: #{detail}" end end diff --git a/lib/puppet/indirector/memory.rb b/lib/puppet/indirector/memory.rb index 19acc14e2..332e95bcb 100644 --- a/lib/puppet/indirector/memory.rb +++ b/lib/puppet/indirector/memory.rb @@ -7,7 +7,7 @@ class Puppet::Indirector::Memory < Puppet::Indirector::Terminus end def destroy(request) - raise ArgumentError.new("Could not find %s to destroy" % request.key) unless @instances.include?(request.key) + raise ArgumentError.new("Could not find #{request.key} to destroy") unless @instances.include?(request.key) @instances.delete(request.key) end diff --git a/lib/puppet/indirector/node/exec.rb b/lib/puppet/indirector/node/exec.rb index 52cbc370c..445059d14 100644 --- a/lib/puppet/indirector/node/exec.rb +++ b/lib/puppet/indirector/node/exec.rb @@ -46,7 +46,7 @@ class Puppet::Node::Exec < Puppet::Indirector::Exec begin YAML.load(output).inject({}) { |hash, data| hash[symbolize(data[0])] = data[1]; hash } rescue => detail - raise Puppet::Error, "Could not load external node results for %s: %s" % [name, detail] + raise Puppet::Error, "Could not load external node results for #{name}: #{detail}" end end end diff --git a/lib/puppet/indirector/node/ldap.rb b/lib/puppet/indirector/node/ldap.rb index 2d58df68a..4cbc97573 100644 --- a/lib/puppet/indirector/node/ldap.rb +++ b/lib/puppet/indirector/node/ldap.rb @@ -39,7 +39,7 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap end } if node_type == 'parent' - raise Puppet::Error.new("Could not find node '%s' with environment '%s'" % [name,name_env]) + raise Puppet::Error.new("Could not find node '#{name}' with environment '#{name_env}'") end info = name2hash('default',name_env,'parent') @@ -222,7 +222,7 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap information[:environment] ||= parent_info[:environment] parent_info[:parent] else - raise Puppet::Error.new("Could not find parent node '%s'" % parent) + raise Puppet::Error.new("Could not find parent node '#{parent}'") nil end @@ -249,7 +249,7 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap parents = [info[:name]] while parent if parents.include?(parent) - raise ArgumentError, "Found loop in LDAP node parents; %s appears twice" % parent + raise ArgumentError, "Found loop in LDAP node parents; #{parent} appears twice" end parents << parent parent = find_and_merge_parent(parent, info) @@ -289,7 +289,7 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap if values.length > 1 raise Puppet::Error, - "Node entry %s specifies more than one parent: %s" % [entry.dn, values.inspect] + "Node entry #{entry.dn} specifies more than one parent: #{values.inspect}" end return nil if values.empty? return values.shift diff --git a/lib/puppet/indirector/queue.rb b/lib/puppet/indirector/queue.rb index 27ef2192c..0e9ff966c 100644 --- a/lib/puppet/indirector/queue.rb +++ b/lib/puppet/indirector/queue.rb @@ -36,12 +36,12 @@ class Puppet::Indirector::Queue < Puppet::Indirector::Terminus def save(request) begin result = nil - benchmark :info, "Queued %s for %s" % [indirection.name, request.key] do + benchmark :info, "Queued #{indirection.name} for #{request.key}" do result = client.send_message(queue, request.instance.render(:pson)) end result rescue => detail - raise Puppet::Error, "Could not write %s to queue: %s\nInstance::%s\n client : %s" % [request.key, detail,request.instance.to_s,client.to_s] + raise Puppet::Error, "Could not write #{request.key} to queue: #{detail}\nInstance::#{request.instance}\n client : #{client}" end end @@ -61,7 +61,7 @@ class Puppet::Indirector::Queue < Puppet::Indirector::Terminus # converts the _message_ from deserialized format to an actual model instance. def self.intern(message) result = nil - benchmark :info, "Loaded queued %s" % [indirection.name] do + benchmark :info, "Loaded queued #{indirection.name}" do result = model.convert_from(:pson, message) end result @@ -76,7 +76,7 @@ class Puppet::Indirector::Queue < Puppet::Indirector::Terminus yield(self.intern(msg)) rescue => detail puts detail.backtrace if Puppet[:trace] - Puppet.err "Error occured with subscription to queue %s for indirection %s: %s" % [queue, indirection_name, detail] + Puppet.err "Error occured with subscription to queue #{queue} for indirection #{indirection_name}: #{detail}" end end end diff --git a/lib/puppet/indirector/report/processor.rb b/lib/puppet/indirector/report/processor.rb index 1ff2e0e84..1b4c5ef8d 100644 --- a/lib/puppet/indirector/report/processor.rb +++ b/lib/puppet/indirector/report/processor.rb @@ -34,10 +34,10 @@ class Puppet::Transaction::Report::Processor < Puppet::Indirector::Code if Puppet[:trace] puts detail.backtrace end - Puppet.err "Report %s failed: %s" % [name, detail] + Puppet.err "Report #{name} failed: #{detail}" end else - Puppet.warning "No report named '%s'" % name + Puppet.warning "No report named '#{name}'" end end end diff --git a/lib/puppet/indirector/request.rb b/lib/puppet/indirector/request.rb index cd354ac16..6d19e59d7 100644 --- a/lib/puppet/indirector/request.rb +++ b/lib/puppet/indirector/request.rb @@ -100,7 +100,7 @@ class Puppet::Indirector::Request def model - raise ArgumentError, "Could not find indirection '%s'" % indirection_name unless i = indirection + raise ArgumentError, "Could not find indirection '#{indirection_name}'" unless i = indirection i.model end @@ -130,10 +130,10 @@ class Puppet::Indirector::Request when Symbol; value = CGI.escape(value.to_s) when Array; value = CGI.escape(YAML.dump(value)) else - raise ArgumentError, "HTTP REST queries cannot handle values of type '%s'" % value.class + raise ArgumentError, "HTTP REST queries cannot handle values of type '#{value.class}'" end - "%s=%s" % [key, value] + "#{key}=#{value}" end.join("&") end @@ -150,7 +150,7 @@ class Puppet::Indirector::Request def to_s return uri if uri - return "/%s/%s" % [indirection_name, key] + return "/#{indirection_name}/#{key}" end private @@ -170,7 +170,7 @@ class Puppet::Indirector::Request begin uri = URI.parse(URI.escape(key)) rescue => detail - raise ArgumentError, "Could not understand URL %s: %s" % [key, detail.to_s] + raise ArgumentError, "Could not understand URL #{key}: #{detail}" end # Just short-circuit these to full paths diff --git a/lib/puppet/indirector/rest.rb b/lib/puppet/indirector/rest.rb index f9b11c16f..f38d1f927 100644 --- a/lib/puppet/indirector/rest.rb +++ b/lib/puppet/indirector/rest.rb @@ -55,7 +55,7 @@ class Puppet::Indirector::REST < Puppet::Indirector::Terminus end else # Raise the http error if we didn't get a 'success' of some kind. - message = "Error %s on SERVER: %s" % [response.code, (response.body||'').empty? ? response.message : uncompress_body(response)] + message = "Error #{response.code} on SERVER: #{(response.body||'').empty? ? response.message : uncompress_body(response)}" raise Net::HTTPError.new(message, response) end end diff --git a/lib/puppet/indirector/ssl_file.rb b/lib/puppet/indirector/ssl_file.rb index 67202699d..f8034a4a1 100644 --- a/lib/puppet/indirector/ssl_file.rb +++ b/lib/puppet/indirector/ssl_file.rb @@ -49,7 +49,7 @@ class Puppet::Indirector::SslFile < Puppet::Indirector::Terminus def initialize Puppet.settings.use(:main, :ssl) - (collection_directory || file_location) or raise Puppet::DevError, "No file or directory setting provided; terminus %s cannot function" % self.class.name + (collection_directory || file_location) or raise Puppet::DevError, "No file or directory setting provided; terminus #{self.class.name} cannot function" end # Use a setting to determine our path. @@ -68,11 +68,11 @@ class Puppet::Indirector::SslFile < Puppet::Indirector::Terminus path = path(request.key) return false unless FileTest.exist?(path) - Puppet.notice "Removing file %s %s at '%s'" % [model, request.key, path] + Puppet.notice "Removing file #{model} #{request.key} at '#{path}'" begin File.unlink(path) rescue => detail - raise Puppet::Error, "Could not remove %s: %s" % [request.key, detail] + raise Puppet::Error, "Could not remove #{request.key}: #{detail}" end end @@ -92,8 +92,8 @@ class Puppet::Indirector::SslFile < Puppet::Indirector::Terminus path = path(request.key) dir = File.dirname(path) - raise Puppet::Error.new("Cannot save %s; parent directory %s does not exist" % [request.key, dir]) unless FileTest.directory?(dir) - raise Puppet::Error.new("Cannot save %s; parent directory %s is not writable" % [request.key, dir]) unless FileTest.writable?(dir) + raise Puppet::Error.new("Cannot save #{request.key}; parent directory #{dir} does not exist") unless FileTest.directory?(dir) + raise Puppet::Error.new("Cannot save #{request.key}; parent directory #{dir} is not writable") unless FileTest.writable?(dir) write(request.key, path) { |f| f.print request.instance.to_s } end @@ -143,7 +143,7 @@ class Puppet::Indirector::SslFile < Puppet::Indirector::Terminus full_file = File.join(dir, real_file) - Puppet.notice "Fixing case in %s; renaming to %s" % [full_file, file] + Puppet.notice "Fixing case in #{full_file}; renaming to #{file}" File.rename(full_file, file) return true @@ -160,7 +160,7 @@ class Puppet::Indirector::SslFile < Puppet::Indirector::Terminus begin Puppet.settings.writesub(setting, path) { |f| yield f } rescue => detail - raise Puppet::Error, "Could not write %s to %s: %s" % [path, setting, detail] + raise Puppet::Error, "Could not write #{path} to #{setting}: #{detail}" end else raise Puppet::DevError, "You must provide a setting to determine where the files are stored" diff --git a/lib/puppet/indirector/terminus.rb b/lib/puppet/indirector/terminus.rb index 4d1d58f87..60f8ec1f2 100644 --- a/lib/puppet/indirector/terminus.rb +++ b/lib/puppet/indirector/terminus.rb @@ -21,7 +21,7 @@ class Puppet::Indirector::Terminus # Convert a constant to a short name. def const2name(const) - const.sub(/^[A-Z]/) { |i| i.downcase }.gsub(/[A-Z]/) { |i| "_" + i.downcase }.intern + const.sub(/^[A-Z]/) { |i| i.downcase }.gsub(/[A-Z]/) { |i| "_#{i.downcase}" }.intern end # Look up the indirection if we were only provided a name. @@ -31,7 +31,7 @@ class Puppet::Indirector::Terminus elsif ind = Puppet::Indirector::Indirection.instance(name) @indirection = ind else - raise ArgumentError, "Could not find indirection instance %s for %s" % [name, self.name] + raise ArgumentError, "Could not find indirection instance #{name} for #{self.name}" end end @@ -50,7 +50,7 @@ class Puppet::Indirector::Terminus names = longname.split("::") # Convert everything to a lower-case symbol, converting camelcase to underscore word separation. - name = names.pop.sub(/^[A-Z]/) { |i| i.downcase }.gsub(/[A-Z]/) { |i| "_" + i.downcase }.intern + name = names.pop.sub(/^[A-Z]/) { |i| i.downcase }.gsub(/[A-Z]/) { |i| "_#{i.downcase}" }.intern subclass.name = name @@ -66,8 +66,8 @@ class Puppet::Indirector::Terminus subclass.terminus_type = self.name # Our subclass is specifically associated with an indirection. - raise("Invalid name %s" % longname) unless names.length > 0 - indirection_name = names.pop.sub(/^[A-Z]/) { |i| i.downcase }.gsub(/[A-Z]/) { |i| "_" + i.downcase }.intern + raise("Invalid name #{longname}") unless names.length > 0 + indirection_name = names.pop.sub(/^[A-Z]/) { |i| i.downcase }.gsub(/[A-Z]/) { |i| "_#{i.downcase}" }.intern if indirection_name == "" or indirection_name.nil? raise Puppet::DevError, "Could not discern indirection model from class constant" @@ -123,7 +123,7 @@ class Puppet::Indirector::Terminus def setup_instance_loading(type) unless instance_loading?(type) - instance_load type, "puppet/indirector/%s" % type + instance_load type, "puppet/indirector/#{type}" end end end diff --git a/lib/puppet/indirector/yaml.rb b/lib/puppet/indirector/yaml.rb index 2ff267f06..d82cbfa1d 100644 --- a/lib/puppet/indirector/yaml.rb +++ b/lib/puppet/indirector/yaml.rb @@ -14,12 +14,12 @@ class Puppet::Indirector::Yaml < Puppet::Indirector::Terminus begin readlock(file) { |fh| yaml = fh.read } rescue => detail - raise Puppet::Error, "Could not read YAML data for %s %s: %s" % [indirection.name, request.key, detail] + raise Puppet::Error, "Could not read YAML data for #{indirection.name} #{request.key}: #{detail}" end begin return from_yaml(yaml) rescue => detail - raise Puppet::Error, "Could not parse YAML data for %s %s: %s" % [indirection.name, request.key, detail] + raise Puppet::Error, "Could not parse YAML data for #{indirection.name} #{request.key}: #{detail}" end end @@ -39,7 +39,7 @@ class Puppet::Indirector::Yaml < Puppet::Indirector::Terminus begin writelock(file, 0660) { |f| f.print to_yaml(request.instance) } rescue TypeError => detail - Puppet.err "Could not save %s %s: %s" % [self.name, request.key, detail] + Puppet.err "Could not save #{self.name} #{request.key}: #{detail}" end end diff --git a/lib/puppet/metatype/manager.rb b/lib/puppet/metatype/manager.rb index 590562633..6d634c245 100644 --- a/lib/puppet/metatype/manager.rb +++ b/lib/puppet/metatype/manager.rb @@ -33,7 +33,7 @@ module Manager def newtype(name, options = {}, &block) # Handle backward compatibility unless options.is_a?(Hash) - Puppet.warning "Puppet::Type.newtype(%s) now expects a hash as the second argument, not %s" % [name, options.inspect] + Puppet.warning "Puppet::Type.newtype(#{name}) now expects a hash as the second argument, not #{options.inspect}" options = {:parent => options} end @@ -111,8 +111,8 @@ module Manager :hash => @types ) - if respond_to?("new" + name.to_s) - singleton_class.send(:remove_method, "new" + name.to_s) + if respond_to?("new#{name}") + singleton_class.send(:remove_method, "new#{name}") end end diff --git a/lib/puppet/module.rb b/lib/puppet/module.rb index 995262ddf..611cbdd4b 100644 --- a/lib/puppet/module.rb +++ b/lib/puppet/module.rb @@ -157,9 +157,9 @@ class Puppet::Module end def to_s - result = "Module %s" % name + result = "Module #{name}" if path - result += "(%s)" % path + result += "(#{path})" end result end @@ -201,6 +201,6 @@ class Puppet::Module end def assert_validity - raise InvalidName, "Invalid module name; module names must be alphanumeric (plus '-'), not '%s'" % name unless name =~ /^[-\w]+$/ + raise InvalidName, "Invalid module name; module names must be alphanumeric (plus '-'), not '#{name}'" unless name =~ /^[-\w]+$/ end end diff --git a/lib/puppet/network/authconfig.rb b/lib/puppet/network/authconfig.rb index 3ee4df306..7c3a51743 100644 --- a/lib/puppet/network/authconfig.rb +++ b/lib/puppet/network/authconfig.rb @@ -72,13 +72,13 @@ module Puppet if tmp == @configstamp return else - Puppet.notice "%s vs %s" % [tmp, @configstamp] + Puppet.notice "#{tmp} vs #{@configstamp}" end else return end else - Puppet.notice "%s and %s" % [@configtimeout, @configstatted] + Puppet.notice "#{@configtimeout} and #{@configstatted}" end end @@ -114,19 +114,19 @@ module Puppet when /^\s*(allow|deny|method|environment|auth(?:enticated)?)\s+(.+)$/ parse_right_directive(right, $1, $2, count) else - raise ConfigurationError, "Invalid line %s: %s" % [count, line] + raise ConfigurationError, "Invalid line #{count}: #{line}" end count += 1 } } rescue Errno::EACCES => detail - Puppet.err "Configuration error: Cannot read %s; cannot serve" % @file - #raise Puppet::Error, "Cannot read %s" % @config + Puppet.err "Configuration error: Cannot read #{@file}; cannot serve" + #raise Puppet::Error, "Cannot read #{@config}" rescue Errno::ENOENT => detail - Puppet.err "Configuration error: '%s' does not exit; cannot serve" % @file - #raise Puppet::Error, "%s does not exit" % @config + Puppet.err "Configuration error: '#{@file}' does not exit; cannot serve" + #raise Puppet::Error, "#{@config} does not exit" #rescue FileServerError => detail - # Puppet.err "FileServer error: %s" % detail + # Puppet.err "FileServer error: #{detail}" end # Verify each of the rights are valid. @@ -146,22 +146,22 @@ module Puppet modify_right(right, :deny, value, "denying %s access", count) when "method" unless right.acl_type == :regex - raise ConfigurationError, "'method' directive not allowed in namespace ACL at line %s of %s" % [count, @config] + raise ConfigurationError, "'method' directive not allowed in namespace ACL at line #{count} of #{@config}" end modify_right(right, :restrict_method, value, "allowing 'method' %s", count) when "environment" unless right.acl_type == :regex - raise ConfigurationError, "'environment' directive not allowed in namespace ACL at line %s of %s" % [count, @config] + raise ConfigurationError, "'environment' directive not allowed in namespace ACL at line #{count} of #{@config}" end modify_right(right, :restrict_environment, value, "adding environment %s", count) when /auth(?:enticated)?/ unless right.acl_type == :regex - raise ConfigurationError, "'authenticated' directive not allowed in namespace ACL at line %s of %s" % [count, @config] + raise ConfigurationError, "'authenticated' directive not allowed in namespace ACL at line #{count} of #{@config}" end modify_right(right, :restrict_authenticated, value, "adding authentication %s", count) else raise ConfigurationError, - "Invalid argument '%s' at line %s" % [var, count] + "Invalid argument '#{var}' at line #{count}" end end @@ -171,7 +171,7 @@ module Puppet right.info msg % val right.send(method, val) rescue AuthStoreError => detail - raise ConfigurationError, "%s at line %s of %s" % [detail.to_s, count, @file] + raise ConfigurationError, "#{detail} at line #{count} of #{@file}" end end end diff --git a/lib/puppet/network/authorization.rb b/lib/puppet/network/authorization.rb index d65aeeb6a..97db59338 100644 --- a/lib/puppet/network/authorization.rb +++ b/lib/puppet/network/authorization.rb @@ -20,31 +20,31 @@ module Puppet::Network # Verify that our client has access. We allow untrusted access to # puppetca methods but no others. def authorized?(request) - msg = "%s client %s access to %s" % [request.authenticated? ? "authenticated" : "unauthenticated", request, request.call] + msg = "#{request.authenticated? ? "authenticated" : "unauthenticated"} client #{request} access to #{request.call}" if request.authenticated? if authconfig.exists? if authconfig.allowed?(request) - Puppet.debug "Allowing " + msg + Puppet.debug "Allowing #{msg}" return true else - Puppet.notice "Denying " + msg + Puppet.notice "Denying #{msg}" return false end else if Puppet.run_mode.master? - Puppet.debug "Allowing " + msg + Puppet.debug "Allowing #{msg}" return true else - Puppet.notice "Denying " + msg + Puppet.notice "Denying #{msg}" return false end end else if request.handler == "puppetca" - Puppet.notice "Allowing " + msg + Puppet.notice "Allowing #{msg}" else - Puppet.notice "Denying " + msg + Puppet.notice "Denying #{msg}" return false end end @@ -55,7 +55,7 @@ module Puppet::Network if handler_loaded?(request.handler) return true else - Puppet.warning "Client %s requested unavailable functionality %s" % [request, request.handler] + Puppet.warning "Client #{request} requested unavailable functionality #{request.handler}" return false end end @@ -64,12 +64,12 @@ module Puppet::Network def verify(request) unless available?(request) raise InvalidClientRequest.new( - "Functionality %s not available" % request.handler + "Functionality #{request.handler} not available" ) end unless authorized?(request) raise InvalidClientRequest.new( - "Host %s not authorized to call %s" % [request, request.call] + "Host #{request} not authorized to call #{request.call}" ) end end diff --git a/lib/puppet/network/authstore.rb b/lib/puppet/network/authstore.rb index eb3400dd9..dc3451e34 100755 --- a/lib/puppet/network/authstore.rb +++ b/lib/puppet/network/authstore.rb @@ -49,7 +49,7 @@ module Puppet return decl.result end - info "defaulting to no access for %s" % name + info "defaulting to no access for #{name}" return false end @@ -176,7 +176,7 @@ module Puppet def type=(type) type = symbolize(type) unless [:allow, :deny].include?(type) - raise ArgumentError, "Invalid declaration type %s" % type + raise ArgumentError, "Invalid declaration type #{type}" end @type = type end @@ -247,7 +247,7 @@ module Puppet when /^\w[-.@\w]*$/ # ? Just like a host name but allow '@'s and ending '.'s [:opaque,:exact,nil,[value]] else - raise AuthStoreError, "Invalid pattern %s" % value + raise AuthStoreError, "Invalid pattern #{value}" end end end diff --git a/lib/puppet/network/client.rb b/lib/puppet/network/client.rb index f53dd3a79..7bdde65be 100644 --- a/lib/puppet/network/client.rb +++ b/lib/puppet/network/client.rb @@ -106,7 +106,7 @@ class Puppet::Network::Client end @local = true else - raise Puppet::Network::ClientError, "%s must be passed a Server or %s" % [self.class, driverparam] + raise Puppet::Network::ClientError, "#{self.class} must be passed a Server or #{driverparam}" end end @@ -135,12 +135,12 @@ class Puppet::Network::Client self.lastrun = Time.now.to_i rescue => detail puts detail.backtrace if Puppet[:trace] - Puppet.err "Could not run %s: %s" % [self.class, detail] + Puppet.err "Could not run #{self.class}: #{detail}" end end def run - raise Puppet::DevError, "Client type %s did not override run" % self.class + raise Puppet::DevError, "Client type #{self.class} did not override run" end def scheduled? @@ -179,7 +179,7 @@ class Puppet::Network::Client self.runnow if self.scheduled? rescue => detail puts detail.backtrace if Puppet[:trace] - Puppet.err "Could not run client; got otherwise uncaught exception: %s" % detail + Puppet.err "Could not run client; got otherwise uncaught exception: #{detail}" end end diff --git a/lib/puppet/network/client/ca.rb b/lib/puppet/network/client/ca.rb index 5fbdfe9e3..2b96cd681 100644 --- a/lib/puppet/network/client/ca.rb +++ b/lib/puppet/network/client/ca.rb @@ -28,7 +28,7 @@ class Puppet::Network::Client::CA < Puppet::Network::Client if Puppet[:trace] puts detail.backtrace end - raise Puppet::Error.new("Certificate retrieval failed: %s" % detail) + raise Puppet::Error.new("Certificate retrieval failed: #{detail}") end if cert.nil? or cert == "" @@ -40,12 +40,12 @@ class Puppet::Network::Client::CA < Puppet::Network::Client @cacert = OpenSSL::X509::Certificate.new(cacert) rescue => detail raise InvalidCertificate.new( - "Invalid certificate: %s" % detail + "Invalid certificate: #{detail}" ) end unless @cert.check_private_key(key) - raise InvalidCertificate, "Certificate does not match private key. Try 'puppetca --clean %s' on the server." % Puppet[:certname] + raise InvalidCertificate, "Certificate does not match private key. Try 'puppetca --clean #{Puppet[:certname]}' on the server." end # Only write the cert out if it passes validating. diff --git a/lib/puppet/network/client/proxy.rb b/lib/puppet/network/client/proxy.rb index 17b1b0e14..d3fc9d142 100644 --- a/lib/puppet/network/client/proxy.rb +++ b/lib/puppet/network/client/proxy.rb @@ -9,7 +9,7 @@ class Puppet::Network::Client::ProxyClient < Puppet::Network::Client interface.methods.each { |ary| method = ary[0] - Puppet.debug "%s: defining %s.%s" % [self, namespace, method] + Puppet.debug "#{self}: defining #{namespace}.#{method}" define_method(method) { |*args| begin @driver.send(method, *args) @@ -17,7 +17,7 @@ class Puppet::Network::Client::ProxyClient < Puppet::Network::Client #Puppet.err "Could not call %s.%s: %s" % # [namespace, method, detail.faultString] #raise NetworkClientError, - # "XMLRPC Error: %s" % detail.faultString + # "XMLRPC Error: #{detail.faultString}" raise NetworkClientError, detail.faultString end } diff --git a/lib/puppet/network/client_request.rb b/lib/puppet/network/client_request.rb index 86dd31bcf..07c974799 100644 --- a/lib/puppet/network/client_request.rb +++ b/lib/puppet/network/client_request.rb @@ -24,7 +24,7 @@ module Puppet::Network # :nodoc: end def to_s - "%s(%s)" % [self.name, self.ip] + "#{self.name}(#{self.ip})" end end end diff --git a/lib/puppet/network/format.rb b/lib/puppet/network/format.rb index 7c3cc7bd8..59082c72a 100644 --- a/lib/puppet/network/format.rb +++ b/lib/puppet/network/format.rb @@ -27,13 +27,13 @@ class Puppet::Network::Format define_method_names() method_list = { - :intern_method => "from_%s" % name, - :intern_multiple_method => "from_multiple_%s" % name, - :render_multiple_method => "to_multiple_%s" % name, - :render_method => "to_%s" % name + :intern_method => "from_#{name}", + :intern_multiple_method => "from_multiple_#{name}", + :render_multiple_method => "to_multiple_#{name}", + :render_method => "to_#{name}" } - init_attribute(:mime, "text/%s" % name) + init_attribute(:mime, "text/#{name}") init_attribute(:weight, 5) init_attribute(:required_methods, method_list.keys) init_attribute(:extension, name.to_s) @@ -43,7 +43,7 @@ class Puppet::Network::Format end unless @options.empty? - raise ArgumentError, "Unsupported option(s) %s" % @options.keys + raise ArgumentError, "Unsupported option(s) #{@options.keys}" end @options = nil @@ -53,12 +53,12 @@ class Puppet::Network::Format def intern(klass, text) return klass.send(intern_method, text) if klass.respond_to?(intern_method) - raise NotImplementedError, "%s does not respond to %s; can not intern instances from %s" % [klass, intern_method, mime] + raise NotImplementedError, "#{klass} does not respond to #{intern_method}; can not intern instances from #{mime}" end def intern_multiple(klass, text) return klass.send(intern_multiple_method, text) if klass.respond_to?(intern_multiple_method) - raise NotImplementedError, "%s does not respond to %s; can not intern multiple instances from %s" % [klass, intern_multiple_method, mime] + raise NotImplementedError, "#{klass} does not respond to #{intern_multiple_method}; can not intern multiple instances from #{mime}" end def mime=(mime) @@ -67,13 +67,13 @@ class Puppet::Network::Format def render(instance) return instance.send(render_method) if instance.respond_to?(render_method) - raise NotImplementedError, "%s does not respond to %s; can not render instances to %s" % [instance.class, render_method, mime] + raise NotImplementedError, "#{instance.class} does not respond to #{render_method}; can not render instances to #{mime}" end def render_multiple(instances) # This method implicitly assumes that all instances are of the same type. return instances[0].class.send(render_multiple_method, instances) if instances[0].class.respond_to?(render_multiple_method) - raise NotImplementedError, "%s does not respond to %s; can not intern multiple instances to %s" % [instances[0].class, render_multiple_method, mime] + raise NotImplementedError, "#{instances[0].class} does not respond to #{render_multiple_method}; can not intern multiple instances to #{mime}" end def required_methods_present?(klass) @@ -91,16 +91,16 @@ class Puppet::Network::Format end def to_s - "Puppet::Network::Format[%s]" % name + "Puppet::Network::Format[#{name}]" end private def define_method_names - @intern_method = "from_%s" % name - @render_method = "to_%s" % name - @intern_multiple_method = "from_multiple_%s" % name - @render_multiple_method = "to_multiple_%s" % name + @intern_method = "from_#{name}" + @render_method = "to_#{name}" + @intern_multiple_method = "from_multiple_#{name}" + @render_multiple_method = "to_multiple_#{name}" end def required_method_present?(name, klass, type) diff --git a/lib/puppet/network/format_handler.rb b/lib/puppet/network/format_handler.rb index 17b804f79..c21979ea4 100644 --- a/lib/puppet/network/format_handler.rb +++ b/lib/puppet/network/format_handler.rb @@ -13,7 +13,7 @@ module Puppet::Network::FormatHandler Puppet::Network::FormatHandler.format(format).send(method, *args) rescue => details direction = method.to_s.include?("intern") ? "from" : "to" - error = FormatError.new("Could not %s %s %s: %s" % [method, direction, format, details]) + error = FormatError.new("Could not #{method} #{direction} #{format}: #{details}") error.set_backtrace(details.backtrace) raise error end @@ -91,7 +91,7 @@ module Puppet::Network::FormatHandler else out = format(format) end - raise ArgumentError, "No format match the given format name or mime-type (%s)" % format if out.nil? + raise ArgumentError, "No format match the given format name or mime-type (#{format})" if out.nil? out.name end diff --git a/lib/puppet/network/handler.rb b/lib/puppet/network/handler.rb index 95e3101f2..3903bdc63 100644 --- a/lib/puppet/network/handler.rb +++ b/lib/puppet/network/handler.rb @@ -22,7 +22,7 @@ module Puppet::Network if defined?(@interface) return @interface else - raise Puppet::DevError, "Handler %s has no defined interface" % self + raise Puppet::DevError, "Handler #{self} has no defined interface" end end @@ -31,7 +31,7 @@ module Puppet::Network if side side = side.intern if side.is_a?(String) unless [:client, :server].include?(side) - raise ArgumentError, "Invalid side registration '%s' for %s" % [side, self.name] + raise ArgumentError, "Invalid side registration '#{side}' for #{self.name}" end @side = side else diff --git a/lib/puppet/network/handler/ca.rb b/lib/puppet/network/handler/ca.rb index 20d971007..8bafb5f9b 100644 --- a/lib/puppet/network/handler/ca.rb +++ b/lib/puppet/network/handler/ca.rb @@ -35,13 +35,13 @@ class Puppet::Network::Handler # we only otherwise know how to handle files unless autosign =~ /^\// - raise Puppet::Error, "Invalid autosign value %s" % autosign.inspect + raise Puppet::Error, "Invalid autosign value #{autosign.inspect}" end unless FileTest.exists?(autosign) unless defined?(@@warnedonautosign) @@warnedonautosign = true - Puppet.info "Autosign is enabled but %s is missing" % autosign + Puppet.info "Autosign is enabled but #{autosign} is missing" end return false end @@ -89,7 +89,7 @@ class Puppet::Network::Handler hostname = nameary[1] unless @ca - Puppet.notice "Host %s asked for signing from non-CA master" % hostname + Puppet.notice "Host #{hostname} asked for signing from non-CA master" return "" end @@ -102,9 +102,9 @@ class Puppet::Network::Handler # first check to see if we already have a signed cert for the host cert, cacert = ca.getclientcert(hostname) if cert and cacert - Puppet.info "Retrieving existing certificate for %s" % hostname + Puppet.info "Retrieving existing certificate for #{hostname}" unless csr.public_key.to_s == cert.public_key.to_s - raise Puppet::Error, "Certificate request does not match existing certificate; run 'puppetca --clean %s'." % hostname + raise Puppet::Error, "Certificate request does not match existing certificate; run 'puppetca --clean #{hostname}'." end return [cert.to_pem, cacert.to_pem] elsif @ca @@ -115,15 +115,15 @@ class Puppet::Network::Handler # okay, we don't have a signed cert # if we're a CA and autosign is turned on, then go ahead and sign # the csr and return the results - Puppet.info "Signing certificate for %s" % hostname + Puppet.info "Signing certificate for #{hostname}" cert, cacert = @ca.sign(csr) - #Puppet.info "Cert: %s; Cacert: %s" % [cert.class, cacert.class] + #Puppet.info "Cert: #{cert.class}; Cacert: #{cacert.class}" return [cert.to_pem, cacert.to_pem] else # just write out the csr for later signing if @ca.getclientcsr(hostname) - Puppet.info "Not replacing existing request from %s" % hostname + Puppet.info "Not replacing existing request from #{hostname}" else - Puppet.notice "Host %s has a waiting certificate request" % hostname + Puppet.notice "Host #{hostname} has a waiting certificate request" @ca.storeclientcsr(csr) end return ["", ""] @@ -142,7 +142,7 @@ class Puppet::Network::Handler if FileTest.exists?(pkeyfile) currentkey = File.open(pkeyfile) { |k| k.read } unless currentkey == public_key.to_s - raise Puppet::Error, "public keys for %s differ" % hostname + raise Puppet::Error, "public keys for #{hostname} differ" end else File.open(pkeyfile, "w", 0644) { |f| diff --git a/lib/puppet/network/handler/fileserver.rb b/lib/puppet/network/handler/fileserver.rb index a48d05d91..756e74909 100755 --- a/lib/puppet/network/handler/fileserver.rb +++ b/lib/puppet/network/handler/fileserver.rb @@ -67,7 +67,7 @@ class Puppet::Network::Handler mount, path = convert(url, client, clientip) - mount.debug("Describing %s for %s" % [url, client]) if client + mount.debug("Describing #{url} for #{client}") if client # use the mount to resolve the path for us. return "" unless full_path = mount.file_path(path, client) @@ -107,7 +107,7 @@ class Puppet::Network::Handler if hash.include?(:Mount) @passedconfig = true unless hash[:Mount].is_a?(Hash) - raise Puppet::DevError, "Invalid mount hash %s" % hash[:Mount].inspect + raise Puppet::DevError, "Invalid mount hash #{hash[:Mount].inspect}" end hash[:Mount].each { |dir, name| @@ -131,14 +131,14 @@ class Puppet::Network::Handler def list(url, links = :ignore, recurse = false, ignore = false, client = nil, clientip = nil) mount, path = convert(url, client, clientip) - mount.debug "Listing %s for %s" % [url, client] if client + mount.debug "Listing #{url} for #{client}" if client return "" unless mount.path_exists?(path, client) desc = mount.list(path, recurse, ignore, client) if desc.length == 0 - mount.notice "Got no information on //%s/%s" % [mount, path] + mount.notice "Got no information on //#{mount}/#{path}" return "" end @@ -158,7 +158,7 @@ class Puppet::Network::Handler def mount(path, name) if @mounts.include?(name) if @mounts[name] != path - raise FileServerError, "%s is already mounted at %s" % [@mounts[name].path, name] + raise FileServerError, "#{@mounts[name].path} is already mounted at #{name}" else # it's already mounted; no problem return @@ -167,7 +167,7 @@ class Puppet::Network::Handler # Let the mounts do their own error-checking. @mounts[name] = Mount.new(name, path) - @mounts[name].info "Mounted %s" % path + @mounts[name].info "Mounted #{path}" return @mounts[name] end @@ -180,7 +180,7 @@ class Puppet::Network::Handler mount, path = convert(url, client, clientip) if client - mount.info "Sending %s to %s" % [url, client] + mount.info "Sending #{url} to #{client}" end unless mount.path_exists?(path, client) @@ -217,8 +217,8 @@ class Puppet::Network::Handler clientip = nil end unless mount.allowed?(client, clientip) - mount.warning "%s cannot access %s" % [client, file] - raise Puppet::AuthorizationError, "Cannot access %s" % mount + mount.warning "#{client} cannot access #{file}" + raise Puppet::AuthorizationError, "Cannot access #{mount}" end end @@ -280,7 +280,7 @@ class Puppet::Network::Handler when /\[([-\w]+)\]/ name = $1 if newmounts.include?(name) - raise FileServerError, "%s is already mounted as %s in %s" % [newmounts[name], name, @configuration.file] + raise FileServerError, "#{newmounts[name]} is already mounted as #{name} in #{@configuration.file}" end mount = Mount.new(name) newmounts[name] = mount @@ -295,14 +295,14 @@ class Puppet::Network::Handler begin mount.path = value rescue FileServerError => detail - Puppet.err "Removing mount %s: %s" % [mount.name, detail] + Puppet.err "Removing mount #{mount.name}: #{detail}" newmounts.delete(mount.name) end end when "allow" value.split(/\s*,\s*/).each { |val| begin - mount.info "allowing %s access" % val + mount.info "allowing #{val} access" mount.allow(val) rescue AuthStoreError => detail puts detail.backtrace if Puppet[:trace] @@ -316,7 +316,7 @@ class Puppet::Network::Handler when "deny" value.split(/\s*,\s*/).each { |val| begin - mount.info "denying %s access" % val + mount.info "denying #{val} access" mount.deny(val) rescue AuthStoreError => detail @@ -327,19 +327,19 @@ class Puppet::Network::Handler end } else - raise FileServerError.new("Invalid argument '%s'" % var, count, @configuration.file) + raise FileServerError.new("Invalid argument '#{var}'", count, @configuration.file) end else - raise FileServerError.new("Invalid line '%s'" % line.chomp, count, @configuration.file) + raise FileServerError.new("Invalid line '#{line.chomp}'", count, @configuration.file) end count += 1 } } rescue Errno::EACCES => detail - Puppet.err "FileServer error: Cannot read %s; cannot serve" % @configuration - #raise Puppet::Error, "Cannot read %s" % @configuration + Puppet.err "FileServer error: Cannot read #{@configuration}; cannot serve" + #raise Puppet::Error, "Cannot read #{@configuration}" rescue Errno::ENOENT => detail - Puppet.err "FileServer error: '%s' does not exist; cannot serve" % @configuration + Puppet.err "FileServer error: '#{@configuration}' does not exist; cannot serve" end unless newmounts[MODULES] @@ -380,7 +380,7 @@ class Puppet::Network::Handler # pointing to the specific problem. newmounts.each { |name, mount| unless mount.valid? - raise FileServerError, "Invalid mount %s" % name + raise FileServerError, "Invalid mount #{name}" end } @mounts = newmounts @@ -398,11 +398,11 @@ class Puppet::Network::Handler unless mount = modules_mount(mount_name, client) unless mount = @mounts[mount_name] - raise FileServerError, "Fileserver module '%s' not mounted" % mount_name + raise FileServerError, "Fileserver module '#{mount_name}' not mounted" end end else - raise FileServerError, "Fileserver error: Invalid path '%s'" % dir + raise FileServerError, "Fileserver error: Invalid path '#{dir}'" end if path.nil? or path == '' @@ -448,7 +448,7 @@ class Puppet::Network::Handler if client map = clientmap(client) else - Puppet.notice "No client; expanding '%s' with local host" % path + Puppet.notice "No client; expanding '#{path}' with local host" # Else, use the local information map = localmap() end @@ -490,7 +490,7 @@ class Puppet::Network::Handler # Create out object. It must have a name. def initialize(name, path = nil) unless name =~ %r{^[-\w]+$} - raise FileServerError, "Invalid name format '%s'" % name + raise FileServerError, "Invalid name format '#{name}'" end @name = name @@ -573,13 +573,13 @@ class Puppet::Network::Handler @expandable = true else unless FileTest.exists?(path) - raise FileServerError, "%s does not exist" % path + raise FileServerError, "#{path} does not exist" end unless FileTest.directory?(path) - raise FileServerError, "%s is not a directory" % path + raise FileServerError, "#{path} is not a directory" end unless FileTest.readable?(path) - raise FileServerError, "%s is not readable" % path + raise FileServerError, "#{path} is not readable" end @expandable = false end @@ -617,7 +617,7 @@ class Puppet::Network::Handler end def to_s - "mount[%s]" % @name + "mount[#{@name}]" end # Verify our configuration is valid. This should really check to diff --git a/lib/puppet/network/handler/master.rb b/lib/puppet/network/handler/master.rb index d16733523..beb6e4c57 100644 --- a/lib/puppet/network/handler/master.rb +++ b/lib/puppet/network/handler/master.rb @@ -67,7 +67,7 @@ class Puppet::Network::Handler when "marshal" return CGI.escape(Marshal.dump(catalog.extract)) else - raise "Invalid markup format '%s'" % format + raise "Invalid markup format '#{format}'" end end diff --git a/lib/puppet/network/handler/report.rb b/lib/puppet/network/handler/report.rb index 960b65f73..9f885518e 100755 --- a/lib/puppet/network/handler/report.rb +++ b/lib/puppet/network/handler/report.rb @@ -12,7 +12,7 @@ class Puppet::Network::Handler # Add a new report type. def self.newreport(name, options = {}, &block) - Puppet.warning "The interface for registering report types has changed; use Puppet::Reports.register_report for report type %s" % name + Puppet.warning "The interface for registering report types has changed; use Puppet::Reports.register_report for report type #{name}" Puppet::Reports.register_report(name, options, &block) end @@ -28,11 +28,11 @@ class Puppet::Network::Handler report = CGI.unescape(report) end - Puppet.info "Processing reports %s for %s" % [reports().join(", "), client] + Puppet.info "Processing reports #{reports().join(", ")} for #{client}" begin process(report) rescue => detail - Puppet.err "Could not process report for %s: %s" % [client, detail] + Puppet.err "Could not process report for #{client}: #{detail}" if Puppet[:trace] puts detail.backtrace end @@ -49,7 +49,7 @@ class Puppet::Network::Handler begin report = YAML.load(yaml) rescue => detail - Puppet.warning "Could not load report: %s" % detail + Puppet.warning "Could not load report: #{detail}" return end @@ -68,10 +68,10 @@ class Puppet::Network::Handler if Puppet[:trace] puts detail.backtrace end - Puppet.err "Report %s failed: %s" % [name, detail] + Puppet.err "Report #{name} failed: #{detail}" end else - Puppet.warning "No report named '%s'" % name + Puppet.warning "No report named '#{name}'" end end end diff --git a/lib/puppet/network/http/api/v1.rb b/lib/puppet/network/http/api/v1.rb index 6a5ff156a..25e27c486 100644 --- a/lib/puppet/network/http/api/v1.rb +++ b/lib/puppet/network/http/api/v1.rb @@ -19,14 +19,14 @@ module Puppet::Network::HTTP::API::V1 def uri2indirection(http_method, uri, params) environment, indirection, key = uri.split("/", 4)[1..-1] # the first field is always nil because of the leading slash - raise ArgumentError, "The environment must be purely alphanumeric, not '%s'" % environment unless environment =~ /^\w+$/ - raise ArgumentError, "The indirection name must be purely alphanumeric, not '%s'" % indirection unless indirection =~ /^\w+$/ + raise ArgumentError, "The environment must be purely alphanumeric, not '#{environment}'" unless environment =~ /^\w+$/ + raise ArgumentError, "The indirection name must be purely alphanumeric, not '#{indirection}'" unless indirection =~ /^\w+$/ method = indirection_method(http_method, indirection) params[:environment] = environment - raise ArgumentError, "No request key specified in %s" % uri if key == "" or key.nil? + raise ArgumentError, "No request key specified in #{uri}" if key == "" or key.nil? key = URI.unescape(key) @@ -40,11 +40,11 @@ module Puppet::Network::HTTP::API::V1 def indirection_method(http_method, indirection) unless METHOD_MAP[http_method] - raise ArgumentError, "No support for http method %s" % http_method + raise ArgumentError, "No support for http method #{http_method}" end unless method = METHOD_MAP[http_method][plurality(indirection)] - raise ArgumentError, "No support for plural %s operations" % http_method + raise ArgumentError, "No support for plural #{http_method} operations" end return method diff --git a/lib/puppet/network/http/handler.rb b/lib/puppet/network/http/handler.rb index a76fefdcc..66e0c720e 100644 --- a/lib/puppet/network/http/handler.rb +++ b/lib/puppet/network/http/handler.rb @@ -37,14 +37,14 @@ module Puppet::Network::HTTP::Handler return format end - raise "No specified acceptable formats (%s) are functional on this machine" % header + raise "No specified acceptable formats (#{header}) are functional on this machine" end def request_format(request) if header = content_type_header(request) header.gsub!(/\s*;.*$/,'') # strip any charset format = Puppet::Network::FormatHandler.mime(header) - raise "Client sent a mime-type (%s) that doesn't correspond to a format we support" % header if format.nil? + raise "Client sent a mime-type (#{header}) that doesn't correspond to a format we support" if format.nil? return format.name.to_s if format.suitable? end @@ -65,7 +65,7 @@ module Puppet::Network::HTTP::Handler check_authorization(indirection_request) - send("do_%s" % indirection_request.method, indirection_request, request, response) + send("do_#{indirection_request.method}", indirection_request, request, response) rescue SystemExit,NoMemoryError raise rescue Exception => e @@ -99,8 +99,8 @@ module Puppet::Network::HTTP::Handler # Execute our find. def do_find(indirection_request, request, response) unless result = indirection_request.model.find(indirection_request.key, indirection_request.to_hash) - Puppet.info("Could not find %s for '%s'" % [indirection_request.indirection_name, indirection_request.key]) - return do_exception(response, "Could not find %s %s" % [indirection_request.indirection_name, indirection_request.key], 404) + Puppet.info("Could not find #{indirection_request.indirection_name} for '#{indirection_request.key}'") + return do_exception(response, "Could not find #{indirection_request.indirection_name} #{indirection_request.key}", 404) end # The encoding of the result must include the format to use, @@ -117,7 +117,7 @@ module Puppet::Network::HTTP::Handler result = indirection_request.model.search(indirection_request.key, indirection_request.to_hash) if result.nil? or (result.is_a?(Array) and result.empty?) - return do_exception(response, "Could not find instances in %s with '%s'" % [indirection_request.indirection_name, indirection_request.to_hash.inspect], 404) + return do_exception(response, "Could not find instances in #{indirection_request.indirection_name} with '#{indirection_request.to_hash.inspect}'", 404) end format = format_to_use(request) @@ -150,7 +150,7 @@ module Puppet::Network::HTTP::Handler begin return Resolv.getname(result[:ip]) rescue => detail - Puppet.err "Could not resolve %s: %s" % [result[:ip], detail] + Puppet.err "Could not resolve #{result[:ip]}: #{detail}" end return result[:ip] end diff --git a/lib/puppet/network/http/rack.rb b/lib/puppet/network/http/rack.rb index 756b66814..a5f69612d 100644 --- a/lib/puppet/network/http/rack.rb +++ b/lib/puppet/network/http/rack.rb @@ -54,7 +54,7 @@ class Puppet::Network::HTTP::Rack # log what happened Puppet.err "Puppet Server (Rack): Internal Server Error: Unhandled Exception: \"%s\"" % detail.message Puppet.err "Backtrace:" - detail.backtrace.each { |line| Puppet.err " > %s" % line } + detail.backtrace.each { |line| Puppet.err " > #{line}" } end response.finish() end diff --git a/lib/puppet/network/http/rack/xmlrpc.rb b/lib/puppet/network/http/rack/xmlrpc.rb index 4fc9e82fc..49eb6fe49 100644 --- a/lib/puppet/network/http/rack/xmlrpc.rb +++ b/lib/puppet/network/http/rack/xmlrpc.rb @@ -6,9 +6,9 @@ class Puppet::Network::HTTP::RackXMLRPC < Puppet::Network::HTTP::RackHttpHandler def initialize(handlers) @xmlrpc_server = Puppet::Network::XMLRPCServer.new handlers.each do |name| - Puppet.debug " -> register xmlrpc namespace %s" % name + Puppet.debug " -> register xmlrpc namespace #{name}" unless handler = Puppet::Network::Handler.handler(name) - raise ArgumentError, "Invalid XMLRPC handler %s" % name + raise ArgumentError, "Invalid XMLRPC handler #{name}" end @xmlrpc_server.add_handler(handler.interface, handler.new({})) end @@ -52,7 +52,7 @@ class Puppet::Network::HTTP::RackXMLRPC < Puppet::Network::HTTP::RackHttpHandler begin node = Resolv.getname(ip) rescue => detail - Puppet.err "Could not resolve %s: %s" % [ip, detail] + Puppet.err "Could not resolve #{ip}: #{detail}" node = "unknown" end authenticated = false diff --git a/lib/puppet/network/http/webrick.rb b/lib/puppet/network/http/webrick.rb index effe92434..d0533f7ff 100644 --- a/lib/puppet/network/http/webrick.rb +++ b/lib/puppet/network/http/webrick.rb @@ -98,7 +98,7 @@ class Puppet::Network::HTTP::WEBrick # Get the cached copy. We know it's been generated, too. host = Puppet::SSL::Host.localhost - raise Puppet::Error, "Could not retrieve certificate for %s and not running on a valid certificate authority" % host.name unless host.certificate + raise Puppet::Error, "Could not retrieve certificate for #{host.name} and not running on a valid certificate authority" unless host.certificate results[:SSLPrivateKey] = host.key.content results[:SSLCertificate] = host.certificate.content @@ -134,7 +134,7 @@ class Puppet::Network::HTTP::WEBrick def xmlrpc_servlet handlers = @xmlrpc_handlers.collect { |handler| unless hclass = Puppet::Network::Handler.handler(handler) - raise "Invalid xmlrpc handler %s" % handler + raise "Invalid xmlrpc handler #{handler}" end hclass.new({}) } diff --git a/lib/puppet/network/http_pool.rb b/lib/puppet/network/http_pool.rb index 980d3de13..458fe2c97 100644 --- a/lib/puppet/network/http_pool.rb +++ b/lib/puppet/network/http_pool.rb @@ -78,7 +78,7 @@ module Puppet::Network::HttpPool # a new one. def self.http_instance(host, port, reset = false) # We overwrite the uninitialized @http here with a cached one. - key = "%s:%s" % [host, port] + key = "#{host}:#{port}" # Return our cached instance if we've got a cache, as long as we're not # resetting the instance. diff --git a/lib/puppet/network/http_server/mongrel.rb b/lib/puppet/network/http_server/mongrel.rb index a10a42928..b26eee602 100644 --- a/lib/puppet/network/http_server/mongrel.rb +++ b/lib/puppet/network/http_server/mongrel.rb @@ -64,7 +64,7 @@ module Puppet::Network @xmlrpc_server = Puppet::Network::XMLRPCServer.new handlers.each do |name| unless handler = Puppet::Network::Handler.handler(name) - raise ArgumentError, "Invalid handler %s" % name + raise ArgumentError, "Invalid handler #{name}" end @xmlrpc_server.add_handler(handler.interface, handler.new({})) end @@ -129,7 +129,7 @@ module Puppet::Network begin client = Resolv.getname(ip) rescue => detail - Puppet.err "Could not resolve %s: %s" % [ip, detail] + Puppet.err "Could not resolve #{ip}: #{detail}" client = "unknown" end valid = false diff --git a/lib/puppet/network/http_server/webrick.rb b/lib/puppet/network/http_server/webrick.rb index fa7ce4872..6cf5c91fe 100644 --- a/lib/puppet/network/http_server/webrick.rb +++ b/lib/puppet/network/http_server/webrick.rb @@ -69,7 +69,7 @@ module Puppet # Create our server, yo. def initialize(hash = {}) - Puppet.info "Starting server for Puppet version %s" % Puppet.version + Puppet.info "Starting server for Puppet version #{Puppet.version}" if handlers = hash[:Handlers] handler_instances = setup_handlers(handlers) @@ -91,7 +91,7 @@ module Puppet super(hash) rescue => detail puts detail.backtrace if Puppet[:trace] - raise Puppet::Error, "Could not start WEBrick: %s" % detail + raise Puppet::Error, "Could not start WEBrick: #{detail}" end # make sure children don't inherit the sockets @@ -99,7 +99,7 @@ module Puppet sock.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) } - Puppet.info "Listening on port %s" % hash[:Port] + Puppet.info "Listening on port #{hash[:Port]}" # this creates a new servlet for every connection, # but all servlets have the same list of handlers @@ -129,7 +129,7 @@ module Puppet handlers.collect { |handler, args| hclass = nil unless hclass = Puppet::Network::Handler.handler(handler) - raise ServerError, "Invalid handler %s" % handler + raise ServerError, "Invalid handler #{handler}" end hclass.new(args) } diff --git a/lib/puppet/network/rest_authconfig.rb b/lib/puppet/network/rest_authconfig.rb index 13ad8dbb4..b22a31461 100644 --- a/lib/puppet/network/rest_authconfig.rb +++ b/lib/puppet/network/rest_authconfig.rb @@ -63,7 +63,7 @@ module Puppet def insert_default_acl DEFAULT_ACL.each do |acl| unless rights[acl[:acl]] - Puppet.info "Inserting default '#{acl[:acl]}'(%s) acl because %s" % [acl[:authenticated] ? "auth" : "non-auth" , ( !exists? ? "#{Puppet[:rest_authconfig]} doesn't exist" : "none where found in '#{@file}'")] + Puppet.info "Inserting default '#{acl[:acl]}'(#{acl[:authenticated] ? "auth" : "non-auth"}) acl because #{( !exists? ? "#{Puppet[:rest_authconfig]} doesn't exist" : "none where found in '#{@file}'")}" mk_acl(acl) end end diff --git a/lib/puppet/network/rights.rb b/lib/puppet/network/rights.rb index e8267c927..57f90727a 100755 --- a/lib/puppet/network/rights.rb +++ b/lib/puppet/network/rights.rb @@ -19,7 +19,7 @@ class Rights if obj = self[name] obj.send(method, *args) else - raise ArgumentError, "Unknown right '%s'" % name + raise ArgumentError, "Unknown right '#{name}'" end end end @@ -61,20 +61,20 @@ class Rights # or failed, in any case will throw an error to the outside world if name =~ /^\// or right # we're a patch ACL, let's fail - msg = "%s access to %s [%s]" % [ (args[:node].nil? ? args[:ip] : "#{args[:node]}(#{args[:ip]})"), name, args[:method] ] + msg = "#{(args[:node].nil? ? args[:ip] : "#{args[:node]}(#{args[:ip]})")} access to #{name} [#{args[:method]}]" msg += " authenticated " if args[:authenticated] - error = AuthorizationError.new("Forbidden request: " + msg) + error = AuthorizationError.new("Forbidden request: #{msg}") if right error.file = right.file error.line = right.line end - Puppet.warning("Denying access: " + error.to_s) + Puppet.warning("Denying access: #{error}") else # there were no rights allowing/denying name # if name is not a path, let's throw - error = ArgumentError.new "Unknown namespace right '%s'" % name + error = ArgumentError.new "Unknown namespace right '#{name}'" end raise error end @@ -156,13 +156,13 @@ class Rights @key = Regexp.new(@name) @methods = ALL else - raise ArgumentError, "Unknown right type '%s'" % name + raise ArgumentError, "Unknown right type '#{name}'" end super() end def to_s - "access[%s]" % @name + "access[#{@name}]" end # There's no real check to do at this point @@ -198,7 +198,7 @@ class Rights m = m.intern if m.is_a?(String) unless ALL.include?(m) - raise ArgumentError, "'%s' is not an allowed value for method directive" % m + raise ArgumentError, "'#{m}' is not an allowed value for method directive" end # if we were allowing all methods, then starts from scratch @@ -207,7 +207,7 @@ class Rights end if @methods.include?(m) - raise ArgumentError, "'%s' is already in the '%s' ACL" % [m, name] + raise ArgumentError, "'#{m}' is already in the '#{name}' ACL" end @methods << m @@ -216,7 +216,7 @@ class Rights def restrict_environment(env) env = Puppet::Node::Environment.new(env) if @environment.include?(env) - raise ArgumentError, "'%s' is already in the '%s' ACL" % [env, name] + raise ArgumentError, "'#{env}' is already in the '#{name}' ACL" end @environment << env @@ -231,7 +231,7 @@ class Rights when "all","any", :all, :any authentication = nil else - raise ArgumentError, "'%s' incorrect authenticated value: %s" % [name, authentication] + raise ArgumentError, "'#{name}' incorrect authenticated value: #{authentication}" end @authentication = authentication end diff --git a/lib/puppet/network/server.rb b/lib/puppet/network/server.rb index 2c899cf15..eb22e1614 100644 --- a/lib/puppet/network/server.rb +++ b/lib/puppet/network/server.rb @@ -23,9 +23,9 @@ class Puppet::Network::Server Puppet::Util::Log.reopen rescue => detail Puppet::Util.secure_open("/tmp/daemonout", "w") { |f| - f.puts "Could not start %s: %s" % [Puppet[:name], detail] + f.puts "Could not start #{Puppet[:name]}: #{detail}" } - raise "Could not start %s: %s" % [Puppet[:name], detail] + raise "Could not start #{Puppet[:name]}: #{detail}" end end @@ -34,7 +34,7 @@ class Puppet::Network::Server def create_pidfile Puppet::Util.sync(Puppet[:name]).synchronize(Sync::EX) do unless Puppet::Util::Pidlock.new(pidfile).lock - raise "Could not create PID file: %s" % [pidfile] + raise "Could not create PID file: #{pidfile}" end end end @@ -44,7 +44,7 @@ class Puppet::Network::Server Puppet::Util.sync(Puppet[:name]).synchronize(Sync::EX) do locker = Puppet::Util::Pidlock.new(pidfile) if locker.locked? - locker.unlock or Puppet.err "Could not remove PID file %s" % [pidfile] + locker.unlock or Puppet.err "Could not remove PID file #{pidfile}" end end end @@ -57,7 +57,7 @@ class Puppet::Network::Server def initialize(args = {}) valid_args = [:handlers, :xmlrpc_handlers, :port] bad_args = args.keys.find_all { |p| ! valid_args.include?(p) }.collect { |p| p.to_s }.join(",") - raise ArgumentError, "Invalid argument(s) %s" % bad_args unless bad_args == "" + raise ArgumentError, "Invalid argument(s) #{bad_args}" unless bad_args == "" @server_type = Puppet[:servertype] or raise "No servertype configuration found." # e.g., WEBrick, Mongrel, etc. http_server_class || raise(ArgumentError, "Could not determine HTTP Server class for server type [#{@server_type}]") @@ -90,7 +90,7 @@ class Puppet::Network::Server indirections = @routes.keys if indirections.empty? indirections.flatten.each do |i| - raise(ArgumentError, "Indirection [%s] is unknown." % i) unless @routes[i.to_sym] + raise(ArgumentError, "Indirection [#{i}] is unknown.") unless @routes[i.to_sym] end indirections.flatten.each do |i| @@ -113,7 +113,7 @@ class Puppet::Network::Server namespaces = @xmlrpc_routes.keys if namespaces.empty? namespaces.flatten.each do |i| - raise(ArgumentError, "XMLRPC handler '%s' is unknown." % i) unless @xmlrpc_routes[i.to_sym] + raise(ArgumentError, "XMLRPC handler '#{i}' is unknown.") unless @xmlrpc_routes[i.to_sym] end namespaces.flatten.each do |i| diff --git a/lib/puppet/network/xmlrpc/client.rb b/lib/puppet/network/xmlrpc/client.rb index c5efe985d..828b8a77a 100644 --- a/lib/puppet/network/xmlrpc/client.rb +++ b/lib/puppet/network/xmlrpc/client.rb @@ -83,7 +83,7 @@ module Puppet::Network Puppet.warning "Certificate validation failed; consider using the certname configuration option" end end - raise XMLRPCClientError, "Certificates were not trusted: %s" % detail + raise XMLRPCClientError, "Certificates were not trusted: #{detail}" end handle_error(:default) do |client, detail, namespace, method| @@ -91,7 +91,7 @@ module Puppet::Network Puppet.warning "XMLRPC returned wrong size. Retrying." return :retry end - Puppet.err "Could not call %s.%s: %s" % [namespace, method, detail.inspect] + Puppet.err "Could not call #{namespace}.#{method}: #{detail.inspect}" error = XMLRPCClientError.new(detail.to_s) error.set_backtrace detail.backtrace raise error @@ -108,7 +108,7 @@ module Puppet::Network Puppet.warning "Certificate validation failed; consider using the certname configuration option" end end - raise XMLRPCClientError, "Certificates were not trusted: %s" % detail + raise XMLRPCClientError, "Certificates were not trusted: #{detail}" end handle_error(::XMLRPC::FaultException) do |client, detail, namespace, method| @@ -116,13 +116,13 @@ module Puppet::Network end handle_error(Errno::ECONNREFUSED) do |client, detail, namespace, method| - msg = "Could not connect to %s on port %s" % [client.host, client.port] + msg = "Could not connect to #{client.host} on port #{client.port}" raise XMLRPCClientError, msg end handle_error(SocketError) do |client, detail, namespace, method| - Puppet.err "Could not find server %s: %s" % [@host, detail.to_s] - error = XMLRPCClientError.new("Could not find server %s" % client.host) + Puppet.err "Could not find server #{@host}: #{detail}" + error = XMLRPCClientError.new("Could not find server #{client.host}") error.set_backtrace detail.backtrace raise error end @@ -134,16 +134,16 @@ module Puppet::Network end handle_error(Timeout::Error) do |client, detail, namespace, method| - Puppet.err "Connection timeout calling %s.%s: %s" % [namespace, method, detail.to_s] + Puppet.err "Connection timeout calling #{namespace}.#{method}: #{detail}" error = XMLRPCClientError.new("Connection Timeout") error.set_backtrace(detail.backtrace) raise error end def make_rpc_call(namespace, method, *args) - Puppet.debug "Calling %s.%s" % [namespace, method] + Puppet.debug "Calling #{namespace}.#{method}" begin - call("%s.%s" % [namespace, method.to_s],*args) + call("#{namespace}.#{method}",*args) rescue SystemExit,NoMemoryError raise rescue Exception => detail @@ -207,7 +207,7 @@ module Puppet::Network begin @http.start unless @http.started? rescue => detail - Puppet.err "Could not connect to server: %s" % detail + Puppet.err "Could not connect to server: #{detail}" end end diff --git a/lib/puppet/network/xmlrpc/processor.rb b/lib/puppet/network/xmlrpc/processor.rb index 2c2dc61ec..14f91d8b4 100644 --- a/lib/puppet/network/xmlrpc/processor.rb +++ b/lib/puppet/network/xmlrpc/processor.rb @@ -53,7 +53,7 @@ module Puppet::Network rescue ::XMLRPC::FaultException raise rescue Puppet::AuthorizationError => detail - Puppet.err "Permission denied: %s" % detail.to_s + Puppet.err "Permission denied: #{detail}" raise ::XMLRPC::FaultException.new( 1, detail.to_s ) @@ -71,7 +71,7 @@ module Puppet::Network if Puppet[:trace] puts detail.backtrace end - Puppet.err "Could not call: %s" % detail.to_s + Puppet.err "Could not call: #{detail}" error = ::XMLRPC::FaultException.new(1, detail.to_s) error.set_backtrace detail.backtrace raise error diff --git a/lib/puppet/network/xmlrpc/webrick_servlet.rb b/lib/puppet/network/xmlrpc/webrick_servlet.rb index a03db01d1..f58286c3a 100644 --- a/lib/puppet/network/xmlrpc/webrick_servlet.rb +++ b/lib/puppet/network/xmlrpc/webrick_servlet.rb @@ -106,7 +106,7 @@ module Puppet::Network::XMLRPC Puppet.warning "Could not retrieve server name from cert" else unless client == nameary[1] - Puppet.debug "Overriding %s with cert name %s" % [client, nameary[1]] + Puppet.debug "Overriding #{client} with cert name #{nameary[1]}" client = nameary[1] end valid = true diff --git a/lib/puppet/node.rb b/lib/puppet/node.rb index 0d9783b5a..2418b3e44 100644 --- a/lib/puppet/node.rb +++ b/lib/puppet/node.rb @@ -63,7 +63,7 @@ class Puppet::Node merge(facts.values) end rescue => detail - error = Puppet::Error.new("Could not retrieve facts for %s: %s" % [name, detail]) + error = Puppet::Error.new("Could not retrieve facts for #{name}: #{detail}") error.set_backtrace(detail.backtrace) raise error end @@ -96,7 +96,7 @@ class Puppet::Node if parameters["hostname"] and parameters["domain"] fqdn = parameters["hostname"] + "." + parameters["domain"] else - Puppet.warning "Host is missing hostname and/or domain: %s" % name + Puppet.warning "Host is missing hostname and/or domain: #{name}" end end diff --git a/lib/puppet/parameter.rb b/lib/puppet/parameter.rb index 4197c8c4a..82b603a57 100644 --- a/lib/puppet/parameter.rb +++ b/lib/puppet/parameter.rb @@ -44,7 +44,7 @@ class Puppet::Parameter @doc += value_collection.doc if f = self.required_features - @doc += " Requires features %s." % f.flatten.collect { |f| f.to_s }.join(" ") + @doc += " Requires features #{f.flatten.collect { |f| f.to_s }.join(" ")}." end @addeddocvals = true end @@ -192,7 +192,7 @@ class Puppet::Parameter self.resource = resource options.delete(:resource) else - raise Puppet::DevError, "No resource set for %s" % self.class.name + raise Puppet::DevError, "No resource set for #{self.class.name}" end set_options(options) @@ -221,7 +221,7 @@ class Puppet::Parameter @noop = false end tmp = @noop || self.resource.noop || Puppet[:noop] || false - #debug "noop is %s" % tmp + #debug "noop is #{tmp}" return tmp end @@ -251,10 +251,10 @@ class Puppet::Parameter begin ret = unsafe_munge(value) rescue Puppet::Error => detail - Puppet.debug "Reraising %s" % detail + Puppet.debug "Reraising #{detail}" raise rescue => detail - raise Puppet::DevError, "Munging failed for value %s in class %s: %s" % [value.inspect, self.name, detail], detail.backtrace + raise Puppet::DevError, "Munging failed for value #{value.inspect} in class #{self.name}: #{detail}", detail.backtrace end ret end @@ -274,7 +274,7 @@ class Puppet::Parameter rescue Puppet::Error, TypeError raise rescue => detail - raise Puppet::DevError, "Validate method failed for class %s: %s" % [self.name, detail], detail.backtrace + raise Puppet::DevError, "Validate method failed for class #{self.name}: #{detail}", detail.backtrace end end diff --git a/lib/puppet/parameter/value_collection.rb b/lib/puppet/parameter/value_collection.rb index 436226ebe..840b892f1 100644 --- a/lib/puppet/parameter/value_collection.rb +++ b/lib/puppet/parameter/value_collection.rb @@ -7,7 +7,7 @@ class Puppet::Parameter::ValueCollection def aliasvalue(name, other) other = other.to_sym unless value = match?(other) - raise Puppet::DevError, "Cannot alias nonexistent value %s" % other + raise Puppet::DevError, "Cannot alias nonexistent value #{other}" end value.alias(name) @@ -21,9 +21,9 @@ class Puppet::Parameter::ValueCollection @doc += " Valid values are " @doc += @strings.collect do |value| if aliases = value.aliases and ! aliases.empty? - "``%s`` (also called ``%s``)" % [value.name, aliases.join(", ")] + "``#{value.name}`` (also called ``#{aliases.join(", ")}``)" else - "``%s``" % value.name + "``#{value.name}``" end end.join(", ") + "." end @@ -105,7 +105,7 @@ class Puppet::Parameter::ValueCollection end if block_given? and ! value.regex? - value.method ||= "set_" + value.name.to_s + value.method ||= "set_#{value.name}" end value @@ -125,14 +125,14 @@ class Puppet::Parameter::ValueCollection return if empty? unless @values.detect { |name, v| v.match?(value) } - str = "Invalid value %s. " % [value.inspect] + str = "Invalid value #{value.inspect}. " unless values.empty? - str += "Valid values are %s. " % values.join(", ") + str += "Valid values are #{values.join(", ")}. " end unless regexes.empty? - str += "Valid values match %s." % regexes.join(", ") + str += "Valid values match #{regexes.join(", ")}." end raise ArgumentError, str diff --git a/lib/puppet/parser/ast.rb b/lib/puppet/parser/ast.rb index f407c78d6..dffc30a8a 100644 --- a/lib/puppet/parser/ast.rb +++ b/lib/puppet/parser/ast.rb @@ -46,7 +46,7 @@ class Puppet::Parser::AST # of the contained children and evaluates them in turn, returning a # list of all of the collected values, rejecting nil values def evaluate(*options) - raise Puppet::DevError, "Did not override #evaluate in %s" % self.class + raise Puppet::DevError, "Did not override #evaluate in #{self.class}" end # Throw a parse error. diff --git a/lib/puppet/parser/ast/arithmetic_operator.rb b/lib/puppet/parser/ast/arithmetic_operator.rb index 8d9cef86a..b4c0215cc 100644 --- a/lib/puppet/parser/ast/arithmetic_operator.rb +++ b/lib/puppet/parser/ast/arithmetic_operator.rb @@ -18,12 +18,12 @@ class Puppet::Parser::AST lval = @lval.safeevaluate(scope) lval = Puppet::Parser::Scope.number?(lval) if lval == nil - raise ArgumentError, "left operand of %s is not a number" % @operator + raise ArgumentError, "left operand of #{@operator} is not a number" end rval = @rval.safeevaluate(scope) rval = Puppet::Parser::Scope.number?(rval) if rval == nil - raise ArgumentError, "right operand of %s is not a number" % @operator + raise ArgumentError, "right operand of #{@operator} is not a number" end # compute result @@ -34,7 +34,7 @@ class Puppet::Parser::AST super unless %w{+ - * / << >>}.include?(@operator) - raise ArgumentError, "Invalid arithmetic operator %s" % @operator + raise ArgumentError, "Invalid arithmetic operator #{@operator}" end end end diff --git a/lib/puppet/parser/ast/boolean_operator.rb b/lib/puppet/parser/ast/boolean_operator.rb index 89725d73b..9214afbd5 100644 --- a/lib/puppet/parser/ast/boolean_operator.rb +++ b/lib/puppet/parser/ast/boolean_operator.rb @@ -41,7 +41,7 @@ class Puppet::Parser::AST super unless %w{and or}.include?(@operator) - raise ArgumentError, "Invalid boolean operator %s" % @operator + raise ArgumentError, "Invalid boolean operator #{@operator}" end end end diff --git a/lib/puppet/parser/ast/branch.rb b/lib/puppet/parser/ast/branch.rb index 0c481ffe6..c0fa0da30 100644 --- a/lib/puppet/parser/ast/branch.rb +++ b/lib/puppet/parser/ast/branch.rb @@ -31,7 +31,7 @@ class Puppet::Parser::AST @children.each { |child| unless child.is_a?(AST) raise Puppet::DevError, - "child %s is a %s instead of ast" % [child, child.class] + "child #{child} is a #{child.class} instead of ast" end } end diff --git a/lib/puppet/parser/ast/collexpr.rb b/lib/puppet/parser/ast/collexpr.rb index eae2b0e42..95fb5a94f 100644 --- a/lib/puppet/parser/ast/collexpr.rb +++ b/lib/puppet/parser/ast/collexpr.rb @@ -68,11 +68,10 @@ class CollExpr < AST::Branch when "tag" str = "puppet_tags.name #{oper} '#{str2}'" else - str = "param_values.value #{oper} '#{str2}' and " + - "param_names.name = '#{str1}'" + str = "param_values.value #{oper} '#{str2}' and param_names.name = '#{str1}'" end else - str = "(%s) %s (%s)" % [str1, oper, str2] + str = "(#{str1}) #{oper} (#{str2})" end return str, code @@ -82,7 +81,7 @@ class CollExpr < AST::Branch super unless %w{== != and or}.include?(@oper) - raise ArgumentError, "Invalid operator %s" % @oper + raise ArgumentError, "Invalid operator #{@oper}" end end end diff --git a/lib/puppet/parser/ast/comparison_operator.rb b/lib/puppet/parser/ast/comparison_operator.rb index 0d2f8b16d..85903ec31 100644 --- a/lib/puppet/parser/ast/comparison_operator.rb +++ b/lib/puppet/parser/ast/comparison_operator.rb @@ -34,7 +34,7 @@ class Puppet::Parser::AST super unless %w{== != < > <= >=}.include?(@operator) - raise ArgumentError, "Invalid comparison operator %s" % @operator + raise ArgumentError, "Invalid comparison operator #{@operator}" end end end diff --git a/lib/puppet/parser/ast/function.rb b/lib/puppet/parser/ast/function.rb index 98204b14a..c3769cbd4 100644 --- a/lib/puppet/parser/ast/function.rb +++ b/lib/puppet/parser/ast/function.rb @@ -14,28 +14,28 @@ class Puppet::Parser::AST # Make sure it's a defined function unless Puppet::Parser::Functions.function(@name) - raise Puppet::ParseError, "Unknown function %s" % @name + raise Puppet::ParseError, "Unknown function #{@name}" end # Now check that it's been used correctly case @ftype when :rvalue unless Puppet::Parser::Functions.rvalue?(@name) - raise Puppet::ParseError, "Function '%s' does not return a value" % @name + raise Puppet::ParseError, "Function '#{@name}' does not return a value" end when :statement if Puppet::Parser::Functions.rvalue?(@name) raise Puppet::ParseError, - "Function '%s' must be the value of a statement" % @name + "Function '#{@name}' must be the value of a statement" end else - raise Puppet::DevError, "Invalid function type %s" % @ftype.inspect + raise Puppet::DevError, "Invalid function type #{@ftype.inspect}" end # We don't need to evaluate the name, because it's plaintext args = @arguments.safeevaluate(scope) - return scope.send("function_" + @name, args) + return scope.send("function_#{@name}", args) end def initialize(hash) diff --git a/lib/puppet/parser/ast/leaf.rb b/lib/puppet/parser/ast/leaf.rb index 30c4a958f..6ef346123 100644 --- a/lib/puppet/parser/ast/leaf.rb +++ b/lib/puppet/parser/ast/leaf.rb @@ -40,7 +40,7 @@ class Puppet::Parser::AST unless @value == true or @value == false raise Puppet::DevError, - "'%s' is not a boolean" % @value + "'#{@value}' is not a boolean" end @value end @@ -108,7 +108,7 @@ class Puppet::Parser::AST @value = @value.to_s.downcase unless @value.is_a?(Regex) if @value =~ /[^-\w.]/ raise Puppet::DevError, - "'%s' is not a valid hostname" % @value + "'#{@value}' is not a valid hostname" end end diff --git a/lib/puppet/parser/ast/match_operator.rb b/lib/puppet/parser/ast/match_operator.rb index 17e27826e..c528a90e5 100644 --- a/lib/puppet/parser/ast/match_operator.rb +++ b/lib/puppet/parser/ast/match_operator.rb @@ -24,7 +24,7 @@ class Puppet::Parser::AST super unless %w{!~ =~}.include?(@operator) - raise ArgumentError, "Invalid regexp operator %s" % @operator + raise ArgumentError, "Invalid regexp operator #{@operator}" end end end diff --git a/lib/puppet/parser/ast/minus.rb b/lib/puppet/parser/ast/minus.rb index b0779a8ee..52d158e0b 100644 --- a/lib/puppet/parser/ast/minus.rb +++ b/lib/puppet/parser/ast/minus.rb @@ -15,7 +15,7 @@ class Puppet::Parser::AST val = @value.safeevaluate(scope) val = Puppet::Parser::Scope.number?(val) if val == nil - raise ArgumentError, "minus operand %s is not a number" % val + raise ArgumentError, "minus operand #{val} is not a number" end return -val end diff --git a/lib/puppet/parser/ast/resource_override.rb b/lib/puppet/parser/ast/resource_override.rb index f667ed23a..f9071fe96 100644 --- a/lib/puppet/parser/ast/resource_override.rb +++ b/lib/puppet/parser/ast/resource_override.rb @@ -13,7 +13,7 @@ class Puppet::Parser::AST # Iterate across all of our children. def each [@object,@parameters].flatten.each { |param| - #Puppet.debug("yielding param %s" % param) + #Puppet.debug("yielding param #{param}") yield param } end diff --git a/lib/puppet/parser/ast/selector.rb b/lib/puppet/parser/ast/selector.rb index 647bdcde1..8eb930cc4 100644 --- a/lib/puppet/parser/ast/selector.rb +++ b/lib/puppet/parser/ast/selector.rb @@ -34,7 +34,7 @@ class Puppet::Parser::AST # Unless we found something, look for the default. return default.value.safeevaluate(scope) if default - self.fail Puppet::ParseError, "No matching value for selector param '%s'" % paramvalue + self.fail Puppet::ParseError, "No matching value for selector param '#{paramvalue}'" ensure scope.unset_ephemeral_var(level) end diff --git a/lib/puppet/parser/collector.rb b/lib/puppet/parser/collector.rb index 9283d06ae..3f1432af2 100644 --- a/lib/puppet/parser/collector.rb +++ b/lib/puppet/parser/collector.rb @@ -80,7 +80,7 @@ class Puppet::Parser::Collector @equery = equery @vquery = vquery - raise(ArgumentError, "Invalid query form %s" % form) unless [:exported, :virtual].include?(form) + raise(ArgumentError, "Invalid query form #{form}") unless [:exported, :virtual].include?(form) @form = form end @@ -106,7 +106,7 @@ class Puppet::Parser::Collector search = "(exported=? AND restype=?)" values = [true, @type] - search += " AND (%s)" % @equery if @equery + search += " AND (#{@equery})" if @equery # note: # we're not eagerly including any relations here because @@ -125,7 +125,7 @@ class Puppet::Parser::Collector # We're going to collect objects from rails, but we don't want any # objects from this host. - search = ("host_id != ? AND %s" % search) and values.unshift(host.id) if host + search = ("host_id != ? AND #{search}") and values.unshift(host.id) if host query[:conditions] = [search, *values] @@ -207,7 +207,7 @@ class Puppet::Parser::Collector return nil if existing.rails_id == obj.id # This is the one we've already collected - raise Puppet::ParseError, "Exported resource %s cannot override local resource" % [obj.ref] + raise Puppet::ParseError, "Exported resource #{obj.ref} cannot override local resource" end resource = obj.to_resource(self.scope) diff --git a/lib/puppet/parser/compiler.rb b/lib/puppet/parser/compiler.rb index e64ec4ba3..a2186b2c9 100644 --- a/lib/puppet/parser/compiler.rb +++ b/lib/puppet/parser/compiler.rb @@ -158,7 +158,7 @@ class Puppet::Parser::Compiler resource.evaluate unless lazy_evaluate found << name else - Puppet.info "Could not find class %s for %s" % [name, node.name] + Puppet.info "Could not find class #{name} for #{node.name}" @catalog.tag(name) end end @@ -181,7 +181,7 @@ class Puppet::Parser::Compiler begin send(param.to_s + "=", value) rescue NoMethodError - raise ArgumentError, "Compiler objects do not accept %s" % param + raise ArgumentError, "Compiler objects do not accept #{param}" end end @@ -222,7 +222,7 @@ class Puppet::Parser::Compiler end unless (astnode ||= known_resource_types.node("default")) - raise Puppet::ParseError, "Could not find default node or by name with '%s'" % node.names.join(", ") + raise Puppet::ParseError, "Could not find default node or by name with '#{node.names.join(", ")}'" end # Create a resource to model this node, and then add it to the list @@ -355,7 +355,7 @@ class Puppet::Parser::Compiler end unless remaining.empty? - raise Puppet::ParseError, "Failed to realize virtual resources %s" % remaining.join(', ') + raise Puppet::ParseError, "Failed to realize virtual resources #{remaining.join(', ')}" end end diff --git a/lib/puppet/parser/functions.rb b/lib/puppet/parser/functions.rb index a99e8dc95..5b07a9c09 100644 --- a/lib/puppet/parser/functions.rb +++ b/lib/puppet/parser/functions.rb @@ -41,16 +41,16 @@ module Puppet::Parser::Functions name = symbolize(name) if functions.include?(name) - raise Puppet::DevError, "Function %s already defined" % name + raise Puppet::DevError, "Function #{name} already defined" end ftype = options[:type] || :statement unless ftype == :statement or ftype == :rvalue - raise Puppet::DevError, "Invalid statement type %s" % ftype.inspect + raise Puppet::DevError, "Invalid statement type #{ftype.inspect}" end - fname = "function_" + name.to_s + fname = "function_#{name}" environment_module.send(:define_method, fname, &block) # Someday we'll support specifying an arity, but for now, nope @@ -66,12 +66,12 @@ module Puppet::Parser::Functions name = symbolize(name) unless functions.include? name - raise Puppet::DevError, "Function %s is not defined" % name + raise Puppet::DevError, "Function #{name} is not defined" end functions.delete name - fname = "function_" + name.to_s + fname = "function_#{name}" environment_module.send(:remove_method, fname) end @@ -92,15 +92,15 @@ module Puppet::Parser::Functions ret = "" functions.sort { |a,b| a[0].to_s <=> b[0].to_s }.each do |name, hash| - #ret += "%s\n%s\n" % [name, hash[:type]] - ret += "%s\n%s\n" % [name, "-" * name.to_s.length] + #ret += "#{name}\n#{hash[:type]}\n" + ret += "#{name}\n#{"-" * name.to_s.length}\n" if hash[:doc] ret += Puppet::Util::Docs.scrub(hash[:doc]) else ret += "Undocumented.\n" end - ret += "\n\n- **Type**: %s\n\n" % hash[:type] + ret += "\n\n- **Type**: #{hash[:type]}\n\n" end return ret diff --git a/lib/puppet/parser/functions/file.rb b/lib/puppet/parser/functions/file.rb index f78823d3a..d13b01ede 100644 --- a/lib/puppet/parser/functions/file.rb +++ b/lib/puppet/parser/functions/file.rb @@ -18,6 +18,6 @@ if ret ret else - raise Puppet::ParseError, "Could not find any files from %s" % vals.join(", ") + raise Puppet::ParseError, "Could not find any files from #{vals.join(", ")}" end end diff --git a/lib/puppet/parser/functions/include.rb b/lib/puppet/parser/functions/include.rb index 213a04136..a8b6f175b 100644 --- a/lib/puppet/parser/functions/include.rb +++ b/lib/puppet/parser/functions/include.rb @@ -19,7 +19,7 @@ Puppet::Parser::Functions::newfunction(:include, :doc => "Evaluate one or more c str += " " + missing.join(", ") if n = namespaces and ! n.empty? and n != [""] - str += " in namespaces %s" % @namespaces.join(", ") + str += " in namespaces #{@namespaces.join(", ")}" end self.fail Puppet::ParseError, str end diff --git a/lib/puppet/parser/functions/inline_template.rb b/lib/puppet/parser/functions/inline_template.rb index fde8006b4..6c0485d1e 100644 --- a/lib/puppet/parser/functions/inline_template.rb +++ b/lib/puppet/parser/functions/inline_template.rb @@ -14,7 +14,7 @@ Puppet::Parser::Functions::newfunction(:inline_template, :type => :rvalue, :doc wrapper.result(string) rescue => detail raise Puppet::ParseError, - "Failed to parse inline template: %s" % [detail] + "Failed to parse inline template: #{detail}" end end.join("") end diff --git a/lib/puppet/parser/functions/require.rb b/lib/puppet/parser/functions/require.rb index 45b89c77a..c5c4c851f 100644 --- a/lib/puppet/parser/functions/require.rb +++ b/lib/puppet/parser/functions/require.rb @@ -43,7 +43,7 @@ fail if used with earlier clients. if classobj = find_hostclass(klass) klass = classobj.name else - raise Puppet::ParseError, "Could not find class %s" % klass + raise Puppet::ParseError, "Could not find class #{klass}" end # This is a bit hackish, in some ways, but it's the only way diff --git a/lib/puppet/parser/functions/split.rb b/lib/puppet/parser/functions/split.rb index 405a5bc9a..c3466ba4a 100644 --- a/lib/puppet/parser/functions/split.rb +++ b/lib/puppet/parser/functions/split.rb @@ -23,7 +23,7 @@ way to do that for a single character is to enclose it in square brackets.") do |args| if args.length != 2 - raise Puppet::ParseError, ("split(): wrong number of arguments" + " (#{args.length}; must be 2)") + raise Puppet::ParseError, ("split(): wrong number of arguments (#{args.length}; must be 2)") end return args[0].split(Regexp.compile(args[1])) diff --git a/lib/puppet/parser/functions/template.rb b/lib/puppet/parser/functions/template.rb index 35c54c66a..6c4873efe 100644 --- a/lib/puppet/parser/functions/template.rb +++ b/lib/puppet/parser/functions/template.rb @@ -8,7 +8,7 @@ Puppet::Parser::Functions::newfunction(:template, :type => :rvalue, :doc => vals.collect do |file| # Use a wrapper, so the template can't get access to the full # Scope object. - debug "Retrieving template %s" % file + debug "Retrieving template #{file}" wrapper = Puppet::Parser::TemplateWrapper.new(self) wrapper.file = file @@ -16,7 +16,7 @@ Puppet::Parser::Functions::newfunction(:template, :type => :rvalue, :doc => wrapper.result rescue => detail raise Puppet::ParseError, - "Failed to parse template %s: %s" % [file, detail] + "Failed to parse template #{file}: #{detail}" end end.join("") end diff --git a/lib/puppet/parser/lexer.rb b/lib/puppet/parser/lexer.rb index 5d1ce8bc7..b5eab9fc8 100644 --- a/lib/puppet/parser/lexer.rb +++ b/lib/puppet/parser/lexer.rb @@ -63,7 +63,7 @@ class Puppet::Parser::Lexer # Create a new token. def add_token(name, regex, options = {}, &block) token = Token.new(regex, name) - raise(ArgumentError, "Token %s already exists" % name) if @tokens.include?(name) + raise(ArgumentError, "Token #{name} already exists") if @tokens.include?(name) @tokens[token.name] = token if token.string @string_tokens << token @@ -487,7 +487,7 @@ class Puppet::Parser::Lexer if @previous_token.name == :DEFINE if indefine? - msg = "Cannot nest definition %s inside %s" % [value, @indefine] + msg = "Cannot nest definition #{value} inside #{@indefine}" self.indefine = false raise Puppet::ParseError, msg end diff --git a/lib/puppet/parser/parser_support.rb b/lib/puppet/parser/parser_support.rb index 24ee5fab3..f2fd710cf 100644 --- a/lib/puppet/parser/parser_support.rb +++ b/lib/puppet/parser/parser_support.rb @@ -21,9 +21,9 @@ class Puppet::Parser::Parser def addcontext(message, obj = nil) obj ||= @lexer - message += " on line %s" % obj.line + message += " on line #{obj.line}" if file = obj.file - message += " in file %s" % file + message += " in file #{file}" end return message @@ -91,7 +91,7 @@ class Puppet::Parser::Parser file = file + ".pp" end unless FileTest.exist?(file) - raise Puppet::Error, "Could not find file %s" % file + raise Puppet::Error, "Could not find file #{file}" end end raise Puppet::AlreadyImportedError, "Import loop detected" if known_resource_types.watching_file?(file) @@ -161,12 +161,12 @@ class Puppet::Parser::Parser if token == 0 # denotes end of file value = 'end of file' else - value = "'%s'" % value[:value] + value = "'#{value[:value]}'" end - error = "Syntax error at %s" % [value] + error = "Syntax error at #{value}" if brace = @lexer.expected - error += "; expected '%s'" % brace + error += "; expected '#{brace}'" end except = Puppet::ParseError.new(error) diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb index e1af32fba..257440ab4 100644 --- a/lib/puppet/parser/resource.rb +++ b/lib/puppet/parser/resource.rb @@ -248,7 +248,7 @@ class Puppet::Parser::Resource < Puppet::Resource def add_defaults scope.lookupdefaults(self.type).each do |name, param| unless @parameters.include?(name) - self.debug "Adding default for %s" % name + self.debug "Adding default for #{name}" @parameters[name] = param.dup end @@ -286,15 +286,15 @@ class Puppet::Parser::Resource < Puppet::Resource # The parameter is already set. Fail if they're not allowed to override it. unless param.source.child_of?(current.source) puts caller if Puppet[:trace] - msg = "Parameter '%s' is already set on %s" % [param.name, self.to_s] + msg = "Parameter '#{param.name}' is already set on #{self}" if current.source.to_s != "" - msg += " by %s" % current.source + msg += " by #{current.source}" end if current.file or current.line fields = [] fields << current.file if current.file fields << current.line.to_s if current.line - msg += " at %s" % fields.join(":") + msg += " at #{fields.join(":")}" end msg += "; cannot redefine" raise Puppet::ParseError.new(msg, param.line, param.file) @@ -331,7 +331,7 @@ class Puppet::Parser::Resource < Puppet::Resource params.each do |param| # Don't set the same parameter twice if @parameters[param.name] - self.fail Puppet::ParseError, "Duplicate parameter '%s' for on %s" % [param.name, self.to_s] + self.fail Puppet::ParseError, "Duplicate parameter '#{param.name}' for on #{self}" end set_parameter(param) diff --git a/lib/puppet/parser/resource/param.rb b/lib/puppet/parser/resource/param.rb index 26b067703..3514f1d0c 100644 --- a/lib/puppet/parser/resource/param.rb +++ b/lib/puppet/parser/resource/param.rb @@ -22,6 +22,6 @@ class Puppet::Parser::Resource::Param end def to_s - "%s => %s" % [self.name, self.value] + "#{self.name} => #{self.value}" end end diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb index d9ea3cc8f..02dd3e733 100644 --- a/lib/puppet/parser/scope.rb +++ b/lib/puppet/parser/scope.rb @@ -142,7 +142,7 @@ class Puppet::Parser::Scope if self.respond_to? method self.send(method, val) else - raise Puppet::DevError, "Invalid scope argument %s" % name + raise Puppet::DevError, "Invalid scope argument #{name}" end } @@ -227,11 +227,11 @@ class Puppet::Parser::Scope klassname = parts.join("::") klass = find_hostclass(klassname) unless klass - warning "Could not look up qualified variable '%s'; class %s could not be found" % [name, klassname] + warning "Could not look up qualified variable '#{name}'; class #{klassname} could not be found" return usestring ? "" : :undefined end unless kscope = class_scope(klass) - warning "Could not look up qualified variable '%s'; class %s has not been evaluated" % [name, klassname] + warning "Could not look up qualified variable '#{name}'; class #{klassname} has not been evaluated" return usestring ? "" : :undefined end return kscope.lookupvar(shortname, usestring) @@ -320,7 +320,7 @@ class Puppet::Parser::Scope #Puppet.debug "Default for %s is %s => %s" % # [type,ary[0].inspect,ary[1].inspect] if table.include?(param.name) - raise Puppet::ParseError.new("Default already defined for %s { %s }; cannot redefine" % [type, param.name], param.line, param.file) + raise Puppet::ParseError.new("Default already defined for #{type} { #{param.name} }; cannot redefine", param.line, param.file) end table[param.name] = param } @@ -335,9 +335,9 @@ class Puppet::Parser::Scope # [name.inspect,value,self.level, append] if table.include?(name) unless options[:append] - error = Puppet::ParseError.new("Cannot reassign variable %s" % name) + error = Puppet::ParseError.new("Cannot reassign variable #{name}") else - error = Puppet::ParseError.new("Cannot append, variable %s is defined in this scope" % name) + error = Puppet::ParseError.new("Cannot append, variable #{name} is defined in this scope") end if options[:file] error.file = options[:file] @@ -400,10 +400,10 @@ class Puppet::Parser::Scope else str = "Unrecognised escape sequence '#{ss.matched}'" if file - str += " in file %s" % file + str += " in file #{file}" end if line - str += " at line %s" % line + str += " at line #{line}" end Puppet.warning str out << ss.matched @@ -416,7 +416,7 @@ class Puppet::Parser::Scope tmp = ss.scan(/[^\\$]+/) # Puppet.debug("Got other: pos:%d; m:%s" % [ss.pos, tmp]) unless tmp - error = Puppet::ParseError.new("Could not parse string %s" % string.inspect) + error = Puppet::ParseError.new("Could not parse string #{string.inspect}") {:file= => file, :line= => line}.each do |m,v| error.send(m, v) if v end @@ -438,7 +438,7 @@ class Puppet::Parser::Scope # Used mainly for logging def to_s - "Scope(%s)" % @resource.to_s + "Scope(#{@resource})" end # Undefine a variable; only used for testing. diff --git a/lib/puppet/parser/templatewrapper.rb b/lib/puppet/parser/templatewrapper.rb index 61c74e970..36dc62261 100644 --- a/lib/puppet/parser/templatewrapper.rb +++ b/lib/puppet/parser/templatewrapper.rb @@ -62,13 +62,13 @@ class Puppet::Parser::TemplateWrapper else # Just throw an error immediately, instead of searching for # other missingmethod things or whatever. - raise Puppet::ParseError, "Could not find value for '%s'" % name + raise Puppet::ParseError, "Could not find value for '#{name}'" end end def file=(filename) unless @file = Puppet::Parser::Files.find_template(filename, scope.compiler.environment.to_s) - raise Puppet::ParseError, "Could not find template '%s'" % filename + raise Puppet::ParseError, "Could not find template '#{filename}'" end # We'll only ever not have a parser in testing, but, eh. @@ -109,6 +109,6 @@ class Puppet::Parser::TemplateWrapper end def to_s - "template[%s]" % (file ? file : "inline") + "template[#{(file ? file : "inline")}]" end end diff --git a/lib/puppet/parser/type_loader.rb b/lib/puppet/parser/type_loader.rb index 5f779cb8d..e0b4143fc 100644 --- a/lib/puppet/parser/type_loader.rb +++ b/lib/puppet/parser/type_loader.rb @@ -99,7 +99,7 @@ class Puppet::Parser::TypeLoader return [name.sub(/^::/, '').gsub("::", File::SEPARATOR)] if name =~ /^::/ result = namespaces.inject([]) do |names_to_try, namespace| - fullname = (namespace + "::" + name).sub(/^::/, '') + fullname = (namespace + "::#{name}").sub(/^::/, '') # Try to load the module init file if we're a qualified name if fullname.include?("::") diff --git a/lib/puppet/property/ensure.rb b/lib/puppet/property/ensure.rb index 2b1d1d433..d6aa99ef3 100644 --- a/lib/puppet/property/ensure.rb +++ b/lib/puppet/property/ensure.rb @@ -49,12 +49,12 @@ class Puppet::Property::Ensure < Puppet::Property elsif newvalue == :absent return "removed" else - return "%s changed '%s' to '%s'" % [self.name, self.is_to_s(currentvalue), self.should_to_s(newvalue)] + return "#{self.name} changed '#{self.is_to_s(currentvalue)}' to '#{self.should_to_s(newvalue)}'" end rescue Puppet::Error, Puppet::DevError raise rescue => detail - raise Puppet::DevError, "Could not convert change %s to string: %s" % [self.name, detail] + raise Puppet::DevError, "Could not convert change #{self.name} to string: #{detail}" end end @@ -69,7 +69,7 @@ class Puppet::Property::Ensure < Puppet::Property elsif @resource.respond_to?(:exists?) result = @resource.exists? else - raise Puppet::DevError, "No ability to determine if %s exists" % @resource.class.name + raise Puppet::DevError, "No ability to determine if #{@resource.class.name} exists" end if result return :present diff --git a/lib/puppet/provider.rb b/lib/puppet/provider.rb index b68602aae..ed7142e51 100644 --- a/lib/puppet/provider.rb +++ b/lib/puppet/provider.rb @@ -40,7 +40,7 @@ class Puppet::Provider elsif superclass.respond_to? :command and command = superclass.command(name) # nothing else - raise Puppet::DevError, "No command %s defined for provider %s" % [name, self.name] + raise Puppet::DevError, "No command #{name} defined for provider #{self.name}" end return binary(command) @@ -102,7 +102,7 @@ class Puppet::Provider # The method for returning a list of provider instances. Note that it returns providers, preferably with values already # filled in, not resources. def self.instances - raise Puppet::DevError, "Provider %s has not defined the 'instances' class method" % self.name + raise Puppet::DevError, "Provider #{self.name} has not defined the 'instances' class method" end # Create the methods for a given command. @@ -111,7 +111,7 @@ class Puppet::Provider unless singleton_class.method_defined?(name) meta_def(name) do |*args| unless command(name) - raise Puppet::Error, "Command %s is missing" % name + raise Puppet::Error, "Command #{name} is missing" end if args.empty? cmd = [command(name)] @@ -190,7 +190,7 @@ class Puppet::Provider klass = param else unless klass = resource_type.attrclass(param) - raise Puppet::DevError, "'%s' is not a valid parameter for %s" % [param, resource_type.name] + raise Puppet::DevError, "'#{param}' is not a valid parameter for #{resource_type.name}" end end return true unless features = klass.required_features @@ -205,9 +205,9 @@ class Puppet::Provider # def self.to_s # unless defined?(@str) # if self.resource_type -# @str = "%s provider %s" % [resource_type.name, self.name] +# @str = "#{resource_type.name} provider #{self.name}" # else -# @str = "unattached provider %s" % [self.name] +# @str = "unattached provider #{self.name}" # end # end # @str @@ -274,7 +274,7 @@ class Puppet::Provider elsif self.resource resource.name else - raise Puppet::DevError, "No resource and no name in property hash in %s instance" % self.class.name + raise Puppet::DevError, "No resource and no name in property hash in #{self.class.name} instance" end end @@ -286,7 +286,7 @@ class Puppet::Provider end def to_s - "%s(provider=%s)" % [@resource.to_s, self.class.name] + "#{@resource}(provider=#{self.class.name})" end end diff --git a/lib/puppet/provider/confine.rb b/lib/puppet/provider/confine.rb index ff97831ee..12d8f245e 100644 --- a/lib/puppet/provider/confine.rb +++ b/lib/puppet/provider/confine.rb @@ -13,7 +13,7 @@ class Puppet::Provider::Confine def self.inherited(klass) name = klass.to_s.split("::").pop.downcase.to_sym - raise "Test %s is already defined" % name if @tests.include?(name) + raise "Test #{name} is already defined" if @tests.include?(name) klass.name = name @@ -23,10 +23,10 @@ class Puppet::Provider::Confine def self.test(name) unless @tests[name] begin - require "puppet/provider/confine/%s" % name + require "puppet/provider/confine/#{name}" rescue LoadError => detail unless detail.to_s =~ /No such file/i - warn "Could not load confine test '%s': %s" % [name, detail] + warn "Could not load confine test '#{name}': #{detail}" end # Could not find file end diff --git a/lib/puppet/provider/confine/exists.rb b/lib/puppet/provider/confine/exists.rb index 1d1ed8c84..27c404acb 100644 --- a/lib/puppet/provider/confine/exists.rb +++ b/lib/puppet/provider/confine/exists.rb @@ -13,7 +13,7 @@ class Puppet::Provider::Confine::Exists < Puppet::Provider::Confine end def message(value) - "file %s does not exist" % value + "file #{value} does not exist" end def summary diff --git a/lib/puppet/provider/confine/feature.rb b/lib/puppet/provider/confine/feature.rb index 1d92b001a..8cd5daaec 100644 --- a/lib/puppet/provider/confine/feature.rb +++ b/lib/puppet/provider/confine/feature.rb @@ -11,7 +11,7 @@ class Puppet::Provider::Confine::Feature < Puppet::Provider::Confine end def message(value) - "feature %s is missing" % value + "feature #{value} is missing" end end diff --git a/lib/puppet/provider/confine/variable.rb b/lib/puppet/provider/confine/variable.rb index 8067ae954..0a5cc2960 100644 --- a/lib/puppet/provider/confine/variable.rb +++ b/lib/puppet/provider/confine/variable.rb @@ -30,7 +30,7 @@ class Puppet::Provider::Confine::Variable < Puppet::Provider::Confine end def message(value) - "facter value '%s' for '%s' not in required list '%s'" % [test_value, self.name, values.join(",")] + "facter value '#{test_value}' for '#{self.name}' not in required list '#{values.join(",")}'" end # Compare the passed-in value to the retrieved value. diff --git a/lib/puppet/provider/cron/crontab.rb b/lib/puppet/provider/cron/crontab.rb index c7ccd190f..5f2999fa2 100755 --- a/lib/puppet/provider/cron/crontab.rb +++ b/lib/puppet/provider/cron/crontab.rb @@ -67,7 +67,7 @@ tab = case Facter.value(:operatingsystem) def to_line(record) str = "" if record[:name] - str = "# Puppet Name: %s\n" % record[:name] + str = "# Puppet Name: #{record[:name]}\n" end if record[:environment] and record[:environment] != :absent and record[:environment] != [:absent] record[:environment].each do |env| @@ -76,7 +76,7 @@ tab = case Facter.value(:operatingsystem) end if record[:special] - str += "@%s %s" % [record[:special], record[:command]] + str += "@#{record[:special]} #{record[:command]}" else str += join(record) end diff --git a/lib/puppet/provider/file/posix.rb b/lib/puppet/provider/file/posix.rb index 63d80ead1..a2d102152 100644 --- a/lib/puppet/provider/file/posix.rb +++ b/lib/puppet/provider/file/posix.rb @@ -34,7 +34,7 @@ Puppet::Type.type(:file).provide :posix do if value =~ /^\d+$/ uid = Integer(value) elsif value.is_a?(String) - fail "Could not find user %s" % value unless uid = uid(value) + fail "Could not find user #{value}" unless uid = uid(value) else uid = value end @@ -76,7 +76,7 @@ Puppet::Type.type(:file).provide :posix do # large UIDs instead of negative ones. This isn't a Ruby bug, # it's an OS X bug, since it shows up in perl, too. if currentvalue > Puppet[:maximum_uid].to_i - self.warning "Apparently using negative UID (%s) on a platform that does not consistently handle them" % currentvalue + self.warning "Apparently using negative UID (#{currentvalue}) on a platform that does not consistently handle them" currentvalue = :silly end @@ -96,12 +96,12 @@ Puppet::Type.type(:file).provide :posix do break if uid = validuser?(user) end - raise Puppet::Error, "Could not find user(s) %s" % should.join(",") unless uid + raise Puppet::Error, "Could not find user(s) #{should.join(",")}" unless uid begin File.send(method, uid, nil, path) rescue => detail - raise Puppet::Error, "Failed to set owner to '%s': %s" % [uid, detail] + raise Puppet::Error, "Failed to set owner to '#{uid}': #{detail}" end return :file_changed diff --git a/lib/puppet/provider/file/win32.rb b/lib/puppet/provider/file/win32.rb index da6db1e8c..d2b392104 100644 --- a/lib/puppet/provider/file/win32.rb +++ b/lib/puppet/provider/file/win32.rb @@ -21,7 +21,7 @@ Puppet::Type.type(:file).provide :microsoft_windows do if value =~ /^\d+$/ uid = Integer(value) elsif value.is_a?(String) - fail "Could not find user %s" % value unless uid = uid(value) + fail "Could not find user #{value}" unless uid = uid(value) else uid = value end @@ -39,7 +39,7 @@ Puppet::Type.type(:file).provide :microsoft_windows do # Determine if the user is valid, and if so, return the UID def validuser?(value) - info "Is '%s' a valid user?" % value + info "Is '#{value}' a valid user?" return 0 begin number = Integer(value) @@ -65,7 +65,7 @@ Puppet::Type.type(:file).provide :microsoft_windows do # large UIDs instead of negative ones. This isn't a Ruby bug, # it's an OS X bug, since it shows up in perl, too. if currentvalue > Puppet[:maximum_uid].to_i - self.warning "Apparently using negative UID (%s) on a platform that does not consistently handle them" % currentvalue + self.warning "Apparently using negative UID (#{currentvalue}) on a platform that does not consistently handle them" currentvalue = :silly end diff --git a/lib/puppet/provider/group/ldap.rb b/lib/puppet/provider/group/ldap.rb index 6d5f663ed..87d62d53a 100644 --- a/lib/puppet/provider/group/ldap.rb +++ b/lib/puppet/provider/group/ldap.rb @@ -40,7 +40,7 @@ Puppet::Type.type(:group).provide :ldap, :parent => Puppet::Provider::Ldap do # Convert a group name to an id. def self.name2id(group) - return nil unless result = manager.search("cn=%s" % group) and result.length > 0 + return nil unless result = manager.search("cn=#{group}") and result.length > 0 # Only use the first result. group = result[0] diff --git a/lib/puppet/provider/host/parsed.rb b/lib/puppet/provider/host/parsed.rb index f4282c5a6..7c824ac9b 100644 --- a/lib/puppet/provider/host/parsed.rb +++ b/lib/puppet/provider/host/parsed.rb @@ -42,7 +42,7 @@ end end end else - raise Puppet::Error, "Could not match '%s'" % line + raise Puppet::Error, "Could not match '#{line}'" end if hash[:host_aliases] == "" @@ -57,15 +57,15 @@ end return super unless hash[:record_type] == :parsed [:ip, :name].each do |n| unless hash[n] and hash[n] != :absent - raise ArgumentError, "%s is a required attribute for hosts" % n + raise ArgumentError, "#{n} is a required attribute for hosts" end end - str = "%s\t%s" % [hash[:ip], hash[:name]] + str = "#{hash[:ip]}\t#{hash[:name]}" if hash.include? :host_aliases and !hash[:host_aliases].empty? if hash[:host_aliases].is_a? Array - str += "\t%s" % hash[:host_aliases].join("\t") + str += "\t#{hash[:host_aliases].join("\t")}" else raise ArgumentError, "Host aliases must be specified as an array" end diff --git a/lib/puppet/provider/ldap.rb b/lib/puppet/provider/ldap.rb index 38668e5e5..098daa6ab 100644 --- a/lib/puppet/provider/ldap.rb +++ b/lib/puppet/provider/ldap.rb @@ -70,8 +70,8 @@ class Puppet::Provider::Ldap < Puppet::Provider end def initialize(*args) - raise(Puppet::DevError, "No LDAP Configuration defined for %s" % self.class) unless self.class.manager - raise(Puppet::DevError, "Invalid LDAP Configuration defined for %s" % self.class) unless self.class.manager.valid? + raise(Puppet::DevError, "No LDAP Configuration defined for #{self.class}") unless self.class.manager + raise(Puppet::DevError, "Invalid LDAP Configuration defined for #{self.class}") unless self.class.manager.valid? super @property_hash = @property_hash.inject({}) do |result, ary| diff --git a/lib/puppet/provider/mailalias/aliases.rb b/lib/puppet/provider/mailalias/aliases.rb index 5b7f0e2ec..f946e13df 100755 --- a/lib/puppet/provider/mailalias/aliases.rb +++ b/lib/puppet/provider/mailalias/aliases.rb @@ -37,7 +37,7 @@ require 'puppet/provider/parsedfile' d end end.join(",") - return "%s: %s" % [record[:name], dest] + return "#{record[:name]}: #{dest}" end end end diff --git a/lib/puppet/provider/maillist/mailman.rb b/lib/puppet/provider/maillist/mailman.rb index 51b7fa34b..5e60b20f1 100755 --- a/lib/puppet/provider/maillist/mailman.rb +++ b/lib/puppet/provider/maillist/mailman.rb @@ -37,7 +37,7 @@ Puppet::Type.type(:maillist).provide(:mailman) do name = self.name.downcase aliases = {name => "| #{mailman} post #{name}"} %w{admin bounces confirm join leave owner request subscribe unsubscribe}.each do |address| - aliases["%s-%s" % [name, address]] = "| %s %s %s" % [mailman, address, name] + aliases["#{name}-#{address}"] = "| #{mailman} #{address} #{name}" end aliases end diff --git a/lib/puppet/provider/naginator.rb b/lib/puppet/provider/naginator.rb index 5510eb9c8..592eb43fd 100644 --- a/lib/puppet/provider/naginator.rb +++ b/lib/puppet/provider/naginator.rb @@ -13,7 +13,7 @@ class Puppet::Provider::Naginator < Puppet::Provider::ParsedFile unless defined?(@nagios_type) and @nagios_type name = resource_type.name.to_s.sub(/^nagios_/, '') unless @nagios_type = Nagios::Base.type(name.to_sym) - raise Puppet::DevError, "Could not find nagios type '%s'" % name + raise Puppet::DevError, "Could not find nagios type '#{name}'" end # And add our 'ensure' settings, since they aren't a part of @@ -27,7 +27,7 @@ class Puppet::Provider::Naginator < Puppet::Provider::ParsedFile begin Nagios::Parser.new.parse(text.gsub(NAME_STRING, "_naginator_name")) rescue => detail - raise Puppet::Error, "Could not parse configuration for %s: %s" % [resource_type.name, detail] + raise Puppet::Error, "Could not parse configuration for #{resource_type.name}: #{detail}" end end diff --git a/lib/puppet/provider/nameservice.rb b/lib/puppet/provider/nameservice.rb index 8a759e4f3..dace6b512 100644 --- a/lib/puppet/provider/nameservice.rb +++ b/lib/puppet/provider/nameservice.rb @@ -45,7 +45,7 @@ class Puppet::Provider::NameService < Puppet::Provider def options(name, hash) unless resource_type.valid_parameter?(name) - raise Puppet::DevError, "%s is not a valid attribute for %s" % [name, resource_type.name] + raise Puppet::DevError, "#{name} is not a valid attribute for #{resource_type.name}" end @options ||= {} @options[name] ||= {} @@ -61,16 +61,16 @@ class Puppet::Provider::NameService < Puppet::Provider # for both users and groups. def listbyname names = [] - Etc.send("set%sent" % section()) + Etc.send("set#{section()}ent") begin - while ent = Etc.send("get%sent" % section()) + while ent = Etc.send("get#{section()}ent") names << ent.name if block_given? yield ent.name end end ensure - Etc.send("end%sent" % section()) + Etc.send("end#{section()}ent") end return names @@ -110,7 +110,7 @@ class Puppet::Provider::NameService < Puppet::Provider if @checks.include? name block = @checks[name][:block] unless block.call(value) - raise ArgumentError, "Invalid value %s: %s" % [value, @checks[name][:error]] + raise ArgumentError, "Invalid value #{value}: #{@checks[name][:error]}" end end end @@ -123,7 +123,7 @@ class Puppet::Provider::NameService < Puppet::Provider private def op(property) - @ops[property.name] || ("-" + property.name) + @ops[property.name] || ("-#{property.name}") end end @@ -137,8 +137,8 @@ class Puppet::Provider::NameService < Puppet::Provider else if value = self.class.autogen_default(field) return value - elsif respond_to?("autogen_%s" % [field]) - return send("autogen_%s" % field) + elsif respond_to?("autogen_#{field}") + return send("autogen_#{field}") else return nil end @@ -155,7 +155,7 @@ class Puppet::Provider::NameService < Puppet::Provider when :user; group = :passwd; method = :uid when :group; group = :group; method = :gid else - raise Puppet::DevError, "Invalid resource name %s" % resource + raise Puppet::DevError, "Invalid resource name #{resource}" end # Make sure we don't use the same value multiple times @@ -186,7 +186,7 @@ class Puppet::Provider::NameService < Puppet::Provider begin execute(self.addcmd) rescue Puppet::ExecutionFailure => detail - raise Puppet::Error, "Could not create %s %s: %s" % [@resource.class.name, @resource.name, detail] + raise Puppet::Error, "Could not create #{@resource.class.name} #{@resource.name}: #{detail}" end end @@ -200,7 +200,7 @@ class Puppet::Provider::NameService < Puppet::Provider begin execute(self.deletecmd) rescue Puppet::ExecutionFailure => detail - raise Puppet::Error, "Could not delete %s %s: %s" % [@resource.class.name, @resource.name, detail] + raise Puppet::Error, "Could not delete #{@resource.class.name} #{@resource.name}: #{detail}" end end @@ -304,7 +304,7 @@ class Puppet::Provider::NameService < Puppet::Provider begin execute(cmd) rescue Puppet::ExecutionFailure => detail - raise Puppet::Error, "Could not set %s on %s[%s]: %s" % [param, @resource.class.name, @resource.name, detail] + raise Puppet::Error, "Could not set #{param} on #{@resource.class.name}[#{@resource.name}]: #{detail}" end end end diff --git a/lib/puppet/provider/nameservice/directoryservice.rb b/lib/puppet/provider/nameservice/directoryservice.rb index 1eb0aec6c..251f496d5 100644 --- a/lib/puppet/provider/nameservice/directoryservice.rb +++ b/lib/puppet/provider/nameservice/directoryservice.rb @@ -123,12 +123,12 @@ class DirectoryService < Puppet::Provider::NameService product_version_major = product_version.scan(/(\d+)\.(\d+)./).join(".") end if %w{10.0 10.1 10.2 10.3}.include?(product_version_major) - fail("%s is not supported by the directoryservice provider" % product_version_major) + fail("#{product_version_major} is not supported by the directoryservice provider") end @macosx_version_major = product_version_major return @macosx_version_major rescue Puppet::ExecutionFailure => detail - fail("Could not determine OS X version: %s" % detail) + fail("Could not determine OS X version: #{detail}") end end @@ -138,7 +138,7 @@ class DirectoryService < Puppet::Provider::NameService begin dscl_output = execute(get_exec_preamble("-list")) rescue Puppet::ExecutionFailure => detail - fail("Could not get %s list from DirectoryService" % [ @resource_type.name.to_s ]) + fail("Could not get #{@resource_type.name} list from DirectoryService") end return dscl_output.split("\n") end @@ -279,9 +279,9 @@ class DirectoryService < Puppet::Provider::NameService # JJM: get_ds_path will spit back "Users" or "Groups", # etc... Depending on the Puppet::Type of our self. if resource_name - command_vector << "/%s/%s" % [ get_ds_path, resource_name ] + command_vector << "/#{get_ds_path}/#{resource_name}" else - command_vector << "/%s" % [ get_ds_path ] + command_vector << "/#{get_ds_path}" end # JJM: This returns most of the preamble of the command. # e.g. 'dscl / -create /Users/mccune' @@ -368,7 +368,7 @@ class DirectoryService < Puppet::Provider::NameService guid = guid_plist["dsAttrTypeStandard:#{@@ns_to_ds_attribute_map[:guid]}"][0] self.class.set_password(@resource.name, guid, passphrase) rescue Puppet::ExecutionFailure => detail - fail("Could not set %s on %s[%s]: %s" % [param, @resource.class.name, @resource.name, detail]) + fail("Could not set #{param} on #{@resource.class.name}[#{@resource.name}]: #{detail}") end end @@ -399,7 +399,7 @@ class DirectoryService < Puppet::Provider::NameService begin execute(exec_arg_vector) rescue Puppet::ExecutionFailure => detail - fail("Could not set %s on %s[%s]: %s" % [param, @resource.class.name, @resource.name, detail]) + fail("Could not set #{param} on #{@resource.class.name}[#{@resource.name}]: #{detail}") end end end @@ -426,7 +426,7 @@ class DirectoryService < Puppet::Provider::NameService begin execute(exec_arg_vector) rescue Puppet::ExecutionFailure => detail - fail("Could not set GeneratedUID for %s %s: %s" % [@resource.class.name, @resource.name, detail]) + fail("Could not set GeneratedUID for #{@resource.class.name} #{@resource.name}: #{detail}") end if value = @resource.should(:password) and value != "" @@ -447,7 +447,7 @@ class DirectoryService < Puppet::Provider::NameService begin execute(exec_arg_vector) rescue Puppet::ExecutionFailure => detail - fail("Could not create %s %s: %s" % [@resource.class.name, @resource.name, detail]) + fail("Could not create #{@resource.class.name} #{@resource.name}: #{detail}") end end end @@ -461,7 +461,7 @@ class DirectoryService < Puppet::Provider::NameService begin execute(cmd) rescue Puppet::ExecutionFailure => detail - fail("Could not remove %s from group: %s, %s" % [member, @resource.name, detail]) + fail("Could not remove #{member} from group: #{@resource.name}, #{detail}") end end end @@ -474,7 +474,7 @@ class DirectoryService < Puppet::Provider::NameService begin execute(cmd) rescue Puppet::ExecutionFailure => detail - fail("Could not add %s to group: %s, %s" % [new_member, @resource.name, detail]) + fail("Could not add #{new_member} to group: #{@resource.name}, #{detail}") end end end diff --git a/lib/puppet/provider/package/aix.rb b/lib/puppet/provider/package/aix.rb index 385d33fac..7523b776d 100644 --- a/lib/puppet/provider/package/aix.rb +++ b/lib/puppet/provider/package/aix.rb @@ -95,7 +95,7 @@ Puppet::Type.type(:package).provide :aix, :parent => Puppet::Provider::Package d if hash[:pkgname] return nil else - raise Puppet::Error, "Could not list installed Packages: %s" % detail + raise Puppet::Error, "Could not list installed Packages: #{detail}" end end diff --git a/lib/puppet/provider/package/apt.rb b/lib/puppet/provider/package/apt.rb index 9ae2a861e..622e182ea 100755 --- a/lib/puppet/provider/package/apt.rb +++ b/lib/puppet/provider/package/apt.rb @@ -65,7 +65,7 @@ Puppet::Type.type(:package).provide :apt, :parent => :dpkg, :source => :dpkg do # pass else # Add the package version and --force-yes option - str += "=%s" % should + str += "=#{should}" cmd << "--force-yes" end @@ -91,7 +91,7 @@ Puppet::Type.type(:package).provide :apt, :parent => :dpkg, :source => :dpkg do # def run_preseed if response = @resource[:responsefile] and FileTest.exist?(response) - self.info("Preseeding %s to debconf-set-selections" % response) + self.info("Preseeding #{response} to debconf-set-selections") preseed response else diff --git a/lib/puppet/provider/package/aptitude.rb b/lib/puppet/provider/package/aptitude.rb index 0842856c1..607f8c0dc 100755 --- a/lib/puppet/provider/package/aptitude.rb +++ b/lib/puppet/provider/package/aptitude.rb @@ -19,7 +19,7 @@ Puppet::Type.type(:package).provide :aptitude, :parent => :apt, :source => :dpkg # Yay, stupid aptitude doesn't throw an error when the package is missing. if args.include?(:install) and output =~ /Couldn't find any package/ raise Puppet::Error.new( - "Could not find package %s" % self.name + "Could not find package #{self.name}" ) end end diff --git a/lib/puppet/provider/package/aptrpm.rb b/lib/puppet/provider/package/aptrpm.rb index 4b3841d88..a3ad3b447 100644 --- a/lib/puppet/provider/package/aptrpm.rb +++ b/lib/puppet/provider/package/aptrpm.rb @@ -31,7 +31,7 @@ Puppet::Type.type(:package).provide :aptrpm, :parent => :rpm, :source => :rpm do # pass else # Add the package version - str += "=%s" % should + str += "=#{should}" end cmd = %w{-q -y} @@ -50,7 +50,7 @@ Puppet::Type.type(:package).provide :aptrpm, :parent => :rpm, :source => :rpm do if version =~ /^([^\(]+)\(/ $1 else - self.warning "Could not match version '%s'" % version + self.warning "Could not match version '#{version}'" nil end }.reject { |vers| vers.nil? }.sort { |a,b| diff --git a/lib/puppet/provider/package/blastwave.rb b/lib/puppet/provider/package/blastwave.rb index 9b2bbf6a5..ee1e8f73a 100755 --- a/lib/puppet/provider/package/blastwave.rb +++ b/lib/puppet/provider/package/blastwave.rb @@ -83,7 +83,7 @@ Puppet::Type.type(:package).provide :blastwave, :parent => :sun, :source => :sun return hash else - Puppet.warning "Cannot match %s" % line + Puppet.warning "Cannot match #{line}" return nil end end diff --git a/lib/puppet/provider/package/darwinport.rb b/lib/puppet/provider/package/darwinport.rb index 5cced62d5..2153d2f83 100755 --- a/lib/puppet/provider/package/darwinport.rb +++ b/lib/puppet/provider/package/darwinport.rb @@ -27,7 +27,7 @@ Puppet::Type.type(:package).provide :darwinport, :parent => Puppet::Provider::Pa yield hash.dup else raise Puppet::DevError, - "Failed to match dpkg line %s" % line + "Failed to match dpkg line #{line}" end } } @@ -49,7 +49,7 @@ Puppet::Type.type(:package).provide :darwinport, :parent => Puppet::Provider::Pa # Seems like you can always say 'upgrade' output = port "upgrade", @resource[:name] if output =~ /^Error: No port/ - raise Puppet::ExecutionFailure, "Could not find package %s" % @resource[:name] + raise Puppet::ExecutionFailure, "Could not find package #{@resource[:name]}" end end diff --git a/lib/puppet/provider/package/dpkg.rb b/lib/puppet/provider/package/dpkg.rb index aaa277944..3c3141b4f 100755 --- a/lib/puppet/provider/package/dpkg.rb +++ b/lib/puppet/provider/package/dpkg.rb @@ -16,7 +16,7 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package # list out all of the packages cmd = "#{command(:dpkgquery)} -W --showformat '${Status} ${Package} ${Version}\\n'" - Puppet.debug "Executing '%s'" % cmd + Puppet.debug "Executing '#{cmd}'" execpipe(cmd) do |process| # our regex for matching dpkg output regex = %r{^(\S+) +(\S+) +(\S+) (\S+) (\S*)$} @@ -56,7 +56,7 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package hash[:ensure] = :held end else - Puppet.warning "Failed to match dpkg-query line %s" % line.inspect + Puppet.warning "Failed to match dpkg-query line #{line.inspect}" return nil end @@ -92,7 +92,7 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package output = dpkg_deb "--show", @resource[:source] matches = /^(\S+)\t(\S+)$/.match(output).captures unless matches[0].match( Regexp.escape(@resource[:name]) ) - warning "source doesn't contain named package, but %s" % matches[0] + warning "source doesn't contain named package, but #{matches[0]}" end matches[1] end @@ -122,7 +122,7 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package if hash[:error] != "ok" raise Puppet::Error.new( - "Package %s, version %s is in error state: %s" % [hash[:name], hash[:ensure], hash[:error]] + "Package #{hash[:name]}, version #{hash[:ensure]} is in error state: #{hash[:error]}" ) end diff --git a/lib/puppet/provider/package/fink.rb b/lib/puppet/provider/package/fink.rb index d859c0e32..3f0d79475 100755 --- a/lib/puppet/provider/package/fink.rb +++ b/lib/puppet/provider/package/fink.rb @@ -33,7 +33,7 @@ Puppet::Type.type(:package).provide :fink, :parent => :dpkg, :source => :dpkg do # pass else # Add the package version - str += "=%s" % should + str += "=#{should}" end cmd = %w{-b -q -y} @@ -61,7 +61,7 @@ Puppet::Type.type(:package).provide :fink, :parent => :dpkg, :source => :dpkg do # def run_preseed if response = @resource[:responsefile] and FileTest.exists?(response) - self.info("Preseeding %s to debconf-set-selections" % response) + self.info("Preseeding #{response} to debconf-set-selections") preseed response else diff --git a/lib/puppet/provider/package/freebsd.rb b/lib/puppet/provider/package/freebsd.rb index 79316f80f..0c816cdb6 100755 --- a/lib/puppet/provider/package/freebsd.rb +++ b/lib/puppet/provider/package/freebsd.rb @@ -30,7 +30,7 @@ Puppet::Type.type(:package).provide :freebsd, :parent => :openbsd do end else if @resource[:source] - Puppet.warning "source is defined but does not have trailing slash, ignoring %s" % @resource[:source] + Puppet.warning "source is defined but does not have trailing slash, ignoring #{@resource[:source]}" end pkgadd "-r", @resource[:name] end @@ -46,7 +46,7 @@ Puppet::Type.type(:package).provide :freebsd, :parent => :openbsd do end def uninstall - pkgdelete "%s-%s" % [@resource[:name], @resource.should(:ensure)] + pkgdelete "#{@resource[:name]}-#{@resource.should(:ensure)}" end end diff --git a/lib/puppet/provider/package/gem.rb b/lib/puppet/provider/package/gem.rb index 9dca08d5c..1c345097f 100755 --- a/lib/puppet/provider/package/gem.rb +++ b/lib/puppet/provider/package/gem.rb @@ -35,7 +35,7 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d end end.compact rescue Puppet::ExecutionFailure => detail - raise Puppet::Error, "Could not list gems: %s" % detail + raise Puppet::Error, "Could not list gems: #{detail}" end if hash[:justme] @@ -56,7 +56,7 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d :ensure => version } else - Puppet.warning "Could not match %s" % desc + Puppet.warning "Could not match #{desc}" nil end end @@ -79,7 +79,7 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d begin uri = URI.parse(source) rescue => detail - fail "Invalid source '%s': %s" % [uri, detail] + fail "Invalid source '#{uri}': #{detail}" end case uri.scheme @@ -102,7 +102,7 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d output = execute(command) # Apparently some stupid gem versions don't exit non-0 on failure if output.include?("ERROR") - self.fail "Could not install: %s" % output.chomp + self.fail "Could not install: #{output.chomp}" end end diff --git a/lib/puppet/provider/package/openbsd.rb b/lib/puppet/provider/package/openbsd.rb index 254c9ab61..149b557ae 100755 --- a/lib/puppet/provider/package/openbsd.rb +++ b/lib/puppet/provider/package/openbsd.rb @@ -38,7 +38,7 @@ Puppet::Type.type(:package).provide :openbsd, :parent => Puppet::Provider::Packa else # Print a warning on lines we can't match, but move # on, since it should be non-fatal - warning("Failed to match line %s" % line) + warning("Failed to match line #{line}") end } end diff --git a/lib/puppet/provider/package/pkg.rb b/lib/puppet/provider/package/pkg.rb index 7d21acb66..c0767a7f0 100644 --- a/lib/puppet/provider/package/pkg.rb +++ b/lib/puppet/provider/package/pkg.rb @@ -47,7 +47,7 @@ Puppet::Type.type(:package).provide :pkg, :parent => Puppet::Provider::Package d hash[:ensure] = :absent end else - Puppet.warning "Failed to match 'pkg list' line %s" % line.inspect + Puppet.warning "Failed to match 'pkg list' line #{line.inspect}" return nil end @@ -66,7 +66,7 @@ Puppet::Type.type(:package).provide :pkg, :parent => Puppet::Provider::Package d when "installed" version = v else - Puppet.warn "unknown package state for %s: %s" % [@resource[:name], v] + Puppet.warn "unknown package state for #{@resource[:name]}: #{v}" end end version @@ -101,7 +101,7 @@ Puppet::Type.type(:package).provide :pkg, :parent => Puppet::Provider::Package d {:ensure => :absent, :status => 'missing', :name => @resource[:name], :error => 'ok'} if hash[:error] != "ok" - raise Puppet::Error.new( "Package %s, version %s is in error state: %s" % [hash[:name], hash[:version], hash[:error]]) + raise Puppet::Error.new( "Package #{hash[:name]}, version #{hash[:version]} is in error state: #{hash[:error]}") end return hash diff --git a/lib/puppet/provider/package/pkgdmg.rb b/lib/puppet/provider/package/pkgdmg.rb index 4e9e50802..ac4853d83 100644 --- a/lib/puppet/provider/package/pkgdmg.rb +++ b/lib/puppet/provider/package/pkgdmg.rb @@ -93,7 +93,7 @@ Puppet::Type.type(:package).provide :pkgdmg, :parent => Puppet::Provider::Packag xml_str = hdiutil "mount", "-plist", "-nobrowse", "-readonly", "-noidme", "-mountrandom", "/tmp", dmg.path hdiutil_info = Plist::parse_xml(xml_str) unless hdiutil_info.has_key?("system-entities") - raise Puppet::Error.new("No disk entities returned by mount at %s" % dmg.path) + raise Puppet::Error.new("No disk entities returned by mount at #{dmg.path}") end mounts = hdiutil_info["system-entities"].collect { |entity| entity["mount-point"] diff --git a/lib/puppet/provider/package/portage.rb b/lib/puppet/provider/package/portage.rb index 5f3a5bd4c..7e1119a1a 100644 --- a/lib/puppet/provider/package/portage.rb +++ b/lib/puppet/provider/package/portage.rb @@ -54,14 +54,14 @@ Puppet::Type.type(:package).provide :portage, :parent => Puppet::Provider::Packa name = package_name unless should == :present or should == :latest # We must install a specific version - name = "=%s-%s" % [name, should] + name = "=#{name}-#{should}" end emerge name end # The common package name format. def package_name - @resource[:category] ? "%s/%s" % [@resource[:category], @resource[:name]] : @resource[:name] + @resource[:category] ? "#{@resource[:category]}/#{@resource[:name]}" : @resource[:name] end def uninstall @@ -108,7 +108,7 @@ Puppet::Type.type(:package).provide :portage, :parent => Puppet::Provider::Packa case packages.size when 0 - not_found_value = "%s/%s" % [@resource[:category] ? @resource[:category] : "<unspecified category>", @resource[:name]] + not_found_value = "#{@resource[:category] ? @resource[:category] : "<unspecified category>"}/#{@resource[:name]}" raise Puppet::Error.new("No package found with the specified name [#{not_found_value}]") when 1 return packages[0] diff --git a/lib/puppet/provider/package/ports.rb b/lib/puppet/provider/package/ports.rb index 16e065ef8..286aca8e1 100755 --- a/lib/puppet/provider/package/ports.rb +++ b/lib/puppet/provider/package/ports.rb @@ -22,7 +22,7 @@ Puppet::Type.type(:package).provide :ports, :parent => :freebsd, :source => :fre output = portupgrade(*cmd) if output =~ /\*\* No such / - raise Puppet::ExecutionFailure, "Could not find package %s" % @resource[:name] + raise Puppet::ExecutionFailure, "Could not find package #{@resource[:name]}" end end @@ -48,7 +48,7 @@ Puppet::Type.type(:package).provide :ports, :parent => :freebsd, :source => :fre unless pkgstuff =~ /^(\S+)-([^-\s]+)$/ raise Puppet::Error, - "Could not match package info '%s'" % pkgstuff + "Could not match package info '#{pkgstuff}'" end name, version = $1, $2 @@ -62,12 +62,12 @@ Puppet::Type.type(:package).provide :ports, :parent => :freebsd, :source => :fre unless info =~ /\((\w+) has (.+)\)/ raise Puppet::Error, - "Could not match version info '%s'" % info + "Could not match version info '#{info}'" end source, newversion = $1, $2 - debug "Newer version in %s" % source + debug "Newer version in #{source}" return newversion end diff --git a/lib/puppet/provider/package/portupgrade.rb b/lib/puppet/provider/package/portupgrade.rb index acdcab6f7..c3aea98bf 100644 --- a/lib/puppet/provider/package/portupgrade.rb +++ b/lib/puppet/provider/package/portupgrade.rb @@ -70,7 +70,7 @@ Puppet::Type.type(:package).provide :portupgrade, :parent => Puppet::Provider::P else # unrecognised output from pkg_info - Puppet.debug "portupgrade.Instances() - unable to match output: %s" % data + Puppet.debug "portupgrade.Instances() - unable to match output: #{data}" end } @@ -82,7 +82,7 @@ Puppet::Type.type(:package).provide :portupgrade, :parent => Puppet::Provider::P ######## Installation sub command def install - Puppet.debug "portupgrade.install() - Installation call on %s" % @resource[:name] + Puppet.debug "portupgrade.install() - Installation call on #{@resource[:name]}" # -M: yes, we're a batch, so don't ask any questions cmdline = ["-M BATCH=yes", @resource[:name]] @@ -94,7 +94,7 @@ Puppet::Type.type(:package).provide :portupgrade, :parent => Puppet::Provider::P end if output =~ /\*\* No such / - raise Puppet::ExecutionFailure, "Could not find package %s" % @resource[:name] + raise Puppet::ExecutionFailure, "Could not find package #{@resource[:name]}" end # No return code required, so do nil to be clean @@ -104,7 +104,7 @@ Puppet::Type.type(:package).provide :portupgrade, :parent => Puppet::Provider::P ######## Latest subcommand (returns the latest version available, or current version if installed is latest) def latest - Puppet.debug "portupgrade.latest() - Latest check called on %s" % @resource[:name] + Puppet.debug "portupgrade.latest() - Latest check called on #{@resource[:name]}" # search for latest version available, or return current version. # cmdline = "portversion -v <portorigin>", returns "<portname> <code> <stuff>" # or "** No matching package found: <portname>" @@ -128,24 +128,24 @@ Puppet::Type.type(:package).provide :portupgrade, :parent => Puppet::Provider::P # all others return the current version so no unexpected 'upgrades' occur. case comparison when "=", ">" - Puppet.debug "portupgrade.latest() - Installed package is latest (%s)" % installedversion + Puppet.debug "portupgrade.latest() - Installed package is latest (#{installedversion})" return installedversion when "<" # "portpkg-1.7_5 < needs updating (port has 1.14)" # "portpkg-1.7_5 < needs updating (port has 1.14) (=> 'newport/pkg') if otherdata =~ /\(port has (\S+)\)/ newversion = $1 - Puppet.debug "portupgrade.latest() - Installed version needs updating to (%s)" % newversion + Puppet.debug "portupgrade.latest() - Installed version needs updating to (#{newversion})" return newversion else - Puppet.debug "portupgrade.latest() - Unable to determine new version from (%s)" % otherdata + Puppet.debug "portupgrade.latest() - Unable to determine new version from (#{otherdata})" return installedversion end when "?", "!", "#" - Puppet.debug "portupgrade.latest() - Comparison Error reported from portversion (%s)" % output + Puppet.debug "portupgrade.latest() - Comparison Error reported from portversion (#{output})" return installedversion else - Puppet.debug "portupgrade.latest() - Unknown code from portversion output (%s)" % output + Puppet.debug "portupgrade.latest() - Unknown code from portversion output (#{output})" return installedversion end @@ -154,10 +154,10 @@ Puppet::Type.type(:package).provide :portupgrade, :parent => Puppet::Provider::P # Seriously - this section should never be called in a perfect world. # as verification that the port is installed has already happened in query. if output =~ /^\*\* No matching package / - raise Puppet::ExecutionFailure, "Could not find package %s" % @resource[:name] + raise Puppet::ExecutionFailure, "Could not find package #{@resource[:name]}" else # Any other error (dump output to log) - raise Puppet::ExecutionFailure, "Unexpected output from portversion: %s" % output + raise Puppet::ExecutionFailure, "Unexpected output from portversion: #{output}" end # Just in case we still are running, return nil @@ -166,7 +166,7 @@ Puppet::Type.type(:package).provide :portupgrade, :parent => Puppet::Provider::P # At this point normal operation has finished and we shouldn't have been called. # Error out and let the admin deal with it. - raise Puppet::Error, "portversion.latest() - fatal error with portversion: %s" % output + raise Puppet::Error, "portversion.latest() - fatal error with portversion: #{output}" return nil end @@ -175,7 +175,7 @@ Puppet::Type.type(:package).provide :portupgrade, :parent => Puppet::Provider::P # Used to make sure the package is installed def query - Puppet.debug "portupgrade.query() - Called on %s" % @resource[:name] + Puppet.debug "portupgrade.query() - Called on #{@resource[:name]}" cmdline = ["-qO", @resource[:name]] begin @@ -198,7 +198,7 @@ Puppet::Type.type(:package).provide :portupgrade, :parent => Puppet::Provider::P # return the hash to the caller return hash else - Puppet.debug "portupgrade.query() - package (%s) not installed" % @resource[:name] + Puppet.debug "portupgrade.query() - package (#{@resource[:name]}) not installed" return nil end @@ -207,7 +207,7 @@ Puppet::Type.type(:package).provide :portupgrade, :parent => Puppet::Provider::P ####### Uninstall command def uninstall - Puppet.debug "portupgrade.uninstall() - called on %s" % @resource[:name] + Puppet.debug "portupgrade.uninstall() - called on #{@resource[:name]}" # Get full package name from port origin to uninstall with cmdline = ["-qO", @resource[:name]] begin @@ -226,7 +226,7 @@ Puppet::Type.type(:package).provide :portupgrade, :parent => Puppet::Provider::P ######## Update/upgrade command def update - Puppet.debug "portupgrade.update() - called on (%s)" % @resource[:name] + Puppet.debug "portupgrade.update() - called on (#{@resource[:name]})" cmdline = ["-qO", @resource[:name]] begin diff --git a/lib/puppet/provider/package/rug.rb b/lib/puppet/provider/package/rug.rb index 9f09b35fe..227edc7c2 100644 --- a/lib/puppet/provider/package/rug.rb +++ b/lib/puppet/provider/package/rug.rb @@ -20,13 +20,13 @@ Puppet::Type.type(:package).provide :rug, :parent => :rpm do # pass else # Add the package version - wanted += "-%s" % should + wanted += "-#{should}" end output = rug "--quiet", :install, "-y", wanted unless self.query raise Puppet::ExecutionFailure.new( - "Could not find package %s" % self.name + "Could not find package #{self.name}" ) end end diff --git a/lib/puppet/provider/package/up2date.rb b/lib/puppet/provider/package/up2date.rb index 1de7c6ea5..8780e7fd4 100644 --- a/lib/puppet/provider/package/up2date.rb +++ b/lib/puppet/provider/package/up2date.rb @@ -15,7 +15,7 @@ Puppet::Type.type(:package).provide :up2date, :parent => :rpm, :source => :rpm d unless self.query raise Puppet::ExecutionFailure.new( - "Could not find package %s" % self.name + "Could not find package #{self.name}" ) end end diff --git a/lib/puppet/provider/package/urpmi.rb b/lib/puppet/provider/package/urpmi.rb index 05eed42d7..a7732c4a2 100644 --- a/lib/puppet/provider/package/urpmi.rb +++ b/lib/puppet/provider/package/urpmi.rb @@ -27,14 +27,14 @@ Puppet::Type.type(:package).provide :urpmi, :parent => :rpm, :source => :rpm do # pass else # Add the package version - wanted += "-%s" % should + wanted += "-#{should}" end output = urpmi "--auto", wanted unless self.query raise Puppet::Error.new( - "Could not find package %s" % self.name + "Could not find package #{self.name}" ) end end diff --git a/lib/puppet/provider/package/yum.rb b/lib/puppet/provider/package/yum.rb index 32ab2c124..4ff365de7 100755 --- a/lib/puppet/provider/package/yum.rb +++ b/lib/puppet/provider/package/yum.rb @@ -62,14 +62,14 @@ Puppet::Type.type(:package).provide :yum, :parent => :rpm, :source => :rpm do should = nil else # Add the package version - wanted += "-%s" % should + wanted += "-#{should}" end output = yum "-d", "0", "-e", "0", "-y", :install, wanted is = self.query unless is - raise Puppet::Error, "Could not find package %s" % self.name + raise Puppet::Error, "Could not find package #{self.name}" end # FIXME: Should we raise an exception even if should == :latest diff --git a/lib/puppet/provider/package/zypper.rb b/lib/puppet/provider/package/zypper.rb index 03a504fe5..9f7386b20 100644 --- a/lib/puppet/provider/package/zypper.rb +++ b/lib/puppet/provider/package/zypper.rb @@ -20,13 +20,13 @@ Puppet::Type.type(:package).provide :zypper, :parent => :rpm do # pass else # Add the package version - wanted = "%s-%s" % [wanted, should] + wanted = "#{wanted}-#{should}" end output = zypper "--quiet", :install, "-l", "-y", wanted unless self.query raise Puppet::ExecutionFailure.new( - "Could not find package %s" % self.name + "Could not find package #{self.name}" ) end end diff --git a/lib/puppet/provider/parsedfile.rb b/lib/puppet/provider/parsedfile.rb index 47e4fcd69..e4d1e95f3 100755 --- a/lib/puppet/provider/parsedfile.rb +++ b/lib/puppet/provider/parsedfile.rb @@ -48,7 +48,7 @@ class Puppet::Provider::ParsedFile < Puppet::Provider elsif klass = Puppet::Util::FileType.filetype(type) @filetype = klass else - raise ArgumentError, "Invalid filetype %s" % type + raise ArgumentError, "Invalid filetype #{type}" end end @@ -70,7 +70,7 @@ class Puppet::Provider::ParsedFile < Puppet::Provider flushed = [] @modified.sort { |a,b| a.to_s <=> b.to_s }.uniq.each do |target| - Puppet.debug "Flushing %s provider target %s" % [@resource_type.name, target] + Puppet.debug "Flushing #{@resource_type.name} provider target #{target}" flush_target(target) flushed << target end @@ -234,7 +234,7 @@ class Puppet::Provider::ParsedFile < Puppet::Provider end unless target_records - raise Puppet::DevError, "Prefetching %s for provider %s returned nil" % [target, self.name] + raise Puppet::DevError, "Prefetching #{target} for provider #{self.name} returned nil" end target_records diff --git a/lib/puppet/provider/port/parsed.rb b/lib/puppet/provider/port/parsed.rb index 624c267b9..5c973b6af 100755 --- a/lib/puppet/provider/port/parsed.rb +++ b/lib/puppet/provider/port/parsed.rb @@ -27,7 +27,7 @@ require 'puppet/provider/parsedfile' # record_line :parsed, :fields => %w{name port protocols alias description}, # :optional => %w{alias description} do |line| # if line =~ /\/ddp/ -# raise "missed ddp in %s" % line +# raise "missed ddp in #{line}" # end # # The record might contain multiple port lines separated by \n. # hashes = line.split("\n").collect { |l| parse_port(l) } @@ -113,7 +113,7 @@ require 'puppet/provider/parsedfile' # # line.inspect # next # end -# Puppet.notice "Ignoring unparseable line '%s' in %s" % [line, self.target] +# Puppet.notice "Ignoring unparseable line '#{line}' in #{self.target}" # end # # if hash.empty? @@ -157,14 +157,14 @@ require 'puppet/provider/parsedfile' # # # Strangely, most sites seem to use tabs as separators. # hash[:protocols].collect { |proto| -# str = "%s\t\t%s/%s" % [hash[:name], hash[:number], proto] +# str = "#{hash[:name]}\t\t#{hash[:number]}/#{proto}" # # if value = hash[:alias] and value != :absent -# str += "\t\t%s" % value.join(" ") +# str += "\t\t#{value.join(" ")}" # end # # if value = hash[:description] and value != :absent -# str += "\t# %s" % value +# str += "\t# #{value}" # end # str # }.join("\n") diff --git a/lib/puppet/provider/selboolean/getsetsebool.rb b/lib/puppet/provider/selboolean/getsetsebool.rb index c993c3748..940ce3b70 100644 --- a/lib/puppet/provider/selboolean/getsetsebool.rb +++ b/lib/puppet/provider/selboolean/getsetsebool.rb @@ -15,7 +15,7 @@ Puppet::Type.type(:selboolean).provide(:getsetsebool) do return :on else status.chomp! - raise Puppet::Error, "Invalid response '%s' returned from getsebool" % [status] + raise Puppet::Error, "Invalid response '#{status}' returned from getsebool" end end diff --git a/lib/puppet/provider/selmodule/semodule.rb b/lib/puppet/provider/selmodule/semodule.rb index c75acfa5e..2f2416b4b 100644 --- a/lib/puppet/provider/selmodule/semodule.rb +++ b/lib/puppet/provider/selmodule/semodule.rb @@ -7,7 +7,7 @@ Puppet::Type.type(:selmodule).provide(:semodule) do begin execoutput("#{command(:semodule)} --install #{selmod_name_to_filename}") rescue Puppet::ExecutionFailure => detail - raise Puppet::Error, "Could not load policy module: %s" % [detail]; + raise Puppet::Error, "Could not load policy module: #{detail}"; end return :true end @@ -16,7 +16,7 @@ Puppet::Type.type(:selmodule).provide(:semodule) do begin execoutput("#{command(:semodule)} --remove #{@resource[:name]}") rescue Puppet::ExecutionFailure => detail - raise Puppet::Error, "Could not remove policy module: %s" % [detail]; + raise Puppet::Error, "Could not remove policy module: #{detail}"; end end @@ -50,7 +50,7 @@ Puppet::Type.type(:selmodule).provide(:semodule) do begin execoutput("#{command(:semodule)} --upgrade #{selmod_name_to_filename}") rescue Puppet::ExecutionFailure => detail - raise Puppet::Error, "Could not upgrade policy module: %s" % [detail]; + raise Puppet::Error, "Could not upgrade policy module: #{detail}"; end end @@ -136,7 +136,7 @@ Puppet::Type.type(:selmodule).provide(:semodule) do end end rescue Puppet::ExecutionFailure - raise Puppet::ExecutionFailure, "Could not list policy modules: %s" % [lines.join(' ').chomp!] + raise Puppet::ExecutionFailure, "Could not list policy modules: #{lines.join(' ').chomp!}" end return nil end diff --git a/lib/puppet/provider/service/base.rb b/lib/puppet/provider/service/base.rb index 2e9ac778a..7428f266c 100755 --- a/lib/puppet/provider/service/base.rb +++ b/lib/puppet/provider/service/base.rb @@ -70,7 +70,7 @@ Puppet::Type.type(:service).provide :base do return :stopped end elsif pid = self.getpid - self.debug "PID is %s" % pid + self.debug "PID is #{pid}" return :running else return :stopped @@ -108,13 +108,13 @@ Puppet::Type.type(:service).provide :base do else pid = getpid unless pid - self.info "%s is not running" % self.name + self.info "#{self.name} is not running" return false end begin output = kill pid rescue Puppet::ExecutionFailure => detail - @resource.fail "Could not kill %s, PID %s: %s" % [self.name, pid, output] + @resource.fail "Could not kill #{self.name}, PID #{pid}: #{output}" end return true end @@ -130,7 +130,7 @@ Puppet::Type.type(:service).provide :base do # #565: Services generally produce no output, so squelch them. execute(command, :failonfail => fof, :squelch => true) rescue Puppet::ExecutionFailure => detail - @resource.fail "Could not %s %s: %s" % [type, @resource.ref, detail] + @resource.fail "Could not #{type} #{@resource.ref}: #{detail}" end return nil end diff --git a/lib/puppet/provider/service/daemontools.rb b/lib/puppet/provider/service/daemontools.rb index cb3ac51a1..e8409860a 100644 --- a/lib/puppet/provider/service/daemontools.rb +++ b/lib/puppet/provider/service/daemontools.rb @@ -66,7 +66,7 @@ Puppet::Type.type(:service).provide :daemontools, :parent => :base do def self.instances path = self.defpath unless FileTest.directory?(path) - Puppet.notice "Service path %s does not exist" % path + Puppet.notice "Service path #{path} does not exist" next end @@ -119,7 +119,7 @@ Puppet::Type.type(:service).provide :daemontools, :parent => :base do return :running end rescue Puppet::ExecutionFailure => detail - raise Puppet::Error.new( "Could not get status for service %s: %s" % [ resource.ref, detail] ) + raise Puppet::Error.new( "Could not get status for service #{resource.ref}: #{detail}" ) end return :stopped end @@ -127,13 +127,13 @@ Puppet::Type.type(:service).provide :daemontools, :parent => :base do def setupservice begin if resource[:manifest] - Puppet.notice "Configuring %s" % resource[:name] + Puppet.notice "Configuring #{resource[:name]}" command = [ resource[:manifest], resource[:name] ] #texecute("setupservice", command) rv = system("#{command}") end rescue Puppet::ExecutionFailure => detail - raise Puppet::Error.new( "Cannot config %s to enable it: %s" % [ self.service, detail ] ) + raise Puppet::Error.new( "Cannot config #{self.service} to enable it: #{detail}" ) end end @@ -151,34 +151,34 @@ Puppet::Type.type(:service).provide :daemontools, :parent => :base do def enable begin if ! FileTest.directory?(self.daemon) - Puppet.notice "No daemon dir, calling setupservice for %s" % resource[:name] + Puppet.notice "No daemon dir, calling setupservice for #{resource[:name]}" self.setupservice end if self.daemon if ! FileTest.symlink?(self.service) - Puppet.notice "Enabling %s: linking %s -> %s" % [ self.service, self.daemon, self.service ] + Puppet.notice "Enabling #{self.service}: linking #{self.daemon} -> #{self.service}" File.symlink(self.daemon, self.service) end end rescue Puppet::ExecutionFailure => detail - raise Puppet::Error.new( "No daemon directory found for %s" % self.service ) + raise Puppet::Error.new( "No daemon directory found for #{self.service}") end end def disable begin if ! FileTest.directory?(self.daemon) - Puppet.notice "No daemon dir, calling setupservice for %s" % resource[:name] + Puppet.notice "No daemon dir, calling setupservice for #{resource[:name]}" self.setupservice end if self.daemon if FileTest.symlink?(self.service) - Puppet.notice "Disabling %s: removing link %s -> %s" % [ self.service, self.daemon, self.service ] + Puppet.notice "Disabling #{self.service}: removing link #{self.daemon} -> #{self.service}" File.unlink(self.service) end end rescue Puppet::ExecutionFailure => detail - raise Puppet::Error.new( "No daemon directory found for %s" % self.service ) + raise Puppet::Error.new( "No daemon directory found for #{self.service}") end self.stop end diff --git a/lib/puppet/provider/service/gentoo.rb b/lib/puppet/provider/service/gentoo.rb index 0327eb297..a3d477751 100644 --- a/lib/puppet/provider/service/gentoo.rb +++ b/lib/puppet/provider/service/gentoo.rb @@ -21,7 +21,7 @@ Puppet::Type.type(:service).provide :gentoo, :parent => :init do begin output = update :del, @resource[:name], :default rescue Puppet::ExecutionFailure - raise Puppet::Error, "Could not disable %s: %s" % [self.name, output] + raise Puppet::Error, "Could not disable #{self.name}: #{output}" end end @@ -48,7 +48,7 @@ Puppet::Type.type(:service).provide :gentoo, :parent => :init do begin output = update :add, @resource[:name], :default rescue Puppet::ExecutionFailure - raise Puppet::Error, "Could not enable %s: %s" % [self.name, output] + raise Puppet::Error, "Could not enable #{self.name}: #{output}" end end end diff --git a/lib/puppet/provider/service/init.rb b/lib/puppet/provider/service/init.rb index 5804732ed..d5dc21477 100755 --- a/lib/puppet/provider/service/init.rb +++ b/lib/puppet/provider/service/init.rb @@ -36,7 +36,7 @@ Puppet::Type.type(:service).provide :init, :parent => :base do instances = [] defpath.each do |path| unless FileTest.directory?(path) - Puppet.debug "Service path %s does not exist" % path + Puppet.debug "Service path #{path} does not exist" next end @@ -63,7 +63,7 @@ Puppet::Type.type(:service).provide :init, :parent => :base do when true, "true"; @parameters[:hasstatus] = true when false, "false"; @parameters[:hasstatus] = false else - raise Puppet::Error, "Invalid 'hasstatus' value %s" % value.inspect + raise Puppet::Error, "Invalid 'hasstatus' value #{value.inspect}" end end @@ -94,7 +94,7 @@ Puppet::Type.type(:service).provide :init, :parent => :base do stat = File.stat(fqname) rescue # should probably rescue specific errors... - self.debug("Could not find %s in %s" % [name,path]) + self.debug("Could not find #{name} in #{path}") next end @@ -108,14 +108,14 @@ Puppet::Type.type(:service).provide :init, :parent => :base do stat = File.stat(fqname_sh) rescue # should probably rescue specific errors... - self.debug("Could not find %s.sh in %s" % [name,path]) + self.debug("Could not find #{name}.sh in #{path}") next end # if we've gotten this far, we found a valid script return fqname_sh } - raise Puppet::Error, "Could not find init script for '%s'" % name + raise Puppet::Error, "Could not find init script for '#{name}'" end # The start command is just the init scriptwith 'start'. diff --git a/lib/puppet/provider/service/launchd.rb b/lib/puppet/provider/service/launchd.rb index c65e1cc1a..635c30b49 100644 --- a/lib/puppet/provider/service/launchd.rb +++ b/lib/puppet/provider/service/launchd.rb @@ -111,12 +111,12 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do product_version_major = product_version.scan(/(\d+)\.(\d+)./).join(".") end if %w{10.0 10.1 10.2 10.3}.include?(product_version_major) - fail("%s is not supported by the launchd provider" % product_version_major) + fail("#{product_version_major} is not supported by the launchd provider") end @macosx_version_major = product_version_major return @macosx_version_major rescue Puppet::ExecutionFailure => detail - fail("Could not determine OS X version: %s" % detail) + fail("Could not determine OS X version: #{detail}") end end @@ -171,7 +171,7 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do begin execute(cmds) rescue Puppet::ExecutionFailure - raise Puppet::Error.new("Unable to start service: %s at path: %s" % [resource[:name], job_path]) + raise Puppet::Error.new("Unable to start service: #{resource[:name]} at path: #{job_path}") end # As load -w clears the Disabled flag, we need to add it in after if did_enable_job and resource[:enable] == :false @@ -193,7 +193,7 @@ Puppet::Type.type(:service).provide :launchd, :parent => :base do begin execute(cmds) rescue Puppet::ExecutionFailure - raise Puppet::Error.new("Unable to stop service: %s at path: %s" % [resource[:name], job_path]) + raise Puppet::Error.new("Unable to stop service: #{resource[:name]} at path: #{job_path}") end # As unload -w sets the Disabled flag, we need to add it in after if did_disable_job and resource[:enable] == :true diff --git a/lib/puppet/provider/service/redhat.rb b/lib/puppet/provider/service/redhat.rb index f3d5caee0..c49df3142 100755 --- a/lib/puppet/provider/service/redhat.rb +++ b/lib/puppet/provider/service/redhat.rb @@ -25,7 +25,7 @@ Puppet::Type.type(:service).provide :redhat, :parent => :init, :source => :init begin output = chkconfig(@resource[:name], :off) rescue Puppet::ExecutionFailure - raise Puppet::Error, "Could not disable %s: %s" % [self.name, output] + raise Puppet::Error, "Could not disable #{self.name}: #{output}" end end @@ -51,12 +51,12 @@ Puppet::Type.type(:service).provide :redhat, :parent => :init, :source => :init begin output = chkconfig(@resource[:name], :on) rescue Puppet::ExecutionFailure => detail - raise Puppet::Error, "Could not enable %s: %s" % [self.name, detail] + raise Puppet::Error, "Could not enable #{self.name}: #{detail}" end end def initscript - raise Puppet::Error, "Do not directly call the init script for '%s'; use 'service' instead" % @resource[:name] + raise Puppet::Error, "Do not directly call the init script for '#{@resource[:name]}'; use 'service' instead" end # use hasstatus=>true when its set for the provider. diff --git a/lib/puppet/provider/service/runit.rb b/lib/puppet/provider/service/runit.rb index 265111469..3b49d14ef 100644 --- a/lib/puppet/provider/service/runit.rb +++ b/lib/puppet/provider/service/runit.rb @@ -72,7 +72,7 @@ Puppet::Type.type(:service).provide :runit, :parent => :daemontools do return :running if output =~ /^run: / rescue Puppet::ExecutionFailure => detail unless detail.message =~ /(warning: |runsv not running$)/ - raise Puppet::Error.new( "Could not get status for service %s: %s" % [ resource.ref, detail] ) + raise Puppet::Error.new( "Could not get status for service #{resource.ref}: #{detail}" ) end end return :stopped diff --git a/lib/puppet/provider/service/smf.rb b/lib/puppet/provider/service/smf.rb index 72f34ef37..0407c8479 100755 --- a/lib/puppet/provider/service/smf.rb +++ b/lib/puppet/provider/service/smf.rb @@ -23,12 +23,12 @@ Puppet::Type.type(:service).provide :smf, :parent => :base do if resource[:manifest] [command(:svcs), "-l", @resource[:name]] if $CHILD_STATUS.exitstatus == 1 - Puppet.notice "Importing %s for %s" % [ @resource[:manifest], @resource[:name] ] + Puppet.notice "Importing #{@resource[:manifest]} for #{@resource[:name]}" svccfg :import, resource[:manifest] end end rescue Puppet::ExecutionFailure => detail - raise Puppet::Error.new( "Cannot config %s to enable it: %s" % [ self.service, detail ] ) + raise Puppet::Error.new( "Cannot config #{self.service} to enable it: #{detail}" ) end end @@ -75,16 +75,16 @@ Puppet::Type.type(:service).provide :smf, :parent => :base do states = svcs("-H", "-o", "state,nstate", @resource[:name]).chomp.split state = states[1] == "-" ? states[0] : states[1] rescue Puppet::ExecutionFailure - info "Could not get status on service %s" % self.name + info "Could not get status on service #{self.name}" return :stopped end case state when "online" - #self.warning "matched running %s" % line.inspect + #self.warning "matched running #{line.inspect}" return :running when "offline", "disabled", "uninitialized" - #self.warning "matched stopped %s" % line.inspect + #self.warning "matched stopped #{line.inspect}" return :stopped when "maintenance" return :maintenance @@ -93,7 +93,7 @@ Puppet::Type.type(:service).provide :smf, :parent => :base do "Cannot manage legacy services through SMF" else raise Puppet::Error, - "Unmanageable state '%s' on service %s" % [state, self.name] + "Unmanageable state '#{state}' on service #{self.name}" end end diff --git a/lib/puppet/provider/service/src.rb b/lib/puppet/provider/service/src.rb index fe178ab4f..135edcb65 100755 --- a/lib/puppet/provider/service/src.rb +++ b/lib/puppet/provider/service/src.rb @@ -55,12 +55,12 @@ Puppet::Type.type(:service).provide :src, :parent => :base do end return :true rescue Puppet::ExecutionFailure => detail - raise Puppet::Error.new("Unable to restart service %s, error was: %s" % [ @resource[:name], detail ] ) + raise Puppet::Error.new("Unable to restart service #{@resource[:name]}, error was: #{detail}" ) end end self.fail("No such service found") rescue Puppet::ExecutionFailure => detail - raise Puppet::Error.new("Cannot get status of %s, error was: %s" % [ @resource[:name], detail ] ) + raise Puppet::Error.new("Cannot get status of #{@resource[:name]}, error was: #{detail}" ) end end @@ -83,7 +83,7 @@ Puppet::Type.type(:service).provide :src, :parent => :base do end self.fail("No such service found") rescue Puppet::ExecutionFailure => detail - raise Puppet::Error.new("Cannot get status of %s, error was: %s" % [ @resource[:name], detail ] ) + raise Puppet::Error.new("Cannot get status of #{@resource[:name]}, error was: #{detail}" ) end end diff --git a/lib/puppet/provider/user/directoryservice.rb b/lib/puppet/provider/user/directoryservice.rb index ffb7a65de..d3cb4f244 100644 --- a/lib/puppet/provider/user/directoryservice.rb +++ b/lib/puppet/provider/user/directoryservice.rb @@ -59,7 +59,7 @@ Puppet::Type.type(:user).provide :directoryservice, :parent => Puppet::Provider: # when String # groups = groups.split(/\s*,\s*/) # else - # raise Puppet::DevError, "got invalid groups value %s of type %s" % [groups.class, groups] + # raise Puppet::DevError, "got invalid groups value #{groups.class} of type #{groups}" # end # # Get just the groups we need to modify # diff = groups - (@is || []) diff --git a/lib/puppet/provider/user/ldap.rb b/lib/puppet/provider/user/ldap.rb index 7c38880cb..888d3bfd7 100644 --- a/lib/puppet/provider/user/ldap.rb +++ b/lib/puppet/provider/user/ldap.rb @@ -61,7 +61,7 @@ Puppet::Type.type(:user).provide :ldap, :parent => Puppet::Provider::Ldap do # We want to cache the current result, so we know if we # have to remove old values. unless @property_hash[:groups] - unless result = group_manager.search("memberUid=%s" % name) + unless result = group_manager.search("memberUid=#{name}") return @property_hash[:groups] = :absent end @@ -93,7 +93,7 @@ Puppet::Type.type(:user).provide :ldap, :parent => Puppet::Provider::Ldap do end modes.each do |group, form| - self.fail "Could not find ldap group %s" % group unless ldap_group = group_manager.find(group) + self.fail "Could not find ldap group #{group}" unless ldap_group = group_manager.find(group) current = ldap_group[:members] diff --git a/lib/puppet/provider/user/user_role_add.rb b/lib/puppet/provider/user/user_role_add.rb index 961cb5e73..126b95e95 100644 --- a/lib/puppet/provider/user/user_role_add.rb +++ b/lib/puppet/provider/user/user_role_add.rb @@ -54,7 +54,7 @@ Puppet::Type.type(:user).provide :user_role_add, :parent => :useradd, :source => def command(cmd) if is_role? or (!exists? and @resource[:ensure] == :role) - cmd = ("role_" + cmd.to_s).intern + cmd = ("role_#{cmd}").intern end super(cmd) end @@ -67,7 +67,7 @@ Puppet::Type.type(:user).provide :user_role_add, :parent => :useradd, :source => begin execute(cmd) rescue Puppet::ExecutionFailure => detail - raise Puppet::Error, "Could not %s %s %s: %s" % [msg, @resource.class.name, @resource.name, detail] + raise Puppet::Error, "Could not #{msg} #{@resource.class.name} #{@resource.name}: #{detail}" end end @@ -182,7 +182,7 @@ Puppet::Type.type(:user).provide :user_role_add, :parent => :useradd, :source => end File.rename("/etc/shadow_tmp", "/etc/shadow") rescue => detail - fail "Could not write temporary shadow file: %s" % detail + fail "Could not write temporary shadow file: #{detail}" ensure # Make sure this *always* gets deleted File.unlink("/etc/shadow_tmp") if File.exist?("/etc/shadow_tmp") diff --git a/lib/puppet/provider/zone/solaris.rb b/lib/puppet/provider/zone/solaris.rb index 4d7e7473d..a5345e457 100644 --- a/lib/puppet/provider/zone/solaris.rb +++ b/lib/puppet/provider/zone/solaris.rb @@ -37,7 +37,7 @@ Puppet::Type.type(:zone).provide(:solaris) do def configure # If the thing is entirely absent, then we need to create the config. # Is there someway to get this on one line? - str = "create -b #{@resource[:create_args]}\nset zonepath=%s\n" % @resource[:path] + str = "create -b #{@resource[:create_args]}\nset zonepath=#{@resource[:path]}\n" # Then perform all of our configuration steps. It's annoying # that we need this much internal info on the resource. @@ -131,10 +131,10 @@ Puppet::Type.type(:zone).provide(:solaris) do end current[$1.intern] = $2 else - err "Ignoring '%s'" % line + err "Ignoring '#{line}'" end else - debug "Ignoring zone output '%s'" % line + debug "Ignoring zone output '#{line}'" end end @@ -144,8 +144,8 @@ Puppet::Type.type(:zone).provide(:solaris) do # Execute a configuration string. Can't be private because it's called # by the properties. def setconfig(str) - command = "#{command(:cfg)} -z %s -f -" % @resource[:name] - debug "Executing '%s' in zone %s with '%s'" % [command, @resource[:name], str] + command = "#{command(:cfg)} -z #{@resource[:name]} -f -" + debug "Executing '#{command}' in zone #{@resource[:name]} with '#{str}'" IO.popen(command, "w") do |pipe| pipe.puts str end @@ -174,7 +174,7 @@ Puppet::Type.type(:zone).provide(:solaris) do if Puppet[:debug] puts detail.stacktrace end - raise Puppet::Error, "Could not create sysidcfg: %s" % detail + raise Puppet::Error, "Could not create sysidcfg: #{detail}" end end end @@ -233,9 +233,9 @@ Puppet::Type.type(:zone).provide(:solaris) do if net = config["net"] result[:ip] = net.collect do |params| if params[:defrouter] - "%s:%s:%s" % [params[:physical], params[:address], params[:defrouter]] + "#{params[:physical]}:#{params[:address]}:#{params[:defrouter]}" elsif params[:address] - "%s:%s" % [params[:physical], params[:address]] + "#{params[:physical]}:#{params[:address]}" else params[:physical] end @@ -249,7 +249,7 @@ Puppet::Type.type(:zone).provide(:solaris) do begin adm("-z", @resource[:name], *cmd) rescue Puppet::ExecutionFailure => detail - self.fail "Could not %s zone: %s" % [cmd[0], detail] + self.fail "Could not #{cmd[0]} zone: #{detail}" end end @@ -260,7 +260,7 @@ Puppet::Type.type(:zone).provide(:solaris) do begin cfg("-z", self.name, *cmd) rescue Puppet::ExecutionFailure => detail - self.fail "Could not %s zone: %s" % [cmd[0], detail] + self.fail "Could not #{cmd[0]} zone: #{detail}" end end end diff --git a/lib/puppet/provider/zpool/solaris.rb b/lib/puppet/provider/zpool/solaris.rb index 8fc01ba81..a54af3df8 100644 --- a/lib/puppet/provider/zpool/solaris.rb +++ b/lib/puppet/provider/zpool/solaris.rb @@ -108,7 +108,7 @@ Puppet::Type.type(:zpool).provide(:solaris) do end define_method(field.to_s + "=") do |should| - Puppet.warning "NO CHANGES BEING MADE: zpool %s does not match, should be '%s' currently is '%s'" % [field, should, current_pool[field]] + Puppet.warning "NO CHANGES BEING MADE: zpool #{field} does not match, should be '#{should}' currently is '#{current_pool[field]}'" end end diff --git a/lib/puppet/rails.rb b/lib/puppet/rails.rb index be252e444..33abe8d8a 100644 --- a/lib/puppet/rails.rb +++ b/lib/puppet/rails.rb @@ -18,7 +18,7 @@ module Puppet::Rails loglevel = Logger.const_get(Puppet[:rails_loglevel].upcase) ActiveRecord::Base.logger.level = loglevel rescue => detail - Puppet.warning "'%s' is not a valid Rails log level; using debug" % Puppet[:rails_loglevel] + Puppet.warning "'#{Puppet[:rails_loglevel]}' is not a valid Rails log level; using debug" ActiveRecord::Base.logger.level = Logger::DEBUG end @@ -36,7 +36,7 @@ module Puppet::Rails if Puppet[:trace] puts detail.backtrace end - raise Puppet::Error, "Could not connect to database: %s" % detail + raise Puppet::Error, "Could not connect to database: #{detail}" end end @@ -70,7 +70,7 @@ module Puppet::Rails connections = Puppet[:dbconnections].to_i args[:pool] = connections if connections > 0 else - raise ArgumentError, "Invalid db adapter %s" % adapter + raise ArgumentError, "Invalid db adapter #{adapter}" end args end @@ -121,7 +121,7 @@ module Puppet::Rails if Puppet[:trace] puts detail.backtrace end - raise Puppet::Error, "Could not migrate database: %s" % detail + raise Puppet::Error, "Could not migrate database: #{detail}" end end @@ -139,7 +139,7 @@ module Puppet::Rails if Puppet[:trace] puts detail.backtrace end - raise Puppet::Error, "Could not connect to database: %s" % detail + raise Puppet::Error, "Could not connect to database: #{detail}" end ActiveRecord::Base.connection.tables.each do |t| diff --git a/lib/puppet/rails/benchmark.rb b/lib/puppet/rails/benchmark.rb index 1fbd011e9..72ffa7443 100644 --- a/lib/puppet/rails/benchmark.rb +++ b/lib/puppet/rails/benchmark.rb @@ -45,7 +45,7 @@ module Puppet::Rails::Benchmark end $benchmarks[:accumulated][message].each do |label, value| - Puppet.debug(message + ("(%s)" % label) + (" in %0.2f seconds" % value)) + Puppet.debug(message + ("(#{label})") + (" in %0.2f seconds" % value)) end end diff --git a/lib/puppet/rails/param_value.rb b/lib/puppet/rails/param_value.rb index d0bb8d7d3..e4b5a668f 100644 --- a/lib/puppet/rails/param_value.rb +++ b/lib/puppet/rails/param_value.rb @@ -48,7 +48,7 @@ class Puppet::Rails::ParamValue < ActiveRecord::Base # returns an array of hash containing all the parameters of a given resource def self.find_all_params_from_resource(db_resource) - params = db_resource.connection.select_all("SELECT v.id, v.value, v.line, v.resource_id, v.param_name_id, n.name FROM param_values v INNER JOIN param_names n ON v.param_name_id=n.id WHERE v.resource_id=%s" % db_resource.id) + params = db_resource.connection.select_all("SELECT v.id, v.value, v.line, v.resource_id, v.param_name_id, n.name FROM param_values v INNER JOIN param_names n ON v.param_name_id=n.id WHERE v.resource_id=#{db_resource.id}") params.each do |val| val['value'] = unserialize_value(val['value']) val['line'] = val['line'] ? Integer(val['line']) : nil @@ -59,7 +59,7 @@ class Puppet::Rails::ParamValue < ActiveRecord::Base # returns an array of hash containing all the parameters of a given host def self.find_all_params_from_host(db_host) - params = db_host.connection.select_all("SELECT v.id, v.value, v.line, v.resource_id, v.param_name_id, n.name FROM param_values v INNER JOIN resources r ON v.resource_id=r.id INNER JOIN param_names n ON v.param_name_id=n.id WHERE r.host_id=%s" % db_host.id) + params = db_host.connection.select_all("SELECT v.id, v.value, v.line, v.resource_id, v.param_name_id, n.name FROM param_values v INNER JOIN resources r ON v.resource_id=r.id INNER JOIN param_names n ON v.param_name_id=n.id WHERE r.host_id=#{db_host.id}") params.each do |val| val['value'] = unserialize_value(val['value']) val['line'] = val['line'] ? Integer(val['line']) : nil @@ -69,6 +69,6 @@ class Puppet::Rails::ParamValue < ActiveRecord::Base end def to_s - "%s => %s" % [self.name, self.value] + "#{self.name} => #{self.value}" end end diff --git a/lib/puppet/rails/resource.rb b/lib/puppet/rails/resource.rb index 7b37a52bf..f2c41c17e 100644 --- a/lib/puppet/rails/resource.rb +++ b/lib/puppet/rails/resource.rb @@ -194,7 +194,7 @@ class Puppet::Rails::Resource < ActiveRecord::Base end def ref(dummy_argument=:work_arround_for_ruby_GC_bug) - "%s[%s]" % [self[:restype].split("::").collect { |s| s.capitalize }.join("::"), self.title.to_s] + "#{self[:restype].split("::").collect { |s| s.capitalize }.join("::")}[#{self.title}]" end # Returns a hash of parameter names and values, no ActiveRecord instances. diff --git a/lib/puppet/rails/resource_tag.rb b/lib/puppet/rails/resource_tag.rb index f094eabb8..0bbac11d3 100644 --- a/lib/puppet/rails/resource_tag.rb +++ b/lib/puppet/rails/resource_tag.rb @@ -8,7 +8,7 @@ class Puppet::Rails::ResourceTag < ActiveRecord::Base # returns an array of hash containing tags of resource def self.find_all_tags_from_resource(db_resource) - tags = db_resource.connection.select_all("SELECT t.id, t.resource_id, p.name FROM resource_tags t INNER JOIN puppet_tags p ON t.puppet_tag_id=p.id WHERE t.resource_id=%s" % db_resource.id) + tags = db_resource.connection.select_all("SELECT t.id, t.resource_id, p.name FROM resource_tags t INNER JOIN puppet_tags p ON t.puppet_tag_id=p.id WHERE t.resource_id=#{db_resource.id}") tags.each do |val| val['resource_id'] = Integer(val['resource_id']) end @@ -17,7 +17,7 @@ class Puppet::Rails::ResourceTag < ActiveRecord::Base # returns an array of hash containing tags of a host def self.find_all_tags_from_host(db_host) - tags = db_host.connection.select_all("SELECT t.id, t.resource_id, p.name FROM resource_tags t INNER JOIN resources r ON t.resource_id=r.id INNER JOIN puppet_tags p ON t.puppet_tag_id=p.id WHERE r.host_id=%s" % db_host.id) + tags = db_host.connection.select_all("SELECT t.id, t.resource_id, p.name FROM resource_tags t INNER JOIN resources r ON t.resource_id=r.id INNER JOIN puppet_tags p ON t.puppet_tag_id=p.id WHERE r.host_id=#{db_host.id}") tags.each do |val| val['resource_id'] = Integer(val['resource_id']) end diff --git a/lib/puppet/reference/configuration.rb b/lib/puppet/reference/configuration.rb index 352116cd5..2f60ecc65 100644 --- a/lib/puppet/reference/configuration.rb +++ b/lib/puppet/reference/configuration.rb @@ -31,9 +31,9 @@ config = Puppet::Util::Reference.newreference(:configuration, :depth => 1, :doc end # Leave out the section information; it was apparently confusing people. - #str += "- **Section**: %s\n" % object.section + #str += "- **Section**: #{object.section}\n" unless val == "" - str += "- **Default**: %s\n" % val + str += "- **Default**: #{val}\n" end str += "\n" end diff --git a/lib/puppet/reference/metaparameter.rb b/lib/puppet/reference/metaparameter.rb index 8e0a89ac6..9368de186 100644 --- a/lib/puppet/reference/metaparameter.rb +++ b/lib/puppet/reference/metaparameter.rb @@ -29,7 +29,7 @@ metaparameter = Puppet::Util::Reference.newreference :metaparameter, :doc => "Al a.to_s <=> b.to_s }.each { |param| str += paramwrap(param.to_s, scrub(Puppet::Type.metaparamdoc(param)), :level => 4) - #puts "<dt>" + param.to_s + "</dt>" + #puts "<dt>#{param}</dt>" #puts tab(1) + Puppet::Type.metaparamdoc(param).scrub.indent($tab)gsub(/\n\s*/,' ') #puts "<dd>" #puts indent(scrub(Puppet::Type.metaparamdoc(param)), $tab) @@ -40,7 +40,7 @@ metaparameter = Puppet::Util::Reference.newreference :metaparameter, :doc => "Al } rescue => detail puts detail.backtrace - puts "incorrect metaparams: %s" % detail + puts "incorrect metaparams: #{detail}" exit(1) end diff --git a/lib/puppet/reference/providers.rb b/lib/puppet/reference/providers.rb index 33d85061e..cc47876d6 100644 --- a/lib/puppet/reference/providers.rb +++ b/lib/puppet/reference/providers.rb @@ -53,31 +53,31 @@ providers = Puppet::Util::Reference.newreference :providers, :title => "Provider suit = true functional = true else - data << "[%s]_" % [count] # A pointer to the appropriate footnote + data << "[#{count}]_" # A pointer to the appropriate footnote suit = false end # Add a footnote with the details about why this provider is unsuitable, if that's the case unless suit - details = ".. [%s]\n" % count + details = ".. [#{count}]\n" missing.each do |test, values| case test when :exists - details += " - Missing files %s\n" % values.join(", ") + details += " - Missing files #{values.join(", ")}\n" when :variable values.each do |name, facts| if Puppet.settings.valid?(name) - details += " - Setting %s (currently %s) not in list %s\n" % [name, Puppet.settings.value(name).inspect, facts.join(", ")] + details += " - Setting #{name} (currently #{Puppet.settings.value(name).inspect}) not in list #{facts.join(", ")}\n" else - details += " - Fact %s (currently %s) not in list %s\n" % [name, Facter.value(name).inspect, facts.join(", ")] + details += " - Fact #{name} (currently #{Facter.value(name).inspect}) not in list #{facts.join(", ")}\n" end end when :true - details += " - Got %s true tests that should have been false\n" % values + details += " - Got #{values} true tests that should have been false\n" when :false - details += " - Got %s false tests that should have been true\n" % values + details += " - Got #{values} false tests that should have been true\n" when :feature - details += " - Missing features %s\n" % values.collect { |f| f.to_s }.join(",") + details += " - Missing features #{values.collect { |f| f.to_s }.join(",")}\n" end end notes << details @@ -97,7 +97,7 @@ providers = Puppet::Util::Reference.newreference :providers, :title => "Provider ret += h(type.name.to_s + "_", 2) - ret += ".. _%s: %s\n\n" % [type.name, "http://reductivelabs.com/trac/puppet/wiki/TypeReference#%s" % type.name] + ret += ".. _#{type.name}: #{"http://reductivelabs.com/trac/puppet/wiki/TypeReference##{type.name}"}\n\n" ret += option("Default provider", default) ret += doctable(headers, table_data) diff --git a/lib/puppet/reference/type.rb b/lib/puppet/reference/type.rb index c18681c1f..6bd8be835 100644 --- a/lib/puppet/reference/type.rb +++ b/lib/puppet/reference/type.rb @@ -79,12 +79,12 @@ type = Puppet::Util::Reference.newreference :type, :doc => "All Puppet resource property = type.propertybyname(sname) unless property - raise "Could not retrieve property %s on type %s" % [sname, type.name] + raise "Could not retrieve property #{sname} on type #{type.name}" end doc = nil unless doc = property.doc - $stderr.puts "No docs for %s[%s]" % [type, sname] + $stderr.puts "No docs for #{type}[#{sname}]" next end doc = doc.dup diff --git a/lib/puppet/relationship.rb b/lib/puppet/relationship.rb index 95f347539..ea91d0e69 100644 --- a/lib/puppet/relationship.rb +++ b/lib/puppet/relationship.rb @@ -70,7 +70,7 @@ class Puppet::Relationship end def ref - "%s => %s" % [source, target] + "#{source} => #{target}" end def to_pson_data_hash diff --git a/lib/puppet/reports.rb b/lib/puppet/reports.rb index df992d46c..8407d67de 100755 --- a/lib/puppet/reports.rb +++ b/lib/puppet/reports.rb @@ -35,7 +35,7 @@ class Puppet::Reports instance_loader(:report).loadall loaded_instances(:report).sort { |a,b| a.to_s <=> b.to_s }.each do |name| mod = self.report(name) - docs += "%s\n%s\n" % [name, "-" * name.to_s.length] + docs += "#{name}\n#{"-" * name.to_s.length}\n" docs += Puppet::Util::Docs.scrub(mod.doc) + "\n\n" end diff --git a/lib/puppet/reports/log.rb b/lib/puppet/reports/log.rb index d99333434..827572c2c 100644 --- a/lib/puppet/reports/log.rb +++ b/lib/puppet/reports/log.rb @@ -6,7 +6,7 @@ Puppet::Reports.register_report(:log) do def process self.logs.each do |log| - log.source = "//" + self.host + "/" + log.source + log.source = "//#{self.host}/#{log.source}" Puppet::Util::Log.newmessage(log) end end diff --git a/lib/puppet/reports/rrdgraph.rb b/lib/puppet/reports/rrdgraph.rb index 508b1d28b..4e618d5ee 100644 --- a/lib/puppet/reports/rrdgraph.rb +++ b/lib/puppet/reports/rrdgraph.rb @@ -29,9 +29,9 @@ Puppet::Reports.register_report(:rrdgraph) do end def htmlfile(type, graphs, field) - file = File.join(hostdir, "%s.html" % type) + file = File.join(hostdir, "#{type}.html") File.open(file, "w") do |of| - of.puts "<html><head><title>%s graphs for %s</title></head><body>" % [type.capitalize, host] + of.puts "<html><head><title>#{type.capitalize} graphs for #{host}</title></head><body>" graphs.each do |graph| if field == :first @@ -39,7 +39,7 @@ Puppet::Reports.register_report(:rrdgraph) do else name = graph.sub(/\w+-/, '').sub(".png", '').capitalize end - of.puts "<img src=%s><br>" % graph + of.puts "<img src=#{graph}><br>" end of.puts "</body></html>" end @@ -66,7 +66,7 @@ Puppet::Reports.register_report(:rrdgraph) do # Make the period html files periodorder.each do |period| unless ary = periods[period] - raise Puppet::Error, "Could not find graphs for %s" % period + raise Puppet::Error, "Could not find graphs for #{period}" end files << htmlfile(period, ary, :first) end @@ -75,10 +75,10 @@ Puppet::Reports.register_report(:rrdgraph) do types.sort { |a,b| a[0] <=> b[0] }.each do |type, ary| newary = [] periodorder.each do |period| - if graph = ary.find { |g| g.include?("-%s.png" % period) } + if graph = ary.find { |g| g.include?("-#{period}.png") } newary << graph else - raise "Could not find %s-%s graph" % [type, period] + raise "Could not find #{type}-#{period} graph" end end @@ -86,9 +86,9 @@ Puppet::Reports.register_report(:rrdgraph) do end File.open(File.join(hostdir, "index.html"), "w") do |of| - of.puts "<html><head><title>Report graphs for %s</title></head><body>" % host + of.puts "<html><head><title>Report graphs for #{host}</title></head><body>" files.each do |file| - of.puts "<a href='%s'>%s</a><br/>" % [File.basename(file), File.basename(file).sub(".html",'').capitalize] + of.puts "<a href='#{File.basename(file)}'>#{File.basename(file).sub(".html",'').capitalize}</a><br/>" end of.puts "</body></html>" end diff --git a/lib/puppet/reports/store.rb b/lib/puppet/reports/store.rb index 8317ee243..547b45a33 100644 --- a/lib/puppet/reports/store.rb +++ b/lib/puppet/reports/store.rb @@ -15,7 +15,7 @@ Puppet::Reports.register_report(:store) do "reportclient-#{client}".to_sym, "client-#{client}-dir" => { :default => dir, :mode => 0750, - :desc => "Client dir for %s" % client, + :desc => "Client dir for #{client}", :owner => 'service', :group => 'service' }, @@ -54,7 +54,7 @@ Puppet::Reports.register_report(:store) do if Puppet[:trace] puts detail.backtrace end - Puppet.warning "Could not write report for %s at %s: %s" % [client, file, detail] + Puppet.warning "Could not write report for #{client} at #{file}: #{detail}" end # Only testing cares about the return value diff --git a/lib/puppet/reports/tagmail.rb b/lib/puppet/reports/tagmail.rb index 01ff1b033..270cadb91 100644 --- a/lib/puppet/reports/tagmail.rb +++ b/lib/puppet/reports/tagmail.rb @@ -59,7 +59,7 @@ Puppet::Reports.register_report(:tagmail) do end if messages.empty? - Puppet.info "No messages to report to %s" % emails.join(",") + Puppet.info "No messages to report to #{emails.join(",")}" next else matching_logs << [emails, messages.collect { |m| m.to_report }.join("\n")] @@ -88,13 +88,13 @@ Puppet::Reports.register_report(:tagmail) do neg = [] taglist.sub(/\s+$/,'').split(/\s*,\s*/).each do |tag| unless tag =~ /^!?[-\w]+$/ - raise ArgumentError, "Invalid tag %s" % tag.inspect + raise ArgumentError, "Invalid tag #{tag.inspect}" end case tag when /^\w+/; pos << tag when /^!\w+/; neg << tag.sub("!", '') else - raise Puppet::Error, "Invalid tag '%s'" % tag + raise Puppet::Error, "Invalid tag '#{tag}'" end end @@ -108,7 +108,7 @@ Puppet::Reports.register_report(:tagmail) do # Process the report. This just calls the other associated messages. def process unless FileTest.exists?(Puppet[:tagmap]) - Puppet.notice "Cannot send tagmail report; no tagmap file %s" % Puppet[:tagmap] + Puppet.notice "Cannot send tagmail report; no tagmap file #{Puppet[:tagmap]}" return end @@ -129,9 +129,9 @@ Puppet::Reports.register_report(:tagmail) do reports.each do |emails, messages| smtp.open_message_stream(Puppet[:reportfrom], *emails) do |p| p.puts "From: #{Puppet[:reportfrom]}" - p.puts "Subject: Puppet Report for %s" % self.host + p.puts "Subject: Puppet Report for #{self.host}" p.puts "To: " + emails.join(", ") - p.puts "Date: " + Time.now.rfc2822 + p.puts "Date: #{Time.now.rfc2822}" p.puts p.puts messages end @@ -142,7 +142,7 @@ Puppet::Reports.register_report(:tagmail) do puts detail.backtrace end raise Puppet::Error, - "Could not send report emails through smtp: %s" % detail + "Could not send report emails through smtp: #{detail}" end elsif Puppet[:sendmail] != "" begin @@ -150,7 +150,7 @@ Puppet::Reports.register_report(:tagmail) do # We need to open a separate process for every set of email addresses IO.popen(Puppet[:sendmail] + " " + emails.join(" "), "w") do |p| p.puts "From: #{Puppet[:reportfrom]}" - p.puts "Subject: Puppet Report for %s" % self.host + p.puts "Subject: Puppet Report for #{self.host}" p.puts "To: " + emails.join(", ") p.puts messages @@ -161,7 +161,7 @@ Puppet::Reports.register_report(:tagmail) do puts detail.backtrace end raise Puppet::Error, - "Could not send report emails via sendmail: %s" % detail + "Could not send report emails via sendmail: #{detail}" end else raise Puppet::Error, "SMTP server is unset and could not find sendmail" diff --git a/lib/puppet/resource/catalog.rb b/lib/puppet/resource/catalog.rb index 2c5c94920..98a380e87 100644 --- a/lib/puppet/resource/catalog.rb +++ b/lib/puppet/resource/catalog.rb @@ -71,7 +71,7 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph def add_resource(*resources) resources.each do |resource| unless resource.respond_to?(:ref) - raise ArgumentError, "Can only add objects that respond to :ref, not instances of %s" % resource.class + raise ArgumentError, "Can only add objects that respond to :ref, not instances of #{resource.class}" end end.each { |resource| fail_on_duplicate_type_and_title(resource) }.each do |resource| title_key = title_key_for_ref(resource.ref) @@ -105,7 +105,7 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph newref = [class_name, key] if key.is_a? String - ref_string = "%s[%s]" % [class_name, key] + ref_string = "#{class_name}[#{key}]" return if ref_string == resource.ref end @@ -115,7 +115,7 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph # isn't sufficient. if existing = @resource_table[newref] return if existing == resource - raise(ArgumentError, "Cannot alias %s to %s; resource %s already exists" % [resource.ref, key.inspect, newref.inspect]) + raise(ArgumentError, "Cannot alias #{resource.ref} to #{key.inspect}; resource #{newref.inspect} already exists") end @resource_table[newref] = resource @aliases[resource.ref] ||= [] @@ -148,10 +148,10 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph transaction.evaluate rescue Puppet::Error => detail puts detail.backtrace if Puppet[:trace] - Puppet.err "Could not apply complete catalog: %s" % detail + Puppet.err "Could not apply complete catalog: #{detail}" rescue => detail puts detail.backtrace if Puppet[:trace] - Puppet.err "Got an uncaught exception of type %s: %s" % [detail.class, detail] + Puppet.err "Got an uncaught exception of type #{detail.class}: #{detail}" ensure # Don't try to store state unless we're a host config # too recursive. @@ -190,7 +190,7 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph # Create a new resource and register it in the catalog. def create_resource(type, options) unless klass = Puppet::Type.type(type) - raise ArgumentError, "Unknown resource type %s" % type + raise ArgumentError, "Unknown resource type #{type}" end return unless resource = klass.new(options) @@ -238,7 +238,7 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph bucket = tmp || bucket if child = target.to_trans unless bucket - raise "No bucket created for %s" % source + raise "No bucket created for #{source}" end bucket.push child @@ -332,10 +332,10 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph vertex.autorequire(self).each do |edge| unless @relationship_graph.edge?(edge.source, edge.target) # don't let automatic relationships conflict with manual ones. unless @relationship_graph.edge?(edge.target, edge.source) - vertex.debug "Autorequiring %s" % [edge.source] + vertex.debug "Autorequiring #{edge.source}" @relationship_graph.add_edge(edge) else - vertex.debug "Skipping automatic relationship with %s" % (edge.source == vertex ? edge.target : edge.source) + vertex.debug "Skipping automatic relationship with #{(edge.source == vertex ? edge.target : edge.source)}" end end end @@ -491,7 +491,7 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph f.puts classes.join("\n") end rescue => detail - Puppet.err "Could not create class file %s: %s" % [Puppet[:classfile], detail] + Puppet.err "Could not create class file #{Puppet[:classfile]}: #{detail}" end end @@ -516,10 +516,10 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph return unless existing_resource = @resource_table[title_key_for_ref(resource.ref)] # If we've gotten this far, it's a real conflict - msg = "Duplicate definition: %s is already defined" % resource.ref + msg = "Duplicate definition: #{resource.ref} is already defined" if existing_resource.file and existing_resource.line - msg << " in file %s at line %s" % [existing_resource.file, existing_resource.line] + msg << " in file #{existing_resource.file} at line #{existing_resource.line}" end if resource.line or resource.file @@ -581,11 +581,11 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph next if block_given? and yield edge.target unless source = map[edge.source.ref] - raise Puppet::DevError, "Could not find resource %s when converting %s resources" % [edge.source.ref, message] + raise Puppet::DevError, "Could not find resource #{edge.source.ref} when converting #{message} resources" end unless target = map[edge.target.ref] - raise Puppet::DevError, "Could not find resource %s when converting %s resources" % [edge.target.ref, message] + raise Puppet::DevError, "Could not find resource #{edge.target.ref} when converting #{message} resources" end result.add_edge(source, target, edge.label) diff --git a/lib/puppet/run.rb b/lib/puppet/run.rb index 4e9c160de..1a1a98332 100644 --- a/lib/puppet/run.rb +++ b/lib/puppet/run.rb @@ -26,7 +26,7 @@ class Puppet::Run valid_options = [:tags, :ignoreschedules] options.each do |key, value| - raise ArgumentError, "Run does not accept %s" % key unless valid_options.include?(key) + raise ArgumentError, "Run does not accept #{key}" unless valid_options.include?(key) end @options = options diff --git a/lib/puppet/simple_graph.rb b/lib/puppet/simple_graph.rb index 51382682c..aeb70af2e 100644 --- a/lib/puppet/simple_graph.rb +++ b/lib/puppet/simple_graph.rb @@ -59,7 +59,7 @@ class Puppet::SimpleGraph # a false impression of what the degree is. That's just # as expensive as just getting the edge list, so I've decided # to only add this method. - define_method("%s_edges" % direction) do + define_method("#{direction}_edges") do @adjacencies[direction].values.inject([]) { |total, adjacent| total += adjacent.to_a; total } end end @@ -207,7 +207,7 @@ class Puppet::SimpleGraph # If we have any vertices left with non-zero in-degrees, then we've found a cycle. if cycles = degree.find_all { |vertex, edges| edges.length > 0 } and cycles.length > 0 message = cycles.collect { |vertex, edges| edges.collect { |e| e.to_s }.join(", ") }.join(", ") - raise Puppet::Error, "Found dependency cycles in the following relationships: %s; try using the '--graph' option and open the '.dot' files in OmniGraffle or GraphViz" % message + raise Puppet::Error, "Found dependency cycles in the following relationships: #{message}; try using the '--graph' option and open the '.dot' files in OmniGraffle or GraphViz" end return result @@ -447,7 +447,7 @@ class Puppet::SimpleGraph Puppet.settings.use(:graphing) - file = File.join(Puppet[:graphdir], "%s.dot" % name.to_s) + file = File.join(Puppet[:graphdir], "#{name}.dot") File.open(file, "w") { |f| f.puts to_dot("name" => name.to_s.capitalize) } diff --git a/lib/puppet/ssl/base.rb b/lib/puppet/ssl/base.rb index 7452a513d..745d733dc 100644 --- a/lib/puppet/ssl/base.rb +++ b/lib/puppet/ssl/base.rb @@ -18,7 +18,7 @@ class Puppet::SSL::Base end def self.wrapped_class - raise(Puppet::DevError, "%s has not declared what class it wraps" % self) unless defined?(@wrapped_class) + raise(Puppet::DevError, "#{self} has not declared what class it wraps") unless defined?(@wrapped_class) @wrapped_class end @@ -30,7 +30,7 @@ class Puppet::SSL::Base end def generate - raise Puppet::DevError, "%s did not override 'generate'" % self.class + raise Puppet::DevError, "#{self.class} did not override 'generate'" end def initialize(name) diff --git a/lib/puppet/ssl/certificate_authority.rb b/lib/puppet/ssl/certificate_authority.rb index aa1ccf936..b66725cbf 100644 --- a/lib/puppet/ssl/certificate_authority.rb +++ b/lib/puppet/ssl/certificate_authority.rb @@ -78,7 +78,7 @@ class Puppet::SSL::CertificateAuthority return false if ['false', false].include?(auto) return true if ['true', true].include?(auto) - raise ArgumentError, "The autosign configuration '%s' must be a fully qualified file" % auto unless auto =~ /^\// + raise ArgumentError, "The autosign configuration '#{auto}' must be a fully qualified file" unless auto =~ /^\// if FileTest.exist?(auto) return auto else @@ -117,7 +117,7 @@ class Puppet::SSL::CertificateAuthority # Generate a new certificate. def generate(name) - raise ArgumentError, "A Certificate already exists for %s" % name if Puppet::SSL::Certificate.find(name) + raise ArgumentError, "A Certificate already exists for #{name}" if Puppet::SSL::Certificate.find(name) host = Puppet::SSL::Host.new(name) host.generate_certificate_request @@ -170,7 +170,7 @@ class Puppet::SSL::CertificateAuthority begin Puppet.settings.write(:capass) { |f| f.print pass } rescue Errno::EACCES => detail - raise Puppet::Error, "Could not write CA password: %s" % detail.to_s + raise Puppet::Error, "Could not write CA password: #{detail}" end @password = pass @@ -228,7 +228,7 @@ class Puppet::SSL::CertificateAuthority if cert = Puppet::SSL::Certificate.find(name) serial = cert.content.serial elsif ! serial = inventory.serial(name) - raise ArgumentError, "Could not find a serial number for %s" % name + raise ArgumentError, "Could not find a serial number for #{name}" end crl.revoke(serial, host.key.content) end @@ -249,7 +249,7 @@ class Puppet::SSL::CertificateAuthority issuer = csr.content else unless csr = Puppet::SSL::CertificateRequest.find(hostname) - raise ArgumentError, "Could not find certificate request for %s" % hostname + raise ArgumentError, "Could not find certificate request for #{hostname}" end issuer = host.certificate.content end @@ -258,7 +258,7 @@ class Puppet::SSL::CertificateAuthority cert.content = Puppet::SSL::CertificateFactory.new(cert_type, csr.content, issuer, next_serial).result cert.content.sign(host.key.content, OpenSSL::Digest::SHA1.new) - Puppet.notice "Signed certificate request for %s" % hostname + Puppet.notice "Signed certificate request for #{hostname}" # Add the cert to the inventory before we save it, since # otherwise we could end up with it being duplicated, if @@ -278,7 +278,7 @@ class Puppet::SSL::CertificateAuthority # Verify a given host's certificate. def verify(name) unless cert = Puppet::SSL::Certificate.find(name) - raise ArgumentError, "Could not find a certificate for %s" % name + raise ArgumentError, "Could not find a certificate for #{name}" end store = OpenSSL::X509::Store.new store.add_file Puppet[:cacert] @@ -293,7 +293,7 @@ class Puppet::SSL::CertificateAuthority def fingerprint(name, md = :MD5) unless cert = Puppet::SSL::Certificate.find(name) || Puppet::SSL::CertificateRequest.find(name) - raise ArgumentError, "Could not find a certificate or csr for %s" % name + raise ArgumentError, "Could not find a certificate or csr for #{name}" end cert.fingerprint(md) end diff --git a/lib/puppet/ssl/certificate_authority/interface.rb b/lib/puppet/ssl/certificate_authority/interface.rb index ffae66d2d..64e983cf6 100644 --- a/lib/puppet/ssl/certificate_authority/interface.rb +++ b/lib/puppet/ssl/certificate_authority/interface.rb @@ -14,7 +14,7 @@ module Puppet # Actually perform the work. def apply(ca) unless subjects or method == :list - raise ArgumentError, "You must provide hosts or :all when using %s" % method + raise ArgumentError, "You must provide hosts or :all when using #{method}" end begin @@ -29,7 +29,7 @@ module Puppet raise rescue => detail puts detail.backtrace if Puppet[:trace] - Puppet.err "Could not call %s: %s" % [method, detail] + Puppet.err "Could not call #{method}: #{detail}" end end @@ -84,7 +84,7 @@ module Puppet # Set the method to apply. def method=(method) - raise ArgumentError, "Invalid method %s to apply" % method unless INTERFACE_METHODS.include?(method) + raise ArgumentError, "Invalid method #{method} to apply" unless INTERFACE_METHODS.include?(method) @method = method end @@ -94,7 +94,7 @@ module Puppet if value = ca.print(host) puts value else - Puppet.err "Could not find certificate for %s" % host + Puppet.err "Could not find certificate for #{host}" end end end @@ -105,7 +105,7 @@ module Puppet if value = ca.fingerprint(host, @digest) puts "#{host} #{value}" else - Puppet.err "Could not find certificate for %s" % host + Puppet.err "Could not find certificate for #{host}" end end end @@ -122,7 +122,7 @@ module Puppet # Set the list of hosts we're operating on. Also supports keywords. def subjects=(value) unless value == :all or value == :signed or value.is_a?(Array) - raise ArgumentError, "Subjects must be an array or :all; not %s" % value + raise ArgumentError, "Subjects must be an array or :all; not #{value}" end if value.is_a?(Array) and value.empty? diff --git a/lib/puppet/ssl/certificate_factory.rb b/lib/puppet/ssl/certificate_factory.rb index 73b8a54c3..9273bb902 100644 --- a/lib/puppet/ssl/certificate_factory.rb +++ b/lib/puppet/ssl/certificate_factory.rb @@ -61,7 +61,7 @@ class Puppet::SSL::CertificateFactory begin send(method) rescue NoMethodError - raise ArgumentError, "%s is an invalid certificate type" % @cert_type + raise ArgumentError, "#{@cert_type} is an invalid certificate type" end @extensions << @ef.create_extension("nsComment", "Puppet Ruby/OpenSSL Generated Certificate") diff --git a/lib/puppet/ssl/certificate_request.rb b/lib/puppet/ssl/certificate_request.rb index f18fe4a16..3cd3ce0be 100644 --- a/lib/puppet/ssl/certificate_request.rb +++ b/lib/puppet/ssl/certificate_request.rb @@ -24,7 +24,7 @@ class Puppet::SSL::CertificateRequest < Puppet::SSL::Base # How to create a certificate request with our system defaults. def generate(key) - Puppet.info "Creating a new SSL certificate request for %s" % name + Puppet.info "Creating a new SSL certificate request for #{name}" # Support either an actual SSL key, or a Puppet key. key = key.content if key.is_a?(Puppet::SSL::Key) @@ -40,7 +40,7 @@ class Puppet::SSL::CertificateRequest < Puppet::SSL::Base csr.public_key = key.public_key csr.sign(key, OpenSSL::Digest::MD5.new) - raise Puppet::Error, "CSR sign verification failed; you need to clean the certificate request for %s on the server" % name unless csr.verify(key.public_key) + raise Puppet::Error, "CSR sign verification failed; you need to clean the certificate request for #{name} on the server" unless csr.verify(key.public_key) @content = csr Puppet.info "Certificate Request fingerprint (md5): #{fingerprint}" diff --git a/lib/puppet/ssl/certificate_revocation_list.rb b/lib/puppet/ssl/certificate_revocation_list.rb index c725bde48..b2bff4830 100644 --- a/lib/puppet/ssl/certificate_revocation_list.rb +++ b/lib/puppet/ssl/certificate_revocation_list.rb @@ -53,7 +53,7 @@ class Puppet::SSL::CertificateRevocationList < Puppet::SSL::Base # CA, then write the CRL back to disk. The REASON must be one of the # OpenSSL::OCSP::REVOKED_* reasons def revoke(serial, cakey, reason = OpenSSL::OCSP::REVOKED_STATUS_KEYCOMPROMISE) - Puppet.notice "Revoked certificate with serial %s" % serial + Puppet.notice "Revoked certificate with serial #{serial}" time = Time.now # Add our revocation to the CRL. diff --git a/lib/puppet/ssl/host.rb b/lib/puppet/ssl/host.rb index f367adaca..6d1ae1a16 100644 --- a/lib/puppet/ssl/host.rb +++ b/lib/puppet/ssl/host.rb @@ -85,7 +85,7 @@ class Puppet::SSL::Host # Specify how we expect to interact with our certificate authority. def self.ca_location=(mode) - raise ArgumentError, "CA Mode can only be %s" % CA_MODES.collect { |m| m.to_s }.join(", ") unless CA_MODES.include?(mode) + raise ArgumentError, "CA Mode can only be #{CA_MODES.collect { |m| m.to_s }.join(", ")}" unless CA_MODES.include?(mode) @ca_location = mode @@ -231,7 +231,7 @@ class Puppet::SSL::Host raise rescue Exception => detail puts detail.backtrace if Puppet[:trace] - Puppet.err "Could not request certificate: %s" % detail.to_s + Puppet.err "Could not request certificate: #{detail}" if time < 1 puts "Exiting; failed to retrieve certificate and waitforcert is disabled" exit(1) @@ -253,7 +253,7 @@ class Puppet::SSL::Host Puppet.notice "Did not receive certificate" rescue StandardError => detail puts detail.backtrace if Puppet[:trace] - Puppet.err "Could not request certificate: %s" % detail.to_s + Puppet.err "Could not request certificate: #{detail}" end end end diff --git a/lib/puppet/ssl/key.rb b/lib/puppet/ssl/key.rb index d91df03f6..cb03729c1 100644 --- a/lib/puppet/ssl/key.rb +++ b/lib/puppet/ssl/key.rb @@ -18,7 +18,7 @@ class Puppet::SSL::Key < Puppet::SSL::Base # Knows how to create keys with our system defaults. def generate - Puppet.info "Creating a new SSL key for %s" % name + Puppet.info "Creating a new SSL key for #{name}" @content = OpenSSL::PKey::RSA.new(Puppet[:keylength].to_i) end diff --git a/lib/puppet/sslcertificates.rb b/lib/puppet/sslcertificates.rb index ae539cc74..6a0d19ca2 100755 --- a/lib/puppet/sslcertificates.rb +++ b/lib/puppet/sslcertificates.rb @@ -9,7 +9,7 @@ module Puppet::SSLCertificates def self.mkcert(hash) [:type, :name, :ttl, :issuer, :serial, :publickey].each { |param| unless hash.include?(param) - raise ArgumentError, "mkcert called without %s" % param + raise ArgumentError, "mkcert called without #{param}" end } @@ -79,7 +79,7 @@ module Puppet::SSLCertificates ext_key_usage = %w{clientAuth emailProtection} ex << ef.create_extension("nsCertType", "client,email") else - raise Puppet::Error, "unknown cert type '%s'" % hash[:type] + raise Puppet::Error, "unknown cert type '#{hash[:type]}'" end @@ -116,7 +116,7 @@ module Puppet::SSLCertificates hash = "%08x" % cert.issuer.hash hashpath = nil 10.times { |i| - path = File.join(dir, "%s.%s" % [hash, i]) + path = File.join(dir, "#{hash}.#{i}") if FileTest.exists?(path) if FileTest.symlink?(path) dest = File.readlink(path) diff --git a/lib/puppet/sslcertificates/ca.rb b/lib/puppet/sslcertificates/ca.rb index 5f32dd0a4..c2ed7349f 100644 --- a/lib/puppet/sslcertificates/ca.rb +++ b/lib/puppet/sslcertificates/ca.rb @@ -21,13 +21,13 @@ class Puppet::SSLCertificates::CA if FileTest.exists?(file) begin if Puppet[:name] == "cert" - puts "Removing %s" % file + puts "Removing #{file}" else - Puppet.info "Removing %s" % file + Puppet.info "Removing #{file}" end File.unlink(file) rescue => detail - raise Puppet::Error, "Could not delete %s: %s" % [file, detail] + raise Puppet::Error, "Could not delete #{file}: #{detail}" end end @@ -57,8 +57,8 @@ class Puppet::SSLCertificates::CA if Puppet[:capass] if FileTest.exists?(Puppet[:capass]) - #puts "Reading %s" % Puppet[:capass] - #system "ls -al %s" % Puppet[:capass] + #puts "Reading #{Puppet[:capass]}" + #system "ls -al #{Puppet[:capass]}" #File.read Puppet[:capass] @config[:password] = self.getpass else @@ -96,7 +96,7 @@ class Puppet::SSLCertificates::CA if @config[:capass] and File.readable?(@config[:capass]) return File.read(@config[:capass]) else - raise Puppet::Error, "Could not decrypt CA key with password: %s" % detail + raise Puppet::Error, "Could not decrypt CA key with password: #{detail}" end end @@ -156,7 +156,7 @@ class Puppet::SSLCertificates::CA # Make the root cert's name the FQDN of the host running the CA. name = Facter["hostname"].value if domain = Facter["domain"].value - name += "." + domain + name += ".#{domain}" end cert = Certificate.new( @@ -187,7 +187,7 @@ class Puppet::SSLCertificates::CA def removeclientcsr(host) csrfile = host2csrfile(host) unless File.exists?(csrfile) - raise Puppet::Error, "No certificate request for %s" % host + raise Puppet::Error, "No certificate request for #{host}" end File.unlink(csrfile) @@ -227,12 +227,12 @@ class Puppet::SSLCertificates::CA end if hash.length > 0 - raise ArgumentError, "Unknown parameters %s" % hash.keys.join(",") + raise ArgumentError, "Unknown parameters #{hash.keys.join(",")}" end [:cadir, :csrdir, :signeddir].each { |dir| unless @config[dir] - raise Puppet::DevError, "%s is undefined" % dir + raise Puppet::DevError, "#{dir} is undefined" end } end @@ -241,7 +241,7 @@ class Puppet::SSLCertificates::CA def sign(csr) unless csr.is_a?(OpenSSL::X509::Request) raise Puppet::Error, - "CA#sign only accepts OpenSSL::X509::Request objects, not %s" % csr.class + "CA#sign only accepts OpenSSL::X509::Request objects, not #{csr.class}" end unless csr.verify(csr.public_key) @@ -283,7 +283,7 @@ class Puppet::SSLCertificates::CA csrfile = host2csrfile(host) if File.exists?(csrfile) - raise Puppet::Error, "Certificate request for %s already exists" % host + raise Puppet::Error, "Certificate request for #{host} already exists" end Puppet.settings.writesub(:csrdir, csrfile) do |f| @@ -297,7 +297,7 @@ class Puppet::SSLCertificates::CA certfile = host2certfile(host) if File.exists?(certfile) - Puppet.notice "Overwriting signed certificate %s for %s" % [certfile, host] + Puppet.notice "Overwriting signed certificate #{certfile} for #{host}" end Puppet::SSLCertificates::Inventory::add(cert) diff --git a/lib/puppet/sslcertificates/certificate.rb b/lib/puppet/sslcertificates/certificate.rb index d1acc1269..8df7605d7 100644 --- a/lib/puppet/sslcertificates/certificate.rb +++ b/lib/puppet/sslcertificates/certificate.rb @@ -106,7 +106,7 @@ class Puppet::SSLCertificates::Certificate case hash[:type] when :ca, :client, :server; @type = hash[:type] else - raise "Invalid Cert type %s" % hash[:type] + raise "Invalid Cert type #{hash[:type]}" end else @type = :client diff --git a/lib/puppet/sslcertificates/support.rb b/lib/puppet/sslcertificates/support.rb index 6fa220f24..fc40d3538 100644 --- a/lib/puppet/sslcertificates/support.rb +++ b/lib/puppet/sslcertificates/support.rb @@ -10,10 +10,10 @@ module Puppet::SSLCertificates::Support # Some metaprogramming to create methods for retrieving and creating keys. # This probably isn't fewer lines than defining each separately... def self.keytype(name, options, &block) - var = "@%s" % name + var = "@#{name}" - maker = "mk_%s" % name - reader = "read_%s" % name + maker = "mk_#{name}" + reader = "read_#{name}" unless param = options[:param] raise ArgumentError, "You must specify the parameter for the key" @@ -33,7 +33,7 @@ module Puppet::SSLCertificates::Support begin instance_variable_set(var, klass.new(File.read(Puppet[param]))) rescue => detail - raise InvalidCertificate, "Could not read %s: %s" % [param, detail] + raise InvalidCertificate, "Could not read #{param}: #{detail}" end end @@ -53,7 +53,7 @@ module Puppet::SSLCertificates::Support # The key pair. keytype :key, :param => :hostprivkey, :class => OpenSSL::PKey::RSA do - Puppet.info "Creating a new SSL key at %s" % Puppet[:hostprivkey] + Puppet.info "Creating a new SSL key at #{Puppet[:hostprivkey]}" key = OpenSSL::PKey::RSA.new(Puppet[:keylength]) # Our key meta programming can only handle one file, so we have @@ -66,7 +66,7 @@ module Puppet::SSLCertificates::Support # Our certificate request keytype :csr, :param => :hostcsr, :class => OpenSSL::X509::Request do - Puppet.info "Creating a new certificate request for %s" % Puppet[:certname] + Puppet.info "Creating a new certificate request for #{Puppet[:certname]}" csr = OpenSSL::X509::Request.new csr.version = 0 @@ -95,7 +95,7 @@ module Puppet::SSLCertificates::Support if Puppet[:trace] puts detail.backtrace end - raise Puppet::Error.new("Certificate retrieval failed: %s" % detail) + raise Puppet::Error.new("Certificate retrieval failed: #{detail}") end if cert.nil? or cert == "" @@ -111,7 +111,7 @@ module Puppet::SSLCertificates::Support retrieved = true rescue => detail raise Puppet::Error.new( - "Invalid certificate: %s" % detail + "Invalid certificate: #{detail}" ) end @@ -142,7 +142,7 @@ module Puppet::SSLCertificates::Support full_file = File.join(dir, real_file) - Puppet.notice "Fixing case in %s; renaming to %s" % [full_file, file] + Puppet.notice "Fixing case in #{full_file}; renaming to #{file}" File.rename(full_file, file) return true diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb index b7cb39b92..75b3140bb 100644 --- a/lib/puppet/transaction.rb +++ b/lib/puppet/transaction.rb @@ -74,7 +74,7 @@ class Puppet::Transaction unless relationship_graph.edge?(edge[1], edge[0]) relationship_graph.add_edge(*edge) else - resource.debug "Skipping automatic relationship to %s" % gen_child + resource.debug "Skipping automatic relationship to #{gen_child}" end end end @@ -129,7 +129,7 @@ class Puppet::Transaction prepare() - Puppet.info "Applying configuration version '%s'" % catalog.version if catalog.version + Puppet.info "Applying configuration version '#{catalog.version}'" if catalog.version begin @sorted_resources.each do |resource| @@ -188,7 +188,7 @@ class Puppet::Transaction made = resource.send(method) rescue => detail puts detail.backtrace if Puppet[:trace] - resource.err "Failed to generate additional resources using '%s': %s" % [method, detail] + resource.err "Failed to generate additional resources using '#{method}': #{detail}" end return [] unless made made = [made] unless made.is_a?(Array) @@ -260,14 +260,14 @@ class Puppet::Transaction # Now call prefetch, passing in the resources so that the provider instances can be replaced. prefetchers.each do |provider, resources| - Puppet.debug "Prefetching %s resources for %s" % [provider.name, provider.resource_type.name] + Puppet.debug "Prefetching #{provider.name} resources for #{provider.resource_type.name}" begin provider.prefetch(resources) rescue => detail if Puppet[:trace] puts detail.backtrace end - Puppet.err "Could not prefetch %s provider '%s': %s" % [provider.resource_type.name, provider.name, detail] + Puppet.err "Could not prefetch #{provider.resource_type.name} provider '#{provider.name}': #{detail}" end end end @@ -294,7 +294,7 @@ class Puppet::Transaction begin report = generate_report() rescue => detail - Puppet.err "Could not generate report: %s" % detail + Puppet.err "Could not generate report: #{detail}" return end @@ -306,7 +306,7 @@ class Puppet::Transaction begin report.save() rescue => detail - Puppet.err "Reporting failed: %s" % detail + Puppet.err "Reporting failed: #{detail}" end end end @@ -327,7 +327,7 @@ class Puppet::Transaction # Should this resource be skipped? def skip?(resource) if missing_tags?(resource) - resource.debug "Not tagged with %s" % tags.join(", ") + resource.debug "Not tagged with #{tags.join(", ")}" elsif ! scheduled?(resource) resource.debug "Not scheduled" elsif failed_dependencies?(resource) diff --git a/lib/puppet/transaction/change.rb b/lib/puppet/transaction/change.rb index 605457a21..18f11c016 100644 --- a/lib/puppet/transaction/change.rb +++ b/lib/puppet/transaction/change.rb @@ -63,7 +63,7 @@ class Puppet::Transaction::Change end def to_s - return "change %s" % @property.change_to_s(@is, @should) + return "change #{@property.change_to_s(@is, @should)}" end private diff --git a/lib/puppet/transaction/report.rb b/lib/puppet/transaction/report.rb index 8e3812096..24e69ea7a 100644 --- a/lib/puppet/transaction/report.rb +++ b/lib/puppet/transaction/report.rb @@ -67,7 +67,7 @@ class Puppet::Transaction::Report ret = "" @metrics.sort { |a,b| a[1].label <=> b[1].label }.each do |name, metric| - ret += "%s:\n" % metric.label + ret += "#{metric.label}:\n" metric.values.sort { |a,b| # sort by label if a[0] == :total diff --git a/lib/puppet/transportable.rb b/lib/puppet/transportable.rb index 52747da66..01045243d 100644 --- a/lib/puppet/transportable.rb +++ b/lib/puppet/transportable.rb @@ -49,7 +49,7 @@ module Puppet trans = TransObject.new(ref, :component) @params.each { |param,value| next unless Puppet::Type::Component.valid_parameter?(param) - Puppet.debug "Defining %s on %s" % [param, ref] + Puppet.debug "Defining #{param} on #{ref}" trans[param] = value } trans.catalog = self.catalog @@ -61,7 +61,7 @@ module Puppet end def to_s - return "%s(%s) => %s" % [@type,@name,super] + return "#{@type}(#{@name}) => #{super}" end def to_manifest @@ -106,7 +106,7 @@ module Puppet %w{delete shift include? length empty? << []}.each { |method| define_method(method) do |*args| - #Puppet.warning "Calling %s with %s" % [method, args.inspect] + #Puppet.warning "Calling #{method} with #{args.inspect}" @children.send(method, *args) #Puppet.warning @params.inspect end @@ -150,7 +150,7 @@ module Puppet # nada else raise Puppet::DevError, - "TransBuckets cannot handle objects of type %s" % arg.class + "TransBuckets cannot handle objects of type #{arg.class}" end } @children += args diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index 3ac68c173..28afab3ef 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -234,7 +234,7 @@ class Type end def self.newstate(name, options = {}, &block) - Puppet.warning "newstate() has been deprecrated; use newproperty(%s)" % name + Puppet.warning "newstate() has been deprecrated; use newproperty(#{name})" newproperty(name, options, &block) end @@ -251,11 +251,11 @@ class Type # a parent class. unless options.is_a? Hash raise Puppet::DevError, - "Options must be a hash, not %s" % options.inspect + "Options must be a hash, not #{options.inspect}" end if @validproperties.include?(name) - raise Puppet::DevError, "Class %s already has a property named %s" % [self.name, name] + raise Puppet::DevError, "Class #{self.name} already has a property named #{name}" end if parent = options[:parent] @@ -347,7 +347,7 @@ class Type # does the name reflect a valid parameter? def self.validparameter?(name) unless defined?(@parameters) - raise Puppet::DevError, "Class %s has not defined parameters" % self + raise Puppet::DevError, "Class #{self} has not defined parameters" end if @paramhash.include?(name) or @@metaparamhash.include?(name) return true @@ -403,7 +403,7 @@ class Type name = attr_alias(name) unless self.class.validattr?(name) - fail("Invalid parameter %s(%s)" % [name, name.inspect]) + fail("Invalid parameter #{name}(#{name.inspect})") end if name == :name @@ -426,14 +426,14 @@ class Type name = attr_alias(name) unless self.class.validattr?(name) - fail("Invalid parameter %s" % [name]) + fail("Invalid parameter #{name}") end if name == :name name = name_var end if value.nil? - raise Puppet::Error.new("Got nil value for %s" % name) + raise Puppet::Error.new("Got nil value for #{name}") end property = self.newattr(name) @@ -442,7 +442,7 @@ class Type # make sure the parameter doesn't have any errors property.value = value rescue => detail - error = Puppet::Error.new("Parameter %s failed: %s" % [name, detail]) + error = Puppet::Error.new("Parameter #{name} failed: #{detail}") error.set_backtrace(detail.backtrace) raise error end @@ -501,7 +501,7 @@ class Type end unless klass = self.class.attrclass(name) - raise Puppet::Error, "Resource type %s does not support parameter %s" % [self.class.name, name] + raise Puppet::Error, "Resource type #{self.class.name} does not support parameter #{name}" end if @parameters.include?(name) @@ -687,7 +687,7 @@ class Type if property = @parameters[:ensure] unless is.include? property raise Puppet::DevError, - "The is value is not in the is array for '%s'" % [property.name] + "The is value is not in the is array for '#{property.name}'" end ensureis = is[property] if property.insync?(ensureis) and property.should == :absent @@ -698,19 +698,19 @@ class Type properties.each { |property| unless is.include? property raise Puppet::DevError, - "The is value is not in the is array for '%s'" % [property.name] + "The is value is not in the is array for '#{property.name}'" end propis = is[property] unless property.insync?(propis) - property.debug("Not in sync: %s vs %s" % [propis.inspect, property.should.inspect]) + property.debug("Not in sync: #{propis.inspect} vs #{property.should.inspect}") insync = false #else # property.debug("In sync") end } - #self.debug("%s sync status is %s" % [self,insync]) + #self.debug("#{self} sync status is #{insync}") return insync end @@ -809,13 +809,13 @@ class Type end if exobj = @objects[name] and self.isomorphic? - msg = "Object '%s[%s]' already exists" % [newobj.class.name, name] + msg = "Object '#{newobj.class.name}[#{name}]' already exists" if exobj.file and exobj.line - msg += ("in file %s at line %s" % [object.file, object.line]) + msg += ("in file #{object.file} at line #{object.line}") end if object.file and object.line - msg += ("and cannot be redefined in file %s at line %s" % [object.file, object.line]) + msg += ("and cannot be redefined in file #{object.file} at line #{object.line}") end error = Puppet::Error.new(msg) raise error @@ -833,7 +833,7 @@ class Type if @objects.include?(name) unless @objects[name] == obj raise Puppet::Error.new( - "Cannot create alias %s: object already exists" % [name] + "Cannot create alias #{name}: object already exists" ) end end @@ -841,7 +841,7 @@ class Type if @aliases.include?(name) unless @aliases[name] == obj raise Puppet::Error.new( - "Object %s already has alias %s" % [@aliases[name].name, name] + "Object #{@aliases[name].name} already has alias #{name}" ) end end @@ -910,7 +910,7 @@ class Type # Retrieve all known instances. Either requires providers or must be overridden. def self.instances if provider_hash.empty? - raise Puppet::DevError, "%s has no providers and has not overridden 'instances'" % self.name + raise Puppet::DevError, "#{self.name} has no providers and has not overridden 'instances'" end # Put the default provider first, then the rest of the suitable providers. @@ -1129,7 +1129,7 @@ class Type aliases.each do |other| if obj = @resource.catalog.resource(@resource.class.name, other) unless obj.object_id == @resource.object_id - self.fail("%s can not create alias %s: object already exists" % [@resource.title, other]) + self.fail("#{@resource.title} can not create alias #{other}: object already exists") end next end @@ -1189,7 +1189,7 @@ class Type @value.each do |ref| unless @resource.catalog.resource(ref.to_s) description = self.class.direction == :in ? "dependency" : "dependent" - fail "Could not find %s %s for %s" % [description, ref.to_s, resource.ref] + fail "Could not find #{description} #{ref} for #{resource.ref}" end end end @@ -1209,7 +1209,7 @@ class Type # Either of the two retrieval attempts could have returned # nil. unless related_resource = reference.resolve - self.fail "Could not retrieve dependency '%s' of %s" % [reference, @resource.ref] + self.fail "Could not retrieve dependency '#{reference}' of #{@resource.ref}" end # Are we requiring them, or vice versa? See the method docs @@ -1227,12 +1227,12 @@ class Type :event => self.class.events, :callback => method } - self.debug("subscribes to %s" % [related_resource.ref]) + self.debug("subscribes to #{related_resource.ref}") else # If there's no callback, there's no point in even adding # a label. subargs = nil - self.debug("requires %s" % [related_resource.ref]) + self.debug("requires #{related_resource.ref}") end rel = Puppet::Relationship.new(source, target, subargs) @@ -1410,13 +1410,13 @@ class Type retval = nil if defaults.length > 1 Puppet.warning( - "Found multiple default providers for %s: %s; using %s" % [self.name, defaults.collect { |i| i.name.to_s }.join(", "), defaults[0].name] + "Found multiple default providers for #{self.name}: #{defaults.collect { |i| i.name.to_s }.join(", ")}; using #{defaults[0].name}" ) retval = defaults.shift elsif defaults.length == 1 retval = defaults.shift else - raise Puppet::DevError, "Could not find a default provider for %s" % self.name + raise Puppet::DevError, "Could not find a default provider for #{self.name}" end @defaultprovider = retval @@ -1462,7 +1462,7 @@ class Type name = Puppet::Util.symbolize(name) if obj = provider_hash[name] - Puppet.debug "Reloading %s %s provider" % [name, self.name] + Puppet.debug "Reloading #{name} #{self.name} provider" unprovide(name) end @@ -1475,7 +1475,7 @@ class Type provider else raise Puppet::DevError, - "Could not find parent provider %s of %s" % [pname, name] + "Could not find parent provider #{pname} of #{name}" end end else @@ -1523,7 +1523,7 @@ class Type @doc + " Available providers are:\n\n" + parenttype().providers.sort { |a,b| a.to_s <=> b.to_s }.collect { |i| - "* **%s**: %s" % [i, parenttype().provider(i).doc] + "* **#{i}**: #{parenttype().provider(i).doc}" }.join("\n") end @@ -1538,7 +1538,7 @@ class Type end unless provider = @resource.class.provider(provider_class) - raise ArgumentError, "Invalid %s provider '%s'" % [@resource.class.name, provider_class] + raise ArgumentError, "Invalid #{@resource.class.name} provider '#{provider_class}'" end end @@ -1592,7 +1592,7 @@ class Type elsif klass = self.class.provider(name) @provider = klass.new(self) else - raise ArgumentError, "Could not find %s provider of %s" % [name, self.class.name] + raise ArgumentError, "Could not find #{name} provider of #{self.class.name}" end end @@ -1720,7 +1720,7 @@ class Type if hash.include?(key) hash[key] else - "Param Documentation for %s not found" % key + "Param Documentation for #{key} not found" end } @@ -1732,7 +1732,7 @@ class Type def self.to_s if defined?(@name) - "Puppet::Type::" + @name.to_s.capitalize + "Puppet::Type::#{@name.to_s.capitalize}" else super end @@ -1836,7 +1836,7 @@ class Type rescue ArgumentError, Puppet::Error, TypeError raise rescue => detail - error = Puppet::DevError.new( "Could not set %s on %s: %s" % [attr, self.class.name, detail]) + error = Puppet::DevError.new( "Could not set #{attr} on #{self.class.name}: #{detail}") error.set_backtrace(detail.backtrace) raise error end @@ -1883,7 +1883,7 @@ class Type # Return the "type[name]" style reference. def ref - "%s[%s]" % [self.class.name.to_s.capitalize, self.title] + "#{self.class.name.to_s.capitalize}[#{self.title}]" end def self_refresh? @@ -1914,7 +1914,7 @@ class Type elsif self.class.validproperty?(name_var) @title = self.should(name_var) else - self.devfail "Could not find namevar %s for %s" % [name_var, self.class.name] + self.devfail "Could not find namevar #{name_var} for #{self.class.name}" end end diff --git a/lib/puppet/type/component.rb b/lib/puppet/type/component.rb index b62954ba0..9fc05c115 100644 --- a/lib/puppet/type/component.rb +++ b/lib/puppet/type/component.rb @@ -72,7 +72,7 @@ Puppet::Type.newtype(:component) do catalog.adjacent(self).each do |child| if child.respond_to?(:refresh) child.refresh - child.log "triggering %s" % :refresh + child.log "triggering #{:refresh}" end end end diff --git a/lib/puppet/type/cron.rb b/lib/puppet/type/cron.rb index 4151610f1..dee0dc3f1 100755 --- a/lib/puppet/type/cron.rb +++ b/lib/puppet/type/cron.rb @@ -197,7 +197,7 @@ Puppet::Type.newtype(:cron) do if retval return retval.to_s else - self.fail "%s is not a valid %s" % [value, self.class.name] + self.fail "#{value} is not a valid #{self.class.name}" end end end @@ -250,7 +250,7 @@ Puppet::Type.newtype(:cron) do validate do |value| unless specials().include?(value) - raise ArgumentError, "Invalid special schedule %s" % value.inspect + raise ArgumentError, "Invalid special schedule #{value.inspect}" end end end @@ -311,7 +311,7 @@ Puppet::Type.newtype(:cron) do validate do |value| unless value =~ /^\s*(\w+)\s*=\s*(.*)\s*$/ or value == :absent or value == "absent" - raise ArgumentError, "Invalid environment setting %s" % value.inspect + raise ArgumentError, "Invalid environment setting #{value.inspect}" end end diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb index cd9c02034..ce662f152 100755 --- a/lib/puppet/type/exec.rb +++ b/lib/puppet/type/exec.rb @@ -147,7 +147,7 @@ module Puppet end unless self.should.include?(@status.exitstatus.to_s) - self.fail("%s returned %s instead of one of [%s]" % [self.resource[:command], @status.exitstatus, self.should.join(",")]) + self.fail("#{self.resource[:command]} returned #{@status.exitstatus} instead of one of [#{self.should.join(",")}]") end return event @@ -264,7 +264,7 @@ module Puppet values = [values] unless values.is_a? Array values.each do |value| unless value =~ /\w+=/ - raise ArgumentError, "Invalid environment setting '%s'" % value + raise ArgumentError, "Invalid environment setting '#{value}'" end end end @@ -432,7 +432,7 @@ module Puppet begin output, status = @resource.run(value, true) rescue Timeout::Error - err "Check %s exceeded timeout" % value.inspect + err "Check #{value.inspect} exceeded timeout" return false end @@ -474,7 +474,7 @@ module Puppet begin output, status = @resource.run(value, true) rescue Timeout::Error - err "Check %s exceeded timeout" % value.inspect + err "Check #{value.inspect} exceeded timeout" return false end @@ -568,7 +568,7 @@ module Puppet path = %x{which #{exe}}.chomp if path == "" raise ArgumentError, - "Could not find command '%s'" % exe + "Could not find command '#{exe}'" else exe = path end @@ -584,11 +584,11 @@ module Puppet end unless FileTest.exists?(exe) - raise ArgumentError, "Could not find executable '%s'" % exe + raise ArgumentError, "Could not find executable '#{exe}'" end unless FileTest.executable?(exe) raise ArgumentError, - "'%s' is not executable" % exe + "'#{exe}' is not executable" end end @@ -625,7 +625,7 @@ module Puppet if check dir = nil else - self.fail "Working directory '%s' does not exist" % dir + self.fail "Working directory '#{dir}' does not exist" end end end @@ -654,12 +654,12 @@ module Puppet value = $2 if environment.include? name warning( - "Overriding environment setting '%s' with '%s'" % [name, value] + "Overriding environment setting '#{name}' with '#{value}'" ) end environment[name] = value else - warning "Cannot understand environment setting %s" % setting.inspect + warning "Cannot understand environment setting #{setting.inspect}" end end end @@ -687,7 +687,7 @@ module Puppet exe = extractexe(cmd) # if we're not fully qualified, require a path if File.expand_path(exe) != exe and self[:path].nil? - self.fail "'%s' is both unqualifed and specified no search path" % cmd + self.fail "'#{cmd}' is both unqualifed and specified no search path" end end diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb index 08bc78327..6a9ec08e7 100644 --- a/lib/puppet/type/file.rb +++ b/lib/puppet/type/file.rb @@ -113,7 +113,7 @@ Puppet::Type.newtype(:file) do when String value else - self.fail "Invalid backup type %s" % value.inspect + self.fail "Invalid backup type #{value.inspect}" end end end @@ -281,7 +281,7 @@ Puppet::Type.newtype(:file) do count += 1 end if count > 1 - self.fail "You cannot specify more than one of %s" % CREATORS.collect { |p| p.to_s}.join(", ") + self.fail "You cannot specify more than one of #{CREATORS.collect { |p| p.to_s}.join(", ")}" end if !self[:source] and self[:recurse] == :remote @@ -353,7 +353,7 @@ Puppet::Type.newtype(:file) do end unless catalog and filebucket = catalog.resource(:filebucket, backup) or backup == "puppet" - fail "Could not find filebucket %s specified in backup" % backup + fail "Could not find filebucket #{backup} specified in backup" end return default_bucket unless filebucket @@ -573,7 +573,7 @@ Puppet::Type.newtype(:file) do total = self[:source].collect do |source| next unless result = perform_recursion(source) return if top = result.find { |r| r.relative_path == "." } and top.ftype != "directory" - result.each { |data| data.source = "%s/%s" % [source, data.relative_path] } + result.each { |data| data.source = "#{source}/#{data.relative_path}" } break result if result and ! result.empty? and sourceselect == :first result end.flatten @@ -631,16 +631,16 @@ Puppet::Type.newtype(:file) do case s.ftype when "directory" if self[:force] == :true - debug "Removing existing directory for replacement with %s" % should + debug "Removing existing directory for replacement with #{should}" FileUtils.rmtree(self[:path]) else notice "Not removing directory; use 'force' to override" end when "link", "file" - debug "Removing existing %s for replacement with %s" % [s.ftype, should] + debug "Removing existing #{s.ftype} for replacement with #{should}" File.unlink(self[:path]) else - self.fail "Could not back up files of type %s" % s.ftype + self.fail "Could not back up files of type #{s.ftype}" end expire end @@ -750,7 +750,7 @@ Puppet::Type.newtype(:file) do fail_if_checksum_is_wrong(path, content_checksum) if validate_checksum? File.rename(path, self[:path]) rescue => detail - fail "Could not rename temporary file %s to %s: %s" % [path, self[:path], detail] + fail "Could not rename temporary file #{path} to #{self[:path]}: #{detail}" ensure # Make sure the created file gets removed File.unlink(path) if FileTest.exists?(path) @@ -774,7 +774,7 @@ Puppet::Type.newtype(:file) do newsum = parameter(:checksum).sum_file(path) return if [:absent, nil, content_checksum].include?(newsum) - self.fail "File written to disk did not match checksum; discarding changes (%s vs %s)" % [content_checksum, newsum] + self.fail "File written to disk did not match checksum; discarding changes (#{content_checksum} vs #{newsum})" end # write the current content. Note that if there is no content property diff --git a/lib/puppet/type/file/content.rb b/lib/puppet/type/file/content.rb index 8d832a6d1..7f9729292 100755 --- a/lib/puppet/type/file/content.rb +++ b/lib/puppet/type/file/content.rb @@ -56,11 +56,11 @@ module Puppet newvalue = tmp end if currentvalue == :absent - return "defined content as '%s'" % [newvalue] + return "defined content as '#{newvalue}'" elsif newvalue == :absent - return "undefined content from '%s'" % [currentvalue] + return "undefined content from '#{currentvalue}'" else - return "content changed '%s' to '%s'" % [currentvalue, newvalue] + return "content changed '#{currentvalue}' to '#{newvalue}'" end end @@ -192,7 +192,7 @@ module Puppet when /^2/; uncompress(response) { |uncompressor| response.read_body { |chunk| yield uncompressor.uncompress(chunk) } } else # Raise the http error if we didn't get a 'success' of some kind. - message = "Error %s on SERVER: %s" % [response.code, (response.body||'').empty? ? response.message : uncompress_body(response)] + message = "Error #{response.code} on SERVER: #{(response.body||'').empty? ? response.message : uncompress_body(response)}" raise Net::HTTPError.new(message, response) end end diff --git a/lib/puppet/type/file/ensure.rb b/lib/puppet/type/file/ensure.rb index 1a7fe5e4f..ab2419c5f 100755 --- a/lib/puppet/type/file/ensure.rb +++ b/lib/puppet/type/file/ensure.rb @@ -62,7 +62,7 @@ module Puppet parent = File.dirname(@resource[:path]) unless FileTest.exists? parent raise Puppet::Error, - "Cannot create %s; parent directory %s does not exist" % [@resource[:path], parent] + "Cannot create #{@resource[:path]}; parent directory #{parent} does not exist" end if mode Puppet::Util.withumask(000) do @@ -122,10 +122,10 @@ module Puppet if ! FileTest.exists?(basedir) raise Puppet::Error, - "Can not create %s; parent directory does not exist" % @resource.title + "Can not create #{@resource.title}; parent directory does not exist" elsif ! FileTest.directory?(basedir) raise Puppet::Error, - "Can not create %s; %s is not a directory" % [@resource.title, dirname] + "Can not create #{@resource.title}; #{dirname} is not a directory" end end diff --git a/lib/puppet/type/file/group.rb b/lib/puppet/type/file/group.rb index e3d7b4ec6..ddfe8381e 100755 --- a/lib/puppet/type/file/group.rb +++ b/lib/puppet/type/file/group.rb @@ -11,7 +11,7 @@ module Puppet @event = :file_changed validate do |group| - raise(Puppet::Error, "Invalid group name '%s'" % group.inspect) unless group and group != "" + raise(Puppet::Error, "Invalid group name '#{group.inspect}'") unless group and group != "" end def id2name(id) @@ -51,7 +51,7 @@ module Puppet if value =~ /^\d+$/ gid = Integer(value) elsif value.is_a?(String) - fail "Could not find group %s" % value unless gid = gid(value) + fail "Could not find group #{value}" unless gid = gid(value) else gid = value end @@ -70,7 +70,7 @@ module Puppet # large GIDs instead of negative ones. This isn't a Ruby bug, # it's an OS X bug, since it shows up in perl, too. if currentvalue > Puppet[:maximum_uid].to_i - self.warning "Apparently using negative GID (%s) on a platform that does not consistently handle them" % currentvalue + self.warning "Apparently using negative GID (#{currentvalue}) on a platform that does not consistently handle them" currentvalue = :silly end @@ -108,13 +108,13 @@ module Puppet break if gid = validgroup?(group) end - raise Puppet::Error, "Could not find group(s) %s" % @should.join(",") unless gid + raise Puppet::Error, "Could not find group(s) #{@should.join(",")}" unless gid begin # set owner to nil so it's ignored File.send(method, nil, gid, resource[:path]) rescue => detail - error = Puppet::Error.new( "failed to chgrp %s to %s: %s" % [resource[:path], gid, detail.message]) + error = Puppet::Error.new( "failed to chgrp #{resource[:path]} to #{gid}: #{detail.message}") raise error end return :file_changed diff --git a/lib/puppet/type/file/mode.rb b/lib/puppet/type/file/mode.rb index 71cd1b4ae..da54b9fdd 100755 --- a/lib/puppet/type/file/mode.rb +++ b/lib/puppet/type/file/mode.rb @@ -34,7 +34,7 @@ module Puppet when Symbol return currentvalue else - raise Puppet::DevError, "Invalid current value for mode: %s" % currentvalue.inspect + raise Puppet::DevError, "Invalid current value for mode: #{currentvalue.inspect}" end end @@ -45,7 +45,7 @@ module Puppet when Symbol return newvalue else - raise Puppet::DevError, "Invalid 'should' value for mode: %s" % newvalue.inspect + raise Puppet::DevError, "Invalid 'should' value for mode: #{newvalue.inspect}" end end @@ -55,17 +55,17 @@ module Puppet value = should if value.is_a?(String) unless value =~ /^\d+$/ - raise Puppet::Error, "File modes can only be numbers, not %s" % value.inspect + raise Puppet::Error, "File modes can only be numbers, not #{value.inspect}" end # Make sure our number looks like octal. unless value =~ /^0/ - value = "0" + value + value = "0#{value}" end old = value begin value = Integer(value) rescue ArgumentError => detail - raise Puppet::DevError, "Could not convert %s to integer" % old.inspect + raise Puppet::DevError, "Could not convert #{old.inspect} to integer" end end @@ -121,7 +121,7 @@ module Puppet begin File.chmod(mode, @resource[:path]) rescue => detail - error = Puppet::Error.new("failed to chmod %s: %s" % [@resource[:path], detail.message]) + error = Puppet::Error.new("failed to chmod #{@resource[:path]}: #{detail.message}") error.set_backtrace detail.backtrace raise error end diff --git a/lib/puppet/type/file/owner.rb b/lib/puppet/type/file/owner.rb index a610a85e3..05754efcc 100755 --- a/lib/puppet/type/file/owner.rb +++ b/lib/puppet/type/file/owner.rb @@ -23,7 +23,7 @@ module Puppet when String newvalue else - raise Puppet::DevError, "Invalid uid type %s(%s)" % [newvalue.class, newvalue] + raise Puppet::DevError, "Invalid uid type #{newvalue.class}(#{newvalue})" end end @@ -34,7 +34,7 @@ module Puppet if tmp = provider.validuser?(val) val = tmp else - raise "Could not find user %s" % val + raise "Could not find user #{val}" end else val diff --git a/lib/puppet/type/file/source.rb b/lib/puppet/type/file/source.rb index fd32f13d6..74cd4c028 100755 --- a/lib/puppet/type/file/source.rb +++ b/lib/puppet/type/file/source.rb @@ -69,11 +69,11 @@ module Puppet begin uri = URI.parse(URI.escape(source)) rescue => detail - self.fail "Could not understand source %s: %s" % [source, detail.to_s] + self.fail "Could not understand source #{source}: #{detail}" end unless uri.scheme.nil? or %w{file puppet}.include?(uri.scheme) - self.fail "Cannot use URLs of type '%s' as source for fileserving" % [uri.scheme] + self.fail "Cannot use URLs of type '#{uri.scheme}' as source for fileserving" end end end @@ -84,11 +84,11 @@ module Puppet end def change_to_s(currentvalue, newvalue) - # newvalue = "{md5}" + @metadata.checksum + # newvalue = "{md5}#{@metadata.checksum}" if @resource.property(:ensure).retrieve == :absent - return "creating from source %s with contents %s" % [metadata.source, metadata.checksum] + return "creating from source #{metadata.source} with contents #{metadata.checksum}" else - return "replacing from source %s with contents %s" % [metadata.source, metadata.checksum] + return "replacing from source #{metadata.source} with contents #{metadata.checksum}" end end @@ -148,10 +148,10 @@ module Puppet break end rescue => detail - fail detail, "Could not retrieve file metadata for %s: %s" % [source, detail] + fail detail, "Could not retrieve file metadata for #{source}: #{detail}" end end - fail "Could not retrieve information from source(s) %s" % value.join(", ") unless result + fail "Could not retrieve information from source(s) #{value.join(", ")}" unless result result end diff --git a/lib/puppet/type/filebucket.rb b/lib/puppet/type/filebucket.rb index 73cd56cd7..dd6d1d63e 100755 --- a/lib/puppet/type/filebucket.rb +++ b/lib/puppet/type/filebucket.rb @@ -85,7 +85,7 @@ module Puppet @bucket = Puppet::FileBucket::Dipper.new(args) rescue => detail puts detail.backtrace if Puppet[:trace] - self.fail("Could not create %s filebucket: %s" % [type, detail]) + self.fail("Could not create #{type} filebucket: #{detail}") end @bucket.name = self.name diff --git a/lib/puppet/type/group.rb b/lib/puppet/type/group.rb index 54563bf2c..aa5031f0c 100755 --- a/lib/puppet/type/group.rb +++ b/lib/puppet/type/group.rb @@ -51,11 +51,11 @@ module Puppet if gid =~ /^[-0-9]+$/ gid = Integer(gid) else - self.fail "Invalid GID %s" % gid + self.fail "Invalid GID #{gid}" end when Symbol unless gid == :absent - self.devfail "Invalid GID %s" % gid + self.devfail "Invalid GID #{gid}" end end diff --git a/lib/puppet/type/host.rb b/lib/puppet/type/host.rb index 5bfcd239c..0b830158c 100755 --- a/lib/puppet/type/host.rb +++ b/lib/puppet/type/host.rb @@ -38,7 +38,7 @@ module Puppet when Array # nothing else - raise Puppet::DevError, "Invalid @is type %s" % is.class + raise Puppet::DevError, "Invalid @is type #{is.class}" end return is end diff --git a/lib/puppet/type/k5login.rb b/lib/puppet/type/k5login.rb index 5526fda21..e192ce479 100644 --- a/lib/puppet/type/k5login.rb +++ b/lib/puppet/type/k5login.rb @@ -76,7 +76,7 @@ Puppet::Type.newtype(:k5login) do # Set the file mode, converting from a string to an integer. def mode=(value) - File.chmod(Integer("0" + value), @resource[:name]) + File.chmod(Integer("0#{value}"), @resource[:name]) end private diff --git a/lib/puppet/type/package.rb b/lib/puppet/type/package.rb index 4fee3b496..6c5b0702b 100644 --- a/lib/puppet/type/package.rb +++ b/lib/puppet/type/package.rb @@ -80,7 +80,7 @@ module Puppet begin provider.update rescue => detail - self.fail "Could not update: %s" % detail + self.fail "Could not update: #{detail}" end if current == :absent @@ -94,7 +94,7 @@ module Puppet begin provider.install rescue => detail - self.fail "Could not update: %s" % detail + self.fail "Could not update: #{detail}" end if self.retrieve == :absent @@ -133,7 +133,7 @@ module Puppet @latest = provider.latest @lateststamp = Time.now.to_i rescue => detail - error = Puppet::Error.new("Could not get latest version: %s" % detail.to_s) + error = Puppet::Error.new("Could not get latest version: #{detail}") error.set_backtrace(detail.backtrace) raise error end @@ -147,7 +147,7 @@ module Puppet # that can't query versions. return true else - self.debug "%s %s is installed, latest is %s" % [@resource.name, is.inspect, @latest.inspect] + self.debug "#{@resource.name} #{is.inspect} is installed, latest is #{@latest.inspect}" end when :absent return true if is == :absent or is == :purged diff --git a/lib/puppet/type/port.rb b/lib/puppet/type/port.rb index 6b9ace239..e19988515 100755 --- a/lib/puppet/type/port.rb +++ b/lib/puppet/type/port.rb @@ -44,7 +44,7 @@ # valids = ["udp", "tcp", "ddp", :absent] # unless valids.include? value # raise Puppet::Error, -# "Protocols can be either 'udp' or 'tcp', not %s" % value +# "Protocols can be either 'udp' or 'tcp', not #{value}" # end # end # end diff --git a/lib/puppet/type/resources.rb b/lib/puppet/type/resources.rb index 8e0649118..1fb866043 100644 --- a/lib/puppet/type/resources.rb +++ b/lib/puppet/type/resources.rb @@ -15,7 +15,7 @@ Puppet::Type.newtype(:resources) do validate do |name| unless Puppet::Type.type(name) - raise ArgumentError, "Could not find resource type '%s'" % name + raise ArgumentError, "Could not find resource type '#{name}'" end end @@ -32,7 +32,7 @@ Puppet::Type.newtype(:resources) do validate do |value| if [:true, true, "true"].include?(value) unless @resource.resource_type.respond_to?(:instances) - raise ArgumentError, "Purging resources of type %s is not supported, since they cannot be queried from the system" % @resource[:name] + raise ArgumentError, "Purging resources of type #{@resource[:name]} is not supported, since they cannot be queried from the system" end unless @resource.resource_type.validproperty?(:ensure) raise ArgumentError, "Purging is only supported on types that accept 'ensure'" @@ -58,7 +58,7 @@ Puppet::Type.newtype(:resources) do false when Integer; value else - raise ArgumentError, "Invalid value %s" % value.inspect + raise ArgumentError, "Invalid value #{value.inspect}" end end @@ -73,7 +73,7 @@ Puppet::Type.newtype(:resources) do def check(resource) unless defined?(@checkmethod) - @checkmethod = "%s_check" % self[:name] + @checkmethod = "#{self[:name]}_check" end unless defined?(@hascheck) @hascheck = respond_to?(@checkmethod) diff --git a/lib/puppet/type/schedule.rb b/lib/puppet/type/schedule.rb index e52249ac1..c35c97ab3 100755 --- a/lib/puppet/type/schedule.rb +++ b/lib/puppet/type/schedule.rb @@ -81,7 +81,7 @@ module Puppet values.each { |value| unless value.is_a?(String) and value =~ /\d+(:\d+){0,2}\s*-\s*\d+(:\d+){0,2}/ - self.fail "Invalid range value '%s'" % value + self.fail "Invalid range value '#{value}'" end } end @@ -99,23 +99,23 @@ module Puppet } if range.length != 2 - self.fail "Invalid range %s" % value + self.fail "Invalid range #{value}" end # Make sure the hours are valid [range[0][0], range[1][0]].each do |n| if n < 0 or n > 23 - raise ArgumentError, "Invalid hour '%s'" % n + raise ArgumentError, "Invalid hour '#{n}'" end end [range[0][1], range[1][1]].each do |n| if n and (n < 0 or n > 59) - raise ArgumentError, "Invalid minute '%s'" % n + raise ArgumentError, "Invalid minute '#{n}'" end end if range[0][0] > range[1][0] - self.fail(("Invalid range %s; " % value) + + self.fail(("Invalid range #{value}; ") + "ranges cannot span days." ) end @@ -153,7 +153,7 @@ module Puppet unless time.hour == range[0] self.devfail( - "Incorrectly converted time: %s: %s vs %s" % [time, time.hour, range[0]] + "Incorrectly converted time: #{time}: #{time.hour} vs #{range[0]}" ) end @@ -291,7 +291,7 @@ module Puppet if value != 1 and @resource[:periodmatch] != :distance raise Puppet::Error, - "Repeat must be 1 unless periodmatch is 'distance', not '%s'" % @resource[:periodmatch] + "Repeat must be 1 unless periodmatch is 'distance', not '#{@resource[:periodmatch]}'" end end diff --git a/lib/puppet/type/ssh_authorized_key.rb b/lib/puppet/type/ssh_authorized_key.rb index dc9193620..ac59823ce 100644 --- a/lib/puppet/type/ssh_authorized_key.rb +++ b/lib/puppet/type/ssh_authorized_key.rb @@ -47,7 +47,7 @@ module Puppet return nil unless user = resource[:user] begin - return File.expand_path("~%s/.ssh/authorized_keys" % user) + return File.expand_path("~#{user}/.ssh/authorized_keys") rescue Puppet.debug "The required user is not yet present on the system" return nil diff --git a/lib/puppet/type/tidy.rb b/lib/puppet/type/tidy.rb index 5eb01194c..63b2ae244 100755 --- a/lib/puppet/type/tidy.rb +++ b/lib/puppet/type/tidy.rb @@ -36,7 +36,7 @@ Puppet::Type.newtype(:tidy) do when Integer, Fixnum, Bignum; value when /^\d+$/; Integer(value) else - raise ArgumentError, "Invalid recurse value %s" % value.inspect + raise ArgumentError, "Invalid recurse value #{value.inspect}" end end end @@ -112,7 +112,7 @@ Puppet::Type.newtype(:tidy) do if num = @@ageconvertors[unit] return num * multi else - self.fail "Invalid age unit '%s'" % unit + self.fail "Invalid age unit '#{unit}'" end end @@ -135,7 +135,7 @@ Puppet::Type.newtype(:tidy) do multi = Integer($1) unit = :d else - self.fail "Invalid tidy age %s" % age + self.fail "Invalid tidy age #{age}" end convert(unit, multi) @@ -162,7 +162,7 @@ Puppet::Type.newtype(:tidy) do num.times do result *= 1024 end return result else - self.fail "Invalid size unit '%s'" % unit + self.fail "Invalid size unit '#{unit}'" end end @@ -183,7 +183,7 @@ Puppet::Type.newtype(:tidy) do multi = Integer($1) unit = :k else - self.fail "Invalid tidy size %s" % age + self.fail "Invalid tidy size #{age}" end convert(unit, multi) @@ -267,7 +267,7 @@ Puppet::Type.newtype(:tidy) do else files = [self[:path]] end - result = files.find_all { |path| tidy?(path) }.collect { |path| mkfile(path) }.each { |file| notice "Tidying %s" % file.ref }.sort { |a,b| b[:path] <=> a[:path] } + result = files.find_all { |path| tidy?(path) }.collect { |path| mkfile(path) }.each { |file| notice "Tidying #{file.ref}" }.sort { |a,b| b[:path] <=> a[:path] } # No need to worry about relationships if we don't have rmdirs; there won't be # any directories. @@ -300,7 +300,7 @@ Puppet::Type.newtype(:tidy) do if self[:matches].find {|pattern| File.fnmatch(pattern, basename, flags) } return true else - debug "No specified patterns match %s, not tidying" % path + debug "No specified patterns match #{path}, not tidying" return false end end diff --git a/lib/puppet/type/user.rb b/lib/puppet/type/user.rb index b3c8619ec..5788c39de 100755 --- a/lib/puppet/type/user.rb +++ b/lib/puppet/type/user.rb @@ -121,7 +121,7 @@ module Puppet end end - fail "Could not find group(s) %s" % @should.join(",") unless found + fail "Could not find group(s) #{@should.join(",")}" unless found # Use the default event. end @@ -208,7 +208,7 @@ module Puppet validate do |val| if val.to_s == "true" unless provider.class.manages_homedir? - raise ArgumentError, "User provider %s can not manage home directories" % provider.class.name + raise ArgumentError, "User provider #{provider.class.name} can not manage home directories" end end end diff --git a/lib/puppet/type/zone.rb b/lib/puppet/type/zone.rb index 97b8d126f..5573241ed 100644 --- a/lib/puppet/type/zone.rb +++ b/lib/puppet/type/zone.rb @@ -123,10 +123,10 @@ Puppet::Type.newtype(:zone) do def self.state_sequence(first, second) findex = sindex = nil unless findex = @parametervalues.index(state_name(first)) - raise ArgumentError, "'%s' is not a valid zone state" % first + raise ArgumentError, "'#{first}' is not a valid zone state" end unless sindex = @parametervalues.index(state_name(second)) - raise ArgumentError, "'%s' is not a valid zone state" % first + raise ArgumentError, "'#{first}' is not a valid zone state" end list = nil @@ -172,11 +172,11 @@ Puppet::Type.newtype(:zone) do end provider.send(method) else - raise Puppet::DevError, "Cannot move %s from %s" % [direction, st[:name]] + raise Puppet::DevError, "Cannot move #{direction} from #{st[:name]}" end end - return ("zone_" + self.should.to_s).intern + return ("zone_#{self.should}").intern end # Are we moving up the property tree? @@ -394,7 +394,7 @@ Puppet::Type.newtype(:zone) do begin IPAddr.new(ip) if ip rescue ArgumentError - self.fail "'%s' is an invalid %s" % [ip, name] + self.fail "'#{ip}' is an invalid #{name}" end end @@ -411,7 +411,7 @@ Puppet::Type.newtype(:zone) do end else unless interface && address.nil? && defrouter.nil? - self.fail "only interface may be specified when using exclusive IP stack: %s" % value + self.fail "only interface may be specified when using exclusive IP stack: #{value}" end end diff --git a/lib/puppet/type/zpool.rb b/lib/puppet/type/zpool.rb index 85f394fa0..48fe9a227 100755 --- a/lib/puppet/type/zpool.rb +++ b/lib/puppet/type/zpool.rb @@ -85,7 +85,7 @@ module Puppet validate do has_should = [:disk, :mirror, :raidz].select { |prop| self.should(prop) } if has_should.length > 1 - self.fail "You cannot specify %s on this type (only one)" % has_should.join(" and ") + self.fail "You cannot specify #{has_should.join(" and ")} on this type (only one)" end end end diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb index 1f974921e..02bac1b88 100644 --- a/lib/puppet/util.rb +++ b/lib/puppet/util.rb @@ -31,15 +31,15 @@ module Util if group = Puppet[:group] group = self.gid(group) unless group - raise Puppet::Error, "No such group %s" % Puppet[:group] + raise Puppet::Error, "No such group #{Puppet[:group]}" end unless Puppet::Util::SUIDManager.gid == group begin Puppet::Util::SUIDManager.egid = group Puppet::Util::SUIDManager.gid = group rescue => detail - Puppet.warning "could not change to group %s: %s" % [group.inspect, detail] - $stderr.puts "could not change to group %s" % group.inspect + Puppet.warning "could not change to group #{group.inspect}: #{detail}" + $stderr.puts "could not change to group #{group.inspect}" # Don't exit on failed group changes, since it's # not fatal @@ -51,7 +51,7 @@ module Util if user = Puppet[:user] user = self.uid(user) unless user - raise Puppet::Error, "No such user %s" % Puppet[:user] + raise Puppet::Error, "No such user #{Puppet[:user]}" end unless Puppet::Util::SUIDManager.uid == user begin @@ -59,7 +59,7 @@ module Util Puppet::Util::SUIDManager.uid = user Puppet::Util::SUIDManager.euid = user rescue => detail - $stderr.puts "Could not change to user %s: %s" % [user, detail] + $stderr.puts "Could not change to user #{user}: #{detail}" exit(74) end end @@ -135,7 +135,7 @@ module Util elsif FileTest.directory?(File.join(path)) next else FileTest.exist?(File.join(path)) - raise "Cannot create %s: basedir %s is a file" % [dir, File.join(path)] + raise "Cannot create #{dir}: basedir #{File.join(path)} is a file" end } return true @@ -173,7 +173,7 @@ module Util end unless level == :none or object.respond_to? level - raise Puppet::DevError, "Benchmarked object does not respond to %s" % level + raise Puppet::DevError, "Benchmarked object does not respond to #{level}" end # Only benchmark if our log level is high enough @@ -205,9 +205,9 @@ module Util # Execute the provided command in a pipe, yielding the pipe object. def execpipe(command, failonfail = true) if respond_to? :debug - debug "Executing '%s'" % command + debug "Executing '#{command}'" else - Puppet.debug "Executing '%s'" % command + Puppet.debug "Executing '#{command}'" end output = open("| #{command} 2>&1") do |pipe| @@ -249,9 +249,9 @@ module Util end if respond_to? :debug - debug "Executing '%s'" % str + debug "Executing '#{str}'" else - Puppet.debug "Executing '%s'" % str + Puppet.debug "Executing '#{str}'" end if arguments[:uid] @@ -321,7 +321,7 @@ module Util end # if child_pid elsif Puppet.features.microsoft_windows? command = command.collect {|part| '"' + part.gsub(/"/, '\\"') + '"'}.join(" ") if command.is_a?(Array) - Puppet.debug "Creating process '%s'" % command + Puppet.debug "Creating process '#{command}'" processinfo = Process.create( :command_line => command ) child_status = (Process.waitpid2(child_pid)[1]).to_i >> 8 end # if posix or win32 @@ -356,7 +356,7 @@ module Util if arguments[:failonfail] unless child_status == 0 - raise ExecutionFailure, "Execution of '%s' returned %s: %s" % [str, child_status, output] + raise ExecutionFailure, "Execution of '#{str}' returned #{child_status}: #{output}" end end diff --git a/lib/puppet/util/autoload.rb b/lib/puppet/util/autoload.rb index f0be0ece2..cdfc194da 100644 --- a/lib/puppet/util/autoload.rb +++ b/lib/puppet/util/autoload.rb @@ -24,7 +24,7 @@ class Puppet::Util::Autoload # List all loaded files. def self.list_loaded @loaded.sort { |a,b| a[0] <=> b[0] }.collect do |path, hash| - "%s: %s" % [path, hash[:file]] + "#{path}: #{hash[:file]}" end end @@ -62,7 +62,7 @@ class Puppet::Util::Autoload begin self.send(opt.to_s + "=", value) rescue NoMethodError - raise ArgumentError, "%s is not a valid option" % opt + raise ArgumentError, "#{opt} is not a valid option" end end diff --git a/lib/puppet/util/backups.rb b/lib/puppet/util/backups.rb index 4270f528c..e08bf57de 100644 --- a/lib/puppet/util/backups.rb +++ b/lib/puppet/util/backups.rb @@ -49,7 +49,7 @@ module Puppet::Util::Backups rescue => detail # since they said they want a backup, let's error out # if we couldn't make one - self.fail "Could not back %s up: %s" % [file, detail.message] + self.fail "Could not back #{file} up: #{detail.message}" end end @@ -67,22 +67,22 @@ module Puppet::Util::Backups end if stat.ftype == "directory" - raise Puppet::Error, "Will not remove directory backup %s; use a filebucket" % newfile + raise Puppet::Error, "Will not remove directory backup #{newfile}; use a filebucket" end - info "Removing old backup of type %s" % stat.ftype + info "Removing old backup of type #{stat.ftype}" begin File.unlink(newfile) rescue => detail puts detail.backtrace if Puppet[:trace] - self.fail "Could not remove old backup: %s" % detail + self.fail "Could not remove old backup: #{detail}" end end def backup_file_with_filebucket(f) sum = self.bucket.backup(f) - self.info "Filebucketed %s to %s with sum %s" % [f, self.bucket.name, sum] + self.info "Filebucketed #{f} to #{self.bucket.name} with sum #{sum}" return sum end end diff --git a/lib/puppet/util/cacher.rb b/lib/puppet/util/cacher.rb index 28786ab53..3a75dc88d 100644 --- a/lib/puppet/util/cacher.rb +++ b/lib/puppet/util/cacher.rb @@ -39,7 +39,7 @@ module Puppet::Util::Cacher # Provide a means of defining an attribute whose value will be cached. # Must provide a block capable of defining the value if it's flushed.. def cached_attr(name, options = {}, &block) - init_method = "init_" + name.to_s + init_method = "init_#{name}" define_method(init_method, &block) define_method(name) do @@ -103,7 +103,7 @@ module Puppet::Util::Cacher value_cache.delete(name) end unless value_cache.include?(name) - value_cache[name] = send("init_%s" % name) + value_cache[name] = send("init_#{name}") end value_cache[name] end diff --git a/lib/puppet/util/classgen.rb b/lib/puppet/util/classgen.rb index 83c302c01..d9022bbdc 100644 --- a/lib/puppet/util/classgen.rb +++ b/lib/puppet/util/classgen.rb @@ -134,11 +134,11 @@ module Puppet::Util::ClassGen if const_defined?(const) if options[:overwrite] - Puppet.info "Redefining %s in %s" % [name, self] + Puppet.info "Redefining #{name} in #{self}" remove_const(const) else raise Puppet::ConstantAlreadyDefined, - "Class %s is already defined in %s" % [const, self] + "Class #{const} is already defined in #{self}" end end const_set(const, klass) @@ -185,7 +185,7 @@ module Puppet::Util::ClassGen if hash = options[:hash] if hash.include? klassname and ! options[:overwrite] raise Puppet::SubclassAlreadyDefined, - "Already a generated class named %s" % klassname + "Already a generated class named #{klassname}" end hash[klassname] = klass @@ -197,7 +197,7 @@ module Puppet::Util::ClassGen array.find { |c| c.name == klassname } and ! options[:overwrite]) raise Puppet::SubclassAlreadyDefined, - "Already a generated class named %s" % klassname + "Already a generated class named #{klassname}" end array << klass diff --git a/lib/puppet/util/constant_inflector.rb b/lib/puppet/util/constant_inflector.rb index 29d334348..20ad384d9 100644 --- a/lib/puppet/util/constant_inflector.rb +++ b/lib/puppet/util/constant_inflector.rb @@ -10,6 +10,6 @@ module Puppet::Util::ConstantInflector end def constant2file(constant) - constant.to_s.gsub(/([a-z])([A-Z])/) { |term| $1 + "_" + $2 }.gsub("::", "/").downcase + constant.to_s.gsub(/([a-z])([A-Z])/) { |term| $1 + "_#{$2}" }.gsub("::", "/").downcase end end diff --git a/lib/puppet/util/docs.rb b/lib/puppet/util/docs.rb index 02374d8b7..d73550d9f 100644 --- a/lib/puppet/util/docs.rb +++ b/lib/puppet/util/docs.rb @@ -9,7 +9,7 @@ module Puppet::Util::Docs # rather than just sticking them in a hash, because otherwise they're # too difficult to do inheritance with. def dochook(name, &block) - method = "dochook_" + name.to_s + method = "dochook_#{name}" meta_def method, &block end diff --git a/lib/puppet/util/errors.rb b/lib/puppet/util/errors.rb index a44c1ca18..d78064227 100644 --- a/lib/puppet/util/errors.rb +++ b/lib/puppet/util/errors.rb @@ -38,7 +38,7 @@ module Puppet::Util::Errors rescue Puppet::Error => detail raise adderrorcontext(detail) rescue => detail - message = options[:message] || "%s failed with error %s: %s" % [self.class, detail.class, detail.to_s] + message = options[:message] || "#{self.class} failed with error #{detail.class}: #{detail}" error = options[:type].new(message) # We can't use self.fail here because it always expects strings, diff --git a/lib/puppet/util/feature.rb b/lib/puppet/util/feature.rb index d5866927a..40ecfe447 100644 --- a/lib/puppet/util/feature.rb +++ b/lib/puppet/util/feature.rb @@ -14,14 +14,14 @@ class Puppet::Util::Feature def add(name, options = {}) method = name.to_s + "?" if self.class.respond_to?(method) - raise ArgumentError, "Feature %s is already defined" % name + raise ArgumentError, "Feature #{name} is already defined" end if block_given? begin result = yield rescue Exception => detail - warn "Failed to load feature test for %s: %s" % [name, detail] + warn "Failed to load feature test for #{name}: #{detail}" result = false end @results[name] = result @@ -78,7 +78,7 @@ class Puppet::Util::Feature def load_library(lib, name) unless lib.is_a?(String) - raise ArgumentError, "Libraries must be passed as strings not %s" % lib.class + raise ArgumentError, "Libraries must be passed as strings not #{lib.class}" end begin @@ -86,7 +86,7 @@ class Puppet::Util::Feature rescue SystemExit,NoMemoryError raise rescue Exception - Puppet.debug "Failed to load library '%s' for feature '%s'" % [lib, name] + Puppet.debug "Failed to load library '#{lib}' for feature '#{name}'" return false end return true diff --git a/lib/puppet/util/file_locking.rb b/lib/puppet/util/file_locking.rb index f1f02be1c..ab43e2353 100644 --- a/lib/puppet/util/file_locking.rb +++ b/lib/puppet/util/file_locking.rb @@ -5,7 +5,7 @@ module Puppet::Util::FileLocking # Create a shared lock for reading def readlock(file) - raise ArgumentError, "%s is not a file" % file unless !File.exists?(file) or File.file?(file) + raise ArgumentError, "#{file} is not a file" unless !File.exists?(file) or File.file?(file) Puppet::Util.sync(file).synchronize(Sync::SH) do File.open(file) { |f| f.lock_shared { |lf| yield lf } @@ -17,9 +17,9 @@ module Puppet::Util::FileLocking # tmp file. def writelock(file, mode = nil) unless FileTest.directory?(File.dirname(file)) - raise Puppet::DevError, "Cannot create %s; directory %s does not exist" % [file, File.dirname(file)] + raise Puppet::DevError, "Cannot create #{file}; directory #{File.dirname(file)} does not exist" end - raise ArgumentError, "%s is not a file" % file unless !File.exists?(file) or File.file?(file) + raise ArgumentError, "#{file} is not a file" unless !File.exists?(file) or File.file?(file) tmpfile = file + ".tmp" unless mode diff --git a/lib/puppet/util/fileparsing.rb b/lib/puppet/util/fileparsing.rb index 7965532fd..974d908b8 100644 --- a/lib/puppet/util/fileparsing.rb +++ b/lib/puppet/util/fileparsing.rb @@ -44,7 +44,7 @@ module Puppet::Util::FileParsing @fields = fields.collect do |field| r = symbolize(field) if INVALID_FIELDS.include?(r) - raise ArgumentError.new("Cannot have fields named %s" % r) + raise ArgumentError.new("Cannot have fields named #{r}") end r end @@ -53,7 +53,7 @@ module Puppet::Util::FileParsing def initialize(type, options = {}, &block) @type = symbolize(type) unless [:record, :text].include?(@type) - raise ArgumentError, "Invalid record type %s" % @type + raise ArgumentError, "Invalid record type #{@type}" end set_options(options) @@ -92,7 +92,7 @@ module Puppet::Util::FileParsing if self.optional.include?(field) self.absent else - raise ArgumentError, "Field '%s' is required" % field + raise ArgumentError, "Field '#{field}' is required" end else details[field].to_s @@ -157,7 +157,7 @@ module Puppet::Util::FileParsing if ret = record.send(:process, line.dup) unless ret.is_a?(Hash) raise Puppet::DevError, - "Process record type %s returned non-hash" % record.name + "Process record type #{record.name} returned non-hash" end else return nil @@ -235,7 +235,7 @@ module Puppet::Util::FileParsing if val = parse_line(line) val else - error = Puppet::Error.new("Could not parse line %s" % line.inspect) + error = Puppet::Error.new("Could not parse line #{line.inspect}") error.line = count raise error end @@ -250,7 +250,7 @@ module Puppet::Util::FileParsing @record_order.each do |record| # These are basically either text or record lines. - method = "handle_%s_line" % record.type + method = "handle_#{record.type}_line" if respond_to?(method) if result = send(method, line, record) if record.respond_to?(:post_parse) @@ -260,7 +260,7 @@ module Puppet::Util::FileParsing end else raise Puppet::DevError, - "Somehow got invalid line type %s" % record.type + "Somehow got invalid line type #{record.type}" end end @@ -323,7 +323,7 @@ module Puppet::Util::FileParsing # Convert our parsed record into a text record. def to_line(details) unless record = record_type(details[:record_type]) - raise ArgumentError, "Invalid record type %s" % details[:record_type].inspect + raise ArgumentError, "Invalid record type #{details[:record_type].inspect}" end if record.respond_to?(:pre_gen) @@ -382,7 +382,7 @@ module Puppet::Util::FileParsing @record_order ||= [] if @record_types.include?(record.name) - raise ArgumentError, "Line type %s is already defined" % record.name + raise ArgumentError, "Line type #{record.name} is already defined" end @record_types[record.name] = record diff --git a/lib/puppet/util/filetype.rb b/lib/puppet/util/filetype.rb index c2291a3ab..3df4fdee0 100755 --- a/lib/puppet/util/filetype.rb +++ b/lib/puppet/util/filetype.rb @@ -47,7 +47,7 @@ class Puppet::Util::FileType if Puppet[:trace] puts detail.backtrace end - raise Puppet::Error, "%s could not read %s: %s" % [self.class, @path, detail] + raise Puppet::Error, "#{self.class} could not read #{@path}: #{detail}" end end @@ -64,7 +64,7 @@ class Puppet::Util::FileType if Puppet[:debug] puts detail.backtrace end - raise Puppet::Error, "%s could not write %s: %s" % [self.class, @path, detail] + raise Puppet::Error, "#{self.class} could not write #{@path}: #{detail}" end end end @@ -137,19 +137,19 @@ class Puppet::Util::FileType # Read the file. def read - Puppet.info "Reading %s from RAM" % @path + Puppet.info "Reading #{@path} from RAM" @@tabs[@path] end # Remove the file. def remove - Puppet.info "Removing %s from RAM" % @path + Puppet.info "Removing #{@path} from RAM" @@tabs[@path] = "" end # Overwrite the file. def write(text) - Puppet.info "Writing %s to RAM" % @path + Puppet.info "Writing #{@path} to RAM" @@tabs[@path] = text end end @@ -164,7 +164,7 @@ class Puppet::Util::FileType begin @uid = Puppet::Util.uid(user) rescue Puppet::Error => detail - raise Puppet::Error, "Could not retrieve user %s" % user + raise Puppet::Error, "Could not retrieve user #{user}" end # XXX We have to have the user name, not the uid, because some @@ -216,10 +216,10 @@ class Puppet::Util::FileType begin output = Puppet::Util.execute(%w{crontab -l}, :uid => @path) return "" if output.include?("can't open your crontab") - raise Puppet::Error, "User %s not authorized to use cron" % @path if output.include?("you are not authorized to use cron") + raise Puppet::Error, "User #{@path} not authorized to use cron" if output.include?("you are not authorized to use cron") return output rescue => detail - raise Puppet::Error, "Could not read crontab for %s: %s" % [@path, detail] + raise Puppet::Error, "Could not read crontab for #{@path}: #{detail}" end end @@ -228,7 +228,7 @@ class Puppet::Util::FileType begin Puppet::Util.execute(%w{crontab -r}, :uid => @path) rescue => detail - raise Puppet::Error, "Could not remove crontab for %s: %s" % [@path, detail] + raise Puppet::Error, "Could not remove crontab for #{@path}: #{detail}" end end @@ -248,7 +248,7 @@ class Puppet::Util::FileType begin Puppet::Util.execute(["crontab", output_file.path], :uid => @path) rescue => detail - raise Puppet::Error, "Could not write crontab for %s: %s" % [@path, detail] + raise Puppet::Error, "Could not write crontab for #{@path}: #{detail}" end output_file.delete end @@ -261,11 +261,11 @@ class Puppet::Util::FileType begin output = Puppet::Util.execute(%w{crontab -l}, :uid => @path) if output.include?("You are not authorized to use the cron command") - raise Puppet::Error, "User %s not authorized to use cron" % @path + raise Puppet::Error, "User #{@path} not authorized to use cron" end return output rescue => detail - raise Puppet::Error, "Could not read crontab for %s: %s" % [@path, detail] + raise Puppet::Error, "Could not read crontab for #{@path}: #{detail}" end end @@ -274,7 +274,7 @@ class Puppet::Util::FileType begin Puppet::Util.execute(%w{crontab -r}, :uid => @path) rescue => detail - raise Puppet::Error, "Could not remove crontab for %s: %s" % [@path, detail] + raise Puppet::Error, "Could not remove crontab for #{@path}: #{detail}" end end @@ -293,7 +293,7 @@ class Puppet::Util::FileType begin Puppet::Util.execute(["crontab", output_file.path], :uid => @path) rescue => detail - raise Puppet::Error, "Could not write crontab for %s: %s" % [@path, detail] + raise Puppet::Error, "Could not write crontab for #{@path}: #{detail}" ensure output_file.delete end diff --git a/lib/puppet/util/inifile.rb b/lib/puppet/util/inifile.rb index 0a957d447..38bc1c574 100644 --- a/lib/puppet/util/inifile.rb +++ b/lib/puppet/util/inifile.rb @@ -122,7 +122,7 @@ module Puppet::Util::IniConfig end elsif " \t\r\n\f".include?(l[0,1]) && section && optname # continuation line - section[optname] += "\n" + l.chomp + section[optname] += "\n#{l.chomp}" elsif l =~ /^\[([^\]]+)\]/ # section heading section.mark_clean unless section.nil? diff --git a/lib/puppet/util/instance_loader.rb b/lib/puppet/util/instance_loader.rb index bf4f9b77f..56d75b698 100755 --- a/lib/puppet/util/instance_loader.rb +++ b/lib/puppet/util/instance_loader.rb @@ -42,7 +42,7 @@ module Puppet::Util::InstanceLoader # Use this method so they all get loaded loaded_instances(type).sort { |a,b| a.to_s <=> b.to_s }.each do |name| mod = self.loaded_instance(name) - docs += "%s\n%s\n" % [name, "-" * name.to_s.length] + docs += "#{name}\n#{"-" * name.to_s.length}\n" docs += Puppet::Util::Docs.scrub(mod.doc) + "\n\n" end @@ -68,7 +68,7 @@ module Puppet::Util::InstanceLoader if instance_loader(type).load(name) unless instances.include? name Puppet.warning( - "Loaded %s file for %s but %s was not defined" % [type, name, type] + "Loaded #{type} file for #{name} but #{type} was not defined" ) return nil end diff --git a/lib/puppet/util/ldap/connection.rb b/lib/puppet/util/ldap/connection.rb index 18d9bf5ab..4f71069ef 100644 --- a/lib/puppet/util/ldap/connection.rb +++ b/lib/puppet/util/ldap/connection.rb @@ -43,7 +43,7 @@ class Puppet::Util::Ldap::Connection begin send(param.to_s + "=", value) rescue - raise ArgumentError, "LDAP connections do not support %s parameters" % param + raise ArgumentError, "LDAP connections do not support #{param} parameters" end end end @@ -73,7 +73,7 @@ class Puppet::Util::Ldap::Connection @connection.set_option(LDAP::LDAP_OPT_REFERRALS, LDAP::LDAP_OPT_ON) @connection.simple_bind(user, password) rescue => detail - raise Puppet::Error, "Could not connect to LDAP: %s" % detail + raise Puppet::Error, "Could not connect to LDAP: #{detail}" end end end diff --git a/lib/puppet/util/ldap/manager.rb b/lib/puppet/util/ldap/manager.rb index 8d444195e..cfa7cb3f7 100644 --- a/lib/puppet/util/ldap/manager.rb +++ b/lib/puppet/util/ldap/manager.rb @@ -80,7 +80,7 @@ class Puppet::Util::Ldap::Manager # Calculate the dn for a given resource. def dn(name) - ["%s=%s" % [rdn, name], base].join(",") + ["#{rdn}=#{name}", base].join(",") end # Convert an ldap-style entry hash to a provider-style hash. @@ -103,7 +103,7 @@ class Puppet::Util::Ldap::Manager # Create our normal search filter. def filter - return "objectclass=%s" % objectclasses[0] if objectclasses.length == 1 + return "objectclass=#{objectclasses[0]}" if objectclasses.length == 1 return "(&(objectclass=" + objectclasses.join(")(objectclass=") + "))" end @@ -139,7 +139,7 @@ class Puppet::Util::Ldap::Manager if generator.source unless value = values[generator.source] - raise ArgumentError, "%s must be defined to generate %s" % [generator.source, generator.name] + raise ArgumentError, "#{generator.source} must be defined to generate #{generator.name}" end result = generator.generate(value) else @@ -216,14 +216,14 @@ class Puppet::Util::Ldap::Manager # Update the ldap entry with the desired state. def update(name, is, should) if should[:ensure] == :absent - Puppet.info "Removing %s from ldap" % dn(name) + Puppet.info "Removing #{dn(name)} from ldap" delete(name) return end # We're creating a new entry if is.empty? or is[:ensure] == :absent - Puppet.info "Creating %s in ldap" % dn(name) + Puppet.info "Creating #{dn(name)} in ldap" # Remove any :absent params and :ensure, then convert the names to ldap names. attrs = ldap_convert(should) create(name, attrs) diff --git a/lib/puppet/util/log.rb b/lib/puppet/util/log.rb index 57be5f5ba..ac1992526 100644 --- a/lib/puppet/util/log.rb +++ b/lib/puppet/util/log.rb @@ -79,7 +79,7 @@ class Puppet::Util::Log raise Puppet::DevError, "Logs require a level" end unless @levels.index(hash[:level]) - raise Puppet::DevError, "Invalid log level %s" % hash[:level] + raise Puppet::DevError, "Invalid log level #{hash[:level]}" end if @levels.index(hash[:level]) >= @loglevel return Puppet::Util::Log.new(hash) @@ -109,7 +109,7 @@ class Puppet::Util::Log end unless @levels.include?(level) - raise Puppet::DevError, "Invalid loglevel %s" % level + raise Puppet::DevError, "Invalid loglevel #{level}" end @loglevel = @levels.index(level) @@ -131,7 +131,7 @@ class Puppet::Util::Log end unless type - raise Puppet::DevError, "Unknown destination type %s" % dest + raise Puppet::DevError, "Unknown destination type #{dest}" end begin @@ -246,7 +246,7 @@ class Puppet::Util::Log def level=(level) raise ArgumentError, "Puppet::Util::Log requires a log level" unless level @level = level.to_sym - raise ArgumentError, "Invalid log level %s" % @level unless self.class.validlevel?(@level) + raise ArgumentError, "Invalid log level #{@level}" unless self.class.validlevel?(@level) # Tag myself with my log level tag(level) diff --git a/lib/puppet/util/log/destinations.rb b/lib/puppet/util/log/destinations.rb index 9fe61d484..37e6d1ae9 100644 --- a/lib/puppet/util/log/destinations.rb +++ b/lib/puppet/util/log/destinations.rb @@ -17,7 +17,7 @@ Puppet::Util::Log.newdesttype :syslog do begin facility = Syslog.const_get("LOG_#{str.upcase}") rescue NameError - raise Puppet::Error, "Invalid syslog facility %s" % str + raise Puppet::Error, "Invalid syslog facility #{str}" end @syslog = Syslog.open(name, options, facility) @@ -61,7 +61,7 @@ Puppet::Util::Log.newdesttype :file do # specified a "special" destination. unless FileTest.exist?(File.dirname(path)) Puppet.recmkdir(File.dirname(path)) - Puppet.info "Creating log directory %s" % File.dirname(path) + Puppet.info "Creating log directory #{File.dirname(path)}" end # create the log file, if it doesn't already exist @@ -73,7 +73,7 @@ Puppet::Util::Log.newdesttype :file do end def handle(msg) - @file.puts("%s %s (%s): %s" % [msg.time, msg.source, msg.level, msg.to_s]) + @file.puts("#{msg.time} #{msg.source} (#{msg.level}): #{msg}") @file.flush if @autoflush end @@ -133,16 +133,16 @@ Puppet::Util::Log.newdesttype :console do def handle(msg) if msg.source == "Puppet" - puts colorize(msg.level, "%s: %s" % [msg.level, msg.to_s]) + puts colorize(msg.level, "#{msg.level}: #{msg}") else - puts colorize(msg.level, "%s: %s: %s" % [msg.level, msg.source, msg.to_s]) + puts colorize(msg.level, "#{msg.level}: #{msg.source}: #{msg}") end end end Puppet::Util::Log.newdesttype :host do def initialize(host) - Puppet.info "Treating %s as a hostname" % host + Puppet.info "Treating #{host} as a hostname" args = {} if host =~ /:(\d+)/ args[:Port] = $1 @@ -164,24 +164,24 @@ Puppet::Util::Log.newdesttype :host do unless defined?(@domain) @domain = Facter["domain"].value if @domain - @hostname += "." + @domain + @hostname += ".#{@domain}" end end if msg.source =~ /^\// - msg.source = @hostname + ":" + msg.source + msg.source = @hostname + ":#{msg.source}" elsif msg.source == "Puppet" - msg.source = @hostname + " " + msg.source + msg.source = @hostname + " #{msg.source}" else - msg.source = @hostname + " " + msg.source + msg.source = @hostname + " #{msg.source}" end begin - #puts "would have sent %s" % msg + #puts "would have sent #{msg}" #puts "would have sent %s" % # CGI.escape(YAML.dump(msg)) begin tmp = CGI.escape(YAML.dump(msg)) rescue => detail - puts "Could not dump: %s" % detail.to_s + puts "Could not dump: #{detail}" return end # Add the hostname to the source diff --git a/lib/puppet/util/methodhelper.rb b/lib/puppet/util/methodhelper.rb index ecc9d537f..771d0e648 100644 --- a/lib/puppet/util/methodhelper.rb +++ b/lib/puppet/util/methodhelper.rb @@ -3,7 +3,7 @@ module Puppet::Util::MethodHelper def requiredopts(*names) names.each do |name| if self.send(name).nil? - devfail("%s is a required option for %s" % [name, self.class]) + devfail("#{name} is a required option for #{self.class}") end end end diff --git a/lib/puppet/util/metric.rb b/lib/puppet/util/metric.rb index cf8ed9ee1..e8de54cf2 100644 --- a/lib/puppet/util/metric.rb +++ b/lib/puppet/util/metric.rb @@ -37,14 +37,14 @@ class Puppet::Util::Metric values.each { |value| # the 7200 is the heartbeat -- this means that any data that isn't # more frequently than every two hours gets thrown away - args.push "DS:%s:GAUGE:7200:U:U" % [value[0]] + args.push "DS:#{value[0]}:GAUGE:7200:U:U" } args.push "RRA:AVERAGE:0.5:1:300" begin @rrd.create( Puppet[:rrdinterval].to_i, start, args) rescue => detail - raise "Could not create RRD file %s: %s" % [path,detail] + raise "Could not create RRD file #{path}: #{detail}" end end @@ -62,7 +62,7 @@ class Puppet::Util::Metric colorstack = %w{#00ff00 #ff0000 #0000ff #ffff00 #ff99ff #ff9966 #66ffff #990000 #099000 #000990 #f00990 #0f0f0f #555555 #333333 #ffffff} {:daily => unit, :weekly => unit * 7, :monthly => unit * 30, :yearly => unit * 365}.each do |name, time| - file = self.path.sub(/\.rrd$/, "-%s.png" % name) + file = self.path.sub(/\.rrd$/, "-#{name}.png") args = [file] args.push("--title",self.label) @@ -75,8 +75,8 @@ class Puppet::Util::Metric values.zip(colorstack).each { |value,color| next if value.nil? # this actually uses the data label - defs.push("DEF:%s=%s:%s:AVERAGE" % [value[0],self.path,value[0]]) - lines.push("LINE2:%s%s:%s" % [value[0],color,value[1]]) + defs.push("DEF:#{value[0]}=#{self.path}:#{value[0]}:AVERAGE") + lines.push("LINE2:#{value[0]}#{color}:#{value[1]}") } args << defs args << lines @@ -91,7 +91,7 @@ class Puppet::Util::Metric #Puppet.warning "args = #{args}" RRDtool.graph( args ) rescue => detail - Puppet.err "Failed to graph %s: %s" % [self.name,detail] + Puppet.err "Failed to graph #{self.name}: #{detail}" end end end @@ -136,9 +136,9 @@ class Puppet::Util::Metric template = temps.join(":") begin @rrd.update( template, [ arg ] ) - #system("rrdtool updatev %s '%s'" % [self.path, arg]) + #system("rrdtool updatev #{self.path} '#{arg}'") rescue => detail - raise Puppet::Error, "Failed to update %s: %s" % [self.name,detail] + raise Puppet::Error, "Failed to update #{self.name}: #{detail}" end end diff --git a/lib/puppet/util/nagios_maker.rb b/lib/puppet/util/nagios_maker.rb index 339d2d1a2..e824b1de2 100644 --- a/lib/puppet/util/nagios_maker.rb +++ b/lib/puppet/util/nagios_maker.rb @@ -7,16 +7,16 @@ module Puppet::Util::NagiosMaker # from the parser. def self.create_nagios_type(name) name = name.to_sym - full_name = ("nagios_" + name.to_s).to_sym + full_name = ("nagios_#{name}").to_sym - raise(Puppet::DevError, "No nagios type for %s" % name) unless nagtype = Nagios::Base.type(name) + raise(Puppet::DevError, "No nagios type for #{name}") unless nagtype = Nagios::Base.type(name) type = Puppet::Type.newtype(full_name) {} type.ensurable type.newparam(nagtype.namevar, :namevar => true) do - desc "The name parameter for Nagios type %s" % nagtype.name + desc "The name parameter for Nagios type #{nagtype.name}" end # We deduplicate the parameters because it makes sense to allow Naginator to have dupes. diff --git a/lib/puppet/util/posix.rb b/lib/puppet/util/posix.rb index 837c37a07..c71a846d9 100755 --- a/lib/puppet/util/posix.rb +++ b/lib/puppet/util/posix.rb @@ -11,7 +11,7 @@ module Puppet::Util::POSIX if id.is_a?(Integer) if id > Puppet[:maximum_uid].to_i - Puppet.err "Tried to get %s field for silly id %s" % [field, id] + Puppet.err "Tried to get #{field} field for silly id #{id}" return nil end method = methodbyid(space) @@ -36,7 +36,7 @@ module Puppet::Util::POSIX if id.is_a?(Integer) integer = true if id > Puppet[:maximum_uid].to_i - Puppet.err "Tried to get %s field for silly id %s" % [field, id] + Puppet.err "Tried to get #{field} field for silly id #{id}" return nil end end diff --git a/lib/puppet/util/provider_features.rb b/lib/puppet/util/provider_features.rb index 86f30cc8b..d106d473c 100644 --- a/lib/puppet/util/provider_features.rb +++ b/lib/puppet/util/provider_features.rb @@ -55,13 +55,13 @@ module Puppet::Util::ProviderFeatures # required to determine if the feature is present. def feature(name, docs, hash = {}) @features ||= {} - raise(Puppet::DevError, "Feature %s is already defined" % name) if @features.include?(name) + raise(Puppet::DevError, "Feature #{name} is already defined") if @features.include?(name) begin obj = ProviderFeature.new(name, docs, hash) @features[obj.name] = obj rescue ArgumentError => detail error = ArgumentError.new( - "Could not create feature %s: %s" % [name, detail] + "Could not create feature #{name}: #{detail}" ) error.set_backtrace(detail.backtrace) raise error @@ -76,7 +76,7 @@ module Puppet::Util::ProviderFeatures names = @features.keys.sort { |a,b| a.to_s <=> b.to_s } names.each do |name| doc = @features[name].docs.gsub(/\n\s+/, " ") - str += "- **%s**: %s\n" % [name, doc] + str += "- **#{name}**: #{doc}\n" end if providers.length > 0 diff --git a/lib/puppet/util/queue.rb b/lib/puppet/util/queue.rb index 329b07b22..31425fbae 100644 --- a/lib/puppet/util/queue.rb +++ b/lib/puppet/util/queue.rb @@ -52,7 +52,7 @@ module Puppet::Util::Queue # each registration. def self.register_queue_type(klass, type = nil) type ||= queue_type_from_class(klass) - raise Puppet::Error, "Queue type %s is already registered" % type.to_s if instance_hash(:queue_clients).include?(type) + raise Puppet::Error, "Queue type #{type} is already registered" if instance_hash(:queue_clients).include?(type) instance_hash(:queue_clients)[type] = klass end @@ -60,7 +60,7 @@ module Puppet::Util::Queue # (meaning it hasn't been registered with this module), an exception is thrown. def self.queue_type_to_class(type) c = loaded_instance :queue_clients, type - raise Puppet::Error, "Queue type %s is unknown." % type unless c + raise Puppet::Error, "Queue type #{type} is unknown." unless c c end diff --git a/lib/puppet/util/queue/stomp.rb b/lib/puppet/util/queue/stomp.rb index a87268b72..ffe745ff7 100644 --- a/lib/puppet/util/queue/stomp.rb +++ b/lib/puppet/util/queue/stomp.rb @@ -15,16 +15,16 @@ class Puppet::Util::Queue::Stomp begin uri = URI.parse(Puppet[:queue_source]) rescue => detail - raise ArgumentError, "Could not create Stomp client instance - queue source %s is invalid: %s" % [Puppet[:queue_source], detail] + raise ArgumentError, "Could not create Stomp client instance - queue source #{Puppet[:queue_source]} is invalid: #{detail}" end unless uri.scheme == "stomp" - raise ArgumentError, "Could not create Stomp client instance - queue source %s is not a Stomp URL: %s" % [Puppet[:queue_source], detail] + raise ArgumentError, "Could not create Stomp client instance - queue source #{Puppet[:queue_source]} is not a Stomp URL: #{detail}" end begin self.stomp_client = Stomp::Client.new(uri.user, uri.password, uri.host, uri.port, true) rescue => detail - raise ArgumentError, "Could not create Stomp client instance with queue source %s: got internal Stomp client error %s" % [Puppet[:queue_source], detail] + raise ArgumentError, "Could not create Stomp client instance with queue source #{Puppet[:queue_source]}: got internal Stomp client error #{detail}" end end diff --git a/lib/puppet/util/rdoc.rb b/lib/puppet/util/rdoc.rb index 1bc48abd0..82076534d 100644 --- a/lib/puppet/util/rdoc.rb +++ b/lib/puppet/util/rdoc.rb @@ -35,7 +35,7 @@ module Puppet::Util::RDoc # launch the documentation process r.document(options) rescue RDoc::RDocError => e - raise Puppet::ParseError.new("RDoc error %s" % e) + raise Puppet::ParseError.new("RDoc error #{e}") end end diff --git a/lib/puppet/util/rdoc/code_objects.rb b/lib/puppet/util/rdoc/code_objects.rb index 995869987..9ee26f47d 100644 --- a/lib/puppet/util/rdoc/code_objects.rb +++ b/lib/puppet/util/rdoc/code_objects.rb @@ -169,7 +169,7 @@ module RDoc end def to_s - res = self.class.name + ": " + @name + " (" + @type + ")\n" + res = self.class.name + ": #{@name} (#{@type})\n" res << @comment.to_s res end @@ -200,7 +200,7 @@ module RDoc end def to_s - res = self.class.name + ": " + @name + "\n" + res = self.class.name + ": #{@name}\n" res << @comment.to_s res end @@ -225,7 +225,7 @@ module RDoc end def full_name - @type + "[" + @title + "]" + @type + "[#{@title}]" end def name @@ -233,7 +233,7 @@ module RDoc end def to_s - res = @type + "[" + @title + "]\n" + res = @type + "[#{@title}]\n" res << @comment.to_s res end diff --git a/lib/puppet/util/rdoc/generators/puppet_generator.rb b/lib/puppet/util/rdoc/generators/puppet_generator.rb index c32a401bd..f73b18dce 100644 --- a/lib/puppet/util/rdoc/generators/puppet_generator.rb +++ b/lib/puppet/util/rdoc/generators/puppet_generator.rb @@ -241,7 +241,7 @@ module Generators res2 = [] collection['methods'].sort.each do |f| if f.document_self - res2 << { "href" => "../"+f.path, "name" => f.index_name.sub(/\(.*\)$/,'') } + res2 << { "href" => "../#{f.path}", "name" => f.index_name.sub(/\(.*\)$/,'') } end end @@ -593,7 +593,7 @@ module Generators @values["parent"] = CGI.escapeHTML(parent_class) if parent_name - lookup = parent_name + "::" + parent_class + lookup = parent_name + "::#{parent_class}" else lookup = parent_class end @@ -839,7 +839,7 @@ module Generators def as_href(from_path) if @options.all_one_file - "#" + path + "##{path}" else HTMLGenerator.gen_url(from_path, path) end @@ -877,7 +877,7 @@ module Generators if @options.all_one_file aref else - @html_class.path + "#" + aref + @html_class.path + "##{aref}" end end diff --git a/lib/puppet/util/rdoc/parser.rb b/lib/puppet/util/rdoc/parser.rb index 9c86ec360..9d14ae6eb 100644 --- a/lib/puppet/util/rdoc/parser.rb +++ b/lib/puppet/util/rdoc/parser.rb @@ -31,7 +31,7 @@ class Parser # main entry point def scan - Puppet.info "rdoc: scanning %s" % @input_file_name + Puppet.info "rdoc: scanning #{@input_file_name}" if @input_file_name =~ /\.pp$/ @parser = Puppet::Parser::Parser.new(Puppet[:environment]) @parser.file = @input_file_name @@ -81,14 +81,14 @@ class Parser def split_module(path) # find a module fullpath = File.expand_path(path) - Puppet.debug "rdoc: testing %s" % fullpath + Puppet.debug "rdoc: testing #{fullpath}" if fullpath =~ /(.*)\/([^\/]+)\/(?:manifests|plugins|lib)\/.+\.(pp|rb)$/ modpath = $1 name = $2 - Puppet.debug "rdoc: module %s into %s ?" % [name, modpath] + Puppet.debug "rdoc: module #{name} into #{modpath} ?" Puppet::Module.modulepath().each do |mp| if File.identical?(modpath,mp) - Puppet.debug "rdoc: found module %s" % name + Puppet.debug "rdoc: found module #{name}" return name end end @@ -127,7 +127,7 @@ class Parser return end - Puppet.debug "rdoc: scanning for %s" % name + Puppet.debug "rdoc: scanning for #{name}" container.module_name = name container.global=true if name == "<site>" @@ -185,7 +185,7 @@ class Parser scan_for_vardef(container,stmt.children) if stmt.is_a?(Puppet::Parser::AST::ASTArray) if stmt.is_a?(Puppet::Parser::AST::VarDef) - Puppet.debug "rdoc: found constant: %s = %s" % [stmt.name.to_s, stmt.value.to_s] + Puppet.debug "rdoc: found constant: #{stmt.name} = #{stmt.value}" container.add_constant(Constant.new(stmt.name.to_s, stmt.value.to_s, stmt.doc)) end end @@ -202,7 +202,7 @@ class Parser begin type = stmt.type.split("::").collect { |s| s.capitalize }.join("::") title = stmt.title.is_a?(Puppet::Parser::AST::ASTArray) ? stmt.title.to_s.gsub(/\[(.*)\]/,'\1') : stmt.title.to_s - Puppet.debug "rdoc: found resource: %s[%s]" % [type,title] + Puppet.debug "rdoc: found resource: #{type}[#{title}]" param = [] stmt.params.children.each do |p| @@ -233,7 +233,7 @@ class Parser # create documentation for a class named +name+ def document_class(name, klass, container) - Puppet.debug "rdoc: found new class %s" % name + Puppet.debug "rdoc: found new class #{name}" container, name = get_class_or_module(container, name) superclass = klass.parent @@ -265,7 +265,7 @@ class Parser # create documentation for a node def document_node(name, node, container) - Puppet.debug "rdoc: found new node %s" % name + Puppet.debug "rdoc: found new node #{name}" superclass = node.parent superclass = "" if superclass.nil? or superclass.empty? @@ -290,7 +290,7 @@ class Parser # create documentation for a define def document_define(name, define, container) - Puppet.debug "rdoc: found new definition %s" % name + Puppet.debug "rdoc: found new definition #{name}" # find superclas if any @stats.num_methods += 1 @@ -308,7 +308,7 @@ class Parser when Puppet::Parser::AST::Leaf declaration << "'#{value.value}'" when Puppet::Parser::AST::ASTArray - declaration << "[%s]" % value.children.collect { |v| "'#{v}'" }.join(", ") + declaration << "[#{value.children.collect { |v| "'#{v}'" }.join(", ")}]" else declaration << "#{value.to_s}" end @@ -322,7 +322,7 @@ class Parser meth.comment = define.doc container.add_method(meth) look_for_directives_in(container, meth.comment) unless meth.comment.empty? - meth.params = "( " + declaration + " )" + meth.params = "( #{declaration} )" meth.visibility = :public meth.document_self = true meth.singleton = false @@ -386,7 +386,7 @@ class Parser container.add_fact(current_fact) current_fact.record_location(@top_level) comments = "" - Puppet.debug "rdoc: found custom fact %s" % current_fact.name + Puppet.debug "rdoc: found custom fact #{current_fact.name}" elsif line =~ /^[ \t]*confine[ \t]*:(.*?)[ \t]*=>[ \t]*(.*)$/ current_fact.confine = { :type => $1, :value => $2 } unless current_fact.nil? else # unknown line type @@ -414,7 +414,7 @@ class Parser current_plugin.comment = comments current_plugin.record_location(@top_level) comments = "" - Puppet.debug "rdoc: found new function plugins %s" % current_plugin.name + Puppet.debug "rdoc: found new function plugins #{current_plugin.name}" elsif line =~ /^[ \t]*Puppet::Type.newtype[ \t]*\([ \t]*:(.*?)\)/ current_plugin = Plugin.new($1, "type") container.add_plugin(current_plugin) @@ -422,7 +422,7 @@ class Parser current_plugin.comment = comments current_plugin.record_location(@top_level) comments = "" - Puppet.debug "rdoc: found new type plugins %s" % current_plugin.name + Puppet.debug "rdoc: found new type plugins #{current_plugin.name}" elsif line =~ /module Puppet::Parser::Functions/ # skip else # unknown line type diff --git a/lib/puppet/util/reference.rb b/lib/puppet/util/reference.rb index 74d75bb3f..c5bfe4722 100644 --- a/lib/puppet/util/reference.rb +++ b/lib/puppet/util/reference.rb @@ -11,7 +11,7 @@ class Puppet::Util::Reference instance_load(:reference, 'puppet/reference') def self.footer - "\n\n----------------\n\n*This page autogenerated on %s*\n" % Time.now + "\n\n----------------\n\n*This page autogenerated on #{Time.now}*\n" end def self.modes @@ -29,7 +29,7 @@ class Puppet::Util::Reference depth = 4 # Use the minimum depth sections.each do |name| - section = reference(name) or raise "Could not find section %s" % name + section = reference(name) or raise "Could not find section #{name}" depth = section.depth if section.depth < depth end text = ".. contents:: :depth: 2\n\n" @@ -69,9 +69,9 @@ class Puppet::Util::Reference def self.markdown(name, text) puts "Creating markdown for #{name} reference." - dir = "/tmp/" + Puppet::PUPPETVERSION + dir = "/tmp/#{Puppet::PUPPETVERSION}" FileUtils.mkdir(dir) unless File.directory?(dir) - Puppet::Util.secure_open(dir + "/" + "#{name}.rst", "w") do |f| + Puppet::Util.secure_open(dir + "/#{name}.rst", "w") do |f| f.puts text end pandoc = %x{which pandoc} @@ -90,7 +90,7 @@ class Puppet::Util::Reference exit(1) end - File.unlink(dir + "/" + "#{name}.rst") + File.unlink(dir + "/#{name}.rst") end def self.references @@ -105,7 +105,7 @@ class Puppet::Util::Reference def doc if defined?(@doc) - return "%s - %s" % [@name, @doc] + return "#{@name} - #{@doc}" else return @title end @@ -116,7 +116,7 @@ class Puppet::Util::Reference end def h(name, level) - return "%s\n%s\n\n" % [name, HEADER_LEVELS[level] * name.to_s.length] + return "#{name}\n#{HEADER_LEVELS[level] * name.to_s.length}\n\n" end def initialize(name, options = {}, &block) @@ -128,7 +128,7 @@ class Puppet::Util::Reference meta_def(:generate, &block) # Now handle the defaults - @title ||= "%s Reference" % @name.to_s.capitalize + @title ||= "#{@name.to_s.capitalize} Reference" @page ||= @title.gsub(/\s+/, '') @depth ||= 2 @header ||= "" @@ -140,12 +140,12 @@ class Puppet::Util::Reference end def option(name, value) - ":%s: %s\n" % [name.to_s.capitalize, value] + ":#{name.to_s.capitalize}: #{value}\n" end def paramwrap(name, text, options = {}) options[:level] ||= 5 - #str = "%s : " % name + #str = "#{name} : " str = h(name, options[:level]) if options[:namevar] str += "- **namevar**\n\n" @@ -171,7 +171,7 @@ class Puppet::Util::Reference text = h(@title, 1) text += "\n\n**This page is autogenerated; any changes will get overwritten** *(last generated on #{Time.now.to_s})*\n\n" if withcontents - text += ".. contents:: :depth: %s\n\n" % @depth + text += ".. contents:: :depth: #{@depth}\n\n" end text += @header @@ -198,7 +198,7 @@ class Puppet::Util::Reference f.puts self.to_trac end - puts "Writing %s reference to trac as %s" % [@name, @page] + puts "Writing #{@name} reference to trac as #{@page}" cmd = %{sudo trac-admin /opt/rl/trac/puppet wiki import %s /tmp/puppetdoc.txt} % self.page output = %x{#{cmd}} unless $CHILD_STATUS == 0 diff --git a/lib/puppet/util/resource_template.rb b/lib/puppet/util/resource_template.rb index 4e333571f..164d75ae3 100644 --- a/lib/puppet/util/resource_template.rb +++ b/lib/puppet/util/resource_template.rb @@ -44,7 +44,7 @@ class Puppet::Util::ResourceTemplate end def initialize(file, resource) - raise ArgumentError, "Template %s does not exist" % file unless FileTest.exist?(file) + raise ArgumentError, "Template #{file} does not exist" unless FileTest.exist?(file) @file = file @resource = resource end diff --git a/lib/puppet/util/selinux.rb b/lib/puppet/util/selinux.rb index 28752cfac..fad15d74e 100644 --- a/lib/puppet/util/selinux.rb +++ b/lib/puppet/util/selinux.rb @@ -125,7 +125,7 @@ module Puppet::Util::SELinux if retval == 0 return true else - Puppet.warning "Failed to set SELinux context %s on %s" % [context, file] + Puppet.warning "Failed to set SELinux context #{context} on #{file}" return false end end diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb index 3a823d30b..afec53a8a 100644 --- a/lib/puppet/util/settings.rb +++ b/lib/puppet/util/settings.rb @@ -100,7 +100,7 @@ class Puppet::Util::Settings elsif pval = self.value(varname) pval else - raise Puppet::DevError, "Could not find value for %s" % value + raise Puppet::DevError, "Could not find value for #{value}" end end @@ -220,7 +220,7 @@ class Puppet::Util::Settings hash[name] = val end hash.sort { |a,b| a[0].to_s <=> b[0].to_s }.each do |name, val| - puts "%s = %s" % [name, val] + puts "#{name} = #{val}" end else val.split(/\s*,\s*/).sort.each do |v| @@ -230,9 +230,9 @@ class Puppet::Util::Settings puts value(val,env) break end - puts "%s = %s" % [v, value(v,env)] + puts "#{v} = #{value(v,env)}" else - puts "invalid parameter: %s" % v + puts "invalid parameter: #{v}" return false end end @@ -382,7 +382,7 @@ class Puppet::Util::Settings end if type = hash[:type] unless klass = {:setting => Setting, :file => FileSetting, :boolean => BooleanSetting}[type] - raise ArgumentError, "Invalid setting type '%s'" % type + raise ArgumentError, "Invalid setting type '#{type}'" end hash.delete(:type) else @@ -394,7 +394,7 @@ class Puppet::Util::Settings when String, Integer, Float # nothing klass = Setting else - raise ArgumentError, "Invalid value '%s' for %s" % [hash[:default].inspect, hash[:name]] + raise ArgumentError, "Invalid value '#{hash[:default].inspect}' for #{hash[:name]}" end end hash[:settings] = self @@ -427,7 +427,7 @@ class Puppet::Util::Settings # Reparse our config file, if necessary. def reparse if file and file.changed? - Puppet.notice "Reparsing %s" % file.file + Puppet.notice "Reparsing #{file.file}" parse reuse() end @@ -501,7 +501,7 @@ class Puppet::Util::Settings return else raise ArgumentError, - "Attempt to assign a value to unknown configuration parameter %s" % param.inspect + "Attempt to assign a value to unknown configuration parameter #{param.inspect}" end end if setting.respond_to?(:munge) @@ -550,12 +550,12 @@ class Puppet::Util::Settings hash[:name] = name hash[:section] = section if @config.include?(name) - raise ArgumentError, "Parameter %s is already defined" % name + raise ArgumentError, "Parameter #{name} is already defined" end tryconfig = newsetting(hash) if short = tryconfig.short if other = @shortnames[short] - raise ArgumentError, "Parameter %s is already using short name '%s'" % [other.name, short] + raise ArgumentError, "Parameter #{other.name} is already using short name '#{short}'" end @shortnames[short] = tryconfig end @@ -612,7 +612,7 @@ Generated on #{Time.now}. # Add a section heading that matches our name. if @config.include?(:run_mode) - str += "[%s]\n" % self[:run_mode] + str += "[#{self[:run_mode]}]\n" end eachsection do |section| persection(section) do |obj| @@ -644,7 +644,7 @@ if @config.include?(:run_mode) catalog = to_catalog(*sections).to_ral rescue => detail puts detail.backtrace if Puppet[:trace] - Puppet.err "Could not create resources for managing Puppet's files and directories in sections %s: %s" % [sections.inspect, detail] + Puppet.err "Could not create resources for managing Puppet's files and directories in sections #{sections.inspect}: #{detail}" # We need some way to get rid of any resources created during the catalog creation # but not cleaned up. @@ -657,7 +657,7 @@ if @config.include?(:run_mode) if transaction.any_failed? report = transaction.report failures = report.logs.find_all { |log| log.level == :err } - raise "Got %s failure(s) while initializing: %s" % [failures.length, failures.collect { |l| l.to_s }.join("; ")] + raise "Got #{failures.length} failure(s) while initializing: #{failures.collect { |l| l.to_s }.join("; ")}" end end end @@ -769,14 +769,14 @@ if @config.include?(:run_mode) tmpfile = file + ".tmp" sync = Sync.new unless FileTest.directory?(File.dirname(tmpfile)) - raise Puppet::DevError, "Cannot create %s; directory %s does not exist" % [file, File.dirname(file)] + raise Puppet::DevError, "Cannot create #{file}; directory #{File.dirname(file)} does not exist" end sync.synchronize(Sync::EX) do File.open(file, ::File::CREAT|::File::RDWR, 0600) do |rf| rf.lock_exclusive do if File.exist?(tmpfile) - raise Puppet::Error, ".tmp file already exists for %s; Aborting locked write. Check the .tmp file and delete if appropriate" % [file] + raise Puppet::Error, ".tmp file already exists for #{file}; Aborting locked write. Check the .tmp file and delete if appropriate" end # If there's a failure, remove our tmpfile @@ -790,7 +790,7 @@ if @config.include?(:run_mode) begin File.rename(tmpfile, file) rescue => detail - Puppet.err "Could not rename %s to %s: %s" % [file, tmpfile, detail] + Puppet.err "Could not rename #{file} to #{tmpfile}: #{detail}" File.unlink(tmpfile) if FileTest.exist?(tmpfile) end end @@ -803,11 +803,11 @@ if @config.include?(:run_mode) def get_config_file_default(default) obj = nil unless obj = @config[default] - raise ArgumentError, "Unknown default %s" % default + raise ArgumentError, "Unknown default #{default}" end unless obj.is_a? FileSetting - raise ArgumentError, "Default %s is not a file" % default + raise ArgumentError, "Default #{default} is not a file" end return obj @@ -860,14 +860,14 @@ if @config.include?(:run_mode) param, value = $1.intern, $2 result[param] = value unless [:owner, :mode, :group].include?(param) - raise ArgumentError, "Invalid file option '%s'" % param + raise ArgumentError, "Invalid file option '#{param}'" end if param == :mode and value !~ /^\d+$/ raise ArgumentError, "File modes must be numbers" end else - raise ArgumentError, "Could not parse '%s'" % string + raise ArgumentError, "Could not parse '#{string}'" end end '' @@ -937,7 +937,7 @@ if @config.include?(:run_mode) raise end else - error = Puppet::Error.new("Could not match line %s" % line) + error = Puppet::Error.new("Could not match line #{line}") error.file = file error.line = line raise error @@ -952,9 +952,9 @@ if @config.include?(:run_mode) begin return File.read(file) rescue Errno::ENOENT - raise ArgumentError, "No such file %s" % file + raise ArgumentError, "No such file #{file}" rescue Errno::EACCES - raise ArgumentError, "Permission denied to file %s" % file + raise ArgumentError, "Permission denied to file #{file}" end end diff --git a/lib/puppet/util/settings/boolean_setting.rb b/lib/puppet/util/settings/boolean_setting.rb index aa365fd8e..67fce9ae3 100644 --- a/lib/puppet/util/settings/boolean_setting.rb +++ b/lib/puppet/util/settings/boolean_setting.rb @@ -24,7 +24,7 @@ class Puppet::Util::Settings::BooleanSetting < Puppet::Util::Settings::Setting when true, "true"; return true when false, "false"; return false else - raise ArgumentError, "Invalid value '%s' for %s" % [value.inspect, @name] + raise ArgumentError, "Invalid value '#{value.inspect}' for #{@name}" end end end diff --git a/lib/puppet/util/settings/file_setting.rb b/lib/puppet/util/settings/file_setting.rb index 815bdcf52..bbb388bd6 100644 --- a/lib/puppet/util/settings/file_setting.rb +++ b/lib/puppet/util/settings/file_setting.rb @@ -17,7 +17,7 @@ class Puppet::Util::Settings::FileSetting < Puppet::Util::Settings::Setting def group=(value) unless AllowedGroups.include?(value) identifying_fields = [desc,name,default].compact.join(': ') - raise SettingError, "Internal error: The :group setting for %s must be 'service', not '%s'" % [identifying_fields,value] + raise SettingError, "Internal error: The :group setting for #{identifying_fields} must be 'service', not '#{value}'" end @group = value end @@ -30,7 +30,7 @@ class Puppet::Util::Settings::FileSetting < Puppet::Util::Settings::Setting def owner=(value) unless AllowedOwners.include?(value) identifying_fields = [desc,name,default].compact.join(': ') - raise SettingError, "Internal error: The :owner setting for %s must be either 'root' or 'service', not '%s'" % [identifying_fields,value] + raise SettingError, "Internal error: The :owner setting for #{identifying_fields} must be either 'root' or 'service', not '#{value}'" end @owner = value end @@ -115,7 +115,7 @@ class Puppet::Util::Settings::FileSetting < Puppet::Util::Settings::Setting name = $1 unless @settings.include?(name) raise ArgumentError, - "Settings parameter '%s' is undefined" % name + "Settings parameter '#{name}' is undefined" end } end diff --git a/lib/puppet/util/settings/setting.rb b/lib/puppet/util/settings/setting.rb index 489dfd01d..6f8e39209 100644 --- a/lib/puppet/util/settings/setting.rb +++ b/lib/puppet/util/settings/setting.rb @@ -38,14 +38,14 @@ class Puppet::Util::Settings::Setting args.each do |param, value| method = param.to_s + "=" unless self.respond_to? method - raise ArgumentError, "%s does not accept %s" % [self.class, param] + raise ArgumentError, "#{self.class} does not accept #{param}" end self.send(method, value) end unless self.desc - raise ArgumentError, "You must provide a description for the %s config option" % self.name + raise ArgumentError, "You must provide a description for the #{self.name} config option" end end @@ -83,7 +83,7 @@ class Puppet::Util::Settings::Setting # Add in a statement about the default. if defined?(@default) and @default - str += "# The default value is '%s'.\n" % @default + str += "# The default value is '#{@default}'.\n" end # If the value has not been overridden, then print it out commented @@ -92,9 +92,9 @@ class Puppet::Util::Settings::Setting value = @settings.value(self.name) if value != @default - line = "%s = %s" % [@name, value] + line = "#{@name} = #{value}" else - line = "# %s = %s" % [@name, @default] + line = "# #{@name} = #{@default}" end str += line + "\n" diff --git a/lib/puppet/util/storage.rb b/lib/puppet/util/storage.rb index 076952c1d..974d56f56 100644 --- a/lib/puppet/util/storage.rb +++ b/lib/puppet/util/storage.rb @@ -53,7 +53,7 @@ class Puppet::Util::Storage return end unless File.file?(Puppet[:statefile]) - Puppet.warning("Checksumfile %s is not a file, ignoring" % Puppet[:statefile]) + Puppet.warning("Checksumfile #{Puppet[:statefile]} is not a file, ignoring") return end Puppet::Util.benchmark(:debug, "Loaded state") do @@ -61,12 +61,12 @@ class Puppet::Util::Storage begin @@state = YAML.load(file) rescue => detail - Puppet.err "Checksumfile %s is corrupt (%s); replacing" % [Puppet[:statefile], detail] + Puppet.err "Checksumfile #{Puppet[:statefile]} is corrupt (#{detail}); replacing" begin File.rename(Puppet[:statefile], Puppet[:statefile] + ".bad") rescue raise Puppet::Error, - "Could not rename corrupt %s; remove manually" % Puppet[:statefile] + "Could not rename corrupt #{Puppet[:statefile]}; remove manually" end end end @@ -77,7 +77,7 @@ class Puppet::Util::Storage self.init end - #Puppet.debug "Loaded state is %s" % @@state.inspect + #Puppet.debug "Loaded state is #{@@state.inspect}" end def self.stateinspect @@ -88,7 +88,7 @@ class Puppet::Util::Storage Puppet.debug "Storing state" unless FileTest.exist?(Puppet[:statefile]) - Puppet.info "Creating state file %s" % Puppet[:statefile] + Puppet.info "Creating state file #{Puppet[:statefile]}" end Puppet::Util.benchmark(:debug, "Stored state") do diff --git a/lib/puppet/util/suidmanager.rb b/lib/puppet/util/suidmanager.rb index 404f78890..c6b5e3c89 100644 --- a/lib/puppet/util/suidmanager.rb +++ b/lib/puppet/util/suidmanager.rb @@ -71,10 +71,10 @@ module Puppet::Util::SUIDManager # Make sure the passed argument is a number. def convert_xid(type, id) map = {:gid => :group, :uid => :user} - raise ArgumentError, "Invalid id type %s" % type unless map.include?(type) + raise ArgumentError, "Invalid id type #{type}" unless map.include?(type) ret = Puppet::Util.send(type, id) if ret == nil - raise Puppet::Error, "Invalid %s: %s" % [map[type], id] + raise Puppet::Error, "Invalid #{map[type]}: #{id}" end return ret end diff --git a/lib/puppet/util/tagging.rb b/lib/puppet/util/tagging.rb index 9ee90799f..51cff9520 100644 --- a/lib/puppet/util/tagging.rb +++ b/lib/puppet/util/tagging.rb @@ -11,7 +11,7 @@ module Puppet::Util::Tagging qualified = [] ary.collect { |tag| tag.to_s.downcase }.each do |tag| - fail(Puppet::ParseError, "Invalid tag %s" % tag.inspect) unless valid_tag?(tag) + fail(Puppet::ParseError, "Invalid tag #{tag.inspect}") unless valid_tag?(tag) qualified << tag if tag.include?("::") @tags << tag unless @tags.include?(tag) end diff --git a/spec/integration/indirector/direct_file_server_spec.rb b/spec/integration/indirector/direct_file_server_spec.rb index 9843c7e65..d2b933cd5 100755 --- a/spec/integration/indirector/direct_file_server_spec.rb +++ b/spec/integration/indirector/direct_file_server_spec.rb @@ -45,11 +45,11 @@ describe Puppet::Indirector::DirectFileServer, " when interacting with FileServi File.open(File.join(@path, "one"), "w") { |f| f.print "one content" } File.open(File.join(@path, "two"), "w") { |f| f.print "two content" } - @request = @terminus.indirection.request(:search, "file:///%s" % @path, :recurse => true) + @request = @terminus.indirection.request(:search, "file:///#{@path}", :recurse => true) end after do - system("rm -rf %s" % @path) + system("rm -rf #{@path}") end it "should return an instance for every file in the fileset" do @@ -66,7 +66,7 @@ describe Puppet::Indirector::DirectFileServer, " when interacting with FileServi when /two/; instance.content.should == "two content" when @path else - raise "No valid key for %s" % instance.path.inspect + raise "No valid key for #{instance.path.inspect}" end end end diff --git a/spec/integration/network/server/webrick_spec.rb b/spec/integration/network/server/webrick_spec.rb index cd2958346..50994f119 100755 --- a/spec/integration/network/server/webrick_spec.rb +++ b/spec/integration/network/server/webrick_spec.rb @@ -29,7 +29,7 @@ describe Puppet::Network::Server do @tmpfile.delete Puppet.settings.clear - system("rm -rf %s" % @dir) + system("rm -rf #{@dir}") Puppet::Util::Cacher.expire end diff --git a/spec/integration/provider/package_spec.rb b/spec/integration/provider/package_spec.rb index 24a196266..6c854fb3e 100755 --- a/spec/integration/provider/package_spec.rb +++ b/spec/integration/provider/package_spec.rb @@ -7,11 +7,11 @@ describe "Package Provider" do provider = Puppet::Type.type(:package).provider(name) describe name do - confine "Provider %s is not suitable" % name => provider.suitable? + confine "Provider #{name} is not suitable" => provider.suitable? it "should fail when asked to install an invalid package" do pending("This test hangs forever with recent versions of RubyGems") if provider.name == :gem - pkg = Puppet::Type.newpackage :name => "nosuch%s" % provider.name.to_s, :provider => provider.name + pkg = Puppet::Type.newpackage :name => "nosuch#{provider.name}", :provider => provider.name lambda { pkg.provider.install }.should raise_error end diff --git a/spec/integration/ssl/certificate_authority_spec.rb b/spec/integration/ssl/certificate_authority_spec.rb index 349e5cb81..5fcbed89e 100755 --- a/spec/integration/ssl/certificate_authority_spec.rb +++ b/spec/integration/ssl/certificate_authority_spec.rb @@ -25,7 +25,7 @@ describe Puppet::SSL::CertificateAuthority do after { Puppet::SSL::Host.ca_location = :none - system("rm -rf %s" % @dir) + system("rm -rf #{@dir}") Puppet.settings.clear Puppet::Util::Cacher.expire diff --git a/spec/integration/ssl/certificate_request_spec.rb b/spec/integration/ssl/certificate_request_spec.rb index 1a7241fa5..5266ba606 100755 --- a/spec/integration/ssl/certificate_request_spec.rb +++ b/spec/integration/ssl/certificate_request_spec.rb @@ -30,7 +30,7 @@ describe Puppet::SSL::CertificateRequest do end after do - system("rm -rf %s" % @dir) + system("rm -rf #{@dir}") Puppet.settings.clear # This is necessary so the terminus instances don't lie around. diff --git a/spec/integration/ssl/certificate_revocation_list_spec.rb b/spec/integration/ssl/certificate_revocation_list_spec.rb index be1a5f4a1..6328ae420 100755 --- a/spec/integration/ssl/certificate_revocation_list_spec.rb +++ b/spec/integration/ssl/certificate_revocation_list_spec.rb @@ -24,7 +24,7 @@ describe Puppet::SSL::CertificateRevocationList do after { Puppet::SSL::Host.ca_location = :none - system("rm -rf %s" % @dir) + system("rm -rf #{@dir}") Puppet.settings.clear # This is necessary so the terminus instances don't lie around. diff --git a/spec/integration/ssl/host_spec.rb b/spec/integration/ssl/host_spec.rb index d5e1396c5..5f2f1e5a4 100755 --- a/spec/integration/ssl/host_spec.rb +++ b/spec/integration/ssl/host_spec.rb @@ -27,7 +27,7 @@ describe Puppet::SSL::Host do after { Puppet::SSL::Host.ca_location = :none - system("rm -rf %s" % @dir) + system("rm -rf #{@dir}") Puppet.settings.clear Puppet::Util::Cacher.expire } diff --git a/spec/integration/transaction_spec.rb b/spec/integration/transaction_spec.rb index 57dd490dd..5b6cd52cb 100755 --- a/spec/integration/transaction_spec.rb +++ b/spec/integration/transaction_spec.rb @@ -117,7 +117,7 @@ describe Puppet::Transaction do exec1 = Puppet::Type.type(:exec).new( :path => ENV["PATH"], - :command => "touch %s" % file1, + :command => "touch #{file1}", :refreshonly => true, :subscribe => Puppet::Resource.new(:file, path) @@ -126,7 +126,7 @@ describe Puppet::Transaction do exec2 = Puppet::Type.type(:exec).new( :path => ENV["PATH"], - :command => "touch %s" % file2, + :command => "touch #{file2}", :refreshonly => true, :subscribe => Puppet::Resource.new(:file, path) @@ -163,7 +163,7 @@ describe Puppet::Transaction do exec2 = Puppet::Type.type(:exec).new( :path => ENV["PATH"], - :command => "touch %s" % newfile, + :command => "touch #{newfile}", :logoutput => true, :refreshonly => true, :subscribe => [file, exec1], diff --git a/spec/integration/type/file_spec.rb b/spec/integration/type/file_spec.rb index e16da67cc..8ecf42b6f 100755 --- a/spec/integration/type/file_spec.rb +++ b/spec/integration/type/file_spec.rb @@ -164,7 +164,7 @@ describe Puppet::Type.type(:file) do %w{three}.each do |file| ffile = File.join(fdir, file) @files << ffile - File.open(ffile, "w") { |f| f.puts "test %s" % file } + File.open(ffile, "w") { |f| f.puts "test #{file}" } File.chmod(0640, ffile) end end diff --git a/spec/integration/type/package_spec.rb b/spec/integration/type/package_spec.rb index bf78d2987..4ba928559 100755 --- a/spec/integration/type/package_spec.rb +++ b/spec/integration/type/package_spec.rb @@ -18,7 +18,7 @@ describe Puppet::Type.type(:package), "when choosing a default package provider" it "should choose the correct provider each platform" do unless default_provider = provider_name(Facter.value(:operatingsystem)) - pending("No default provider specified in this test for %s" % Facter.value(:operatingsystem)) + pending("No default provider specified in this test for #{Facter.value(:operatingsystem)}") end Puppet::Type.type(:package).defaultprovider.name.should == default_provider end diff --git a/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb b/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb index 889919ee0..30e73aba7 100644 --- a/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb +++ b/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb @@ -16,7 +16,7 @@ module Spec success = true example_groups.each do |example_group| unless example_group.runnable? - warn "Skipping unsuitable example group %s: %s" % [example_group.description, example_group.messages.join(", ")] + warn "Skipping unsuitable example group #{example_group.description}: #{example_group.messages.join(", ")}" next end success = success & example_group.run(@options) diff --git a/spec/unit/daemon_spec.rb b/spec/unit/daemon_spec.rb index e163f4067..a4fa64489 100755 --- a/spec/unit/daemon_spec.rb +++ b/spec/unit/daemon_spec.rb @@ -298,7 +298,7 @@ describe Puppet::Daemon do it "should call 'exec' with the original executable and arguments" do @daemon.argv = %w{foo} - @daemon.expects(:exec).with($0 + " " + "foo") + @daemon.expects(:exec).with($0 + " foo") @daemon.reexec end diff --git a/spec/unit/file_collection_spec.rb b/spec/unit/file_collection_spec.rb index 81bcc2d2d..5e8e2ec08 100755 --- a/spec/unit/file_collection_spec.rb +++ b/spec/unit/file_collection_spec.rb @@ -29,12 +29,12 @@ describe Puppet::FileCollection do it "should always correctly relate a file name and its index even when multiple files are in the collection" do indexes = %w{a b c d e f}.inject({}) do |hash, letter| - hash[letter] = @collection.index("/path/to/file/%s" % letter) + hash[letter] = @collection.index("/path/to/file/#{letter}") hash end indexes.each do |letter, index| - @collection.index("/path/to/file/%s" % letter).should == indexes[letter] + @collection.index("/path/to/file/#{letter}").should == indexes[letter] @collection.path(index).should == @collection.path(index) end end diff --git a/spec/unit/file_serving/metadata_spec.rb b/spec/unit/file_serving/metadata_spec.rb index 0e2e71284..a55396577 100755 --- a/spec/unit/file_serving/metadata_spec.rb +++ b/spec/unit/file_serving/metadata_spec.rb @@ -170,12 +170,12 @@ describe Puppet::FileServing::Metadata, " when collecting attributes" do end it "should set the checksum to the file's current checksum" do - @metadata.checksum.should == "{md5}" + @checksum + @metadata.checksum.should == "{md5}#{@checksum}" end describe "when managing files" do it "should default to a checksum of type MD5" do - @metadata.checksum.should == "{md5}" + @checksum + @metadata.checksum.should == "{md5}#{@checksum}" end it "should give a mtime checksum when checksum_type is set" do @@ -183,7 +183,7 @@ describe Puppet::FileServing::Metadata, " when collecting attributes" do @metadata.checksum_type = "mtime" @metadata.expects(:mtime_file).returns(@time) @metadata.collect - @metadata.checksum.should == "{mtime}" + @time.to_s + @metadata.checksum.should == "{mtime}#{@time}" end it "should produce tab-separated mode, type, owner, group, and checksum for xmlrpc" do @@ -200,14 +200,14 @@ describe Puppet::FileServing::Metadata, " when collecting attributes" do it "should only use checksums of type 'ctime' for directories" do @metadata.collect - @metadata.checksum.should == "{ctime}" + @time.to_s + @metadata.checksum.should == "{ctime}#{@time}" end it "should only use checksums of type 'ctime' for directories even if checksum_type set" do @metadata.checksum_type = "mtime" @metadata.expects(:mtime_file).never @metadata.collect - @metadata.checksum.should == "{ctime}" + @time.to_s + @metadata.checksum.should == "{ctime}#{@time}" end it "should produce tab-separated mode, type, owner, group, and checksum for xmlrpc" do diff --git a/spec/unit/indirector/facts/facter_spec.rb b/spec/unit/indirector/facts/facter_spec.rb index 8f39badb1..2b127ad34 100755 --- a/spec/unit/indirector/facts/facter_spec.rb +++ b/spec/unit/indirector/facts/facter_spec.rb @@ -114,7 +114,7 @@ describe Puppet::Node::Facts::Facter do describe Puppet::Node::Facts::Facter, "when loading fact plugins from disk" do it "should load each directory in the Fact path" do Puppet.settings.stubs(:value).returns "foo" - Puppet.settings.expects(:value).with(:factpath).returns("one%stwo" % File::PATH_SEPARATOR) + Puppet.settings.expects(:value).with(:factpath).returns("one#{File::PATH_SEPARATOR}two") Puppet::Node::Facts::Facter.expects(:load_facts_in_dir).with("one") Puppet::Node::Facts::Facter.expects(:load_facts_in_dir).with("two") @@ -126,7 +126,7 @@ describe Puppet::Node::Facts::Facter do Puppet.settings.stubs(:value).returns "foo" Puppet::Node::Facts::Facter.stubs(:load_facts_in_dir) - Puppet.settings.expects(:value).with(:modulepath).returns("one%stwo" % File::PATH_SEPARATOR) + Puppet.settings.expects(:value).with(:modulepath).returns("one#{File::PATH_SEPARATOR}two") Dir.stubs(:glob).returns [] Dir.expects(:glob).with("one/*/lib/facter").returns %w{oneA oneB} diff --git a/spec/unit/indirector/ssl_file_spec.rb b/spec/unit/indirector/ssl_file_spec.rb index 8f46409fe..02c7fcf0c 100755 --- a/spec/unit/indirector/ssl_file_spec.rb +++ b/spec/unit/indirector/ssl_file_spec.rb @@ -53,7 +53,7 @@ describe Puppet::Indirector::SslFile do @searcher = @file_class.new @cert = stub 'certificate', :name => "myname" - @certpath = File.join(@path, "myname" + ".pem") + @certpath = File.join(@path, "myname.pem") @request = stub 'request', :key => @cert.name, :instance => @cert end diff --git a/spec/unit/module_spec.rb b/spec/unit/module_spec.rb index fcc5e60b5..910f74b9e 100755 --- a/spec/unit/module_spec.rb +++ b/spec/unit/module_spec.rb @@ -402,7 +402,7 @@ describe Puppet::Module, "when finding matching manifests" do @mod = Puppet::Module.new("mymod") @mod.stubs(:path).returns "/a" @pq_glob_with_extension = "yay/*.xx" - @fq_glob_with_extension = "/a/manifests/" + @pq_glob_with_extension + @fq_glob_with_extension = "/a/manifests/#{@pq_glob_with_extension}" end it "should return all manifests matching the glob pattern" do diff --git a/spec/unit/parser/compiler_spec.rb b/spec/unit/parser/compiler_spec.rb index 31dc196ef..872cd7961 100755 --- a/spec/unit/parser/compiler_spec.rb +++ b/spec/unit/parser/compiler_spec.rb @@ -16,7 +16,7 @@ class CompilerTestResource end def ref - "%s[%s]" % [type.to_s.capitalize, title] + "#{type.to_s.capitalize}[#{title}]" end def evaluated? diff --git a/spec/unit/parser/functions/generate_spec.rb b/spec/unit/parser/functions/generate_spec.rb index 05c2cb7dc..75a5d6dac 100755 --- a/spec/unit/parser/functions/generate_spec.rb +++ b/spec/unit/parser/functions/generate_spec.rb @@ -28,7 +28,7 @@ describe "the generate function" do it "should not accept a command containing illegal characters" it "should not accept a command containing '..'" do - command = File::SEPARATOR + "command" + File::SEPARATOR + ".." + File::SEPARATOR + command = File::SEPARATOR + "command#{File::SEPARATOR}..#{File::SEPARATOR}" lambda { @scope.function_generate([command]) }.should raise_error(Puppet::ParseError) end diff --git a/spec/unit/parser/scope_spec.rb b/spec/unit/parser/scope_spec.rb index 94192a693..c394282ca 100755 --- a/spec/unit/parser/scope_spec.rb +++ b/spec/unit/parser/scope_spec.rb @@ -471,7 +471,7 @@ describe Puppet::Parser::Scope do # #523 %w{d f h l w z}.each do |l| it "should parse '#{l}' when escaped" do - string = "\\" + l + string = "\\#{l}" @scope.strinterp(string).should == string end end @@ -494,12 +494,12 @@ describe Puppet::Parser::Scope do klass = parser.newclass(name) Puppet::Parser::Resource.new(:type => "class", :title => name, :scope => scope, :source => mock('source')).evaluate scopes[name] = scope.class_scope(klass) - scopes[name].setvar("test", "value-%s" % name.sub(/.+::/,'')) + scopes[name].setvar("test", "value-#{name.sub(/.+::/,'')}") end assert_equal("value", scope.lookupvar("::test"), "did not look up qualified value correctly") tests.each do |input, output| - assert_nothing_raised("Failed to scan %s" % input.inspect) do + assert_nothing_raised("Failed to scan #{input.inspect}") do assert_equal(output, scope.strinterp(input), 'did not parserret %s correctly' % input.inspect) end end @@ -510,7 +510,7 @@ describe Puppet::Parser::Scope do # #523 %w{d f h l w z}.each do |l| - string = "\\" + l + string = "\\#{l}" assert_nothing_raised do assert_equal( @@ -523,7 +523,7 @@ describe Puppet::Parser::Scope do assert( logs.detect { |m| m.message =~ /Unrecognised escape/ }, - "Did not get warning about escape sequence with %s" % string) + "Did not get warning about escape sequence with #{string}") logs.clear end end diff --git a/spec/unit/provider/mount/parsed_spec.rb b/spec/unit/provider/mount/parsed_spec.rb index 4dc33708e..4db167e23 100755 --- a/spec/unit/provider/mount/parsed_spec.rb +++ b/spec/unit/provider/mount/parsed_spec.rb @@ -35,13 +35,13 @@ module ParsedMountTesting @pcount = 1 end args = { - :name => "/fspuppet%s" % @pcount, - :device => "/dev/dsk%s" % @pcount, + :name => "/fspuppet#{@pcount}", + :device => "/dev/dsk#{@pcount}", } @provider_class.fields(:parsed).each do |field| unless args.include? field - args[field] = "fake%s%s" % [field, @pcount] + args[field] = "fake#{field}#{@pcount}" end end diff --git a/spec/unit/provider/zpool/solaris_spec.rb b/spec/unit/provider/zpool/solaris_spec.rb index fc8336f32..b52ddf8f5 100755 --- a/spec/unit/provider/zpool/solaris_spec.rb +++ b/spec/unit/provider/zpool/solaris_spec.rb @@ -102,8 +102,8 @@ describe provider_class do describe "when calling the getters and setters" do [:disk, :mirror, :raidz, :log, :spare].each do |field| - describe "when calling %s" % field do - it "should get the %s value from the current_pool hash" % field do + describe "when calling #{field}" do + it "should get the #{field} value from the current_pool hash" do pool_hash = mock "pool hash" pool_hash.expects(:[]).with(field) @provider.stubs(:current_pool).returns(pool_hash) @@ -111,9 +111,9 @@ describe provider_class do end end - describe "when setting the %s" % field do - it "should warn the %s values were not in sync" % field do - Puppet.expects(:warning).with("NO CHANGES BEING MADE: zpool %s does not match, should be 'shouldvalue' currently is 'currentvalue'" % field) + describe "when setting the #{field}" do + it "should warn the #{field} values were not in sync" do + Puppet.expects(:warning).with("NO CHANGES BEING MADE: zpool #{field} does not match, should be 'shouldvalue' currently is 'currentvalue'") @provider.stubs(:current_pool).returns(Hash.new("currentvalue")) @provider.send((field.to_s + "=").intern, "shouldvalue") end diff --git a/spec/unit/resource/type_collection_spec.rb b/spec/unit/resource/type_collection_spec.rb index c0711bb87..9a7c80e76 100644 --- a/spec/unit/resource/type_collection_spec.rb +++ b/spec/unit/resource/type_collection_spec.rb @@ -140,7 +140,7 @@ describe Puppet::Resource::TypeCollection do end it "should have a method for adding a #{data}" do - Puppet::Resource::TypeCollection.new("env").should respond_to("add_" + data) + Puppet::Resource::TypeCollection.new("env").should respond_to("add_#{data}") end it "should use the name of the instance to add it" do diff --git a/spec/unit/type/augeas_spec.rb b/spec/unit/type/augeas_spec.rb index b71f55f26..ace94109a 100644 --- a/spec/unit/type/augeas_spec.rb +++ b/spec/unit/type/augeas_spec.rb @@ -40,21 +40,21 @@ describe augeas do params = [:name, :context, :onlyif, :changes, :root, :load_path, :type_check] properties.each do |property| - it "should have a %s property" % property do + it "should have a #{property} property" do augeas.attrclass(property).ancestors.should be_include(Puppet::Property) end - it "should have documentation for its %s property" % property do + it "should have documentation for its #{property} property" do augeas.attrclass(property).doc.should be_instance_of(String) end end params.each do |param| - it "should have a %s parameter" % param do + it "should have a #{param} parameter" do augeas.attrclass(param).ancestors.should be_include(Puppet::Parameter) end - it "should have documentation for its %s parameter" % param do + it "should have documentation for its #{param} parameter" do augeas.attrclass(param).doc.should be_instance_of(String) end end diff --git a/spec/unit/type/computer_spec.rb b/spec/unit/type/computer_spec.rb index 7522b9599..b1a6bfe1b 100755 --- a/spec/unit/type/computer_spec.rb +++ b/spec/unit/type/computer_spec.rb @@ -29,11 +29,11 @@ describe Puppet::Type.type(:computer), " when checking computer objects" do params = [:name] properties.each do |property| - it "should have a %s property" % property do + it "should have a #{property} property" do computer.attrclass(property).ancestors.should be_include(Puppet::Property) end - it "should have documentation for its %s property" % property do + it "should have documentation for its #{property} property" do computer.attrclass(property).doc.should be_instance_of(String) end @@ -45,11 +45,11 @@ describe Puppet::Type.type(:computer), " when checking computer objects" do end params.each do |param| - it "should have a %s parameter" % param do + it "should have a #{param} parameter" do computer.attrclass(param).ancestors.should be_include(Puppet::Parameter) end - it "should have documentation for its %s parameter" % param do + it "should have documentation for its #{param} parameter" do computer.attrclass(param).doc.should be_instance_of(String) end end diff --git a/spec/unit/type/file/content_spec.rb b/spec/unit/type/file/content_spec.rb index a07fcba2f..295f21285 100755 --- a/spec/unit/type/file/content_spec.rb +++ b/spec/unit/type/file/content_spec.rb @@ -119,7 +119,7 @@ describe content do time = Time.now @resource.parameter(:checksum).expects(:mtime_file).with(@resource[:path]).returns time - @content.retrieve.should == "{mtime}%s" % time + @content.retrieve.should == "{mtime}#{time}" end it "should return the checksum of the file if it exists and is a normal file" do diff --git a/spec/unit/type/macauthorization_spec.rb b/spec/unit/type/macauthorization_spec.rb index cc9f6783b..c5305d522 100755 --- a/spec/unit/type/macauthorization_spec.rb +++ b/spec/unit/type/macauthorization_spec.rb @@ -24,21 +24,21 @@ describe Puppet::Type.type(:macauthorization), "when checking macauthorization o :session_owner, :shared, :timeout, :tries] parameters.each do |parameter| - it "should have a %s parameter" % parameter do + it "should have a #{parameter} parameter" do macauth_type.attrclass(parameter).ancestors.should be_include(Puppet::Parameter) end - it "should have documentation for its %s parameter" % parameter do + it "should have documentation for its #{parameter} parameter" do macauth_type.attrclass(parameter).doc.should be_instance_of(String) end end properties.each do |property| - it "should have a %s property" % property do + it "should have a #{property} property" do macauth_type.attrclass(property).ancestors.should be_include(Puppet::Property) end - it "should have documentation for its %s property" % property do + it "should have documentation for its #{property} property" do macauth_type.attrclass(property).doc.should be_instance_of(String) end end diff --git a/spec/unit/type/nagios_spec.rb b/spec/unit/type/nagios_spec.rb index 2c26d3a77..bb891e641 100755 --- a/spec/unit/type/nagios_spec.rb +++ b/spec/unit/type/nagios_spec.rb @@ -6,7 +6,7 @@ require 'puppet/external/nagios' describe "Nagios resource types" do Nagios::Base.eachtype do |name, nagios_type| - puppet_type = Puppet::Type.type("nagios_" + name.to_s) + puppet_type = Puppet::Type.type("nagios_#{name}") it "should have a valid type for #{name}" do puppet_type.should_not be_nil @@ -23,11 +23,11 @@ describe "Nagios resource types" do puppet_type.instance_variable_get("@doc").should_not == "" end - it "should have %s as its key attribute" % nagios_type.namevar do + it "should have #{nagios_type.namevar} as its key attribute" do puppet_type.key_attributes.should == [nagios_type.namevar] end - it "should have documentation for its %s parameter" % nagios_type.namevar do + it "should have documentation for its #{nagios_type.namevar} parameter" do puppet_type.attrclass(nagios_type.namevar).instance_variable_get("@doc").should_not be_nil end @@ -44,17 +44,17 @@ describe "Nagios resource types" do end nagios_type.parameters.reject { |param| param == nagios_type.namevar or param.to_s =~ /^[0-9]/ }.each do |param| - it "should have a %s property" % param do + it "should have a #{param} property" do puppet_type.should be_validproperty(param) end - it "should have documentation for its %s property" % param do + it "should have documentation for its #{param} property" do puppet_type.attrclass(param).instance_variable_get("@doc").should_not be_nil end end nagios_type.parameters.find_all { |param| param.to_s =~ /^[0-9]/ }.each do |param| - it "should have not have a %s property" % param do + it "should have not have a #{param} property" do puppet_type.should_not be_validproperty(:param) end end diff --git a/spec/unit/type/schedule_spec.rb b/spec/unit/type/schedule_spec.rb index c81930873..0a1365492 100755 --- a/spec/unit/type/schedule_spec.rb +++ b/spec/unit/type/schedule_spec.rb @@ -86,17 +86,17 @@ describe Puppet::Type.type(:schedule) do include ScheduleTesting it "should match when the start time is before the current time and the end time is after the current time" do - @schedule[:range] = "%s - %s" % [format(Time.now - 10), format(Time.now + 10)] + @schedule[:range] = "#{format(Time.now - 10)} - #{format(Time.now + 10)}" @schedule.match?.should be_true end it "should not match when the start time is after the current time" do - @schedule[:range] = "%s - %s" % [format(Time.now + 5), format(Time.now + 10)] + @schedule[:range] = "#{format(Time.now + 5)} - #{format(Time.now + 10)}" @schedule.match?.should be_false end it "should not match when the end time is previous to the current time" do - @schedule[:range] = "%s - %s" % [format(Time.now - 10), format(Time.now - 5)] + @schedule[:range] = "#{format(Time.now - 10)} - #{format(Time.now - 5)}" @schedule.match?.should be_false end end diff --git a/spec/unit/type/tidy_spec.rb b/spec/unit/type/tidy_spec.rb index 1b2f49798..f39ccb572 100755 --- a/spec/unit/type/tidy_spec.rb +++ b/spec/unit/type/tidy_spec.rb @@ -23,11 +23,11 @@ describe tidy do end [:age, :size, :path, :matches, :type, :recurse, :rmdirs].each do |param| - it "should have a %s parameter" % param do + it "should have a #{param} parameter" do Puppet::Type.type(:tidy).attrclass(param).ancestors.should be_include(Puppet::Parameter) end - it "should have documentation for its %s param" % param do + it "should have documentation for its #{param} param" do Puppet::Type.type(:tidy).attrclass(param).doc.should be_instance_of(String) end end @@ -97,8 +97,8 @@ describe tidy do convertors[:week] = convertors[:day] * 7 convertors.each do |unit, multiple| - it "should consider a %s to be %s seconds" % [unit, multiple] do - @tidy = Puppet::Type.type(:tidy).new :path => @basepath, :age => "5%s" % unit.to_s[0..0] + it "should consider a #{unit} to be #{multiple} seconds" do + @tidy = Puppet::Type.type(:tidy).new :path => @basepath, :age => "5#{unit.to_s[0..0]}" @tidy[:age].should == 5 * multiple end @@ -114,8 +114,8 @@ describe tidy do } convertors.each do |unit, multiple| - it "should consider a %s to be 1024^%s bytes" % [unit, multiple] do - @tidy = Puppet::Type.type(:tidy).new :path => @basepath, :size => "5%s" % unit + it "should consider a #{unit} to be 1024^#{multiple} bytes" do + @tidy = Puppet::Type.type(:tidy).new :path => @basepath, :size => "5#{unit}" total = 5 multiple.times { total *= 1024 } diff --git a/spec/unit/type/user_spec.rb b/spec/unit/type/user_spec.rb index 590b35a94..5a43c9595 100755 --- a/spec/unit/type/user_spec.rb +++ b/spec/unit/type/user_spec.rb @@ -52,11 +52,11 @@ describe user do properties = [:ensure, :uid, :gid, :home, :comment, :shell, :password, :groups, :roles, :auths, :profiles, :project, :keys] properties.each do |property| - it "should have a %s property" % property do + it "should have a #{property} property" do user.attrclass(property).ancestors.should be_include(Puppet::Property) end - it "should have documentation for its %s property" % property do + it "should have documentation for its #{property} property" do user.attrclass(property).doc.should be_instance_of(String) end end @@ -64,7 +64,7 @@ describe user do list_properties = [:groups, :roles, :auths] list_properties.each do |property| - it "should have a list '%s'" % property do + it "should have a list '#{property}'" do user.attrclass(property).ancestors.should be_include(Puppet::Property::List) end end diff --git a/spec/unit/type/zfs_spec.rb b/spec/unit/type/zfs_spec.rb index e1af6821a..7c12a84fb 100755 --- a/spec/unit/type/zfs_spec.rb +++ b/spec/unit/type/zfs_spec.rb @@ -8,7 +8,7 @@ describe zfs do properties = [:ensure, :mountpoint, :compression, :copies, :quota, :reservation, :sharenfs, :snapdir] properties.each do |property| - it "should have a %s property" % property do + it "should have a #{property} property" do zfs.attrclass(property).ancestors.should be_include(Puppet::Property) end end @@ -16,7 +16,7 @@ describe zfs do parameters = [:name] parameters.each do |parameter| - it "should have a %s parameter" % parameter do + it "should have a #{parameter} parameter" do zfs.attrclass(parameter).ancestors.should be_include(Puppet::Parameter) end end diff --git a/spec/unit/type/zone_spec.rb b/spec/unit/type/zone_spec.rb index 746d62a5c..302334bbd 100755 --- a/spec/unit/type/zone_spec.rb +++ b/spec/unit/type/zone_spec.rb @@ -16,7 +16,7 @@ describe zone do parameters = [:create_args, :install_args, :sysidcfg, :path, :realhostname] parameters.each do |parameter| - it "should have a %s parameter" % parameter do + it "should have a #{parameter} parameter" do zone.attrclass(parameter).ancestors.should be_include(Puppet::Parameter) end end @@ -24,7 +24,7 @@ describe zone do properties = [:ip, :iptype, :autoboot, :pool, :shares, :inherit] properties.each do |property| - it "should have a %s property" % property do + it "should have a #{property} property" do zone.attrclass(property).ancestors.should be_include(Puppet::Property) end end diff --git a/spec/unit/type/zpool_spec.rb b/spec/unit/type/zpool_spec.rb index c957e5684..f2aa3cf59 100755 --- a/spec/unit/type/zpool_spec.rb +++ b/spec/unit/type/zpool_spec.rb @@ -13,7 +13,7 @@ describe zpool do properties = [:ensure, :disk, :mirror, :raidz, :spare, :log] properties.each do |property| - it "should have a %s property" % property do + it "should have a #{property} property" do zpool.attrclass(property).ancestors.should be_include(Puppet::Property) end end @@ -21,7 +21,7 @@ describe zpool do parameters = [:pool, :raid_parity] parameters.each do |parameter| - it "should have a %s parameter" % parameter do + it "should have a #{parameter} parameter" do zpool.attrclass(parameter).ancestors.should be_include(Puppet::Parameter) end end diff --git a/spec/unit/util/checksums_spec.rb b/spec/unit/util/checksums_spec.rb index 35d18633a..af18a947d 100755 --- a/spec/unit/util/checksums_spec.rb +++ b/spec/unit/util/checksums_spec.rb @@ -17,19 +17,19 @@ describe Puppet::Util::Checksums do file_only = [:ctime, :mtime, :none] content_sums.each do |sumtype| - it "should be able to calculate %s sums from strings" % sumtype do + it "should be able to calculate #{sumtype} sums from strings" do @summer.should be_respond_to(sumtype) end end [content_sums, file_only].flatten.each do |sumtype| - it "should be able to calculate %s sums from files" % sumtype do + it "should be able to calculate #{sumtype} sums from files" do @summer.should be_respond_to(sumtype.to_s + "_file") end end [content_sums, file_only].flatten.each do |sumtype| - it "should be able to calculate %s sums from stream" % sumtype do + it "should be able to calculate #{sumtype} sums from stream" do @summer.should be_respond_to(sumtype.to_s + "_stream") end end @@ -63,7 +63,7 @@ describe Puppet::Util::Checksums do end {:md5 => Digest::MD5, :sha1 => Digest::SHA1}.each do |sum, klass| - describe("when using %s" % sum) do + describe("when using #{sum}") do it "should use #{klass} to calculate string checksums" do klass.expects(:hexdigest).with("mycontent").returns "whatever" @summer.send(sum, "mycontent").should == "whatever" @@ -102,7 +102,7 @@ describe Puppet::Util::Checksums do end {:md5lite => Digest::MD5, :sha1lite => Digest::SHA1}.each do |sum, klass| - describe("when using %s" % sum) do + describe("when using #{sum}") do it "should use #{klass} to calculate string checksums from the first 512 characters of the string" do content = "this is a test" * 100 klass.expects(:hexdigest).with(content[0..511]).returns "whatever" @@ -129,7 +129,7 @@ describe Puppet::Util::Checksums do end [:ctime, :mtime].each do |sum| - describe("when using %s" % sum) do + describe("when using #{sum}") do it "should use the '#{sum}' on the file to determine the ctime" do file = "/my/file" stat = mock 'stat', sum => "mysum" diff --git a/spec/unit/util/log_spec.rb b/spec/unit/util/log_spec.rb index 6414a37ff..b622422d7 100755 --- a/spec/unit/util/log_spec.rb +++ b/spec/unit/util/log_spec.rb @@ -55,7 +55,7 @@ describe Puppet::Util::Log do end [:level, :message, :time, :remote].each do |attr| - it "should have a %s attribute" % attr do + it "should have a #{attr} attribute" do log = Puppet::Util::Log.new :level => :notice, :message => "A test message" log.should respond_to(attr) log.should respond_to(attr.to_s + "=") diff --git a/spec/unit/util/posix_spec.rb b/spec/unit/util/posix_spec.rb index 95a5608bd..33aa4a6f2 100755 --- a/spec/unit/util/posix_spec.rb +++ b/spec/unit/util/posix_spec.rb @@ -14,29 +14,29 @@ describe Puppet::Util::POSIX do end [:group, :gr].each do |name| - it "should return :gid as the field for %s" % name do + it "should return :gid as the field for #{name}" do @posix.idfield(name).should == :gid end - it "should return :getgrgid as the id method for %s" % name do + it "should return :getgrgid as the id method for #{name}" do @posix.methodbyid(name).should == :getgrgid end - it "should return :getgrnam as the name method for %s" % name do + it "should return :getgrnam as the name method for #{name}" do @posix.methodbyname(name).should == :getgrnam end end [:user, :pw, :passwd].each do |name| - it "should return :uid as the field for %s" % name do + it "should return :uid as the field for #{name}" do @posix.idfield(name).should == :uid end - it "should return :getpwuid as the id method for %s" % name do + it "should return :getpwuid as the id method for #{name}" do @posix.methodbyid(name).should == :getpwuid end - it "should return :getpwnam as the name method for %s" % name do + it "should return :getpwnam as the name method for #{name}" do @posix.methodbyname(name).should == :getpwnam end end diff --git a/spec/unit/util/selinux_spec.rb b/spec/unit/util/selinux_spec.rb index 3e10b59ed..45bc3b433 100755 --- a/spec/unit/util/selinux_spec.rb +++ b/spec/unit/util/selinux_spec.rb @@ -198,10 +198,8 @@ describe Puppet::Util::SELinux do fh = stub 'fh', :close => nil File.stubs(:open).with("/proc/mounts").returns fh fh.stubs(:read_nonblock).returns( - "rootfs / rootfs rw 0 0\n"+ - "/dev/root / ext3 rw,relatime,errors=continue,user_xattr,acl,data=ordered 0 0\n"+ - "/dev /dev tmpfs rw,relatime,mode=755 0 0\n"+ - "/proc /proc proc rw,relatime 0 0\n"+ + "rootfs / rootfs rw 0 0\n/dev/root / ext3 rw,relatime,errors=continue,user_xattr,acl,data=ordered 0 0\n"+ + "/dev /dev tmpfs rw,relatime,mode=755 0 0\n/proc /proc proc rw,relatime 0 0\n"+ "/sys /sys sysfs rw,relatime 0 0\n" ).then.raises EOFError end diff --git a/spec/unit/util/warnings_spec.rb b/spec/unit/util/warnings_spec.rb index 15785cf58..4ce03ebe6 100755 --- a/spec/unit/util/warnings_spec.rb +++ b/spec/unit/util/warnings_spec.rb @@ -9,7 +9,7 @@ describe Puppet::Util::Warnings do end {:notice => "notice_once", :warning => "warnonce"}.each do |log, method| - describe "when registring '%s' messages" % log do + describe "when registring '#{log}' messages" do it "should always return nil" do Puppet::Util::Warnings.send(method, @msg1).should be(nil) end diff --git a/test/certmgr/ca.rb b/test/certmgr/ca.rb index 969bd935f..4ef6a0d80 100755 --- a/test/certmgr/ca.rb +++ b/test/certmgr/ca.rb @@ -42,7 +42,7 @@ class TestCA < Test::Unit::TestCase ca.clean(host) end files.each do |f| - assert(! FileTest.exists?(f), "File %s was not deleted" % f) + assert(! FileTest.exists?(f), "File #{f} was not deleted") end end end @@ -56,7 +56,7 @@ class TestCA < Test::Unit::TestCase val = ca.send(method, host) end assert_equal(File.join(Puppet[dir], host.downcase + ".pem"), val, - "incorrect response from %s" % method) + "incorrect response from #{method}") end end end diff --git a/test/certmgr/certmgr.rb b/test/certmgr/certmgr.rb index 41a4a8782..307420d6c 100755 --- a/test/certmgr/certmgr.rb +++ b/test/certmgr/certmgr.rb @@ -14,7 +14,7 @@ class TestCertMgr < Test::Unit::TestCase super #@dir = File.join(Puppet[:certdir], "testing") @dir = File.join(@configpath, "certest") - system("mkdir -p %s" % @dir) + system("mkdir -p #{@dir}") Puppet::Util::SUIDManager.stubs(:asuser).yields end @@ -161,8 +161,8 @@ class TestCertMgr < Test::Unit::TestCase cert.cacert = cacert cert.write } - #system("find %s" % Puppet[:ssldir]) - #system("cp -R %s /tmp/ssltesting" % Puppet[:ssldir]) + #system("find #{Puppet[:ssldir]}") + #system("cp -R #{Puppet[:ssldir]} /tmp/ssltesting") output = nil assert_nothing_raised { diff --git a/test/certmgr/inventory.rb b/test/certmgr/inventory.rb index a0617525d..71035ba03 100755 --- a/test/certmgr/inventory.rb +++ b/test/certmgr/inventory.rb @@ -45,7 +45,7 @@ class TestCertInventory < Test::Unit::TestCase end [cert1, cert2].each do |cert| - assert(init.include?(cert.subject.to_s), "Did not catch %s" % cert.subject.to_s) + assert(init.include?(cert.subject.to_s), "Did not catch #{cert.subject}") end end diff --git a/test/certmgr/support.rb b/test/certmgr/support.rb index 645d43c42..c241fabf3 100755 --- a/test/certmgr/support.rb +++ b/test/certmgr/support.rb @@ -25,9 +25,9 @@ class TestCertSupport < Test::Unit::TestCase # Yay, metaprogramming def test_keytype [:key, :csr, :cert, :ca_cert].each do |name| - assert(Puppet::SSLCertificates::Support.method_defined?(name), "No retrieval method for %s" % name) - maker = "mk_%s" % name - assert(Puppet::SSLCertificates::Support.method_defined?(maker), "No maker method for %s" % name) + assert(Puppet::SSLCertificates::Support.method_defined?(name), "No retrieval method for #{name}") + maker = "mk_#{name}" + assert(Puppet::SSLCertificates::Support.method_defined?(maker), "No maker method for #{name}") end end @@ -45,7 +45,7 @@ class TestCertSupport < Test::Unit::TestCase assert( FileTest.exists?(Puppet[file]), - "Did not create %s key file" % file) + "Did not create #{file} key file") end # Make sure it's a valid key diff --git a/test/language/functions.rb b/test/language/functions.rb index 9cd4d24b5..83bfe6e8e 100755 --- a/test/language/functions.rb +++ b/test/language/functions.rb @@ -40,7 +40,7 @@ class TestLangFunctions < Test::Unit::TestCase assert_nothing_raised do Puppet::Parser::Functions.newfunction(:fakefunction, :type => :rvalue) do |input| - return "output %s" % input[0] + return "output #{input[0]}" end end @@ -80,7 +80,7 @@ class TestLangFunctions < Test::Unit::TestCase val = func.evaluate(scope) end - assert_equal(retval, val, "'tagged' returned %s for %s" % [val, tag]) + assert_equal(retval, val, "'tagged' returned #{val} for #{tag}") end # Now make sure we correctly get tags. @@ -118,8 +118,7 @@ class TestLangFunctions < Test::Unit::TestCase twop = File.join(Puppet[:templatedir], "two") File.open(onep, "w") do |f| - f.puts "<%- if @one.nil? then raise '@one undefined' end -%>" + - "template <%= @one %>" + f.puts "<%- if @one.nil? then raise '@one undefined' end -%>template <%= @one %>" end File.open(twop, "w") do |f| @@ -393,7 +392,7 @@ class TestLangFunctions < Test::Unit::TestCase assert_equal( "template #{value}\n", scope.lookupvar("output"), - "%s did not get evaluated correctly" % string.inspect) + "#{string.inspect} did not get evaluated correctly") end end diff --git a/test/language/parser.rb b/test/language/parser.rb index b26982d16..a6ce8cf3f 100755 --- a/test/language/parser.rb +++ b/test/language/parser.rb @@ -27,7 +27,7 @@ class TestParser < Test::Unit::TestCase textfiles { |file| Puppet::Node::Environment.clear parser = mkparser - Puppet.debug("parsing %s" % file) if __FILE__ == $0 + Puppet.debug("parsing #{file}") if __FILE__ == $0 assert_nothing_raised() { parser.file = file parser.parse @@ -38,8 +38,8 @@ class TestParser < Test::Unit::TestCase def test_failers failers { |file| parser = mkparser - Puppet.debug("parsing failer %s" % file) if __FILE__ == $0 - assert_raise(Puppet::ParseError, "Did not fail while parsing %s" % file) { + Puppet.debug("parsing failer #{file}") if __FILE__ == $0 + assert_raise(Puppet::ParseError, "Did not fail while parsing #{file}") { parser.file = file ast = parser.parse config = mkcompiler(parser) @@ -76,7 +76,7 @@ class TestParser < Test::Unit::TestCase end def mkmanifest(file) - name = File.join(tmpdir, "file%s" % rand(100)) + name = File.join(tmpdir, "file#{rand(100)}") @@tmpfiles << name File.open(file, "w") { |f| @@ -97,7 +97,7 @@ class TestParser < Test::Unit::TestCase } 4.times { |i| - path = File.join(basedir, subdir, "subfile%s" % i) + path = File.join(basedir, subdir, "subfile#{i}") mkmanifest(path) } @@ -672,7 +672,7 @@ file { "/tmp/yayness": end [one, two].each do |file| - assert(@logs.detect { |l| l.message =~ /importing '#{file}'/}, "did not import %s" % file) + assert(@logs.detect { |l| l.message =~ /importing '#{file}'/}, "did not import #{file}") end end @@ -723,7 +723,7 @@ file { "/tmp/yayness": "one::two::three::four" => ["one::two::three", "four"], }.each do |name, ary| result = parser.namesplit(name) - assert_equal(ary, result, "%s split to %s" % [name, result]) + assert_equal(ary, result, "#{name} split to #{result}") end end end @@ -741,6 +741,6 @@ file { "/tmp/yayness": assert_nothing_raised do result = parser.newdefine "FunTest" end - assert_equal(result, parser.find_definition("", "fUntEst"), "%s was not matched" % "fUntEst") + assert_equal(result, parser.find_definition("", "fUntEst"), "#{"fUntEst"} was not matched") end end diff --git a/test/language/scope.rb b/test/language/scope.rb index 16149a6be..09bf8a1c5 100755 --- a/test/language/scope.rb +++ b/test/language/scope.rb @@ -42,14 +42,14 @@ class TestScope < Test::Unit::TestCase # Set a variable in the top and make sure all three can get it topscope.setvar("first", "topval") scopes.each do |name, scope| - assert_equal("topval", scope.lookupvar("first", false), "Could not find var in %s" % name) + assert_equal("topval", scope.lookupvar("first", false), "Could not find var in #{name}") end # Now set a var in the midscope and make sure the mid and bottom can see it but not the top midscope.setvar("second", "midval") assert_equal(:undefined, scopes[:top].lookupvar("second", false), "Found child var in top scope") [:mid, :bot].each do |name| - assert_equal("midval", scopes[name].lookupvar("second", false), "Could not find var in %s" % name) + assert_equal("midval", scopes[name].lookupvar("second", false), "Could not find var in #{name}") end # And set something in the bottom, and make sure we only find it there. diff --git a/test/language/snippets.rb b/test/language/snippets.rb index 14a267d99..cd8015db7 100755 --- a/test/language/snippets.rb +++ b/test/language/snippets.rb @@ -24,21 +24,21 @@ class TestSnippets < Test::Unit::TestCase def assert_file(path, msg = nil) unless file = @catalog.resource(:file, path) - msg ||= "Could not find file %s" % path + msg ||= "Could not find file #{path}" raise msg end end def assert_not_file(path, msg = nil) if file = @catalog.resource(:file, path) - msg ||= "File %s exists!" % path + msg ||= "File #{path} exists!" raise msg end end def assert_mode_equal(mode, path) unless file = @catalog.resource(:file, path) - raise "Could not find file %s" % path + raise "Could not find file #{path}" end unless mode == file.should(:mode) @@ -145,10 +145,10 @@ class TestSnippets < Test::Unit::TestCase [0..1, 0..2].each { |range| params = rands[range] paramstr = params.collect { |param| - "%s => fake" % param + "#{param} => fake" }.join(", ") - str = "%s { %s }" % [name, paramstr] + str = "#{name} { #{paramstr} }" scope = nil assert_nothing_raised { @@ -163,7 +163,7 @@ class TestSnippets < Test::Unit::TestCase p defaults params.each { |param| - puts "%s => '%s'" % [name,param] + puts "#{name} => '#{param}'" assert(defaults.include?(param)) } } @@ -176,7 +176,7 @@ class TestSnippets < Test::Unit::TestCase def snippet_filecreate %w{a b c d}.each { |letter| - path = "/tmp/create%stest" % letter + path = "/tmp/create#{letter}test" assert_file(path) if %w{a b}.include?(letter) assert_mode_equal(0755, path) @@ -192,7 +192,7 @@ class TestSnippets < Test::Unit::TestCase def snippet_simpleselector files = %w{a b c d}.collect { |letter| - path = "/tmp/snippetselect%stest" % letter + path = "/tmp/snippetselect#{letter}test" assert_file(path) assert_mode_equal(0755, path) } @@ -202,7 +202,7 @@ class TestSnippets < Test::Unit::TestCase path = "/tmp/classtest" file = @catalog.resource(:file, path) - assert(file, "did not create file %s" % path) + assert(file, "did not create file #{path}") assert_equal( "/Stage[main]/Testing/Mytype[componentname]/File[/tmp/classtest]", file.path) end @@ -233,13 +233,13 @@ class TestSnippets < Test::Unit::TestCase paths.each { |path| file = @catalog.resource(:file, path) - assert(file, "File %s is missing" % path) + assert(file, "File #{path} is missing") assert_mode_equal(0755, path) } end def snippet_implicititeration - paths = %w{a b c d e f g h}.collect { |l| "/tmp/iteration%stest" % l } + paths = %w{a b c d e f g h}.collect { |l| "/tmp/iteration#{l}test" } paths.each { |path| file = @catalog.resource(:file, path) @@ -249,7 +249,7 @@ class TestSnippets < Test::Unit::TestCase end def snippet_multipleinstances - paths = %w{a b c}.collect { |l| "/tmp/multipleinstances%s" % l } + paths = %w{a b c}.collect { |l| "/tmp/multipleinstances#{l}" } paths.each { |path| assert_file(path) @@ -275,7 +275,7 @@ class TestSnippets < Test::Unit::TestCase def snippet_selectorvalues nums = %w{1 2 3 4 5 6 7} files = nums.collect { |n| - "/tmp/selectorvalues%s" % n + "/tmp/selectorvalues#{n}" } files.each { |f| @@ -287,7 +287,7 @@ class TestSnippets < Test::Unit::TestCase def snippet_singleselector nums = %w{1 2 3} files = nums.collect { |n| - "/tmp/singleselector%s" % n + "/tmp/singleselector#{n}" } files.each { |f| @@ -303,7 +303,7 @@ class TestSnippets < Test::Unit::TestCase def disabled_snippet_classargtest [1,2].each { |num| - file = "/tmp/classargtest%s" % num + file = "/tmp/classargtest#{num}" assert_file(file) assert_mode_equal(0755, file) } @@ -311,7 +311,7 @@ class TestSnippets < Test::Unit::TestCase def snippet_classheirarchy [1,2,3].each { |num| - file = "/tmp/classheir%s" % num + file = "/tmp/classheir#{num}" assert_file(file) assert_mode_equal(0755, file) } @@ -319,14 +319,14 @@ class TestSnippets < Test::Unit::TestCase def snippet_singleary [1,2,3,4].each { |num| - file = "/tmp/singleary%s" % num + file = "/tmp/singleary#{num}" assert_file(file) } end def snippet_classincludes [1,2,3].each { |num| - file = "/tmp/classincludes%s" % num + file = "/tmp/classincludes#{num}" assert_file(file) assert_mode_equal(0755, file) } @@ -348,7 +348,7 @@ class TestSnippets < Test::Unit::TestCase { 1 => 'a $quote', 2 => 'some "\yayness\"' }.each { |count, str| - path = "/tmp/singlequote%s" % count + path = "/tmp/singlequote#{count}" assert_file(path) assert_equal(str, @catalog.resource(:file, path).parameter(:content).actual_content) } @@ -378,7 +378,7 @@ class TestSnippets < Test::Unit::TestCase def snippet_deepclassheirarchy 5.times { |i| i += 1 - file = "/tmp/deepclassheir%s" % i + file = "/tmp/deepclassheir#{i}" assert_file(file) } end @@ -487,8 +487,8 @@ class TestSnippets < Test::Unit::TestCase mname = "snippet_" + file.sub(/\.pp$/, '') if self.method_defined?(mname) - #eval("alias %s %s" % [testname, mname]) - testname = ("test_" + mname).intern + #eval("alias #{testname} #{mname}") + testname = ("test_#{mname}").intern self.send(:define_method, testname) { Puppet[:manifest] = snippet(file) facts = { diff --git a/test/language/transportable.rb b/test/language/transportable.rb index 247a6eda3..4607c3947 100755 --- a/test/language/transportable.rb +++ b/test/language/transportable.rb @@ -75,7 +75,7 @@ class TestTransportable < Test::Unit::TestCase } top.flatten.each do |obj| - assert(objects.include?(obj), "Missing obj %s[%s]" % [obj.type, obj.name]) + assert(objects.include?(obj), "Missing obj #{obj.type}[#{obj.name}]") end diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb index 522112db8..9bcbff9c1 100755 --- a/test/lib/puppettest.rb +++ b/test/lib/puppettest.rb @@ -274,7 +274,7 @@ module PuppetTest end - @tmpdir = File.join(@tmpdir, "puppettesting" + Process.pid.to_s) + @tmpdir = File.join(@tmpdir, "puppettesting#{Process.pid}") unless File.exists?(@tmpdir) FileUtils.mkdir_p(@tmpdir) @@ -287,12 +287,12 @@ module PuppetTest def remove_tmp_files @@tmpfiles.each { |file| unless file =~ /tmp/ - puts "Not deleting tmpfile %s" % file + puts "Not deleting tmpfile #{file}" next end if FileTest.exists?(file) - system("chmod -R 755 %s" % file) - system("rm -rf %s" % file) + system("chmod -R 755 #{file}") + system("rm -rf #{file}") end } @@tmpfiles.clear @@ -320,7 +320,7 @@ module PuppetTest diff = @memoryatend - @memoryatstart if diff > 1000 - Puppet.info "%s#%s memory growth (%s to %s): %s" % [self.class, @method_name, @memoryatstart, @memoryatend, diff] + Puppet.info "#{self.class}##{@method_name} memory growth (#{@memoryatstart} to #{@memoryatend}): #{diff}" end # reset all of the logs diff --git a/test/lib/puppettest/certificates.rb b/test/lib/puppettest/certificates.rb index 3ba052505..4f643b2d5 100644 --- a/test/lib/puppettest/certificates.rb +++ b/test/lib/puppettest/certificates.rb @@ -9,7 +9,7 @@ module PuppetTest::Certificates keyfile = File.join(@dir, "tmpkeyfile") @@tmpfiles << keyfile unless FileTest.exists?(@dir) - system("mkdir -p %s" % @dir) + system("mkdir -p #{@dir}") end File.open(keyfile, "w", 0600) { |f| f.print "as;dklj23rlkjzdflij23wr" diff --git a/test/lib/puppettest/exetest.rb b/test/lib/puppettest/exetest.rb index b0857d19f..c07615245 100644 --- a/test/lib/puppettest/exetest.rb +++ b/test/lib/puppettest/exetest.rb @@ -50,28 +50,28 @@ module PuppetTest::ExeTest output = nil manifest = mktestmanifest() - args += " --manifest %s" % manifest - args += " --confdir %s" % Puppet[:confdir] - args += " --rundir %s" % File.join(Puppet[:vardir], "run") - args += " --vardir %s" % Puppet[:vardir] - args += " --certdnsnames %s" % Puppet[:certdnsnames] - args += " --masterport %s" % @@port - args += " --user %s" % Puppet::Util::SUIDManager.uid - args += " --group %s" % Puppet::Util::SUIDManager.gid + args += " --manifest #{manifest}" + args += " --confdir #{Puppet[:confdir]}" + args += " --rundir #{File.join(Puppet[:vardir], "run")}" + args += " --vardir #{Puppet[:vardir]}" + args += " --certdnsnames #{Puppet[:certdnsnames]}" + args += " --masterport #{@@port}" + args += " --user #{Puppet::Util::SUIDManager.uid}" + args += " --group #{Puppet::Util::SUIDManager.gid}" args += " --autosign true" #if Puppet[:debug] # args += " --debug" #end - cmd = "puppetmasterd %s" % args + cmd = "puppetmasterd #{args}" assert_nothing_raised { output = %x{#{cmd}}.chomp } - assert_equal("", output, "Puppetmasterd produced output %s" % output) - assert($CHILD_STATUS == 0, "Puppetmasterd exit status was %s" % $CHILD_STATUS) + assert_equal("", output, "Puppetmasterd produced output #{output}") + assert($CHILD_STATUS == 0, "Puppetmasterd exit status was #{$CHILD_STATUS}") sleep(1) cleanup do diff --git a/test/lib/puppettest/fakes.rb b/test/lib/puppettest/fakes.rb index d421b292f..c0e0bd899 100644 --- a/test/lib/puppettest/fakes.rb +++ b/test/lib/puppettest/fakes.rb @@ -22,7 +22,7 @@ module PuppetTest end def self.to_s - "Fake%s" % @name.to_s.capitalize + "Fake#{@name.to_s.capitalize}" end def [](param) @@ -36,7 +36,7 @@ module PuppetTest def []=(param, value) param = symbolize(param) unless @realresource.valid_parameter?(param) - raise Puppet::DevError, "Invalid attribute %s for %s" % [param, @realresource.name] + raise Puppet::DevError, "Invalid attribute #{param} for #{@realresource.name}" end if @realresource.attrtype(param) == :property @should[param] = value @@ -55,7 +55,7 @@ module PuppetTest end def inspect - "%s(%s)" % [self.class.to_s.sub(/.+::/, ''), super()] + "#{self.class.to_s.sub(/.+::/, '')}(#{super()})" end def is(param) @@ -174,7 +174,7 @@ module PuppetTest @@fakeresources[type].name = type resource = Puppet::Type.type(type) - raise("Could not find type %s" % type) unless resource + raise("Could not find type #{type}") unless resource @@fakeresources[type].realresource = resource end diff --git a/test/lib/puppettest/filetesting.rb b/test/lib/puppettest/filetesting.rb index 605de6a73..3c869f5cf 100644 --- a/test/lib/puppettest/filetesting.rb +++ b/test/lib/puppettest/filetesting.rb @@ -88,7 +88,7 @@ module PuppetTest::FileTesting tolist = file_list(todir).sort fromlist.sort.zip(tolist.sort).each { |a,b| - assert_equal(a, b, "Fromfile %s with length %s does not match tofile %s with length %s" % [a, fromlist.length, b, tolist.length]) + assert_equal(a, b, "Fromfile #{a} with length #{fromlist.length} does not match tofile #{b} with length #{tolist.length}") } #assert_equal(fromlist,tolist) diff --git a/test/lib/puppettest/parsertesting.rb b/test/lib/puppettest/parsertesting.rb index f4f0eeb44..2211d17be 100644 --- a/test/lib/puppettest/parsertesting.rb +++ b/test/lib/puppettest/parsertesting.rb @@ -91,7 +91,7 @@ module PuppetTest::ParserTesting end end args[:type] = astarray(*newnames) - assert_nothing_raised("Could not create tag %s" % names.inspect) { + assert_nothing_raised("Could not create tag #{names.inspect}") { return AST::Tag.new(args) } end @@ -100,7 +100,7 @@ module PuppetTest::ParserTesting unless title.is_a?(AST) title = stringobj(title) end - assert_nothing_raised("Could not create %s %s" % [type, title]) { + assert_nothing_raised("Could not create #{type} #{title}") { return AST::Resource.new( @@ -121,7 +121,7 @@ module PuppetTest::ParserTesting end def resourceoverride(type, title, params) - assert_nothing_raised("Could not create %s %s" % [type, name]) { + assert_nothing_raised("Could not create #{type} #{name}") { return AST::ResourceOverride.new( @@ -136,7 +136,7 @@ module PuppetTest::ParserTesting end def resourceref(type, title) - assert_nothing_raised("Could not create %s %s" % [type, title]) { + assert_nothing_raised("Could not create #{type} #{title}") { return AST::ResourceReference.new( @@ -150,13 +150,13 @@ module PuppetTest::ParserTesting end def fileobj(path, hash = {"owner" => "root"}) - assert_nothing_raised("Could not create file %s" % path) { + assert_nothing_raised("Could not create file #{path}") { return resourcedef("file", path, hash) } end def nameobj(name) - assert_nothing_raised("Could not create name %s" % name) { + assert_nothing_raised("Could not create name #{name}") { return AST::Name.new( @@ -169,7 +169,7 @@ module PuppetTest::ParserTesting end def typeobj(name) - assert_nothing_raised("Could not create type %s" % name) { + assert_nothing_raised("Could not create type #{name}") { return AST::Type.new( @@ -182,7 +182,7 @@ module PuppetTest::ParserTesting end def nodedef(name) - assert_nothing_raised("Could not create node %s" % name) { + assert_nothing_raised("Could not create node #{name}") { return AST::NodeDef.new( @@ -194,9 +194,9 @@ module PuppetTest::ParserTesting :code => AST::ASTArray.new( :children => [ - varobj("%svar" % name, "%svalue" % name), + varobj("#{name}var", "#{name}value"), - fileobj("/%s" % name) + fileobj("/#{name}") ] ) ) @@ -224,7 +224,7 @@ module PuppetTest::ParserTesting if value.is_a?(String) value = stringobj(value) end - assert_nothing_raised("Could not create param %s" % param) { + assert_nothing_raised("Could not create param #{param}") { return AST::ResourceParam.new( @@ -252,7 +252,7 @@ module PuppetTest::ParserTesting unless value.is_a? AST value = stringobj(value) end - assert_nothing_raised("Could not create %s code" % name) { + assert_nothing_raised("Could not create #{name} code") { return AST::VarDef.new( @@ -266,7 +266,7 @@ module PuppetTest::ParserTesting end def varref(name) - assert_nothing_raised("Could not create %s variable" % name) { + assert_nothing_raised("Could not create #{name} variable") { return AST::Variable.new( @@ -279,7 +279,7 @@ module PuppetTest::ParserTesting end def argobj(name, value) - assert_nothing_raised("Could not create %s compargument" % name) { + assert_nothing_raised("Could not create #{name} compargument") { return AST::CompArgument.new( :children => [nameobj(name), stringobj(value)] ) @@ -308,7 +308,7 @@ module PuppetTest::ParserTesting :children => pary ) - assert_nothing_raised("Could not create defaults for %s" % type) { + assert_nothing_raised("Could not create defaults for #{type}") { return AST::ResourceDefaults.new( @@ -352,7 +352,7 @@ module PuppetTest::ParserTesting catalog.apply files.each do |file| - assert(FileTest.exists?(file), "Did not create %s" % file) + assert(FileTest.exists?(file), "Did not create #{file}") end ensure Puppet[:manifest] = oldmanifest diff --git a/test/lib/puppettest/reporttesting.rb b/test/lib/puppettest/reporttesting.rb index 97e32b1c3..49520d23a 100644 --- a/test/lib/puppettest/reporttesting.rb +++ b/test/lib/puppettest/reporttesting.rb @@ -5,7 +5,7 @@ module PuppetTest::Reporttesting 3.times { |i| # We have to use warning so that the logs always happen - log = Puppet.warning("Report test message %s" % i) + log = Puppet.warning("Report test message #{i}") report << log } diff --git a/test/lib/puppettest/servertest.rb b/test/lib/puppettest/servertest.rb index bda99c66a..0a7b7f01a 100644 --- a/test/lib/puppettest/servertest.rb +++ b/test/lib/puppettest/servertest.rb @@ -15,9 +15,9 @@ module PuppetTest::ServerTest # create a simple manifest that just creates a file def mktestmanifest - file = File.join(Puppet[:confdir], "%ssite.pp" % (self.class.to_s + "test")) + file = File.join(Puppet[:confdir], "#{(self.class.to_s + "test")}site.pp") #@createdfile = File.join(tmpdir(), self.class.to_s + "manifesttesting" + - # "_" + @method_name) + # "_#{@method_name}") @createdfile = tempfile() File.open(file, "w") { |f| diff --git a/test/lib/puppettest/support/assertions.rb b/test/lib/puppettest/support/assertions.rb index b4dd1338b..528c7b8db 100644 --- a/test/lib/puppettest/support/assertions.rb +++ b/test/lib/puppettest/support/assertions.rb @@ -20,7 +20,7 @@ module PuppetTest Puppet::Util::SUIDManager.gid = gid Puppet::Util::SUIDManager.uid = uid # FIXME: use the tempfile method from puppettest.rb - system("mkfifo "+filename) + system("mkfifo #{filename}") f = File.open(filename, "w") f << "#{Puppet::Util::SUIDManager.uid}\n#{Puppet::Util::SUIDManager.gid}\n" yield if block_given? diff --git a/test/lib/puppettest/support/utils.rb b/test/lib/puppettest/support/utils.rb index db850d699..06ce3ad4a 100644 --- a/test/lib/puppettest/support/utils.rb +++ b/test/lib/puppettest/support/utils.rb @@ -4,7 +4,7 @@ module PuppetTest::Support end module PuppetTest::Support::Utils def gcdebug(type) - Puppet.warning "%s: %s" % [type, ObjectSpace.each_object(type) { |o| }] + Puppet.warning "#{type}: #{ObjectSpace.each_object(type) { |o| }}" end # @@ -84,7 +84,7 @@ module PuppetTest::Support::Utils e.name } - assert_equal(events, newevents, "Incorrect %s %s events" % [type, msg]) + assert_equal(events, newevents, "Incorrect #{type} #{msg} events") return trans end @@ -94,7 +94,7 @@ module PuppetTest::Support::Utils ary += name.split("/") file = File.join(ary) unless FileTest.exists?(file) - raise Puppet::DevError, "No fakedata file %s" % file + raise Puppet::DevError, "No fakedata file #{file}" end return file end @@ -130,7 +130,7 @@ module PuppetTest::Support::Utils }.find_all { |file| FileTest.file?(file) }.sort.each { |file| - Puppet.debug "Processing %s" % file + Puppet.debug "Processing #{file}" yield file } end diff --git a/test/lib/puppettest/testcase.rb b/test/lib/puppettest/testcase.rb index bd566dff2..3521589bf 100644 --- a/test/lib/puppettest/testcase.rb +++ b/test/lib/puppettest/testcase.rb @@ -21,7 +21,7 @@ class PuppetTest::TestCase < Test::Unit::TestCase return super else if defined? $console - puts "Skipping %s: %s" % [name, @messages.join(", ")] + puts "Skipping #{name}: #{@messages.join(", ")}" end suite = Test::Unit::TestSuite.new(name) return suite diff --git a/test/network/authstore.rb b/test/network/authstore.rb index c225b246b..72c4ee584 100755 --- a/test/network/authstore.rb +++ b/test/network/authstore.rb @@ -43,11 +43,11 @@ class TestAuthStore < Test::Unit::TestCase 192.168.0.5 7.0.48.7 }.each { |ip| - assert_nothing_raised("Failed to @store IP address %s" % ip) { + assert_nothing_raised("Failed to @store IP address #{ip}") { @store.allow(ip) } - assert(@store.allowed?("hosttest.com", ip), "IP %s not allowed" % ip) + assert(@store.allowed?("hosttest.com", ip), "IP #{ip} not allowed") } #assert_raise(Puppet::AuthStoreError) { @@ -62,7 +62,7 @@ class TestAuthStore < Test::Unit::TestCase 192.178.* 193.179.0.0/8 }.each { |range| - assert_nothing_raised("Failed to @store IP range %s" % range) { + assert_nothing_raised("Failed to @store IP range #{range}") { @store.allow(range) } } @@ -73,7 +73,7 @@ class TestAuthStore < Test::Unit::TestCase 192.178.0.5 193.0.0.1 }.each { |ip| - assert(@store.allowed?("fakename.com", ip), "IP %s is not allowed" % ip) + assert(@store.allowed?("fakename.com", ip), "IP #{ip} is not allowed") } end @@ -134,7 +134,7 @@ class TestAuthStore < Test::Unit::TestCase %w{localhost 127.0.0.1} ].each { |ary| - assert(@store.allowed?(*ary), "Failed to allow %s" % [ary.join(",")]) + assert(@store.allowed?(*ary), "Failed to allow #{ary.join(",")}") } end @@ -202,10 +202,10 @@ class TestAuthStore < Test::Unit::TestCase luke.madstop.net name-other.madstop.net }.each { |name| - assert_nothing_raised("Failed to @store simple name %s" % name) { + assert_nothing_raised("Failed to @store simple name #{name}") { @store.allow(name) } - assert(@store.allowed?(name, "192.168.0.1"), "Name %s not allowed" % name) + assert(@store.allowed?(name, "192.168.0.1"), "Name #{name} not allowed") } %w{ @@ -217,7 +217,7 @@ class TestAuthStore < Test::Unit::TestCase assert_raise( Puppet::AuthStoreError, - "name '%s' was allowed" % pat) { + "name '#{pat}' was allowed") { @store.allow(pat) } } @@ -239,7 +239,7 @@ class TestAuthStore < Test::Unit::TestCase ya-test.madstop.com some.much.much.longer.more-other.net }.each { |name| - assert(@store.allowed?(name, "192.168.0.1"), "Host %s not allowed" % name) + assert(@store.allowed?(name, "192.168.0.1"), "Host #{name} not allowed") } assert_raise(Puppet::AuthStoreError) { @@ -262,7 +262,7 @@ class TestAuthStore < Test::Unit::TestCase @store.allow("hostname.com") %w{hostname.com Hostname.COM hostname.Com HOSTNAME.COM}.each do |name| - assert(@store.allowed?(name, "127.0.0.1"), "did not allow %s" % name) + assert(@store.allowed?(name, "127.0.0.1"), "did not allow #{name}") end end @@ -385,18 +385,18 @@ class TestAuthStoreDeclaration < PuppetTest::TestCase end [:name, :pattern, :length].zip(output).each do |method, value| - assert_equal(value, @decl.send(method), "Got incorrect value for %s from %s" % [method, input]) + assert_equal(value, @decl.send(method), "Got incorrect value for #{method} from #{input}") end end %w{-hostname.com hostname.*}.each do |input| - assert_raise(Puppet::AuthStoreError, "Did not fail on %s" % input) do + assert_raise(Puppet::AuthStoreError, "Did not fail on #{input}") do @decl.pattern = input end end ["hostname .com", "192.168 .0.1"].each do |input| - assert_raise(Puppet::AuthStoreError, "Did not fail on %s" % input) do + assert_raise(Puppet::AuthStoreError, "Did not fail on #{input}") do @decl.pattern = input end end @@ -405,7 +405,7 @@ class TestAuthStoreDeclaration < PuppetTest::TestCase def test_result ["allow", :allow].each do |val| assert_nothing_raised { @decl.type = val } - assert_equal(true, @decl.result, "did not result to true with %s" % val.inspect) + assert_equal(true, @decl.result, "did not result to true with #{val.inspect}") end [:deny, "deny"].each do |val| @@ -414,11 +414,11 @@ class TestAuthStoreDeclaration < PuppetTest::TestCase assert_equal( false, @decl.result, - "did not result to false with %s" % val.inspect) + "did not result to false with #{val.inspect}") end ["yay", 1, nil, false, true].each do |val| - assert_raise(ArgumentError, "Did not fail on %s" % val.inspect) do + assert_raise(ArgumentError, "Did not fail on #{val.inspect}") do @decl.type = val end end @@ -433,7 +433,7 @@ class TestAuthStoreDeclaration < PuppetTest::TestCase "*.HOSTNAME.Com" => %w{com hostname *}, }.each do |input, output| - assert_equal(output, @decl.send(:munge_name, input), "munged %s incorrectly" % input) + assert_equal(output, @decl.send(:munge_name, input), "munged #{input} incorrectly") end end @@ -510,7 +510,7 @@ class TestAuthStoreDeclaration < PuppetTest::TestCase %w{host.com *.domain.com 192.168.0.1 192.168.0.1/24}.each do |decl| assert_equal(0, Declaration.new(:allow, decl) <=> Declaration.new(:allow, decl), - "Equivalent declarations for %s were considered different" % decl + "Equivalent declarations for #{decl} were considered different" ) end end @@ -532,7 +532,7 @@ class TestAuthStoreDeclaration < PuppetTest::TestCase domain = Declaration.new(:allow, "*.domain.com") %w{host.domain.com domain.com very.long.domain.com very-long.domain.com }.each do |name| - assert(domain.send(:matchname?, name), "Did not match %s" % name) + assert(domain.send(:matchname?, name), "Did not match #{name}") end end end diff --git a/test/network/client/ca.rb b/test/network/client/ca.rb index ae81547db..27350831a 100755 --- a/test/network/client/ca.rb +++ b/test/network/client/ca.rb @@ -23,7 +23,7 @@ class TestClientCA < Test::Unit::TestCase end [:hostprivkey, :hostcert, :localcacert].each do |name| - assert(FileTest.exists?(Puppet.settings[name]), "Did not create cert %s" % name) + assert(FileTest.exists?(Puppet.settings[name]), "Did not create cert #{name}") end end diff --git a/test/network/handler/fileserver.rb b/test/network/handler/fileserver.rb index 357192716..3f93a74e0 100755 --- a/test/network/handler/fileserver.rb +++ b/test/network/handler/fileserver.rb @@ -46,7 +46,7 @@ class TestFileServer < Test::Unit::TestCase @@tmpfiles << testdir assert_nothing_raised { files = %w{a b c d e}.collect { |l| - name = File.join(testdir, "file%s" % l) + name = File.join(testdir, "file#{l}") File.open(name, "w") { |f| f.puts rand(100) } @@ -62,9 +62,9 @@ class TestFileServer < Test::Unit::TestCase file = File.basename(file) assert_nothing_raised { desc = server.describe(base + file) - assert(desc, "Got no description for %s" % file) - assert(desc != "", "Got no description for %s" % file) - assert_match(/^\d+/, desc, "Got invalid description %s" % desc) + assert(desc, "Got no description for #{file}") + assert(desc != "", "Got no description for #{file}") + assert_match(/^\d+/, desc, "Got invalid description #{desc}") } end @@ -82,8 +82,8 @@ class TestFileServer < Test::Unit::TestCase } [" ", "=" "+", "&", "#", "*"].each do |char| - assert_raise(Puppet::Network::Handler::FileServerError, "'%s' did not throw a failure in fileserver module names" % char) { - server.mount("/tmp", "invalid%sname" % char) + assert_raise(Puppet::Network::Handler::FileServerError, "'#{char}' did not throw a failure in fileserver module names") { + server.mount("/tmp", "invalid#{char}name") } end end @@ -250,12 +250,12 @@ class TestFileServer < Test::Unit::TestCase list = nil assert_nothing_raised { - list = server.list("/root/" + testdir, :manage, true, false) + list = server.list("/root/#{testdir}", :manage, true, false) } assert(list =~ pattern) assert_nothing_raised { - list = server.list("/root" + testdir, :manage, true, false) + list = server.list("/root#{testdir}", :manage, true, false) } assert(list =~ pattern) @@ -276,10 +276,10 @@ class TestFileServer < Test::Unit::TestCase # make our deep recursion basedir = File.join(tmpdir(), "recurseremotetesting") - testdir = "%s/with/some/sub/directories/for/the/purposes/of/testing" % basedir + testdir = "#{basedir}/with/some/sub/directories/for/the/purposes/of/testing" oldfile = File.join(testdir, "oldfile") assert_nothing_raised { - system("mkdir -p %s" % testdir) + system("mkdir -p #{testdir}") File.open(oldfile, "w") { |f| 3.times { f.puts rand(100) } } @@ -331,10 +331,10 @@ class TestFileServer < Test::Unit::TestCase # create a deep dir basedir = tempfile() - testdir = "%s/with/some/sub/directories/for/testing" % basedir + testdir = "#{basedir}/with/some/sub/directories/for/testing" oldfile = File.join(testdir, "oldfile") assert_nothing_raised { - system("mkdir -p %s" % testdir) + system("mkdir -p #{testdir}") File.open(oldfile, "w") { |f| 3.times { f.puts rand(100) } } @@ -457,7 +457,7 @@ class TestFileServer < Test::Unit::TestCase Puppet::Network::Handler::FileServerError, "Describing non-existent mount did not raise an error") { - retval = server.describe("/notmounted/" + "noexisties") + retval = server.describe("/notmounted/noexisties") } assert_nil(retval, "Description of non-existent mounts returned a value") @@ -582,11 +582,11 @@ class TestFileServer < Test::Unit::TestCase assert_raise( Puppet::AuthorizationError, - "Host %s, ip %s, allowed %s" % [host, ip, mount]) { + "Host #{host}, ip #{ip}, allowed #{mount}") { list = server.list(mount, :manage, true, false, host, ip) } when :allow - assert_nothing_raised("Host %s, ip %s, denied %s" % [host, ip, mount]) { + assert_nothing_raised("Host #{host}, ip #{ip}, denied #{mount}") { list = server.list(mount, :manage, true, false, host, ip) } end @@ -662,7 +662,7 @@ class TestFileServer < Test::Unit::TestCase assert_raise( Puppet::Network::Handler::FileServerError, - "Invalid config %s did not raise error" % i) { + "Invalid config #{i} did not raise error") { server = Puppet::Network::Handler.fileserver.new( @@ -799,8 +799,8 @@ class TestFileServer < Test::Unit::TestCase assert_equal("link", results[:type]) results.each { |p,v| - assert(v, "%s has no value" % p) - assert(v != "", "%s has no value" % p) + assert(v, "#{p} has no value") + assert(v != "", "#{p} has no value") } end @@ -1063,7 +1063,7 @@ allow * }.each do |pattern, string| file = File.join(dir, string) mount = File.join(dir, pattern) - File.open(file, "w") do |f| f.puts "yayness: %s" % string end + File.open(file, "w") do |f| f.puts "yayness: #{string}" end name = "name" obj = nil assert_nothing_raised { @@ -1229,7 +1229,7 @@ allow * "[valid]\nallow one.two.com\ndeny *.testing something.com", # invalid deny ].each do |failer| File.open(config, "w") { |f| f.puts failer } - assert_raise(Puppet::Network::Handler::FileServerError, "Did not fail on %s" % failer.inspect) { + assert_raise(Puppet::Network::Handler::FileServerError, "Did not fail on #{failer.inspect}") { server = Puppet::Network::Handler::FileServer.new( diff --git a/test/network/handler/report.rb b/test/network/handler/report.rb index 914f03450..fa55137bc 100755 --- a/test/network/handler/report.rb +++ b/test/network/handler/report.rb @@ -38,7 +38,7 @@ class TestReportServer < Test::Unit::TestCase reports = [] $run = [] 2.times do |i| - name = "processtest%s" % i + name = "processtest#{i}" reports << name Report.newreport(name) do @@ -57,7 +57,7 @@ class TestReportServer < Test::Unit::TestCase } reports.each do |name| - assert($run.include?(name.intern), "Did not run %s" % name) + assert($run.include?(name.intern), "Did not run #{name}") end # Now make sure our server doesn't die on missing reports diff --git a/test/other/puppet.rb b/test/other/puppet.rb index 6fdf46850..4acee3ee5 100755 --- a/test/other/puppet.rb +++ b/test/other/puppet.rb @@ -46,7 +46,7 @@ class TestPuppetModule < Test::Unit::TestCase cleanup do ENV["PATH"] = oldpath end - newpath = oldpath + ":" + "/something/else" + newpath = oldpath + ":/something/else" assert_nothing_raised do Puppet[:path] = newpath end diff --git a/test/other/relationships.rb b/test/other/relationships.rb index abdb537a3..3ca944670 100755 --- a/test/other/relationships.rb +++ b/test/other/relationships.rb @@ -42,7 +42,7 @@ class TestRelationships < Test::Unit::TestCase sources.each do |source| targets.each do |target| edge = deps.find { |e| e.source == source and e.target == target } - assert(edge, "Could not find edge for %s => %s" % [source.ref, target.ref]) + assert(edge, "Could not find edge for #{source.ref} => #{target.ref}") if refresher assert_equal(:ALL_EVENTS, edge.event) diff --git a/test/other/report.rb b/test/other/report.rb index af9ecea81..b5cbec0c3 100755 --- a/test/other/report.rb +++ b/test/other/report.rb @@ -78,7 +78,7 @@ class TestReports < Test::Unit::TestCase Puppet.settings.use(:main, :master) 3.times { |i| - log = Puppet.warning("Report test message %s" % i) + log = Puppet.warning("Report test message #{i}") report << log } @@ -123,11 +123,11 @@ class TestReports < Test::Unit::TestCase # Now make sure it creaets each of the rrd files %w{changes resources time}.each do |type| - file = File.join(hostdir, "%s.rrd" % type) - assert(FileTest.exists?(file), "Did not create rrd file for %s" % type) + file = File.join(hostdir, "#{type}.rrd") + assert(FileTest.exists?(file), "Did not create rrd file for #{type}") daily = file.sub ".rrd", "-daily.png" - assert(FileTest.exists?(daily), "Did not make daily graph for %s" % type) + assert(FileTest.exists?(daily), "Did not make daily graph for #{type}") end end diff --git a/test/other/transactions.rb b/test/other/transactions.rb index 5c73f1b9d..e49e96a7f 100755 --- a/test/other/transactions.rb +++ b/test/other/transactions.rb @@ -146,8 +146,8 @@ class TestTransactions < Test::Unit::TestCase end %w{ya ra y r}.each do |name| - assert(trans.catalog.vertex?(Puppet::Type.type(:generator)[name]), "Generated %s was not a vertex" % name) - assert($finished.include?(name), "%s was not finished" % name) + assert(trans.catalog.vertex?(Puppet::Type.type(:generator)[name]), "Generated #{name} was not a vertex") + assert($finished.include?(name), "#{name} was not finished") end end @@ -304,15 +304,15 @@ class TestTransactions < Test::Unit::TestCase rels.each do |after, before| config = mk_catalog(before, after) trans = Puppet::Transaction.new(config) - str = "from %s to %s" % [before, after] + str = "from #{before} to #{after}" - assert_nothing_raised("Failed to create graph %s" % str) do + assert_nothing_raised("Failed to create graph #{str}") do trans.prepare end graph = trans.relationship_graph - assert(graph.edge?(before, after), "did not create manual relationship %s" % str) - assert(! graph.edge?(after, before), "created automatic relationship %s" % str) + assert(graph.edge?(before, after), "did not create manual relationship #{str}") + assert(! graph.edge?(after, before), "created automatic relationship #{str}") end end @@ -329,13 +329,13 @@ class TestTransactions < Test::Unit::TestCase :title => "file") exec = Puppet::Type.type(:exec).new( - :command => "touch %s" % epath, + :command => "touch #{epath}", :path => ENV["PATH"], :subscribe => file, :refreshonly => true, :title => 'exec1') exec2 = Puppet::Type.type(:exec).new( - :command => "touch %s" % spath, + :command => "touch #{spath}", :path => ENV["PATH"], :subscribe => exec, :refreshonly => true, :title => 'exec2') @@ -379,7 +379,7 @@ class TestTransactions < Test::Unit::TestCase file = Puppet::Type.type(:file).new( :path => path, :ensure => :absent, - :backup => false, :title => "file%s" % i) + :backup => false, :title => "file#{i}") File.open(path, "w") { |f| f.puts "" } files << file end diff --git a/test/puppet/defaults.rb b/test/puppet/defaults.rb index 86c67e0be..1620dfd82 100755 --- a/test/puppet/defaults.rb +++ b/test/puppet/defaults.rb @@ -14,7 +14,7 @@ class TestPuppetDefaults < Test::Unit::TestCase @@booleans = %w{noop} def testVersion - assert( Puppet.version =~ /^[0-9]+(\.[0-9]+)*/, "got invalid version number %s" % Puppet.version ) + assert( Puppet.version =~ /^[0-9]+(\.[0-9]+)*/, "got invalid version number #{Puppet.version}") end def testStringOrParam @@ -49,7 +49,7 @@ class TestPuppetDefaults < Test::Unit::TestCase value = Puppet[param] unless value !~ notval - assert_nothing_raised { raise "%s is incorrectly set to %s" % [param,value] } + assert_nothing_raised { raise "#{param} is incorrectly set to #{value}" } end } end diff --git a/test/rails/railsparameter.rb b/test/rails/railsparameter.rb index 73d6ab664..ca7d207ba 100755 --- a/test/rails/railsparameter.rb +++ b/test/rails/railsparameter.rb @@ -70,7 +70,7 @@ class TestRailsParameter < Test::Unit::TestCase assert_instance_of(Puppet::Parser::Resource::Param, pp) assert_equal(name.to_sym, pp.name, "parameter name was not equal") - assert_equal(value, pp.value, "value was not equal for %s" % value.inspect) + assert_equal(value, pp.value, "value was not equal for #{value.inspect}") end end end diff --git a/test/ral/manager/attributes.rb b/test/ral/manager/attributes.rb index 4502a3258..7e9f34b52 100755 --- a/test/ral/manager/attributes.rb +++ b/test/ral/manager/attributes.rb @@ -42,15 +42,15 @@ class TestTypeAttributes < Test::Unit::TestCase end if param == :property - assert(inst.property(param), "did not get obj for %s" % param) + assert(inst.property(param), "did not get obj for #{param}") assert_equal( true, inst.should(param), "should value did not get set") else - assert_equal(true, inst[param], "did not get correct value for %s from symbol" % param) - assert_equal(true, inst[param.to_s], "did not get correct value for %s from string" % param) + assert_equal(true, inst[param], "did not get correct value for #{param} from symbol") + assert_equal(true, inst[param.to_s], "did not get correct value for #{param} from string") end end end @@ -88,11 +88,11 @@ class TestTypeAttributes < Test::Unit::TestCase def attr_check(type) @num ||= 0 @num += 1 - name = "name%s" % @num + name = "name#{@num}" inst = type.new(:name => name) [:meta, :param, :prop].each do |name| klass = type.attrclass(name) - assert(klass, "did not get class for %s" % name) + assert(klass, "did not get class for #{name}") obj = yield inst, klass assert_instance_of(klass, obj, "did not get object back") @@ -112,7 +112,7 @@ class TestTypeAttributes < Test::Unit::TestCase { :meta => :newmetaparam, :param => :newparam, :prop => :newproperty }.each do |name, method| - assert_nothing_raised("Could not make %s of type %s" % [name, method]) do + assert_nothing_raised("Could not make #{name} of type #{method}") do type.send(method, name) {} end end @@ -157,13 +157,13 @@ class TestTypeAttributes < Test::Unit::TestCase :four => :two } aliases.each do |new, old| - assert_nothing_raised("Could not create alias parameter %s" % new) do + assert_nothing_raised("Could not create alias parameter #{new}") do type.set_attr_alias new => old end end aliases.each do |new, old| - assert_equal(old, type.attr_alias(new), "did not return alias info for %s" % new) + assert_equal(old, type.attr_alias(new), "did not return alias info for #{new}") end assert_nil(type.attr_alias(:name), "got invalid alias info for name") @@ -172,7 +172,7 @@ class TestTypeAttributes < Test::Unit::TestCase assert(inst, "could not create instance") aliases.each do |new, old| - val = "value %s" % new + val = "value #{new}" assert_nothing_raised do inst[new] = val end @@ -183,12 +183,12 @@ class TestTypeAttributes < Test::Unit::TestCase assert_equal( val, inst[new], - "Incorrect alias value for %s in []" % new) + "Incorrect alias value for #{new} in []") else - assert_equal(val, inst.should(new), "Incorrect alias value for %s in should" % new) + assert_equal(val, inst.should(new), "Incorrect alias value for #{new} in should") end - assert_equal(val, inst.value(new), "Incorrect alias value for %s" % new) - assert_equal(val, inst.value(old), "Incorrect orig value for %s" % old) + assert_equal(val, inst.value(new), "Incorrect alias value for #{new}") + assert_equal(val, inst.value(old), "Incorrect orig value for #{old}") end end @@ -214,7 +214,7 @@ class TestTypeAttributes < Test::Unit::TestCase # Now make sure that we get warnings and no properties in those cases where our providers do not support the features requested [nope, maybe, yep].each_with_index do |prov, i| - resource = type.new(:provider => prov.name, :name => "test%s" % i, :none => "a", :one => "b", :two => "c") + resource = type.new(:provider => prov.name, :name => "test#{i}", :none => "a", :one => "b", :two => "c") case prov.name when :nope @@ -227,7 +227,7 @@ class TestTypeAttributes < Test::Unit::TestCase yes = [:none, :one, :two] no = [] end - yes.each { |a| assert(resource.should(a), "Did not get value for %s in %s" % [a, prov.name]) } + yes.each { |a| assert(resource.should(a), "Did not get value for #{a} in #{prov.name}") } no.each do |a| # These may or may not get passed to the provider. We shouldn't care. end @@ -245,14 +245,14 @@ class TestTypeAttributes < Test::Unit::TestCase inst = klass.new(:resource => resource) {:property => [:owner, :group], :parameter => [:ignore, :recurse], :metaparam => [:require, :subscribe]}.each do |attrtype, attrs| - assert_nothing_raised("Could not set check to a single %s value" % attrtype) do + assert_nothing_raised("Could not set check to a single #{attrtype} value") do inst.value = attrs[0] end if attrtype == :property assert(resource.property(attrs[0]), "Check did not create property instance during single check") end - assert_nothing_raised("Could not set check to multiple %s values" % attrtype) do + assert_nothing_raised("Could not set check to multiple #{attrtype} values") do inst.value = attrs end if attrtype == :property diff --git a/test/ral/manager/type.rb b/test/ral/manager/type.rb index 04ecf95ea..9182dab09 100755 --- a/test/ral/manager/type.rb +++ b/test/ral/manager/type.rb @@ -10,11 +10,11 @@ class TestType < Test::Unit::TestCase def test_typemethods Puppet::Type.eachtype { |type| name = nil - assert_nothing_raised("Searching for name for %s caused failure" % type.to_s) { + assert_nothing_raised("Searching for name for #{type} caused failure") { name = type.name } - assert(name, "Could not find name for %s" % type.to_s) + assert(name, "Could not find name for #{type}") assert_equal( @@ -22,7 +22,7 @@ class TestType < Test::Unit::TestCase type, Puppet::Type.type(name), - "Failed to retrieve %s by name" % name + "Failed to retrieve #{name} by name" ) # Skip types with no parameters or valid properties @@ -36,7 +36,7 @@ class TestType < Test::Unit::TestCase type.properties, - "Properties for %s are nil" % name + "Properties for #{name} are nil" ) @@ -44,7 +44,7 @@ class TestType < Test::Unit::TestCase type.validproperties, - "Valid properties for %s are nil" % name + "Valid properties for #{name} are nil" ) } } @@ -345,7 +345,7 @@ class TestType < Test::Unit::TestCase end [:path, :owner, :recurse, :loglevel].each do |param| - assert(hash[param], "Hash did not include %s" % param) + assert(hash[param], "Hash did not include #{param}") end end diff --git a/test/ral/providers/cron/crontab.rb b/test/ral/providers/cron/crontab.rb index f1e404ccf..46678dc7d 100755 --- a/test/ral/providers/cron/crontab.rb +++ b/test/ral/providers/cron/crontab.rb @@ -57,13 +57,13 @@ class TestCronParsedProvider < Test::Unit::TestCase # Make sure a cron job matches up. Any non-passed fields are considered absent. def assert_cron_equal(msg, cron, options) - assert_instance_of(@provider, cron, "not an instance of provider in %s" % msg) + assert_instance_of(@provider, cron, "not an instance of provider in #{msg}") options.each do |param, value| - assert_equal(value, cron.send(param), "%s was not equal in %s" % [param, msg]) + assert_equal(value, cron.send(param), "#{param} was not equal in #{msg}") end %w{command environment minute hour month monthday weekday}.each do |var| unless options.include?(var.intern) - assert_equal(:absent, cron.send(var), "%s was not parsed absent in %s" % [var, msg]) + assert_equal(:absent, cron.send(var), "#{var} was not parsed absent in #{msg}") end end end @@ -73,13 +73,13 @@ class TestCronParsedProvider < Test::Unit::TestCase unless options.include?(:record_type) raise ArgumentError, "You must pass the required record type" end - assert_instance_of(Hash, record, "not an instance of a hash in %s" % msg) + assert_instance_of(Hash, record, "not an instance of a hash in #{msg}") options.each do |param, value| - assert_equal(value, record[param], "%s was not equal in %s" % [param, msg]) + assert_equal(value, record[param], "#{param} was not equal in #{msg}") end FIELDS[record[:record_type]].each do |var| unless options.include?(var) - assert_equal(:absent, record[var], "%s was not parsed absent in %s" % [var, msg]) + assert_equal(:absent, record[var], "#{var} was not parsed absent in #{msg}") end end end @@ -100,10 +100,10 @@ class TestCronParsedProvider < Test::Unit::TestCase # First just do each sample record one by one sample_records.each do |name, options| result = nil - assert_nothing_raised("Could not parse %s: '%s'" % [name, options[:text]]) do + assert_nothing_raised("Could not parse #{name}: '#{options[:text]}'") do result = @provider.parse_line(options[:text]) end - assert_record_equal("record for %s" % name, result, options[:record]) + assert_record_equal("record for #{name}", result, options[:record]) end # Then do them all at once. @@ -120,7 +120,7 @@ class TestCronParsedProvider < Test::Unit::TestCase end records.zip(result).each do |should, record| - assert_record_equal("record for %s in full match" % should.inspect, record, should) + assert_record_equal("record for #{should.inspect} in full match", record, should) end end @@ -129,10 +129,10 @@ class TestCronParsedProvider < Test::Unit::TestCase # First just do each sample record one by one sample_records.each do |name, options| result = nil - assert_nothing_raised("Could not generate %s: '%s'" % [name, options[:record]]) do + assert_nothing_raised("Could not generate #{name}: '#{options[:record]}'") do result = @provider.to_line(options[:record]) end - assert_equal(options[:text], result, "Did not generate correct text for %s" % name) + assert_equal(options[:text], result, "Did not generate correct text for #{name}") end # Then do them all at once. @@ -160,7 +160,7 @@ class TestCronParsedProvider < Test::Unit::TestCase sample_crons.each do |name, record_names| records = record_names.collect do |record_name| unless record = sample_records[record_name] - raise "Could not find sample record %s" % record_name + raise "Could not find sample record #{record_name}" end record end @@ -174,18 +174,18 @@ class TestCronParsedProvider < Test::Unit::TestCase # First make sure we generate each one correctly result = nil - assert_nothing_raised("Could not generate multi-line cronjob %s" % [name]) do + assert_nothing_raised("Could not generate multi-line cronjob #{name}") do result = @provider.to_file(record_list) end assert_header(result) - assert_equal(text, result, "Did not generate correct text for multi-line cronjob %s" % name) + assert_equal(text, result, "Did not generate correct text for multi-line cronjob #{name}") # Now make sure we parse each one correctly - assert_nothing_raised("Could not parse multi-line cronjob %s" % [name]) do + assert_nothing_raised("Could not parse multi-line cronjob #{name}") do result = @provider.parse(text) end record_list.zip(result).each do |should, record| - assert_record_equal("multiline cronjob %s" % name, record, should) + assert_record_equal("multiline cronjob #{name}", record, should) end end @@ -211,14 +211,14 @@ class TestCronParsedProvider < Test::Unit::TestCase def test_parse_and_generate_sample_files @provider.stubs(:filetype).returns(Puppet::Util::FileType.filetype(:ram)) crondir = datadir(File.join(%w{providers cron})) - files = Dir.glob("%s/crontab.*" % crondir) + files = Dir.glob("#{crondir}/crontab.*") setme @provider.default_target = @me target = @provider.target_object(@me) files.each do |file| str = args = nil - assert_nothing_raised("could not load %s" % file) do + assert_nothing_raised("could not load #{file}") do str, args = YAML.load(File.read(file)) end @@ -238,7 +238,7 @@ class TestCronParsedProvider < Test::Unit::TestCase end end target.write(str) - assert_nothing_raised("could not parse %s" % file) do + assert_nothing_raised("could not parse #{file}") do @provider.prefetch end records = @provider.send(:instance_variable_get, "@records") @@ -257,14 +257,14 @@ class TestCronParsedProvider < Test::Unit::TestCase assert_equal( should, is, - "Did not parse %s correctly" % file) + "Did not parse #{file} correctly") end - assert_nothing_raised("could not generate %s" % file) do + assert_nothing_raised("could not generate #{file}") do @provider.flush_target(@me) end - assert_equal(str, target.read, "%s changed" % file) + assert_equal(str, target.read, "#{file} changed") @provider.clear end end @@ -345,7 +345,7 @@ class TestCronParsedProvider < Test::Unit::TestCase assert(is, "Did not get record") should.each do |p, v| - assert_equal(v, is[p], "did not parse %s correctly" % p) + assert_equal(v, is[p], "did not parse #{p} correctly") end end @@ -403,10 +403,10 @@ class TestCronParsedProvider < Test::Unit::TestCase str, target.read, "Did not write correctly") - assert_nothing_raised("Could not prefetch with %s" % str.inspect) do + assert_nothing_raised("Could not prefetch with #{str.inspect}") do @provider.prefetch end - assert_nothing_raised("Could not flush with %s" % str.inspect) do + assert_nothing_raised("Could not flush with #{str.inspect}") do @provider.flush_target(@me) end @@ -494,16 +494,16 @@ class TestCronParsedProvider < Test::Unit::TestCase end matchers.each do |cron| - assert_equal(:present, cron.provider.ensure, "Cron %s was not matched" % cron.name) + assert_equal(:present, cron.provider.ensure, "Cron #{cron.name} was not matched") if value = cron.value(:minute) and value == "*" value = :absent end assert_equal(value, cron.provider.minute, "Minutes were not retrieved, so cron was not matched") - assert_equal(cron.value(:target), cron.provider.target, "Cron %s was matched from the wrong target" % cron.name) + assert_equal(cron.value(:target), cron.provider.target, "Cron #{cron.name} was matched from the wrong target") end nonmatchers.each do |cron| - assert_equal(:absent, cron.provider.ensure, "Cron %s was incorrectly matched" % cron.name) + assert_equal(:absent, cron.provider.ensure, "Cron #{cron.name} was incorrectly matched") end end @@ -515,7 +515,7 @@ class TestCronParsedProvider < Test::Unit::TestCase text = File.read(file) target.write(text) - assert_nothing_raised("Could not parse %s" % file) do + assert_nothing_raised("Could not parse #{file}") do @provider.prefetch end # mark the provider modified @@ -525,7 +525,7 @@ class TestCronParsedProvider < Test::Unit::TestCase target.write("") result = nil - assert_nothing_raised("Could not generate %s" % file) do + assert_nothing_raised("Could not generate #{file}") do @provider.flush_target(@me) end @@ -552,7 +552,7 @@ class TestCronParsedProvider < Test::Unit::TestCase @provider.initvars str += "\n" target.write(str) - assert_nothing_raised("Could not prefetch with %s" % str.inspect) do + assert_nothing_raised("Could not prefetch with #{str.inspect}") do @provider.prefetch end records = @provider.send(:instance_variable_get, "@records") @@ -563,7 +563,7 @@ class TestCronParsedProvider < Test::Unit::TestCase "Did not create lines as freebsd lines") end - assert_nothing_raised("Could not flush with %s" % str.inspect) do + assert_nothing_raised("Could not flush with #{str.inspect}") do @provider.flush_target(@me) end @@ -654,7 +654,7 @@ class TestCronParsedProvider < Test::Unit::TestCase assert(is, "Did not get record") should.each do |p, v| - assert_equal(v, is[p], "did not parse %s correctly" % p) + assert_equal(v, is[p], "did not parse #{p} correctly") end end end diff --git a/test/ral/providers/group.rb b/test/ral/providers/group.rb index 990b0b42c..067affd68 100755 --- a/test/ral/providers/group.rb +++ b/test/ral/providers/group.rb @@ -57,13 +57,13 @@ class TestGroupProvider < Test::Unit::TestCase return false end - assert_equal("", output, "Group %s is present:\n%s" % [group, output]) + assert_equal("", output, "Group #{group} is present:\n#{output}") end def gid(name) %x{nireport / /groups name gid}.split("\n").each { |line| group, id = line.chomp.split(/\s+/) - assert(id =~ /^-?\d+$/, "Group id %s for %s is not a number" % [id.inspect, group]) + assert(id =~ /^-?\d+$/, "Group id #{id.inspect} for #{group} is not a number") if group == name return Integer(id) end @@ -73,7 +73,7 @@ class TestGroupProvider < Test::Unit::TestCase end def remove(group) - system("niutil -destroy / /groups/%s" % group) + system("niutil -destroy / /groups/#{group}") end else def missing?(group) @@ -95,7 +95,7 @@ class TestGroupProvider < Test::Unit::TestCase end def remove(group) - system("groupdel %s" % group) + system("groupdel #{group}") end end @@ -183,7 +183,7 @@ class TestGroupProvider < Test::Unit::TestCase gobj = nil comp = nil name = "pptestgr" - assert(missing?(name), "Group %s is still present" % name) + assert(missing?(name), "Group #{name} is still present") group = mkgroup(name) @@tmpgroups << name @@ -192,15 +192,15 @@ class TestGroupProvider < Test::Unit::TestCase assert_nothing_raised { group.create } - assert(!missing?(name), "Group %s is missing" % name) + assert(!missing?(name), "Group #{name} is missing") tests = Puppet::Type.type(:group).validproperties tests.each { |test| - if self.respond_to?("attrtest_%s" % test) - self.send("attrtest_%s" % test, group) + if self.respond_to?("attrtest_#{test}") + self.send("attrtest_#{test}", group) else - $stderr.puts "Not testing attr %s of group" % test + $stderr.puts "Not testing attr #{test} of group" end } diff --git a/test/ral/providers/host/parsed.rb b/test/ral/providers/host/parsed.rb index 0339f7c27..2060276d7 100755 --- a/test/ral/providers/host/parsed.rb +++ b/test/ral/providers/host/parsed.rb @@ -43,9 +43,9 @@ class TestParsedHostProvider < Test::Unit::TestCase end return { - :name => "fakehost%s" % @hcount, - :ip => "192.168.27.%s" % @hcount, - :host_aliases => ["alias%s" % @hcount], + :name => "fakehost#{@hcount}", + :ip => "192.168.27.#{@hcount}", + :host_aliases => ["alias#{@hcount}"], :ensure => :present } end @@ -224,10 +224,10 @@ class TestParsedHostProvider < Test::Unit::TestCase # And verify that we have data for everything hosts.each { |host| name = host.resource[:name] - assert(text.include?(name), "Host %s is not in file" % name) + assert(text.include?(name), "Host #{name} is not in file") hash = host.property_hash - assert(! hash.empty?, "Could not find host %s" % name) - assert(hash[:ip], "Could not find ip for host %s" % name) + assert(! hash.empty?, "Could not find host #{name}") + assert(hash[:ip], "Could not find ip for host #{name}") } end end diff --git a/test/ral/providers/package.rb b/test/ral/providers/package.rb index b408d9482..600770f13 100755 --- a/test/ral/providers/package.rb +++ b/test/ral/providers/package.rb @@ -18,7 +18,7 @@ class TestPackageProvider < Test::Unit::TestCase require 'yaml' file = File.join(PuppetTest.datadir(), "providers", "package", "testpackages.yaml") unless FileTest.exists?(file) - raise "Could not find file %s" % file + raise "Could not find file #{file}" end array = YAML::load(File.read(file)).collect { |hash| # Stupid ruby 1.8.1. YAML is sometimes broken such that @@ -74,7 +74,7 @@ class TestPackageProvider < Test::Unit::TestCase elsif result.is_a?(Hash) assert (result[:ensure] == :absent or result[:ensure] == :purged), msg else - raise "dunno how to handle %s" % result.inspect + raise "dunno how to handle #{result.inspect}" end end @@ -122,7 +122,7 @@ class TestPackageProvider < Test::Unit::TestCase if hash[:source] unless FileTest.exists?(hash[:source]) - $stderr.puts "Create a package at %s for testing" % hash[:source] + $stderr.puts "Create a package at #{hash[:source]} for testing" return end end @@ -133,7 +133,7 @@ class TestPackageProvider < Test::Unit::TestCase pkg = nil assert_nothing_raised( - "Could not turn %s into a package" % hash.inspect + "Could not turn #{hash.inspect} into a package" ) do pkg = Puppet::Type.newpackage(hash) end @@ -191,7 +191,7 @@ class TestPackageProvider < Test::Unit::TestCase end provider.flush new = provider.properties - assert(current != new, "package was not upgraded: %s did not change" % current.inspect) + assert(current != new, "package was not upgraded: #{current.inspect} did not change") end unless versions.empty? @@ -202,7 +202,7 @@ class TestPackageProvider < Test::Unit::TestCase end provider.flush new = provider.properties - assert(current != new, "package was not upgraded: %s did not change" % current.inspect) + assert(current != new, "package was not upgraded: #{current.inspect} did not change") end # Now call 'latest' after the package is installed @@ -227,7 +227,7 @@ class TestPackageProvider < Test::Unit::TestCase mname = ["test", hash[:name].to_s, hash[:provider].to_s].join("_").intern if method_defined?(mname) - warn "Already a test method defined for %s" % mname + warn "Already a test method defined for #{mname}" else define_method(mname) do run_package_installation_test(hash) diff --git a/test/ral/providers/parsedfile.rb b/test/ral/providers/parsedfile.rb index a1d2435d1..93716a3ce 100755 --- a/test/ral/providers/parsedfile.rb +++ b/test/ral/providers/parsedfile.rb @@ -36,7 +36,7 @@ class TestParsedFile < Test::Unit::TestCase # A simple block to skip the complexity of a full transaction. def apply(resource) [:one, :two, :ensure, :target].each do |st| - Puppet.info "Setting %s: %s => %s" % [resource[:name], st, resource.should(st)] + Puppet.info "Setting #{resource[:name]}: #{st} => #{resource.should(st)}" resource.provider.send(st.to_s + "=", resource.should(st)) end end @@ -81,7 +81,7 @@ class TestParsedFile < Test::Unit::TestCase end [:one, :two, :name].each do |attr| - assert(prov.method_defined?(attr), "Did not define %s" % attr) + assert(prov.method_defined?(attr), "Did not define #{attr}") end # Now make sure they stay around @@ -323,7 +323,7 @@ class TestParsedFile < Test::Unit::TestCase if name == :resources assert(! list.include?(file), "Provider somehow found resource target when no resource was passed") else - assert(list.include?(file), "Provider did not find %s file" % name) + assert(list.include?(file), "Provider did not find #{name} file") end end @@ -334,7 +334,7 @@ class TestParsedFile < Test::Unit::TestCase # And make sure we get all three files files.each do |name, file| - assert(list.include?(file), "Provider did not find %s file when resource was passed" % name) + assert(list.include?(file), "Provider did not find #{name} file when resource was passed") end end @@ -434,7 +434,7 @@ class TestParsedFile < Test::Unit::TestCase mover = mkresource "mover", :target => :first [first, second, mover].each do |m| - assert_nothing_raised("Could not apply %s" % m[:name]) do + assert_nothing_raised("Could not apply #{m[:name]}") do apply(m) end end @@ -447,7 +447,7 @@ class TestParsedFile < Test::Unit::TestCase end check = proc do |target, name| - assert(prov.target_object(target).read.include?("%s a c" % name), "Did not sync %s" % name) + assert(prov.target_object(target).read.include?("#{name} a c"), "Did not sync #{name}") end # Make sure the data is there check.call(:first, :first) @@ -502,7 +502,7 @@ class TestParsedFile < Test::Unit::TestCase # Now make sure all of the data is copied over correctly. notdisk.class.validproperties.each do |property| assert_equal(notdisk.should(property), notdisk.provider.property_hash[property], - "%s was not copied over during creation" % property) + "#{property} was not copied over during creation") end # Flush it to disk and make sure it got copied down @@ -571,7 +571,7 @@ class TestParsedFile < Test::Unit::TestCase prov = bill.provider 4.times do |i| - assert(prov.one, "Did not get a value for 'one' on try %s" % (i + 1)) + assert(prov.one, "Did not get a value for 'one' on try #{(i + 1)}") end # First make sure we can retrieve values multiple times from the diff --git a/test/ral/providers/port/parsed.rb b/test/ral/providers/port/parsed.rb index 154d21260..13cc87d2c 100755 --- a/test/ral/providers/port/parsed.rb +++ b/test/ral/providers/port/parsed.rb @@ -48,7 +48,7 @@ require 'puppettest' # end # @provider.default_target = file # -# assert_nothing_raised("failed to fetch %s" % file) { +# assert_nothing_raised("failed to fetch #{file}") { # @provider.prefetch # } # @@ -60,7 +60,7 @@ require 'puppettest' # assert_equal("53", dns[:number], "dns number is wrong") # # text = nil -# assert_nothing_raised("failed to generate %s" % file) do +# assert_nothing_raised("failed to generate #{file}") do # text = @provider.to_file(@provider.target_records(file)) # end # @@ -83,7 +83,7 @@ require 'puppettest' # end # # assert_equal(old.chomp.gsub(/\s+/, ''), # # new.gsub(/\s+/, ''), -# # "Lines are not equal in %s" % file) +# # "Lines are not equal in #{file}") # end # end # end @@ -121,13 +121,13 @@ require 'puppettest' # hash.each do |param, value| # if value # assert_equal(value, record[param], -# "did not get %s out of '%s'" % [param, line]) +# "did not get #{param} out of '#{line}'") # end # end # # # Now make sure it generates correctly # assert_equal(line, @provider.to_line(record), -# "Did not generate %s correctly" % line) +# "Did not generate #{line} correctly") # end # end # end diff --git a/test/ral/providers/provider.rb b/test/ral/providers/provider.rb index e7625b95d..f716bc1cf 100755 --- a/test/ral/providers/provider.rb +++ b/test/ral/providers/provider.rb @@ -64,7 +64,7 @@ class TestProvider < Test::Unit::TestCase end end - assert_equal(result, provider.suitable?, "Failed for %s" % [hash.inspect]) + assert_equal(result, provider.suitable?, "Failed for #{hash.inspect}") provider.initvars end @@ -106,7 +106,7 @@ class TestProvider < Test::Unit::TestCase def test_command {:echo => "echo", :echo_with_path => echo, :missing => "nosuchcommand", :missing_qualified => "/path/to/nosuchcommand"}.each do |name, command| provider = newprovider - assert_nothing_raised("Could not define command %s with argument %s for provider" % [name, command]) do + assert_nothing_raised("Could not define command #{name} with argument #{command} for provider") do provider.commands(name => command) end @@ -122,7 +122,7 @@ class TestProvider < Test::Unit::TestCase # Now make sure they both work inst = provider.new(nil) [provider, inst].each do |thing| - assert_nothing_raised("Could not call %s on %s" % [command, thing]) do + assert_nothing_raised("Could not call #{command} on #{thing}") do out = thing.send(name, "some", "text") assert_equal("some text\n", out) end @@ -239,23 +239,23 @@ class TestProvider < Test::Unit::TestCase obj = prov.new(nil) %w{prop1 prop2 param1 param2}.each do |param| - assert(prov.public_method_defined?(param), "no getter for %s" % param) - assert(prov.public_method_defined?(param + "="), "no setter for %s" % param) + assert(prov.public_method_defined?(param), "no getter for #{param}") + assert(prov.public_method_defined?(param + "="), "no setter for #{param}") assert_equal( :absent, obj.send(param), "%s did not default to :absent") - val = "testing %s" % param - assert_nothing_raised("Could not call setter for %s" % param) do + val = "testing #{param}" + assert_nothing_raised("Could not call setter for #{param}") do obj.send(param + "=", val) end assert_equal( val, obj.send(param), - "did not get correct value for %s" % param) + "did not get correct value for #{param}") end end @@ -384,7 +384,7 @@ class TestProviderFeatures < Test::Unit::TestCase @providers[:neither] = [:something, :else] @providers.each do |name, methods| - assert_nothing_raised("Could not create provider %s" % name) do + assert_nothing_raised("Could not create provider #{name}") do @type.provide(name) do methods.each do |name| define_method(name) {} @@ -397,29 +397,29 @@ class TestProviderFeatures < Test::Unit::TestCase {:numbers => [:numeric], :letters => [:alpha], :both => [:numeric, :alpha], :mixed => [], :neither => []}.each do |name, should| should.sort! { |a,b| a.to_s <=> b.to_s } provider = @type.provider(name) - assert(provider, "Could not find provider %s" % name) - assert_equal(should, provider.features, "Provider %s has incorrect features" % name) + assert(provider, "Could not find provider #{name}") + assert_equal(should, provider.features, "Provider #{name} has incorrect features") inst = provider.new(resource) # Make sure the boolean methods work on both the provider and # instance. @features.keys.each do |feature| method = feature.to_s + "?" - assert(inst.respond_to?(method), "No boolean instance method for %s on %s" % [name, feature]) - assert(provider.respond_to?(method), "No boolean class method for %s on %s" % [name, feature]) + assert(inst.respond_to?(method), "No boolean instance method for #{name} on #{feature}") + assert(provider.respond_to?(method), "No boolean class method for #{name} on #{feature}") if should.include?(feature) - assert(provider.feature?(feature), "class missing feature? %s" % feature) - assert(inst.feature?(feature), "instance missing feature? %s" % feature) - assert(provider.send(method), "class missing feature %s" % feature) - assert(inst.send(method), "instance missing feature %s" % feature) - assert(inst.satisfies?(feature), "instance.satisfy %s returned false" % feature) + assert(provider.feature?(feature), "class missing feature? #{feature}") + assert(inst.feature?(feature), "instance missing feature? #{feature}") + assert(provider.send(method), "class missing feature #{feature}") + assert(inst.send(method), "instance missing feature #{feature}") + assert(inst.satisfies?(feature), "instance.satisfy #{feature} returned false") else - assert(! provider.feature?(feature), "class has feature? %s" % feature) - assert(! inst.feature?(feature), "instance has feature? %s" % feature) - assert(! provider.send(method), "class has feature %s" % feature) - assert(! inst.send(method), "instance has feature %s" % feature) - assert(! inst.satisfies?(feature), "instance.satisfy %s returned true" % feature) + assert(! provider.feature?(feature), "class has feature? #{feature}") + assert(! inst.feature?(feature), "instance has feature? #{feature}") + assert(! provider.send(method), "class has feature #{feature}") + assert(! inst.send(method), "instance has feature #{feature}") + assert(! inst.satisfies?(feature), "instance.satisfy #{feature} returned true") end end @@ -428,7 +428,7 @@ class TestProviderFeatures < Test::Unit::TestCase Puppet[:trace] = true Puppet::Type.loadall Puppet::Type.eachtype do |type| - assert(type.respond_to?(:feature), "No features method defined for %s" % type.name) + assert(type.respond_to?(:feature), "No features method defined for #{type.name}") end end @@ -482,13 +482,13 @@ class TestProviderFeatures < Test::Unit::TestCase provider_class = @type.provider(name) provider = provider_class.new({}) - assert(provider, "did not get provider named %s" % name) + assert(provider, "did not get provider named #{name}") features.sort! { |a,b| a.to_s <=> b.to_s } - assert_equal(features, provider.features, "Got incorrect feature list for provider instance %s" % name) - assert_equal(features, provider_class.features, "Got incorrect feature list for provider class %s" % name) + assert_equal(features, provider.features, "Got incorrect feature list for provider instance #{name}") + assert_equal(features, provider_class.features, "Got incorrect feature list for provider class #{name}") features.each do |feat| - assert(provider.feature?(feat), "Provider instance %s did not have feature %s" % [name, feat]) - assert(provider_class.feature?(feat), "Provider class %s did not have feature %s" % [name, feat]) + assert(provider.feature?(feat), "Provider instance #{name} did not have feature #{feat}") + assert(provider_class.feature?(feat), "Provider class #{name} did not have feature #{feat}") end end end @@ -506,7 +506,7 @@ class TestProviderFeatures < Test::Unit::TestCase # Now make sure our providers answer correctly. [nope, maybe, yep].each do |prov| - assert(prov.respond_to?(:supports_parameter?), "%s does not respond to :supports_parameter?" % prov.name) + assert(prov.respond_to?(:supports_parameter?), "#{prov.name} does not respond to :supports_parameter?") case prov.name when :nope supported = [:neither] @@ -520,10 +520,10 @@ class TestProviderFeatures < Test::Unit::TestCase end supported.each do |param| - assert(prov.supports_parameter?(param), "%s was not supported by %s" % [param, prov.name]) + assert(prov.supports_parameter?(param), "#{param} was not supported by #{prov.name}") end un.each do |param| - assert(! prov.supports_parameter?(param), "%s was incorrectly supported by %s" % [param, prov.name]) + assert(! prov.supports_parameter?(param), "#{param} was incorrectly supported by #{prov.name}") end end end diff --git a/test/ral/providers/service/base.rb b/test/ral/providers/service/base.rb index 015905180..f1db0470d 100755 --- a/test/ral/providers/service/base.rb +++ b/test/ral/providers/service/base.rb @@ -26,10 +26,10 @@ class TestBaseServiceProvider < Test::Unit::TestCase service = Puppet::Type.type(:service).new( :name => "yaytest", :provider => :base, - :start => "%s %s" % [commands[:touch], running], - :status => "%s -f %s" % [commands[:test], running], + :start => "#{commands[:touch]} #{running}", + :status => "#{commands[:test]} -f #{running}", - :stop => "%s %s" % [commands[:rm], running] + :stop => "#{commands[:rm]} #{running}" ) provider = service.provider @@ -71,7 +71,7 @@ class TestBaseServiceProvider < Test::Unit::TestCase # We can't fail well when status is messed up, because we depend on the return code # of the command for data. %w{start stop restart}.each do |command| - assert_raise(Puppet::Error, "did not throw error when %s failed" % command) do + assert_raise(Puppet::Error, "did not throw error when #{command} failed") do provider.send(command) end end diff --git a/test/ral/providers/sshkey/parsed.rb b/test/ral/providers/sshkey/parsed.rb index 8a18d5e9a..e58f59173 100755 --- a/test/ral/providers/sshkey/parsed.rb +++ b/test/ral/providers/sshkey/parsed.rb @@ -30,8 +30,8 @@ class TestParsedSSHKey < Test::Unit::TestCase @pcount = 1 end args = { - :name => name || "/fspuppet%s" % @pcount, - :key => "thisismykey%s" % @pcount, + :name => name || "/fspuppet#{@pcount}", + :key => "thisismykey#{@pcount}", :host_aliases => ["host1.domain.com","192.168.0.1"], :type => "dss", :ensure => :present @@ -82,7 +82,7 @@ class TestParsedSSHKey < Test::Unit::TestCase hash.each do |p, v| next unless key.respond_to?(p) - assert_equal(v, key.send(p), "%s did not match" % p) + assert_equal(v, key.send(p), "#{p} did not match") end assert(key.name !~ /,/, "Aliases were not split out during parsing") diff --git a/test/ral/providers/user.rb b/test/ral/providers/user.rb index 7b031891b..81b3afd3e 100755 --- a/test/ral/providers/user.rb +++ b/test/ral/providers/user.rb @@ -42,7 +42,7 @@ class TestUserProvider < Test::Unit::TestCase return false end - assert_equal("", output, "User %s is present:\n%s" % [user, output]) + assert_equal("", output, "User #{user} is present:\n#{output}") end def current?(param, user) @@ -67,7 +67,7 @@ class TestUserProvider < Test::Unit::TestCase end def remove(user) - system("niutil -destroy / /users/%s" % user) + system("niutil -destroy / /users/#{user}") end else def missing?(user) @@ -93,7 +93,7 @@ class TestUserProvider < Test::Unit::TestCase end def remove(user) - system("userdel %s" % user) + system("userdel #{user}") end end @@ -120,10 +120,10 @@ class TestUserProvider < Test::Unit::TestCase case param when :name; name when :ensure; :present - when :comment; "Puppet's Testing User %s" % name # use a single quote a la #375 + when :comment; "Puppet's Testing User #{name}" # use a single quote a la #375 when :gid; nonrootgroup.gid when :shell; findshell() - when :home; "/home/%s" % name + when :home; "/home/#{name}" else return nil end @@ -196,9 +196,9 @@ class TestUserProvider < Test::Unit::TestCase assert( val != :absent, - "Property %s is missing" % property) + "Property #{property} is missing") - assert(val, "Did not get value for %s" % property) + assert(val, "Did not get value for #{property}") end end @@ -386,7 +386,7 @@ class TestUserProvider < Test::Unit::TestCase extra = [] 5.times do |i| i += 1 - name = "pptstgr%s" % i + name = "pptstgr#{i}" tmpgroup = Puppet::Type.type(:group).new( @@ -443,7 +443,7 @@ class TestUserProvider < Test::Unit::TestCase def test_simpleuser name = "pptest" - assert(missing?(name), "User %s is present" % name) + assert(missing?(name), "User #{name} is present") user = mkuser(name) @@ -474,7 +474,7 @@ class TestUserProvider < Test::Unit::TestCase user = nil name = "pptest" - assert(missing?(name), "User %s is present" % name) + assert(missing?(name), "User #{name} is present") user = mkuser(name) @@ -496,10 +496,10 @@ class TestUserProvider < Test::Unit::TestCase just = nil tests.each { |test| - if self.respond_to?("attrtest_%s" % test) - self.send("attrtest_%s" % test, user) + if self.respond_to?("attrtest_#{test}") + self.send("attrtest_#{test}", user) else - Puppet.err "Not testing attr %s of user" % test + Puppet.err "Not testing attr #{test} of user" end } @@ -586,9 +586,9 @@ class TestUserProvider < Test::Unit::TestCase should.each do |param, value| if darwin - assert_equal(value, provider.autogen(param), "did not autogen %s for darwin correctly" % param) + assert_equal(value, provider.autogen(param), "did not autogen #{param} for darwin correctly") else - assert_nil(provider.autogen(param), "autogenned %s for non-darwin os" % param) + assert_nil(provider.autogen(param), "autogenned #{param} for non-darwin os") end end end diff --git a/test/ral/providers/user/useradd.rb b/test/ral/providers/user/useradd.rb index 7dedeefc9..2e98d7f5d 100755 --- a/test/ral/providers/user/useradd.rb +++ b/test/ral/providers/user/useradd.rb @@ -39,7 +39,7 @@ class UserAddProviderTest < PuppetTest::TestCase assert( @provider.feature?(feature), - "useradd provider is missing %s" % feature) + "useradd provider is missing #{feature}") end end @@ -74,7 +74,7 @@ class UserAddProviderTest < PuppetTest::TestCase :uid => "-u", :comment => "-c"} flags.each do |param, flag| - assert_equal(@vals[param], options[flag], "Got incorrect value for %s" % param) + assert_equal(@vals[param], options[flag], "Got incorrect value for #{param}") end true diff --git a/test/ral/type/cron.rb b/test/ral/type/cron.rb index bd334f2ec..fcee21dd0 100755 --- a/test/ral/type/cron.rb +++ b/test/ral/type/cron.rb @@ -61,7 +61,7 @@ class TestCron < Test::Unit::TestCase # Create a cron job with all fields filled in. def mkcron(name, addargs = true) cron = nil - command = "date > %s/crontest%s" % [tmpdir(), name] + command = "date > #{tmpdir()}/crontest#{name}" args = nil if addargs args = { @@ -101,7 +101,7 @@ class TestCron < Test::Unit::TestCase curtext = obj.read text.split("\n").each do |line| - assert(curtext.include?(line), "Missing '%s'" % line) + assert(curtext.include?(line), "Missing '#{line}'") end obj = Puppet::Type::Cron.cronobj(@me) @@ -201,7 +201,7 @@ class TestCron < Test::Unit::TestCase assert_equal([value.to_s], cron.should(param), "Cron value was not set correctly") end when :invalid - assert_raise(Puppet::Error, "%s is incorrectly a valid %s" % [value, param]) { + assert_raise(Puppet::Error, "#{value} is incorrectly a valid #{param}") { cron[param] = value } end @@ -348,7 +348,7 @@ class TestCron < Test::Unit::TestCase def provider_set(cron, param, value) unless param =~ /=$/ - param = "%s=" % param + param = "#{param}=" end cron.provider.send(param, value) @@ -362,7 +362,7 @@ class TestCron < Test::Unit::TestCase cron.newattr(param) property = cron.property(param) - assert(property, "Did not get %s property" % param) + assert(property, "Did not get #{param} property") assert_nothing_raised { # property.is = :absent @@ -444,7 +444,7 @@ class TestCron < Test::Unit::TestCase crons << cron assert_equal(cron.should(:user), cron.should(:target), - "Target was not set correctly for %s" % user) + "Target was not set correctly for #{user}") end provider = crons[0].provider.class @@ -459,7 +459,7 @@ class TestCron < Test::Unit::TestCase assert( text !~ /testcron-#{user}/, - "%s's cron job is in %s's tab" % [user, other]) + "#{user}'s cron job is in #{other}'s tab") end end end diff --git a/test/ral/type/exec.rb b/test/ral/type/exec.rb index cc163ead5..454458ff3 100755 --- a/test/ral/type/exec.rb +++ b/test/ral/type/exec.rb @@ -132,7 +132,7 @@ class TestExec < Test::Unit::TestCase cmd = Puppet::Type.type(:exec).new( - :command => "touch %s" % maker, + :command => "touch #{maker}", :path => "/usr/bin:/bin:/usr/sbin:/sbin", :subscribe => file, @@ -187,7 +187,7 @@ class TestExec < Test::Unit::TestCase exec = Puppet::Type.type(:exec).new( - :command => "touch %s" % file, + :command => "touch #{file}", :path => "/usr/bin:/bin:/usr/sbin:/sbin", :creates => file @@ -274,7 +274,7 @@ class TestExec < Test::Unit::TestCase cat = Puppet::Type.type(:exec).new( - :command => "cat %s %s" % [exe, oexe], + :command => "cat #{exe} #{oexe}", :path => ENV["PATH"] ) @@ -312,18 +312,18 @@ class TestExec < Test::Unit::TestCase exec = Puppet::Type.type(:exec).new( - :command => "touch %s" % bfile, - :onlyif => "test -f %s" % afile, + :command => "touch #{bfile}", + :onlyif => "test -f #{afile}", :path => ENV['PATH'] ) } assert_events([], exec) - system("touch %s" % afile) + system("touch #{afile}") assert_events([:executed_command], exec) assert_events([:executed_command], exec) - system("rm %s" % afile) + system("rm #{afile}") assert_events([], exec) end @@ -336,8 +336,8 @@ class TestExec < Test::Unit::TestCase exec = Puppet::Type.type(:exec).new( - :command => "touch %s" % bfile, - :unless => "test -f %s" % afile, + :command => "touch #{bfile}", + :unless => "test -f #{afile}", :path => ENV['PATH'] ) @@ -346,10 +346,10 @@ class TestExec < Test::Unit::TestCase assert_events([:executed_command], comp) assert_events([:executed_command], comp) - system("touch %s" % afile) + system("touch #{afile}") assert_events([], comp) assert_events([], comp) - system("rm %s" % afile) + system("rm #{afile}") assert_events([:executed_command], comp) assert_events([:executed_command], comp) end @@ -360,12 +360,12 @@ class TestExec < Test::Unit::TestCase File.umask(0022) args = { - :command => "touch %s" % file, + :command => "touch #{file}", :path => "/usr/bin:/bin:/usr/sbin:/sbin", } if user - #Puppet.warning "Using user %s" % user.name + #Puppet.warning "Using user #{user.name}" if id # convert to a string, because that's what the object expects args[:user] = user.uid.to_s @@ -375,7 +375,7 @@ class TestExec < Test::Unit::TestCase end if group - #Puppet.warning "Using group %s" % group.name + #Puppet.warning "Using group #{group.name}" if id args[:group] = group.gid.to_s else @@ -460,7 +460,7 @@ class TestExec < Test::Unit::TestCase :path => "/usr/bin:/bin", :creates => basedir, - :command => "mkdir %s; touch %s" % [basedir, path] + :command => "mkdir #{basedir}; touch #{path}" ) } @@ -497,7 +497,7 @@ class TestExec < Test::Unit::TestCase Puppet::Type.type(:exec).checks.each do |check| klass = Puppet::Type.type(:exec).paramclass(check) next if klass.value_collection.values.include? :false - assert_raise(Puppet::Error, "Check '%s' did not fail on false" % check) do + assert_raise(Puppet::Error, "Check '#{check}' did not fail on false") do exec[check] = false end end @@ -704,7 +704,7 @@ and stuff" assert_raise(Timeout::Error) { exec.run("sleep 1") } - Puppet.info "%s seconds, vs a timeout of %s" % [Time.now.to_f - time.to_f, exec[:timeout]] + Puppet.info "#{Time.now.to_f - time.to_f} seconds, vs a timeout of #{exec[:timeout]}" assert_apply(exec) diff --git a/test/ral/type/file.rb b/test/ral/type/file.rb index 24aab1fd6..f7c4c2b2a 100755 --- a/test/ral/type/file.rb +++ b/test/ral/type/file.rb @@ -35,7 +35,7 @@ class TestFile < Test::Unit::TestCase end def teardown - system("rm -rf %s" % Puppet[:statefile]) + system("rm -rf #{Puppet[:statefile]}") super end @@ -325,7 +325,7 @@ class TestFile < Test::Unit::TestCase def test_create_dir basedir = tempfile() Dir.mkdir(basedir) - %w{a b c d}.collect { |name| "#{basedir}/%s" % name }.each { |path| + %w{a b c d}.collect { |name| "#{basedir}/#{name}" }.each { |path| file = nil assert_nothing_raised() { @@ -336,7 +336,7 @@ class TestFile < Test::Unit::TestCase :ensure => "directory" ) } - assert(! FileTest.directory?(path), "Directory %s already exists" % [path]) + assert(! FileTest.directory?(path), "Directory #{path} already exists") assert_events([:directory_created], file) assert_events([], file) assert(FileTest.directory?(path)) @@ -463,7 +463,7 @@ class TestFile < Test::Unit::TestCase assert(file, "Could not retrieve file object") - assert_equal("/%s" % file.ref, file.path) + assert_equal("/#{file.ref}", file.path) end def test_autorequire @@ -812,12 +812,12 @@ class TestFile < Test::Unit::TestCase catalog = mk_catalog obj transaction = Puppet::Transaction.new(catalog) - assert_equal("/%s" % obj.ref, obj.path) + assert_equal("/#{obj.ref}", obj.path) list = transaction.eval_generate(obj) fileobj = catalog.resource(:file, file) assert(fileobj, "did not generate file object") - assert_equal("/%s" % fileobj.ref, fileobj.path, "did not generate correct subfile path") + assert_equal("/#{fileobj.ref}", fileobj.path, "did not generate correct subfile path") end # Testing #403 @@ -837,12 +837,12 @@ class TestFile < Test::Unit::TestCase second = tempfile() params = [:content, :source, :target] params.each do |param| - assert_nothing_raised("%s conflicted with ensure" % [param]) do + assert_nothing_raised("#{param} conflicted with ensure") do Puppet::Type.newfile(:path => file, param => first, :ensure => :file) end params.each do |other| next if other == param - assert_raise(Puppet::Error, "%s and %s did not conflict" % [param, other]) do + assert_raise(Puppet::Error, "#{param} and #{other} did not conflict") do Puppet::Type.newfile(:path => file, other => first, param => second) end end @@ -871,7 +871,7 @@ class TestFile < Test::Unit::TestCase else current = stat.send(should) end - assert_equal(sval, current, "Attr %s was not correct %s" % [should, msg]) + assert_equal(sval, current, "Attr #{should} was not correct #{msg}") end end @@ -883,7 +883,7 @@ class TestFile < Test::Unit::TestCase {:source => source, :content => "some content"}.each do |attr, value| file[attr] = value # First create the file - run.call(file, "upon creation with %s" % attr) + run.call(file, "upon creation with #{attr}") # Now change something so that we replace the file case attr @@ -891,11 +891,11 @@ class TestFile < Test::Unit::TestCase File.open(source, "w") { |f| f.puts "some different text" } when :content; file[:content] = "something completely different" else - raise "invalid attr %s" % attr + raise "invalid attr #{attr}" end # Run it again - run.call(file, "after modification with %s" % attr) + run.call(file, "after modification with #{attr}") # Now remove the file and the attr file.delete(attr) diff --git a/test/ral/type/file/target.rb b/test/ral/type/file/target.rb index 6b252d28f..20e68a578 100755 --- a/test/ral/type/file/target.rb +++ b/test/ral/type/file/target.rb @@ -52,8 +52,8 @@ class TestFileTarget < Test::Unit::TestCase subdir = File.join(source, "subdir") file = File.join(subdir, "file") - system("mkdir -p %s" % subdir) - system("touch %s" % file) + system("mkdir -p #{subdir}") + system("touch #{file}") link = Puppet::Type.type(:file).new( @@ -88,13 +88,13 @@ class TestFileTarget < Test::Unit::TestCase # Make a bunch of files and dirs Dir.mkdir(source) Dir.chdir(source) do - system("mkdir -p %s" % "some/path/of/dirs") - system("mkdir -p %s" % "other/path/of/dirs") - system("touch %s" % "file") - system("touch %s" % "other/file") - system("touch %s" % "some/path/of/file") - system("touch %s" % "some/path/of/dirs/file") - system("touch %s" % "other/path/of/file") + system("mkdir -p #{"some/path/of/dirs"}") + system("mkdir -p #{"other/path/of/dirs"}") + system("touch #{"file"}") + system("touch #{"other/file"}") + system("touch #{"some/path/of/file"}") + system("touch #{"some/path/of/dirs/file"}") + system("touch #{"other/path/of/file"}") files = %x{find . -type f}.chomp.split(/\n/) dirs = %x{find . -type d}.chomp.split(/\n/).reject{|d| d =~ /^\.+$/ } @@ -117,8 +117,8 @@ class TestFileTarget < Test::Unit::TestCase files.each do |f| f.sub!(/^\.#{File::SEPARATOR}/, '') path = File.join(dest, f) - assert(FileTest.exists?(path), "Link %s was not created" % path) - assert(FileTest.symlink?(path), "%s is not a link" % f) + assert(FileTest.exists?(path), "Link #{path} was not created") + assert(FileTest.symlink?(path), "#{f} is not a link") target = File.readlink(path) assert_equal(File.join(source, f), target) end @@ -126,8 +126,8 @@ class TestFileTarget < Test::Unit::TestCase dirs.each do |d| d.sub!(/^\.#{File::SEPARATOR}/, '') path = File.join(dest, d) - assert(FileTest.exists?(path), "Dir %s was not created" % path) - assert(FileTest.directory?(path), "%s is not a directory" % d) + assert(FileTest.exists?(path), "Dir #{path} was not created") + assert(FileTest.directory?(path), "#{d} is not a directory") end end @@ -163,7 +163,7 @@ class TestFileTarget < Test::Unit::TestCase resources << Puppet::Type.type(:exec).new( - :command => "mkdir %s; touch %s/file" % [source, source], + :command => "mkdir #{source}; touch #{source}/file", :title => "yay", :path => ENV["PATH"] diff --git a/test/ral/type/fileignoresource.rb b/test/ral/type/fileignoresource.rb index f158ac20d..19f510957 100755 --- a/test/ral/type/fileignoresource.rb +++ b/test/ral/type/fileignoresource.rb @@ -16,7 +16,7 @@ class TestFileIgnoreSources < Test::Unit::TestCase begin initstorage rescue - system("rm -rf %s" % Puppet[:statefile]) + system("rm -rf #{Puppet[:statefile]}") end Facter.stubs(:to_hash).returns({}) diff --git a/test/ral/type/filesources.rb b/test/ral/type/filesources.rb index 0ca09d2ff..a928fd7db 100755 --- a/test/ral/type/filesources.rb +++ b/test/ral/type/filesources.rb @@ -33,7 +33,7 @@ class TestFileSources < Test::Unit::TestCase begin initstorage rescue - system("rm -rf %s" % Puppet[:statefile]) + system("rm -rf #{Puppet[:statefile]}") end end @@ -71,7 +71,7 @@ class TestFileSources < Test::Unit::TestCase catalog = mk_catalog(tofile) catalog.apply - assert(FileTest.exists?(todir), "Created dir %s does not exist" % todir) + assert(FileTest.exists?(todir), "Created dir #{todir} does not exist") end def run_complex_sources(networked = false) @@ -91,7 +91,7 @@ class TestFileSources < Test::Unit::TestCase todir = File.join(path, "todir") source = fromdir if networked - source = "puppet://localhost/%s%s" % [networked, fromdir] + source = "puppet://localhost/#{networked}#{fromdir}" end recursive_source_test(source, todir) @@ -245,7 +245,7 @@ class TestFileSources < Test::Unit::TestCase Puppet[:certdnsnames] = "localhost" serverpid = nil - assert_nothing_raised("Could not start on port %s" % @port) { + assert_nothing_raised("Could not start on port #{@port}") { server = Puppet::Network::HTTPServer::WEBrick.new( @@ -410,7 +410,7 @@ class TestFileSources < Test::Unit::TestCase i = i + 1 source = tempfile() sources << source - file = File.join(source, "file%s" % i) + file = File.join(source, "file#{i}") Dir.mkdir(source) File.open(file, "w") { |f| f.print "yay" } } @@ -463,12 +463,12 @@ class TestFileSources < Test::Unit::TestCase [source1, source2, File.join(source1, "subdir"), File.join(source2, "subdir")].each_with_index do |dir, i| Dir.mkdir(dir) # Make a single file in each directory - file = File.join(dir, "file%s" % i) - File.open(file, "w") { |f| f.puts "yay%s" % i} + file = File.join(dir, "file#{i}") + File.open(file, "w") { |f| f.puts "yay#{i}"} # Now make a second one in each directory - file = File.join(dir, "second-file%s" % i) - File.open(file, "w") { |f| f.puts "yaysecond-%s" % i} + file = File.join(dir, "second-file#{i}") + File.open(file, "w") { |f| f.puts "yaysecond-#{i}"} files << file end @@ -478,9 +478,9 @@ class TestFileSources < Test::Unit::TestCase ["file0", "file1", "second-file0", "second-file1", "subdir/file2", "subdir/second-file2", "subdir/file3", "subdir/second-file3"].each do |file| path = File.join(dest, file) - assert(FileTest.exists?(path), "did not create %s" % file) + assert(FileTest.exists?(path), "did not create #{file}") - assert_equal("yay%s\n" % File.basename(file).sub("file", ''), File.read(path), "file was not copied correctly") + assert_equal("yay#{File.basename(file).sub("file", '')}\n", File.read(path), "file was not copied correctly") end end diff --git a/test/ral/type/host.rb b/test/ral/type/host.rb index b6c4d9c66..3259e3ae9 100755 --- a/test/ral/type/host.rb +++ b/test/ral/type/host.rb @@ -46,9 +46,9 @@ class TestHost < Test::Unit::TestCase host = Puppet::Type.type(:host).new( - :name => "fakehost%s" % @hcount, - :ip => "192.168.27.%s" % @hcount, - :alias => "alias%s" % @hcount, + :name => "fakehost#{@hcount}", + :ip => "192.168.27.#{@hcount}", + :alias => "alias#{@hcount}", :catalog => @catalog ) diff --git a/test/ral/type/port.rb b/test/ral/type/port.rb index fa57cf55f..d48aa8c2a 100755 --- a/test/ral/type/port.rb +++ b/test/ral/type/port.rb @@ -41,11 +41,11 @@ require 'puppettest' # end # assert_nothing_raised { # port = Puppet::Type.type(:port).new( -# :name => "puppet%s" % @pcount, -# :number => "813%s" % @pcount, +# :name => "puppet#{@pcount}", +# :number => "813#{@pcount}", # :protocols => "tcp", # :description => "The port that Puppet runs on", -# :alias => "coolness%s" % @pcount +# :alias => "coolness#{@pcount}" # ) # } # diff --git a/test/ral/type/resources.rb b/test/ral/type/resources.rb index 2dd747eca..eb53a7edf 100755 --- a/test/ral/type/resources.rb +++ b/test/ral/type/resources.rb @@ -22,7 +22,7 @@ class TestResources < Test::Unit::TestCase def mk_purger(managed = false) @purgenum ||= 0 @purgenum += 1 - obj = @purgetype.create :name => "purger%s" % @purgenum + obj = @purgetype.create :name => "purger#{@purgenum}" $purgemembers[obj[:name]] = obj if managed obj[:fake] = "testing" @@ -101,11 +101,11 @@ class TestResources < Test::Unit::TestCase } if low - assert(! res.check(@user.create(:name => low)), "low user %s passed check" % low) + assert(! res.check(@user.create(:name => low)), "low user #{low} passed check") end if high res[:unless_system_user] = 50 - assert(res.check(@user.create(:name => high)), "high user %s failed check" % high) + assert(res.check(@user.create(:name => high)), "high user #{high} failed check") end end end diff --git a/test/ral/type/sshkey.rb b/test/ral/type/sshkey.rb index a774af393..e362de839 100755 --- a/test/ral/type/sshkey.rb +++ b/test/ral/type/sshkey.rb @@ -51,10 +51,10 @@ class TestSSHKey < Test::Unit::TestCase key = @sshkeytype.new( - :name => "host%s.madstop.com" % @kcount, - :key => "%sAAAAB3NzaC1kc3MAAACBAMnhSiku76y3EGkNCDsUlvpO8tRgS9wL4Eh54WZfQ2lkxqfd2uT/RTT9igJYDtm/+UHuBRdNGpJYW1Nw2i2JUQgQEEuitx4QKALJrBotejGOAWxxVk6xsh9xA0OW8Q3ZfuX2DDitfeC8ZTCl4xodUMD8feLtP+zEf8hxaNamLlt/AAAAFQDYJyf3vMCWRLjTWnlxLtOyj/bFpwAAAIEAmRxxXb4jjbbui9GYlZAHK00689DZuX0EabHNTl2yGO5KKxGC6Esm7AtjBd+onfu4Rduxut3jdI8GyQCIW8WypwpJofCIyDbTUY4ql0AQUr3JpyVytpnMijlEyr41FfIb4tnDqnRWEsh2H7N7peW+8DWZHDFnYopYZJ9Yu4/jHRYAAACAERG50e6aRRb43biDr7Ab9NUCgM9bC0SQscI/xdlFjac0B/kSWJYTGVARWBDWug705hTnlitY9cLC5Ey/t/OYOjylTavTEfd/bh/8FkAYO+pWdW3hx6p97TBffK0b6nrc6OORT2uKySbbKOn0681nNQh4a6ueR3JRppNkRPnTk5c=" % @kcount, + :name => "host#{@kcount}.madstop.com", + :key => "#{@kcount}AAAAB3NzaC1kc3MAAACBAMnhSiku76y3EGkNCDsUlvpO8tRgS9wL4Eh54WZfQ2lkxqfd2uT/RTT9igJYDtm/+UHuBRdNGpJYW1Nw2i2JUQgQEEuitx4QKALJrBotejGOAWxxVk6xsh9xA0OW8Q3ZfuX2DDitfeC8ZTCl4xodUMD8feLtP+zEf8hxaNamLlt/AAAAFQDYJyf3vMCWRLjTWnlxLtOyj/bFpwAAAIEAmRxxXb4jjbbui9GYlZAHK00689DZuX0EabHNTl2yGO5KKxGC6Esm7AtjBd+onfu4Rduxut3jdI8GyQCIW8WypwpJofCIyDbTUY4ql0AQUr3JpyVytpnMijlEyr41FfIb4tnDqnRWEsh2H7N7peW+8DWZHDFnYopYZJ9Yu4/jHRYAAACAERG50e6aRRb43biDr7Ab9NUCgM9bC0SQscI/xdlFjac0B/kSWJYTGVARWBDWug705hTnlitY9cLC5Ey/t/OYOjylTavTEfd/bh/8FkAYO+pWdW3hx6p97TBffK0b6nrc6OORT2uKySbbKOn0681nNQh4a6ueR3JRppNkRPnTk5c=", :type => "ssh-dss", - :alias => ["192.168.0.%s" % @kcount], + :alias => ["192.168.0.#{@kcount}"], :catalog => @catalog ) diff --git a/test/ral/type/user.rb b/test/ral/type/user.rb index 8e1bc9359..3187101e1 100755 --- a/test/ral/type/user.rb +++ b/test/ral/type/user.rb @@ -72,7 +72,7 @@ class TestUser < Test::Unit::TestCase :gid => Puppet::Util::SUIDManager.gid, :shell => findshell(), - :home => "/home/%s" % name + :home => "/home/#{name}" ) } diff --git a/test/ral/type/zone.rb b/test/ral/type/zone.rb index d8a191b98..f87774786 100755 --- a/test/ral/type/zone.rb +++ b/test/ral/type/zone.rb @@ -118,7 +118,7 @@ class TestZone < PuppetTest::TestCase assert( prov.method_defined?(m), - "Zone provider %s does not define method %s" % [prov.name, m]) + "Zone provider #{prov.name} does not define method #{m}") end end @@ -398,7 +398,7 @@ end [:uninstall, :configured], [:unconfigure, :absent] ].each do |method, property| - Puppet.info "Testing %s" % method + Puppet.info "Testing #{method}" current_values = nil assert_nothing_raised { current_values = zone.retrieve @@ -410,7 +410,7 @@ end assert_nothing_raised { current_values = zone.retrieve } - assert_equal(property, current_values[zone.property(:ensure)], "Method %s did not correctly set property %s" % [method, property]) + assert_equal(property, current_values[zone.property(:ensure)], "Method #{method} did not correctly set property #{property}") end end diff --git a/test/util/fileparsing.rb b/test/util/fileparsing.rb index 097254a50..fac5f3e83 100755 --- a/test/util/fileparsing.rb +++ b/test/util/fileparsing.rb @@ -36,7 +36,7 @@ class TestUtilFileParsing < Test::Unit::TestCase "Did not set separator") tests.each do |test| - assert_equal(["one two", "three four"], @parser.lines(test), "Incorrectly parsed %s" % test.inspect) + assert_equal(["one two", "three four"], @parser.lines(test), "Incorrectly parsed #{test.inspect}") end end end @@ -177,7 +177,7 @@ class TestUtilFileParsing < Test::Unit::TestCase # Make sure we always require an appropriate set of options [{:separator => "\t"}, {}, {:fields => %w{record_type}}].each do |opts| - assert_raise(ArgumentError, "Accepted %s" % opts.inspect) do + assert_raise(ArgumentError, "Accepted #{opts.inspect}") do @parser.record_line :record, opts end end @@ -334,11 +334,11 @@ class TestUtilFileParsing < Test::Unit::TestCase assert_equal( record[param], result[param], - "Did not correctly parse %s" % start.inspect) + "Did not correctly parse #{start.inspect}") end # And generating - assert_equal(final, @parser.to_line(result), "Did not correctly generate %s from %s" % [final.inspect, record.inspect]) + assert_equal(final, @parser.to_line(result), "Did not correctly generate #{final.inspect} from #{record.inspect}") end # First try it with symmetric characters @@ -452,12 +452,12 @@ assert_nothing_raised do assert_nothing_raised do result = @parser.handle_record_line(line, options) end - assert(result, "Did not get a result back for '%s'" % line) + assert(result, "Did not get a result back for '#{line}'") should.each do |field| if field == :alias and line =~ /null/ - assert_equal(%w{sink null}, result[field], "Field %s was not right in '%s'" % [field, line]) + assert_equal(%w{sink null}, result[field], "Field #{field} was not right in '#{line}'") else - assert_equal(values[field], result[field], "Field %s was not right in '%s'" % [field, line]) + assert_equal(values[field], result[field], "Field #{field} was not right in '#{line}'") end end end @@ -644,7 +644,7 @@ class TestUtilFileRecord < Test::Unit::TestCase [ [:fake, {}], [nil, ] ].each do |args| - assert_raise(ArgumentError, "Did not fail on %s" % args.inspect) do + assert_raise(ArgumentError, "Did not fail on #{args.inspect}") do Record.new(*args) end end @@ -658,7 +658,7 @@ class TestUtilFileRecord < Test::Unit::TestCase # Make sure we fail on invalid fields [:record_type, :target, :on_disk].each do |field| - assert_raise(ArgumentError, "Did not fail on invalid field %s" % field) { + assert_raise(ArgumentError, "Did not fail on invalid field #{field}") { Record.new(:record, :fields => [field]) } end @@ -667,12 +667,12 @@ class TestUtilFileRecord < Test::Unit::TestCase def test_defaults record = Record.new(:text, :match => %r{^#}) [:absent, :separator, :joiner, :optional].each do |field| - assert_nil(record.send(field), "%s was not nil" % field) + assert_nil(record.send(field), "#{field} was not nil") end record = Record.new(:record, :fields => %w{fields}) {:absent => "", :separator => /\s+/, :joiner => " ", :optional => []}.each do |field, default| - assert_equal(default, record.send(field), "%s was not default" % field) + assert_equal(default, record.send(field), "#{field} was not default") end end diff --git a/test/util/inifile.rb b/test/util/inifile.rb index b4d7f9353..c33a27ecd 100755 --- a/test/util/inifile.rb +++ b/test/util/inifile.rb @@ -38,8 +38,7 @@ class TestFileType < Test::Unit::TestCase def test_multi fmain = mkfile("[main]\nkey1=main.value1\n# Comment\nkey2=main.value2") - fsub = mkfile("[sub1]\nkey1=sub1 value1\n\n" + - "[sub2]\nkey1=sub2.value1") + fsub = mkfile("[sub1]\nkey1=sub1 value1\n\n[sub2]\nkey1=sub2.value1") main_mtime = File::stat(fmain).mtime assert_nothing_raised { @file.read(fmain) @@ -68,15 +67,13 @@ class TestFileType < Test::Unit::TestCase subtext = File.read(fsub) assert_equal( - "[sub1]\nkey1=sub1 newvalue1\n\n" + - "[sub2]\nkey1=sub2.value1\nkey2=sub2 newvalue2\n", + "[sub1]\nkey1=sub1 newvalue1\n\n[sub2]\nkey1=sub2.value1\nkey2=sub2 newvalue2\n", subtext) end def test_format_nil - fname = mkfile("[main]\nkey1=value1\n# Comment\nkey2=value2\n" + - "# Comment2\n") + fname = mkfile("[main]\nkey1=value1\n# Comment\nkey2=value2\n# Comment2\n") assert_nothing_raised { @file.read(fname) } @@ -123,8 +120,7 @@ class TestFileType < Test::Unit::TestCase assert_equal( v, section[k], - "Expected <#{v}> for #{section.name}[#{k}] " + - "but got <#{section[k]}>") + "Expected <#{v}> for #{section.name}[#{k}] but got <#{section[k]}>") end end diff --git a/test/util/log.rb b/test/util/log.rb index 5fb30cf05..b33e1d2fe 100755 --- a/test/util/log.rb +++ b/test/util/log.rb @@ -41,7 +41,7 @@ class TestLog < Test::Unit::TestCase :level => level, :source => "Test", - :message => "Unit test for %s" % level + :message => "Unit test for #{level}" ) } } @@ -93,7 +93,7 @@ class TestLog < Test::Unit::TestCase } getlevels.each { |level| assert_nothing_raised() { - Puppet.send(level,"Testing for %s" % level) + Puppet.send(level,"Testing for #{level}") } } end @@ -163,7 +163,7 @@ class TestLog < Test::Unit::TestCase } [:destine, "Destine", "destine"].each do |name| - assert(dest.match?(name), "Did not match %s" % name.inspect) + assert(dest.match?(name), "Did not match #{name.inspect}") end assert_nothing_raised { diff --git a/test/util/metrics.rb b/test/util/metrics.rb index 6dcb84119..70b85cebd 100755 --- a/test/util/metrics.rb +++ b/test/util/metrics.rb @@ -64,7 +64,7 @@ class TestMetric < PuppetTest::TestCase File.open(File.join(Puppet[:rrddir],"index.html"),"w") { |of| of.puts "<html><body>" report.metrics.each { |name, metric| - of.puts "<img src=%s.png><br>" % metric.name + of.puts "<img src=#{metric.name}.png><br>" } } end diff --git a/test/util/settings.rb b/test/util/settings.rb index 354a5d7fc..fa47a1227 100755 --- a/test/util/settings.rb +++ b/test/util/settings.rb @@ -79,7 +79,7 @@ class TestSettings < Test::Unit::TestCase } @config.each do |name, object| - assert_equal(@config[name], newc[name], "Parameter %s is not the same" % name) + assert_equal(@config[name], newc[name], "Parameter #{name} is not the same") end end @@ -226,7 +226,7 @@ class TestSettings < Test::Unit::TestCase :four => "five", :six => "seven" }.each do |param, value| - assert_equal(value, main[param], "Param %s was not set correctly in main" % param) + assert_equal(value, main[param], "Param #{param} was not set correctly in main") end section1 = result[:section1] @@ -239,7 +239,7 @@ class TestSettings < Test::Unit::TestCase :attrdir => "/some/dir", :attr3 => "$attrdir/other" }.each do |param, value| - assert_equal(value, section1[param], "Param %s was not set correctly in section1" % param) + assert_equal(value, section1[param], "Param #{param} was not set correctly in section1") end end @@ -270,16 +270,16 @@ class TestSettings < Test::Unit::TestCase arg = nil if @config.boolean?(param) if val - opt = "--%s" % param + opt = "--#{param}" else - opt = "--no-%s" % param + opt = "--no-#{param}" end else - opt = "--%s" % param + opt = "--#{param}" arg = val end - assert_nothing_raised("Could not handle arg %s with value %s" % [opt, val]) { + assert_nothing_raised("Could not handle arg #{opt} with value #{val}") { @config.handlearg(opt, arg) } @@ -512,7 +512,7 @@ class TestSettings < Test::Unit::TestCase assert_instance_of( type, elem, - "%s got created as wrong type" % value.inspect) + "#{value.inspect} got created as wrong type") end end @@ -541,7 +541,7 @@ class TestSettings < Test::Unit::TestCase } %w{singleq doubleq none}.each do |p| - assert_equal("one", config[p], "%s did not match" % p) + assert_equal("one", config[p], "#{p} did not match") end assert_equal('mid"quote', config["middle"], "middle did not match") end diff --git a/test/util/subclass_loader.rb b/test/util/subclass_loader.rb index 622f9c356..d2b035f6c 100755 --- a/test/util/subclass_loader.rb +++ b/test/util/subclass_loader.rb @@ -69,7 +69,7 @@ class TestPuppetUtilSubclassLoader < Test::Unit::TestCase mk_subclass("multipletest", "puppet/other", "OtherLoader") mk_subclass("multipletest", "puppet/fakeloaders", "TestPuppetUtilSubclassLoader::LoadTest") - #system("find %s" % @basedir) + #system("find #{@basedir}") #puts File.read(File.join(@basedir, "puppet/fakeloaders/multipletest.rb")) #puts File.read(File.join(@basedir, "puppet/other/multipletest.rb")) diff --git a/test/util/utiltest.rb b/test/util/utiltest.rb index 82016f3aa..a66b175e5 100755 --- a/test/util/utiltest.rb +++ b/test/util/utiltest.rb @@ -78,7 +78,7 @@ class TestPuppetUtil < Test::Unit::TestCase end [:yay, "cool"].each do |var| - assert_equal(inst.hash[var], inst[var], "Var %s did not take" % var) + assert_equal(inst.hash[var], inst[var], "Var #{var} did not take") end assert_nothing_raised do @@ -87,7 +87,7 @@ class TestPuppetUtil < Test::Unit::TestCase end [:Yay, "Cool"].each do |var| - assert_equal(inst.hash[var], inst[var], "Var %s did not take" % var) + assert_equal(inst.hash[var], inst[var], "Var #{var} did not take") end end |