summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-07-09 18:05:07 -0700
committerMarkus Roberts <Markus@reality.com>2010-07-09 18:05:07 -0700
commit184132e07fc1461555cb4da842df15f32842a843 (patch)
tree67085c1100b28991ee3b5f4745d67777acf8d075
parent9ee56f2e67be973da49b1d3f21de1bf87de35e6f (diff)
downloadpuppet-184132e07fc1461555cb4da842df15f32842a843.tar.gz
puppet-184132e07fc1461555cb4da842df15f32842a843.tar.xz
puppet-184132e07fc1461555cb4da842df15f32842a843.zip
Code smell: Use {} for % notation delimiters wherever practical
* * Replaced 16 occurances of %([qQrwWx])\((.*?)\) with %\1{\2} 3 Examples: The code: # %r(/) != /\// becomes: # %r{/} != /\// The code: ri = glob(%w(bin/*.rb sbin/* lib/**/*.rb)).reject { |e| e=~ /\.(bat|cmd)$/ } becomes: ri = glob(%w{bin/*.rb sbin/* lib/**/*.rb}).reject { |e| e=~ /\.(bat|cmd)$/ } The code: if !FileUtils.uptodate?("/var/cache/eix", %w(/usr/bin/eix /usr/portage/metadata/timestamp)) becomes: if !FileUtils.uptodate?("/var/cache/eix", %w{/usr/bin/eix /usr/portage/metadata/timestamp}) * Replaced 12 occurances of %([qQrwWx])\[(.*?)\] with %\1{\2} 3 Examples: The code: return send(command) if %w[get backup restore].include? command becomes: return send(command) if %w{get backup restore}.include? command The code: for iv in %w[indent space space_before object_nl array_nl check_circular allow_nan max_nesting] becomes: for iv in %w{indent space space_before object_nl array_nl check_circular allow_nan max_nesting} The code: @puppetd.command_line.stubs(:args).returns(%w[--logdest /my/file]) becomes: @puppetd.command_line.stubs(:args).returns(%w{--logdest /my/file}) * Replaced no occurances of %([qQrwWx])<(.*?)> with %\1{\2} * Replaced 19 occurances of %([qQrwWx])([^{\[(<])(.*?)\2 with %\1{\3} 3 Examples: The code: at.add_mapping(%r%^lib/puppet/(.*)\.rb$%) { |filename, m| becomes: at.add_mapping(%r{^lib/puppet/(.*)\.rb$}) { |filename, m| The code: at.add_mapping(%r%^spec/(unit|integration)/.*\.rb$%) { |filename, _| becomes: at.add_mapping(%r{^spec/(unit|integration)/.*\.rb$}) { |filename, _| The code: at.add_mapping(%r!^lib/puppet\.rb$!) { |filename, _| becomes: at.add_mapping(%r{^lib/puppet\.rb$}) { |filename, _|
-rw-r--r--autotest/puppet_rspec.rb24
-rw-r--r--autotest/rspec.rb8
-rw-r--r--autotest/watcher.rb8
-rwxr-xr-xinstall.rb2
-rw-r--r--lib/puppet/application/filebucket.rb2
-rw-r--r--lib/puppet/external/pson/pure/generator.rb2
-rw-r--r--lib/puppet/provider/package/portage.rb4
-rw-r--r--lib/puppet/type/yumrepo.rb2
-rwxr-xr-xspec/unit/application/agent_spec.rb2
-rw-r--r--spec/unit/application/master_spec.rb2
-rwxr-xr-xspec/unit/indirector/node/ldap_spec.rb2
-rwxr-xr-xspec/unit/parser/lexer_spec.rb14
-rw-r--r--spec/unit/util/command_line_spec.rb22
13 files changed, 47 insertions, 47 deletions
diff --git a/autotest/puppet_rspec.rb b/autotest/puppet_rspec.rb
index 55695000a..1504d453d 100644
--- a/autotest/puppet_rspec.rb
+++ b/autotest/puppet_rspec.rb
@@ -5,40 +5,40 @@ Autotest.add_hook :initialize do |at|
at.clear_mappings
# the libraries under lib/puppet
- at.add_mapping(%r%^lib/puppet/(.*)\.rb$%) { |filename, m|
+ at.add_mapping(%r{^lib/puppet/(.*)\.rb$}) { |filename, m|
at.files_matching %r!spec/(unit|integration)/#{m[1]}.rb!
}
# the actual spec files themselves
- at.add_mapping(%r%^spec/(unit|integration)/.*\.rb$%) { |filename, _|
+ at.add_mapping(%r{^spec/(unit|integration)/.*\.rb$}) { |filename, _|
filename
}
# force a complete re-run for all of these:
# main puppet lib
- at.add_mapping(%r!^lib/puppet\.rb$!) { |filename, _|
- at.files_matching %r!spec/(unit|integration)/.*\.rb!
+ at.add_mapping(%r{^lib/puppet\.rb$}) { |filename, _|
+ at.files_matching %r{spec/(unit|integration)/.*\.rb}
}
# the spec_helper
- at.add_mapping(%r!^spec/spec_helper\.rb$!) { |filename, _|
- at.files_matching %r!spec/(unit|integration)/.*\.rb!
+ at.add_mapping(%r{^spec/spec_helper\.rb$}) { |filename, _|
+ at.files_matching %r{spec/(unit|integration)/.*\.rb}
}
# the puppet test libraries
- at.add_mapping(%r!^test/lib/puppettest/.*!) { |filename, _|
- at.files_matching %r!spec/(unit|integration)/.*\.rb!
+ at.add_mapping(%r{^test/lib/puppettest/.*}) { |filename, _|
+ at.files_matching %r{spec/(unit|integration)/.*\.rb}
}
# the puppet spec libraries
- at.add_mapping(%r!^spec/lib/spec.*!) { |filename, _|
- at.files_matching %r!spec/(unit|integration)/.*\.rb!
+ at.add_mapping(%r{^spec/lib/spec.*}) { |filename, _|
+ at.files_matching %r{spec/(unit|integration)/.*\.rb}
}
# the monkey patches for rspec
- at.add_mapping(%r!^spec/lib/monkey_patches/.*!) { |filename, _|
- at.files_matching %r!spec/(unit|integration)/.*\.rb!
+ at.add_mapping(%r{^spec/lib/monkey_patches/.*}) { |filename, _|
+ at.files_matching %r{spec/(unit|integration)/.*\.rb}
}
end
diff --git a/autotest/rspec.rb b/autotest/rspec.rb
index bf3d2d939..89978d866 100644
--- a/autotest/rspec.rb
+++ b/autotest/rspec.rb
@@ -3,14 +3,14 @@ require 'autotest'
Autotest.add_hook :initialize do |at|
at.clear_mappings
# watch out: Ruby bug (1.8.6):
- # %r(/) != /\//
- at.add_mapping(%r%^spec/.*\.rb$%) { |filename, _|
+ # %r{/} != /\//
+ at.add_mapping(%r{^spec/.*\.rb$}) { |filename, _|
filename
}
- at.add_mapping(%r%^lib/(.*)\.rb$%) { |_, m|
+ at.add_mapping(%r{^lib/(.*)\.rb$}) { |_, m|
["spec/#{m[1]}_spec.rb"]
}
- at.add_mapping(%r%^spec/(spec_helper|shared/.*)\.rb$%) {
+ at.add_mapping(%r{^spec/(spec_helper|shared/.*)\.rb$}) {
at.files_matching %r{^spec/.*_spec\.rb$}
}
end
diff --git a/autotest/watcher.rb b/autotest/watcher.rb
index 028d3fe7d..0beaca7c6 100644
--- a/autotest/watcher.rb
+++ b/autotest/watcher.rb
@@ -98,15 +98,15 @@ def run_suite
end
watch('spec/spec_helper.rb') { run_all_specs }
-watch(%r%^spec/(unit|integration)/.*\.rb$%) { |md| run_spec_files(md[0]) }
-watch(%r%^lib/puppet/(.*)\.rb$%) { |md|
+watch(%r{^spec/(unit|integration)/.*\.rb$}) { |md| run_spec_files(md[0]) }
+watch(%r{^lib/puppet/(.*)\.rb$}) { |md|
run_spec_files(file2specs(md[0]))
if t = file2test(md[0])
run_test_file(t)
end
}
-watch(%r!^spec/lib/spec.*!) { |md| run_all_specs }
-watch(%r!^spec/lib/monkey_patches/.*!) { |md| run_all_specs }
+watch(%r{^spec/lib/spec.*}) { |md| run_all_specs }
+watch(%r{^spec/lib/monkey_patches/.*}) { |md| run_all_specs }
watch(%r{test/.+\.rb}) { |md|
if md[0] =~ /\/lib\//
run_all_tests
diff --git a/install.rb b/install.rb
index 54a714674..18da2bebb 100755
--- a/install.rb
+++ b/install.rb
@@ -82,7 +82,7 @@ end
sbins = glob(%w{sbin/*})
bins = glob(%w{bin/*})
rdoc = glob(%w{bin/* sbin/* lib/**/*.rb README README-library CHANGELOG TODO Install}).reject { |e| e=~ /\.(bat|cmd)$/ }
-ri = glob(%w(bin/*.rb sbin/* lib/**/*.rb)).reject { |e| e=~ /\.(bat|cmd)$/ }
+ri = glob(%w{bin/*.rb sbin/* lib/**/*.rb}).reject { |e| e=~ /\.(bat|cmd)$/ }
man = glob(%w{man/man[0-9]/*})
libs = glob(%w{lib/**/*.rb lib/**/*.py})
tests = glob(%w{test/**/*.rb})
diff --git a/lib/puppet/application/filebucket.rb b/lib/puppet/application/filebucket.rb
index 8f9e91771..842e172c1 100644
--- a/lib/puppet/application/filebucket.rb
+++ b/lib/puppet/application/filebucket.rb
@@ -15,7 +15,7 @@ class Puppet::Application::Filebucket < Puppet::Application
def run_command
@args = command_line.args
command = args.shift
- return send(command) if %w[get backup restore].include? command
+ return send(command) if %w{get backup restore}.include? command
help
end
diff --git a/lib/puppet/external/pson/pure/generator.rb b/lib/puppet/external/pson/pure/generator.rb
index 44aa526c7..6656ed1b2 100644
--- a/lib/puppet/external/pson/pure/generator.rb
+++ b/lib/puppet/external/pson/pure/generator.rb
@@ -212,7 +212,7 @@ module PSON
# passed to the configure method.
def to_h
result = {}
- for iv in %w[indent space space_before object_nl array_nl check_circular allow_nan max_nesting]
+ for iv in %w{indent space space_before object_nl array_nl check_circular allow_nan max_nesting}
result[iv.intern] = instance_variable_get("@#{iv}")
end
result
diff --git a/lib/puppet/provider/package/portage.rb b/lib/puppet/provider/package/portage.rb
index ec0d1b7c4..5f3a5bd4c 100644
--- a/lib/puppet/provider/package/portage.rb
+++ b/lib/puppet/provider/package/portage.rb
@@ -20,7 +20,7 @@ Puppet::Type.type(:package).provide :portage, :parent => Puppet::Provider::Packa
search_format = "<category> <name> [<installedversions:LASTVERSION>] [<bestversion:LASTVERSION>] <homepage> <description>\n"
begin
- if !FileUtils.uptodate?("/var/cache/eix", %w(/usr/bin/eix /usr/portage/metadata/timestamp))
+ if !FileUtils.uptodate?("/var/cache/eix", %w{/usr/bin/eix /usr/portage/metadata/timestamp})
update_eix
end
@@ -83,7 +83,7 @@ Puppet::Type.type(:package).provide :portage, :parent => Puppet::Provider::Packa
search_value = package_name
begin
- if !FileUtils.uptodate?("/var/cache/eix", %w(/usr/bin/eix /usr/portage/metadata/timestamp))
+ if !FileUtils.uptodate?("/var/cache/eix", %w{/usr/bin/eix /usr/portage/metadata/timestamp})
update_eix
end
diff --git a/lib/puppet/type/yumrepo.rb b/lib/puppet/type/yumrepo.rb
index b6aceb55c..d430089fa 100644
--- a/lib/puppet/type/yumrepo.rb
+++ b/lib/puppet/type/yumrepo.rb
@@ -294,7 +294,7 @@ module Puppet
newproperty(:failovermethod, :parent => Puppet::IniProperty) do
desc "Either 'roundrobin' or 'priority'.\n#{ABSENT_DOC}"
newvalue(:absent) { self.should = :absent }
- newvalue(%r(roundrobin|priority)) { }
+ newvalue(%r{roundrobin|priority}) { }
end
newproperty(:keepalive, :parent => Puppet::IniProperty) do
diff --git a/spec/unit/application/agent_spec.rb b/spec/unit/application/agent_spec.rb
index 074b3781c..30d8edb58 100755
--- a/spec/unit/application/agent_spec.rb
+++ b/spec/unit/application/agent_spec.rb
@@ -155,7 +155,7 @@ describe Puppet::Application::Agent do
end
it "should parse the log destination from the command line" do
- @puppetd.command_line.stubs(:args).returns(%w[--logdest /my/file])
+ @puppetd.command_line.stubs(:args).returns(%w{--logdest /my/file})
Puppet::Util::Log.expects(:newdestination).with("/my/file")
diff --git a/spec/unit/application/master_spec.rb b/spec/unit/application/master_spec.rb
index 419f63dc7..f3c3b351d 100644
--- a/spec/unit/application/master_spec.rb
+++ b/spec/unit/application/master_spec.rb
@@ -102,7 +102,7 @@ describe Puppet::Application::Master do
end
it "should parse the log destination from ARGV" do
- @master.command_line.stubs(:args).returns(%w[--logdest /my/file])
+ @master.command_line.stubs(:args).returns(%w{--logdest /my/file})
Puppet::Util::Log.expects(:newdestination).with("/my/file")
diff --git a/spec/unit/indirector/node/ldap_spec.rb b/spec/unit/indirector/node/ldap_spec.rb
index 6f53b6ccf..aef623f86 100755
--- a/spec/unit/indirector/node/ldap_spec.rb
+++ b/spec/unit/indirector/node/ldap_spec.rb
@@ -170,7 +170,7 @@ describe Puppet::Node::Ldap do
end
it "should add any classes from ldap" do
- @result[:classes] = %w[a b c d]
+ @result[:classes] = %w{a b c d}
@node.expects(:classes=).with(%w{a b c d})
@searcher.find(@request)
end
diff --git a/spec/unit/parser/lexer_spec.rb b/spec/unit/parser/lexer_spec.rb
index 47a768469..d583d4938 100755
--- a/spec/unit/parser/lexer_spec.rb
+++ b/spec/unit/parser/lexer_spec.rb
@@ -407,15 +407,15 @@ end
describe Puppet::Parser::Lexer,"when lexing strings" do
{
- %q['single quoted string')] => [[:STRING,'single quoted string']],
- %q["double quoted string"] => [[:STRING,'double quoted string']],
- %q['single quoted string with an escaped "\\'"'] => [[:STRING,'single quoted string with an escaped "\'"']],
- %q["string with an escaped '\\"'"] => [[:STRING,"string with an escaped '\"'"]],
- %q["string with an escaped '\\$'"] => [[:STRING,"string with an escaped '$'"]],
- %q["string with $v (but no braces)"] => [[:DQPRE,"string with "],[:VARIABLE,'v'],[:DQPOST,' (but no braces)']],
+ %q{'single quoted string')} => [[:STRING,'single quoted string']],
+ %q{"double quoted string"} => [[:STRING,'double quoted string']],
+ %q{'single quoted string with an escaped "\\'"'} => [[:STRING,'single quoted string with an escaped "\'"']],
+ %q{"string with an escaped '\\"'"} => [[:STRING,"string with an escaped '\"'"]],
+ %q{"string with an escaped '\\$'"} => [[:STRING,"string with an escaped '$'"]],
+ %q{"string with $v (but no braces)"} => [[:DQPRE,"string with "],[:VARIABLE,'v'],[:DQPOST,' (but no braces)']],
%q["string with ${v} in braces"] => [[:DQPRE,"string with "],[:VARIABLE,'v'],[:DQPOST,' in braces']],
%q["string with ${qualified::var} in braces"] => [[:DQPRE,"string with "],[:VARIABLE,'qualified::var'],[:DQPOST,' in braces']],
- %q["string with $v and $v (but no braces)"] => [[:DQPRE,"string with "],[:VARIABLE,"v"],[:DQMID," and "],[:VARIABLE,"v"],[:DQPOST," (but no braces)"]],
+ %q{"string with $v and $v (but no braces)"} => [[:DQPRE,"string with "],[:VARIABLE,"v"],[:DQMID," and "],[:VARIABLE,"v"],[:DQPOST," (but no braces)"]],
%q["string with ${v} and ${v} in braces"] => [[:DQPRE,"string with "],[:VARIABLE,"v"],[:DQMID," and "],[:VARIABLE,"v"],[:DQPOST," in braces"]],
%q["string with ${'a nested single quoted string'} inside it."] => [[:DQPRE,"string with "],[:STRING,'a nested single quoted string'],[:DQPOST,' inside it.']],
%q["string with ${['an array ',$v2]} in it."] => [[:DQPRE,"string with "],:LBRACK,[:STRING,"an array "],:COMMA,[:VARIABLE,"v2"],:RBRACK,[:DQPOST," in it."]],
diff --git a/spec/unit/util/command_line_spec.rb b/spec/unit/util/command_line_spec.rb
index 31b2d1b03..bb2d073ed 100644
--- a/spec/unit/util/command_line_spec.rb
+++ b/spec/unit/util/command_line_spec.rb
@@ -12,42 +12,42 @@ describe Puppet::Util::CommandLine do
end
it "should pull off the first argument if it looks like a subcommand" do
- command_line = Puppet::Util::CommandLine.new("puppet", %w( client --help whatever.pp ), @tty )
+ command_line = Puppet::Util::CommandLine.new("puppet", %w{ client --help whatever.pp }, @tty )
command_line.subcommand_name.should == "client"
- command_line.args.should == %w( --help whatever.pp )
+ command_line.args.should == %w{ --help whatever.pp }
end
it "should use 'apply' if the first argument looks like a .pp file" do
- command_line = Puppet::Util::CommandLine.new("puppet", %w( whatever.pp ), @tty )
+ command_line = Puppet::Util::CommandLine.new("puppet", %w{ whatever.pp }, @tty )
command_line.subcommand_name.should == "apply"
- command_line.args.should == %w( whatever.pp )
+ command_line.args.should == %w{ whatever.pp }
end
it "should use 'apply' if the first argument looks like a .rb file" do
- command_line = Puppet::Util::CommandLine.new("puppet", %w( whatever.rb ), @tty )
+ command_line = Puppet::Util::CommandLine.new("puppet", %w{ whatever.rb }, @tty )
command_line.subcommand_name.should == "apply"
- command_line.args.should == %w( whatever.rb )
+ command_line.args.should == %w{ whatever.rb }
end
it "should use 'apply' if the first argument looks like a flag" do
- command_line = Puppet::Util::CommandLine.new("puppet", %w( --debug ), @tty )
+ command_line = Puppet::Util::CommandLine.new("puppet", %w{ --debug }, @tty )
command_line.subcommand_name.should == "apply"
- command_line.args.should == %w( --debug )
+ command_line.args.should == %w{ --debug }
end
it "should use 'apply' if the first argument is -" do
- command_line = Puppet::Util::CommandLine.new("puppet", %w( - ), @tty )
+ command_line = Puppet::Util::CommandLine.new("puppet", %w{ - }, @tty )
command_line.subcommand_name.should == "apply"
- command_line.args.should == %w( - )
+ command_line.args.should == %w{ - }
end
it "should return nil if the first argument is --help" do
- command_line = Puppet::Util::CommandLine.new("puppet", %w( --help ), @tty )
+ command_line = Puppet::Util::CommandLine.new("puppet", %w{ --help }, @tty )
command_line.subcommand_name.should == nil
end