Skip to content

MODULES-6139 Revert to old ruby 1.X style of hash #858

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ RSpec/BeforeAfterAll:
RSpec/HookArgument:
Description: Prefer explicit :each argument, matching existing module's style
EnforcedStyle: each
Style/HashSyntax:
EnforcedStyle: hash_rockets
Style/BlockDelimiters:
Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to
be consistent then.
Expand Down Expand Up @@ -97,4 +99,4 @@ Style/IfUnlessModifier:
Style/SymbolProc:
Enabled: false
RSpec/NamedSubject:
Enabled: false
Enabled: false
2 changes: 1 addition & 1 deletion lib/facter/facter_dot_d.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def cache_save!
def cache_store(file, data)
load_cache

@cache[file] = { data: data, stored: Time.now.to_i }
@cache[file] = { :data => data, :stored => Time.now.to_i }
rescue # rubocop:disable Lint/HandleExceptions - Is meant to be suppressed
end

Expand Down
4 changes: 2 additions & 2 deletions lib/facter/package_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
Facter.add(:package_provider) do
setcode do
if defined? Gem && Gem::Version.new(Facter.value(:puppetversion).split(' ')[0]) >= Gem::Version.new('3.6')
Puppet::Type.type(:package).newpackage(name: 'dummy', allow_virtual: 'true')[:provider].to_s
Puppet::Type.type(:package).newpackage(:name => 'dummy', :allow_virtual => 'true')[:provider].to_s
else
Puppet::Type.type(:package).newpackage(name: 'dummy')[:provider].to_s
Puppet::Type.type(:package).newpackage(:name => 'dummy')[:provider].to_s
end
end
end
6 changes: 3 additions & 3 deletions lib/facter/pe_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
end

Facter.add('pe_major_version') do
confine is_pe: true
confine :is_pe => true
setcode do
pe_version = Facter.value(:pe_version)
if pe_version
Expand All @@ -41,7 +41,7 @@
end

Facter.add('pe_minor_version') do
confine is_pe: true
confine :is_pe => true
setcode do
pe_version = Facter.value(:pe_version)
if pe_version
Expand All @@ -51,7 +51,7 @@
end

Facter.add('pe_patch_version') do
confine is_pe: true
confine :is_pe => true
setcode do
pe_version = Facter.value(:pe_version)
if pe_version
Expand Down
4 changes: 2 additions & 2 deletions lib/facter/root_home.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def returnt_root_home
end

Facter.add(:root_home) do
confine kernel: :darwin
confine :kernel => :darwin
setcode do
str = Facter::Util::Resolution.exec('dscacheutil -q user -a name root')
hash = {}
Expand All @@ -31,7 +31,7 @@ def returnt_root_home
end

Facter.add(:root_home) do
confine kernel: :aix
confine :kernel => :aix
root_home = nil
setcode do
str = Facter::Util::Resolution.exec('lsuser -c -a home root')
Expand Down
2 changes: 1 addition & 1 deletion lib/facter/service_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@

