lib/chef-api/util.rb in chef-infra-api-0.10.0 vs lib/chef-api/util.rb in chef-infra-api-0.10.2

- old
+ new

@@ -12,14 +12,14 @@ # @return [String] # def underscore(string) string .to_s - .gsub(/::/, '/') - .gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2') - .gsub(/([a-z\d])([A-Z])/,'\1_\2') - .tr('-', '_') + .gsub(/::/, "/") + .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') + .gsub(/([a-z\d])([A-Z])/, '\1_\2') + .tr("-", "_") .downcase end # # Convert an underscored string to it's camelcase equivalent constant. @@ -30,12 +30,12 @@ # @return [String] # def camelize(string) string .to_s - .split('_') - .map { |e| e.capitalize } + .split("_") + .map(&:capitalize) .join end # # Truncate the given string to a certain number of characters. @@ -47,11 +47,11 @@ # def truncate(string, options = {}) length = options[:length] || 30 if string.length > length - string[0..length-3] + '...' + string[0..length - 3] + "..." else string end end @@ -75,10 +75,10 @@ # A array where the first value is the basename of the file and the # second value is the literal contents from +File.read+. # def safe_read(path) path = File.expand_path(path) - name = File.basename(path, '.*') + name = File.basename(path, ".*") contents = File.read(path) [name, contents] rescue Errno::EACCES raise Error::InsufficientFilePermissions.new(path: path)