Facter.add(:service_provider) do
setcode do
Puppet::Type.type(:service).newservice(name: 'dummy')[:provider].to_s
Puppet::Type.type(:service).newservice(:name => 'dummy')[:provider].to_s
end
end
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/abs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# abs.rb
#
module Puppet::Parser::Functions
newfunction(:abs, type: :rvalue, doc: <<-EOS
newfunction(:abs, :type => :rvalue, :doc => <<-EOS
Returns the absolute value of a number, for example -34.56 becomes
34.56. Takes a single integer and float value as an argument.
EOS
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/any2array.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# any2array.rb
#
module Puppet::Parser::Functions
newfunction(:any2array, type: :rvalue, doc: <<-EOS
newfunction(:any2array, :type => :rvalue, :doc => <<-EOS
This converts any object to an array containing that object. Empty argument
lists are converted to an empty array. Arrays are left untouched. Hashes are
converted to arrays of alternating keys and values.
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/any2bool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# any2bool.rb
#
module Puppet::Parser::Functions
newfunction(:any2bool, type: :rvalue, doc: <<-EOS
newfunction(:any2bool, :type => :rvalue, :doc => <<-EOS
This converts 'anything' to a boolean. In practise it does the following:
* Strings such as Y,y,1,T,t,TRUE,yes,'true' will return true
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/assert_private.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# assert_private.rb
#
module Puppet::Parser::Functions
newfunction(:assert_private, doc: <<-'EOS'
newfunction(:assert_private, :doc => <<-'EOS'
Sets the current class or definition as private.
Calling the class or definition from outside the current module will fail.
EOS
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/base64.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085.
module Puppet::Parser::Functions
newfunction(:base64, type: :rvalue, doc: <<-'ENDHEREDOC') do |args|
newfunction(:base64, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
Base64 encode or decode a string based on the command and the string submitted
Usage:
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/basename.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# basename.rb
#
module Puppet::Parser::Functions
newfunction(:basename, type: :rvalue, doc: <<-EOS
newfunction(:basename, :type => :rvalue, :doc => <<-EOS
Strips directory (and optional suffix) from a filename
EOS
) do |arguments|
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/bool2num.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# bool2num.rb
#
module Puppet::Parser::Functions
newfunction(:bool2num, type: :rvalue, doc: <<-EOS
newfunction(:bool2num, :type => :rvalue, :doc => <<-EOS
Converts a boolean to a number. Converts the values:
false, f, 0, n, and no to 0
true, t, 1, y, and yes to 1
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/bool2str.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# bool2str.rb
#
module Puppet::Parser::Functions
newfunction(:bool2str, type: :rvalue, doc: <<-EOS
newfunction(:bool2str, :type => :rvalue, :doc => <<-EOS
Converts a boolean to a string using optionally supplied arguments. The
optional second and third arguments represent what true and false will be
converted to respectively. If only one argument is given, it will be
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/camelcase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085.
#
module Puppet::Parser::Functions
newfunction(:camelcase, type: :rvalue, doc: <<-EOS
newfunction(:camelcase, :type => :rvalue, :doc => <<-EOS
Converts the case of a string or all strings in an array to camel case.
EOS
) do |arguments|
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/capitalize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085.
#
module Puppet::Parser::Functions
newfunction(:capitalize, type: :rvalue, doc: <<-EOS
newfunction(:capitalize, :type => :rvalue, :doc => <<-EOS
Capitalizes the first letter of a string or array of strings.
Requires either a single string or an array as an input.
EOS
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/ceiling.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# ceiling.rb
#
module Puppet::Parser::Functions
newfunction(:ceiling, type: :rvalue, doc: <<-EOS
newfunction(:ceiling, :type => :rvalue, :doc => <<-EOS
Returns the smallest integer greater or equal to the argument.
Takes a single numeric value as an argument.
EOS
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/chomp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# chomp.rb
#
module Puppet::Parser::Functions
newfunction(:chomp, type: :rvalue, doc: <<-'EOS'
newfunction(:chomp, :type => :rvalue, :doc => <<-'EOS'
Removes the record separator from the end of a string or an array of
strings, for example `hello\n` becomes `hello`.
Requires a single string or array as an input.
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/chop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# chop.rb
#
module Puppet::Parser::Functions
newfunction(:chop, type: :rvalue, doc: <<-'EOS'
newfunction(:chop, :type => :rvalue, :doc => <<-'EOS'
Returns a new string with the last character removed. If the string ends
with `\r\n`, both characters are removed. Applying chop to an empty
string returns an empty string. If you wish to merely remove record
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/clamp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# clamp.rb
#
module Puppet::Parser::Functions
newfunction(:clamp, type: :rvalue, arity: -2, doc: <<-EOS
newfunction(:clamp, :type => :rvalue, :arity => -2, :doc => <<-EOS
Clamps value to a range.
EOS
) do |args|
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/concat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# concat.rb
#
module Puppet::Parser::Functions
newfunction(:concat, type: :rvalue, doc: <<-EOS
newfunction(:concat, :type => :rvalue, :doc => <<-EOS
Appends the contents of multiple arrays into array 1.
*Example:*
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/convert_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# convert_base.rb
#
module Puppet::Parser::Functions
newfunction(:convert_base, type: :rvalue, arity: 2, doc: <<-'ENDHEREDOC') do |args|
newfunction(:convert_base, :type => :rvalue, :arity => 2, :doc => <<-'ENDHEREDOC') do |args|
Converts a given integer or base 10 string representing an integer to a specified base, as a string.
Usage:
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/count.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# count.rb
#
module Puppet::Parser::Functions
newfunction(:count, type: :rvalue, arity: -2, doc: <<-EOS
newfunction(:count, :type => :rvalue, :arity => -2, :doc => <<-EOS
Takes an array as first argument and an optional second argument.
Count the number of elements in array that matches second argument.
If called with only an array it counts the number of elements that are not nil/undef.
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/deep_merge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# deep_merge.rb
#
module Puppet::Parser::Functions
newfunction(:deep_merge, type: :rvalue, doc: <<-'ENDHEREDOC') do |args|
newfunction(:deep_merge, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
Recursively merges two or more hashes together and returns the resulting hash.
For example:
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet/parser/functions/defined_with_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
require 'puppet/parser/functions'

Puppet::Parser::Functions.newfunction(:defined_with_params,
type: :rvalue,
doc: <<-'ENDOFDOC'
:type => :rvalue,
:doc => <<-'ENDOFDOC'
Takes a resource reference and an optional hash of attributes.
Returns true if a resource with the specified attributes has already been added
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/delete.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# delete.rb
#
module Puppet::Parser::Functions
newfunction(:delete, type: :rvalue, doc: <<-EOS
newfunction(:delete, :type => :rvalue, :doc => <<-EOS
Deletes all instances of a given element from an array, substring from a
string, or key from a hash.
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/delete_at.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# delete_at.rb
#
module Puppet::Parser::Functions
newfunction(:delete_at, type: :rvalue, doc: <<-EOS
newfunction(:delete_at, :type => :rvalue, :doc => <<-EOS
Deletes a determined indexed value from an array.
*Examples:*
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/delete_regex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085.
#
module Puppet::Parser::Functions
newfunction(:delete_regex, type: :rvalue, doc: <<-EOS
newfunction(:delete_regex, :type => :rvalue, :doc => <<-EOS
deletes all instances of a given element that match a regular expression
from an array or key from a hash. Multiple regular expressions are assumed
to be matched as an OR.
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/delete_undef_values.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# delete_undef_values.rb
#
module Puppet::Parser::Functions
newfunction(:delete_undef_values, type: :rvalue, doc: <<-EOS
newfunction(:delete_undef_values, :type => :rvalue, :doc => <<-EOS
Returns a copy of input hash or array with all undefs deleted.
*Examples:*
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/delete_values.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# delete_values.rb
#
module Puppet::Parser::Functions
newfunction(:delete_values, type: :rvalue, doc: <<-EOS
newfunction(:delete_values, :type => :rvalue, :doc => <<-EOS
Deletes all instances of a given value from a hash.
*Examples:*
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/deprecation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# deprecation.rb
#
module Puppet::Parser::Functions
newfunction(:deprecation, doc: <<-EOS
newfunction(:deprecation, :doc => <<-EOS
Function to print deprecation warnings (this is the 3.X version of it), The uniqueness key - can appear once. The msg is the message text including any positional information that is formatted by the user/caller of the method.).
EOS
) do |arguments|
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/difference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# difference.rb
#
module Puppet::Parser::Functions
newfunction(:difference, type: :rvalue, doc: <<-EOS
newfunction(:difference, :type => :rvalue, :doc => <<-EOS
This function returns the difference between two arrays.
The returned array is a copy of the original array, removing any items that
also appear in the second array.
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/dig.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# dig.rb
#
module Puppet::Parser::Functions
newfunction(:dig, type: :rvalue, doc: <<-EOS
newfunction(:dig, :type => :rvalue, :doc => <<-EOS
DEPRECATED: This function has been replaced in Puppet 4.5.0, please use dig44() for backwards compatibility or use the new version.
EOS
) do |arguments|
Expand Down
6 changes: 3 additions & 3 deletions lib/puppet/parser/functions/dig44.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
module Puppet::Parser::Functions
newfunction(
:dig44,
type: :rvalue,
arity: -2,
doc: <<-eos
:type => :rvalue,
:arity => -2,
:doc => <<-eos
DEPRECATED: This function has been replaced in puppet 4.5.0.
Looks up into a complex structure of arrays and hashes and returns a value
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/dirname.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# dirname.rb
#
module Puppet::Parser::Functions
newfunction(:dirname, type: :rvalue, doc: <<-EOS
newfunction(:dirname, :type => :rvalue, :doc => <<-EOS
Returns the dirname of a path.
EOS
) do |arguments|
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/dos2unix.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Custom Puppet function to convert dos to unix format
module Puppet::Parser::Functions
newfunction(:dos2unix, type: :rvalue, arity: 1, doc: <<-EOS
newfunction(:dos2unix, :type => :rvalue, :arity => 1, :doc => <<-EOS
Returns the Unix version of the given string.
Takes a single string argument.
EOS
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/downcase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085.
#
module Puppet::Parser::Functions
newfunction(:downcase, type: :rvalue, doc: <<-EOS
newfunction(:downcase, :type => :rvalue, :doc => <<-EOS
Converts the case of a string or all strings in an array to lower case.
EOS
) do |arguments|
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/empty.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# empty.rb
#
module Puppet::Parser::Functions
newfunction(:empty, type: :rvalue, doc: <<-EOS
newfunction(:empty, :type => :rvalue, :doc => <<-EOS
Returns true if the variable is empty.
EOS
) do |arguments|
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/enclose_ipv6.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# enclose_ipv6.rb
#
module Puppet::Parser::Functions
newfunction(:enclose_ipv6, type: :rvalue, doc: <<-EOS
newfunction(:enclose_ipv6, :type => :rvalue, :doc => <<-EOS
Takes an array of ip addresses and encloses the ipv6 addresses with square brackets.
EOS
) do |arguments|
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/ensure_packages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# ensure_packages.rb
#
module Puppet::Parser::Functions
newfunction(:ensure_packages, type: :statement, doc: <<-EOS
newfunction(:ensure_packages, :type => :statement, :doc => <<-EOS
Takes a list of packages and only installs them if they don't already exist.
It optionally takes a hash as a second parameter that will be passed as the
third argument to the ensure_resource() function.
Expand Down
Loading