diff --git a/Rakefile b/Rakefile index 7162b79d5..ed17917da 100644 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,7 @@ require "bundler/gem_tasks" require "rspec/core/rake_task" -[:unit, :functional].each do |type| +%i{unit functional}.each do |type| RSpec::Core::RakeTask.new(type) do |t| t.pattern = "spec/#{type}/**/*_spec.rb" t.rspec_opts = [].tap do |a| diff --git a/lib/omnibus/build_version_dsl.rb b/lib/omnibus/build_version_dsl.rb index 6e2468f96..e6e58cbb7 100644 --- a/lib/omnibus/build_version_dsl.rb +++ b/lib/omnibus/build_version_dsl.rb @@ -134,6 +134,7 @@ def maybe_append_timestamp(version) def has_timestamp?(version) _ver, build_info = version.split("+") return false if build_info.nil? + build_info.split(".").any? do |part| begin Time.strptime(part, Omnibus::BuildVersion::TIMESTAMP_FORMAT) diff --git a/lib/omnibus/builder.rb b/lib/omnibus/builder.rb index 4eddbcbca..b71a53e15 100644 --- a/lib/omnibus/builder.rb +++ b/lib/omnibus/builder.rb @@ -235,7 +235,8 @@ def patch(options = {}) clean_patch_path = patch_path if windows? clean_patch_path = Pathname.new(patch_path).relative_path_from( - Pathname.new(software.project_dir)).to_s + Pathname.new(software.project_dir) + ).to_s end if target @@ -385,6 +386,7 @@ def appbundle(software_name, lockdir: nil, gem: nil, without: nil, extra_bin_fil if app_software.nil? raise "could not find software definition for #{software_name}, add a dependency to it, or pass a lockdir argument to appbundle command." end + app_software.project_dir end @@ -500,8 +502,7 @@ def erb(options = {}) render_template(source_path, destination: dest, mode: mode, - variables: vars - ) + variables: vars) end end expose :erb @@ -596,7 +597,7 @@ def delete(path, options = {}) # def strip(path) regexp_ends = ".*(" + IGNORED_ENDINGS.map { |e| e.gsub(/\./, '\.') }.join("|") + ")$" - regexp_patterns = IGNORED_PATTERNS.map { |e| ".*" + e.gsub(/\//, '\/') + ".*" }.join("|") + regexp_patterns = IGNORED_PATTERNS.map { |e| ".*" + e.gsub(%r{/}, '\/') + ".*" }.join("|") regexp = regexp_ends + "|" + regexp_patterns # Do not actually care if strip runs on non-strippable file, as its a no-op. Hence the `|| true` appended. @@ -727,7 +728,7 @@ def sync(source, destination, options = {}) # config.guess.to. Default: "." # install [Array] parts of config.guess to copy. # Default: [:config_guess, :config_sub] - def update_config_guess(target: ".", install: [:config_guess, :config_sub]) + def update_config_guess(target: ".", install: %i{config_guess config_sub}) build_commands << BuildCommand.new("update_config_guess `target: #{target} install: #{install.inspect}'") do config_guess_dir = "#{install_dir}/embedded/lib/config_guess" %w{config.guess config.sub}.each do |c| diff --git a/lib/omnibus/changelog_printer.rb b/lib/omnibus/changelog_printer.rb index 1cc6bc16b..f4e9aabdd 100644 --- a/lib/omnibus/changelog_printer.rb +++ b/lib/omnibus/changelog_printer.rb @@ -8,9 +8,9 @@ def initialize(changelog, diff, source_path = "../") end def print(new_version) - puts "## #{new_version} (#{Time.now.strftime('%Y-%m-%d')})" + puts "## #{new_version} (#{Time.now.strftime("%Y-%m-%d")})" print_changelog - if !diff.empty? + unless diff.empty? print_components puts "" end @@ -23,7 +23,7 @@ def print(new_version) def print_changelog(cl = changelog, indent = 0) cl.changelog_entries.each do |entry| - puts "#{' ' * indent}* #{entry.sub("\n", "\n #{' ' * indent}")}\n" + puts "#{" " * indent}* #{entry.sub("\n", "\n #{" " * indent}")}\n" end end @@ -36,6 +36,7 @@ def print_components def print_new_components return if diff.added.empty? + puts "New Components" diff.added.each do |entry| puts "* #{entry[:name]} (#{entry[:new_version]})" @@ -45,10 +46,11 @@ def print_new_components def print_updated_components return if diff.updated.empty? + puts "Updated Components" diff.updated.each do |entry| puts sprintf("* %s (%.8s -> %.8s)", - entry[:name], entry[:old_version], entry[:new_version]) + entry[:name], entry[:old_version], entry[:new_version]) repo_path = ::File.join(source_path, entry[:name].to_s) if entry[:source_type] == :git && ::File.directory?("#{repo_path}/.git") cl = ChangeLog.new(entry[:old_version], entry[:new_version], GitRepository.new("#{repo_path}")) @@ -60,6 +62,7 @@ def print_updated_components def print_removed_components return if diff.removed.empty? + puts "Removed Components" diff.removed.each do |entry| puts "* #{entry[:name]} (#{entry[:old_version]})" diff --git a/lib/omnibus/cleaner.rb b/lib/omnibus/cleaner.rb index 6ca14f13c..27e6949c4 100644 --- a/lib/omnibus/cleaner.rb +++ b/lib/omnibus/cleaner.rb @@ -48,16 +48,19 @@ def clean_build_dir def clean_package_dir return unless purge? + FileSyncer.glob("#{Config.package_dir}/**/*").each(&method(:remove_file)) end def clean_cache_dir return unless purge? + FileSyncer.glob("#{Config.cache_dir}/**/*").each(&method(:remove_file)) end def clean_install_dir return unless purge? + remove_file(@project.install_dir) end diff --git a/lib/omnibus/cli/changelog.rb b/lib/omnibus/cli/changelog.rb index f68de336d..9479f7af9 100644 --- a/lib/omnibus/cli/changelog.rb +++ b/lib/omnibus/cli/changelog.rb @@ -30,42 +30,42 @@ class Command::ChangeLog < Command::Base # $ omnibus changelog generate # method_option :source_path, - desc: "Path to local checkout of git dependencies", - type: :string, - default: "../" + desc: "Path to local checkout of git dependencies", + type: :string, + default: "../" method_option :starting_manifest, - desc: "Path to version-manifest from the last version (we attempt to pull it from the git history if not given)", - type: :string + desc: "Path to version-manifest from the last version (we attempt to pull it from the git history if not given)", + type: :string method_option :ending_manifest, - desc: "Path to the version-manifest from the current version", - type: :string, - default: "version-manifest.json" + desc: "Path to the version-manifest from the current version", + type: :string, + default: "version-manifest.json" method_option :skip_components, - desc: "Don't include component changes in the changelog", - type: :boolean, - default: false + desc: "Don't include component changes in the changelog", + type: :boolean, + default: false method_option :major, - desc: "Bump the major version", - type: :boolean, - default: false + desc: "Bump the major version", + type: :boolean, + default: false method_option :minor, - desc: "Bump the minor version", - type: :boolean, - default: true + desc: "Bump the minor version", + type: :boolean, + default: true method_option :patch, - desc: "Bump the patch version", - type: :boolean, - default: false + desc: "Bump the patch version", + type: :boolean, + default: false method_option :version, - desc: "Explicit version for this changelog", - type: :string + desc: "Explicit version for this changelog", + type: :string desc "generate [START] [END]", "Generate a changelog for a new release" def generate(start_ref = nil, end_ref = nil) @@ -78,8 +78,8 @@ def generate(start_ref = nil, end_ref = nil) end Omnibus::ChangeLogPrinter.new(ChangeLog.new(starting_revision, ending_revision), - diff, - @options[:source_path]).print(new_version) + diff, + @options[:source_path]).print(new_version) end private diff --git a/lib/omnibus/compressors/dmg.rb b/lib/omnibus/compressors/dmg.rb index 2089a7ea0..64e0c3032 100644 --- a/lib/omnibus/compressors/dmg.rb +++ b/lib/omnibus/compressors/dmg.rb @@ -234,8 +234,7 @@ def prettify_dmg pkg_name: packager.package_name, window_bounds: window_bounds, pkg_position: pkg_position, - } - ) + }) Dir.chdir(staging_dir) do shellout! <<-EOH.gsub(/^ {10}/, "") @@ -316,10 +315,10 @@ def set_dmg_icon Dir.chdir(staging_dir) do shellout! <<-EOH.gsub(/^ {10}/, "") # Convert the png to an icon - sips -i "#{resource_path('icon.png')}" + sips -i "#{resource_path("icon.png")}" # Extract the icon into its own resource - DeRez -only icns "#{resource_path('icon.png')}" > tmp.rsrc + DeRez -only icns "#{resource_path("icon.png")}" > tmp.rsrc # Append the icon reosurce to the DMG Rez -append tmp.rsrc -o "#{package_path}" diff --git a/lib/omnibus/fetchers/git_fetcher.rb b/lib/omnibus/fetchers/git_fetcher.rb index 617a64866..229f258f0 100644 --- a/lib/omnibus/fetchers/git_fetcher.rb +++ b/lib/omnibus/fetchers/git_fetcher.rb @@ -276,6 +276,7 @@ def self.revision_from_remote_reference(ref, source) unless commit_ref raise UnresolvableGitReference.new(ref) end + commit_ref end diff --git a/lib/omnibus/fetchers/net_fetcher.rb b/lib/omnibus/fetchers/net_fetcher.rb index 6f9cee62a..ff3c75641 100644 --- a/lib/omnibus/fetchers/net_fetcher.rb +++ b/lib/omnibus/fetchers/net_fetcher.rb @@ -31,7 +31,7 @@ class NetFetcher < Fetcher ALL_EXTENSIONS = WIN_7Z_EXTENSIONS + TAR_EXTENSIONS # Digest types used for verifying file checksums - DIGESTS = [:sha512, :sha256, :sha1, :md5].freeze + DIGESTS = %i{sha512 sha256 sha1 md5}.freeze # # A fetch is required if the downloaded_file (such as a tarball) does not @@ -314,8 +314,7 @@ def safe_downloaded_file # # @return [[String]] # - def extract_command - end + def extract_command; end # # Primitively determine whether we should use gtar or tar to untar a file. diff --git a/lib/omnibus/health_check.rb b/lib/omnibus/health_check.rb index e4b70da30..d55b92aeb 100644 --- a/lib/omnibus/health_check.rb +++ b/lib/omnibus/health_check.rb @@ -331,7 +331,7 @@ def health_check_aix # def health_check_ldd regexp_ends = ".*(" + IGNORED_ENDINGS.map { |e| e.gsub(/\./, '\.') }.join("|") + ")$" - regexp_patterns = IGNORED_PATTERNS.map { |e| ".*" + e.gsub(/\//, '\/') + ".*" }.join("|") + regexp_patterns = IGNORED_PATTERNS.map { |e| ".*" + e.gsub(%r{/}, '\/') + ".*" }.join("|") regexp = regexp_ends + "|" + regexp_patterns current_library = nil diff --git a/lib/omnibus/licensing.rb b/lib/omnibus/licensing.rb index be89052ce..c1c755d4b 100644 --- a/lib/omnibus/licensing.rb +++ b/lib/omnibus/licensing.rb @@ -130,8 +130,7 @@ def prepare # # @return [void] # - def execute_pre_build(software) - end + def execute_pre_build(software); end # Callback that gets called by Software#build_me after the build is done. # Invokes license copying for the given software. This ensures that @@ -246,7 +245,7 @@ def components_license_summary out << "This product bundles #{name} #{version},\n" out << "which is available under a \"#{license}\" License.\n" - if !license_files.empty? + unless license_files.empty? out << "For details, see:\n" license_files.each do |license_file| out << "#{license_package_location(name, license_file)}\n" diff --git a/lib/omnibus/logger.rb b/lib/omnibus/logger.rb index c8eef69c7..851ec0cbe 100644 --- a/lib/omnibus/logger.rb +++ b/lib/omnibus/logger.rb @@ -102,6 +102,7 @@ def live_stream(level = :debug) # def add(severity, progname, &block) return true if io.nil? || severity < level + message = format_message(severity, progname, yield) MUTEX.synchronize { io.write(message) } true @@ -138,7 +139,7 @@ def format_message(severity, progname, message) else left = "#{format_severity(severity)} | " end - "#{left.rjust(LEFT)}#{Time.now.iso8601()} | #{message}\n" + "#{left.rjust(LEFT)}#{Time.now.iso8601} | #{message}\n" end # diff --git a/lib/omnibus/manifest.rb b/lib/omnibus/manifest.rb index c8303b46d..f5c06a376 100644 --- a/lib/omnibus/manifest.rb +++ b/lib/omnibus/manifest.rb @@ -44,7 +44,7 @@ def entry_for(name) end def add(name, entry) - if ! entry.is_a? Omnibus::ManifestEntry + unless entry.is_a? Omnibus::ManifestEntry raise NotAManifestEntry, "#{entry} is not an Omnibus:ManifestEntry" end diff --git a/lib/omnibus/packagers/appx.rb b/lib/omnibus/packagers/appx.rb index c5e7ae95c..8c43c8ee2 100644 --- a/lib/omnibus/packagers/appx.rb +++ b/lib/omnibus/packagers/appx.rb @@ -69,8 +69,7 @@ def write_manifest_file version: windows_package_version, maintainer: project.maintainer, certificate_subject: certificate_subject.gsub('"', """), - } - ) + }) end # diff --git a/lib/omnibus/packagers/base.rb b/lib/omnibus/packagers/base.rb index af2c8276d..205c5ddc2 100644 --- a/lib/omnibus/packagers/base.rb +++ b/lib/omnibus/packagers/base.rb @@ -142,6 +142,7 @@ def skip_packager(val = false) unless val.is_a?(TrueClass) || val.is_a?(FalseClass) raise InvalidValue.new(:skip_packager, "be TrueClass or FalseClass") end + @skip_package ||= val end expose :skip_packager diff --git a/lib/omnibus/packagers/bff.rb b/lib/omnibus/packagers/bff.rb index 2ff0fe3f9..d8faea6a3 100644 --- a/lib/omnibus/packagers/bff.rb +++ b/lib/omnibus/packagers/bff.rb @@ -153,12 +153,11 @@ def write_gen_template destination: "#{scripts_staging_dir}/config", variables: { name: project.name, - } - ) + }) end File.open(File.join(scripts_staging_dir, "config"), "a") do |file| - file.puts "mv '#{alt.gsub(/^#{staging_dir}/, '')}' '#{path.gsub(/^#{staging_dir}/, '')}'" + file.puts "mv '#{alt.gsub(/^#{staging_dir}/, "")}' '#{path.gsub(/^#{staging_dir}/, "")}'" end path = alt @@ -189,8 +188,7 @@ def write_gen_template description: project.description, files: files, scripts: scripts, - } - ) + }) # Print the full contents of the rendered template file for mkinstallp's use log.debug(log_key) { "Rendered Template:\n" + File.read(File.join(staging_dir, "gen.template")) } @@ -214,19 +212,19 @@ def create_bff_file # we will chown from 'project' on, rather than 'project/dir', which leaves # project owned by the build user (which is incorrect) # First - let's find out who we are. - shellout!("sudo chown -Rh 0:0 #{File.join(staging_dir, project.install_dir.match(/^\/?(\w+)/).to_s)}") + shellout!("sudo chown -Rh 0:0 #{File.join(staging_dir, project.install_dir.match(%r{^/?(\w+)}).to_s)}") log.info(log_key) { "Creating .bff file" } # Since we want the owner to be root, we need to sudo the mkinstallp # command, otherwise it will not have access to the previously chowned # directory. - shellout!("sudo /usr/sbin/mkinstallp -d #{staging_dir} -T #{File.join(staging_dir, 'gen.template')}") + shellout!("sudo /usr/sbin/mkinstallp -d #{staging_dir} -T #{File.join(staging_dir, "gen.template")}") # Print the full contents of the inventory file generated by mkinstallp # from within the staging_dir's .info folder (where control files for the # packaging process are kept.) log.debug(log_key) do - "With .inventory file of:\n" + File.read("#{File.join( staging_dir, '.info', "#{safe_base_package_name}.inventory" )}") + "With .inventory file of:\n" + File.read("#{File.join( staging_dir, ".info", "#{safe_base_package_name}.inventory" )}") end # Copy the resulting package up to the package_dir diff --git a/lib/omnibus/packagers/deb.rb b/lib/omnibus/packagers/deb.rb index 7c76dc7c0..8feac2a98 100644 --- a/lib/omnibus/packagers/deb.rb +++ b/lib/omnibus/packagers/deb.rb @@ -207,7 +207,7 @@ def compression_type(val = NULL) if null?(val) @compression_type || :gzip else - unless val.is_a?(Symbol) && [:gzip, :xz, :none].member?(val) + unless val.is_a?(Symbol) && %i{gzip xz none}.member?(val) raise InvalidValue.new(:compression_type, "be a Symbol (:gzip, :xz, or :none)") end @@ -261,7 +261,7 @@ def compression_strategy(val = NULL) @compression_strategy else unless val.is_a?(Symbol) && - [:filtered, :huffman, :rle, :fixed, :extreme].member?(val) + %i{filtered huffman rle fixed extreme}.member?(val) raise InvalidValue.new(:compression_strategy, "be a Symbol (:filtered, "\ ":huffman, :rle, :fixed, or :extreme)") end @@ -320,8 +320,7 @@ def write_control_file conflicts: project.conflicts, replaces: project.replaces, dependencies: project.runtime_dependencies, - } - ) + }) end # @@ -336,8 +335,7 @@ def write_conffiles_file destination: File.join(debian_dir, "conffiles"), variables: { config_files: project.config_files, - } - ) + }) end # @@ -380,8 +378,7 @@ def write_md5_sums destination: File.join(debian_dir, "md5sums"), variables: { md5sums: hash, - } - ) + }) end # @@ -421,7 +418,7 @@ def compression_params # # @return [void] def sign_deb_file - if !signing_passphrase + unless signing_passphrase log.info(log_key) { "Signing not enabled for .deb file" } return end @@ -447,7 +444,7 @@ def sign_deb_file # Create signature (as +root+) gpg_command = "#{gpg} --armor --sign --detach-sign" gpg_command << " --local-user '#{project.maintainer}'" - gpg_command << " --homedir #{ENV['HOME']}/.gnupg" # TODO: Make this configurable + gpg_command << " --homedir #{ENV["HOME"]}/.gnupg" # TODO: Make this configurable ## pass the +signing_passphrase+ via +STDIN+ gpg_command << " --batch --no-tty" ## Check `gpg` for the compatibility/need of pinentry-mode diff --git a/lib/omnibus/packagers/ips.rb b/lib/omnibus/packagers/ips.rb index e9933cf83..69aa6243c 100644 --- a/lib/omnibus/packagers/ips.rb +++ b/lib/omnibus/packagers/ips.rb @@ -209,8 +209,7 @@ def write_transform_file destination: transform_file, variables: { pathdir: project.install_dir.split("/")[1], - } - ) + }) end # @@ -242,8 +241,7 @@ def render_symlinks render_template_content(resource_path(symlinks_file), { projectdir: project.install_dir, - } - ) + }) end # @@ -262,8 +260,7 @@ def write_pkg_metadata description: project.description, summary: project.friendly_name, arch: safe_architecture, - } - ) + }) # Append the contents of symlinks_file if it exists if symlinks_file diff --git a/lib/omnibus/packagers/makeself.rb b/lib/omnibus/packagers/makeself.rb index 010670b71..b325c799d 100644 --- a/lib/omnibus/packagers/makeself.rb +++ b/lib/omnibus/packagers/makeself.rb @@ -81,8 +81,7 @@ def write_makeselfinst destination: makeselfinst_staging_path, variables: { install_dir: project.install_dir, - } - ) + }) FileUtils.chmod(0755, makeselfinst_staging_path) end diff --git a/lib/omnibus/packagers/msi.rb b/lib/omnibus/packagers/msi.rb index a79aa1bb9..a8a7bda96 100644 --- a/lib/omnibus/packagers/msi.rb +++ b/lib/omnibus/packagers/msi.rb @@ -181,10 +181,12 @@ def wix_light_delay_validation(val = false) unless val.is_a?(TrueClass) || val.is_a?(FalseClass) raise InvalidValue.new(:iwix_light_delay_validation, "be TrueClass or FalseClass") end + @delay_validation ||= val unless @delay_validation return "" end + "-sval" end expose :wix_light_delay_validation @@ -225,6 +227,7 @@ def bundle_msi(val = false) unless val.is_a?(TrueClass) || val.is_a?(FalseClass) raise InvalidValue.new(:bundle_msi, "be TrueClass or FalseClass") end + @bundle_msi ||= val end expose :bundle_msi @@ -244,6 +247,7 @@ def fast_msi(val = false) unless val.is_a?(TrueClass) || val.is_a?(FalseClass) raise InvalidValue.new(:fast_msi, "be TrueClass or FalseClass") end + @fast_msi ||= val end expose :fast_msi @@ -298,6 +302,7 @@ def gem_path(glob = NULL) raise "Could not find `#{search_pattern}'!" if file_paths.none? raise "Multiple possible matches of `#{search_pattern}'! : #{file_paths}" if file_paths.count > 1 + file_paths.first.relative_path_from(install_path).to_s end expose :gem_path @@ -340,8 +345,7 @@ def write_localization_file name: project.package_name, friendly_name: project.friendly_name, maintainer: project.maintainer, - } - ) + }) end # @@ -360,8 +364,7 @@ def write_parameters_file parameters: parameters, version: windows_package_version, display_version: msi_display_version, - } - ) + }) end # @@ -408,8 +411,7 @@ def write_source_file hierarchy: hierarchy, fastmsi: fast_msi, wix_install_dir: wix_install_dir, - } - ) + }) end # @@ -429,8 +431,7 @@ def write_bundle_file version: windows_package_version, display_version: msi_display_version, msi: windows_safe_path(Config.package_dir, msi_name), - } - ) + }) end # @@ -487,7 +488,7 @@ def candle_command(is_bundle: false) -ext WixBalExtension #{wix_extension_switches(wix_candle_extensions)} -dOmnibusCacheDir="#{windows_safe_path(File.expand_path(Config.cache_dir))}" - "#{windows_safe_path(staging_dir, 'bundle.wxs')}" + "#{windows_safe_path(staging_dir, "bundle.wxs")}" EOH else <<-EOH.split.join(" ").squeeze(" ").strip @@ -496,7 +497,7 @@ def candle_command(is_bundle: false) #{wix_candle_flags} #{wix_extension_switches(wix_candle_extensions)} -dProjectSourceDir="#{windows_safe_path(project.install_dir)}" "project-files.wxs" - "#{windows_safe_path(staging_dir, 'source.wxs')}" + "#{windows_safe_path(staging_dir, "source.wxs")}" EOH end end @@ -588,7 +589,7 @@ def wix_candle_flags # @return [String] # def wix_extension_switches(arr) - "#{arr.map { |e| "-ext '#{e}'" }.join(' ')}" + "#{arr.map { |e| "-ext '#{e}'" }.join(" ")}" end end end diff --git a/lib/omnibus/packagers/pkg.rb b/lib/omnibus/packagers/pkg.rb index 9bf749d9c..858811502 100644 --- a/lib/omnibus/packagers/pkg.rb +++ b/lib/omnibus/packagers/pkg.rb @@ -44,8 +44,7 @@ class Packager::PKG < Packager::Base maintainer: project.maintainer, build_version: project.build_version, package_name: project.package_name, - } - ) + }) # Render the welcome template render_template(resource_path("welcome.html.erb"), @@ -56,8 +55,7 @@ class Packager::PKG < Packager::Base maintainer: project.maintainer, build_version: project.build_version, package_name: project.package_name, - } - ) + }) # "Render" the assets copy_file(resource_path("background.png"), "#{resources_dir}/background.png") @@ -221,8 +219,7 @@ def write_distribution_file identifier: safe_identifier, version: safe_version, component_pkg: component_pkg, - } - ) + }) end # diff --git a/lib/omnibus/packagers/rpm.rb b/lib/omnibus/packagers/rpm.rb index d49b47ff2..135fb8eba 100644 --- a/lib/omnibus/packagers/rpm.rb +++ b/lib/omnibus/packagers/rpm.rb @@ -243,7 +243,7 @@ def compression_type(val = NULL) if null?(val) @compression_type || :gzip else - unless val.is_a?(Symbol) && [:gzip, :bzip2, :xz].member?(val) + unless val.is_a?(Symbol) && %i{gzip bzip2 xz}.member?(val) raise InvalidValue.new(:compression_type, "be a Symbol (:gzip, :bzip2, or :xz)") end @@ -317,7 +317,7 @@ def config_files # @return [Array] # def filesystem_directories - @filesystem_directories ||= IO.readlines(resource_path("filesystem_list")).map { |f| f.chomp } + @filesystem_directories ||= IO.readlines(resource_path("filesystem_list")).map(&:chomp) end # @@ -356,7 +356,7 @@ def write_rpm_spec # Get a list of all files files = FileSyncer.glob("#{build_dir}/**/*") - .map { |path| build_filepath(path) } + .map { |path| build_filepath(path) } render_template(resource_path("spec.erb"), destination: spec_file, @@ -383,8 +383,7 @@ def write_rpm_spec build_dir: build_dir, platform_family: Ohai["platform_family"], compression: compression, - } - ) + }) end # @@ -422,8 +421,8 @@ def create_rpm_file if signing_passphrase log.info(log_key) { "Signing enabled for .rpm file" } - if File.exist?("#{ENV['HOME']}/.rpmmacros") - log.info(log_key) { "Detected .rpmmacros file at `#{ENV['HOME']}'" } + if File.exist?("#{ENV["HOME"]}/.rpmmacros") + log.info(log_key) { "Detected .rpmmacros file at `#{ENV["HOME"]}'" } home = ENV["HOME"] else log.info(log_key) { "Using default .rpmmacros file from Omnibus" } @@ -435,9 +434,8 @@ def create_rpm_file destination: "#{home}/.rpmmacros", variables: { gpg_name: project.maintainer, - gpg_path: "#{ENV['HOME']}/.gnupg", # TODO: Make this configurable - } - ) + gpg_path: "#{ENV["HOME"]}/.gnupg", # TODO: Make this configurable + }) end command << " --sign" @@ -466,11 +464,13 @@ def create_rpm_file def build_filepath(path) filepath = rpm_safe("/" + path.gsub("#{build_dir}/", "")) return if config_files.include?(filepath) + full_path = build_dir + filepath.gsub("[%]", "%") # FileSyncer.glob quotes pathnames that contain spaces, which is a problem on el7 full_path.delete!('"') # Mark directories with the %dir directive to prevent rpmbuild from counting their contents twice. return mark_filesystem_directories(filepath) if !File.symlink?(full_path) && File.directory?(full_path) + filepath end @@ -502,8 +502,7 @@ def with_rpm_signing(&block) mode: 0700, variables: { passphrase: signing_passphrase, - } - ) + }) # Yield the destination to the block yield(destination) diff --git a/lib/omnibus/packagers/solaris.rb b/lib/omnibus/packagers/solaris.rb index 6afc70fa5..476a5f728 100644 --- a/lib/omnibus/packagers/solaris.rb +++ b/lib/omnibus/packagers/solaris.rb @@ -76,7 +76,7 @@ def write_scripts # Generate a Prototype file for solaris build # def write_prototype_file - shellout! "cd #{install_dirname} && find #{install_basename} -print > #{staging_dir_path('files')}" + shellout! "cd #{install_dirname} && find #{install_basename} -print > #{staging_dir_path("files")}" File.open staging_dir_path("files.clean"), "w+" do |fout| File.open staging_dir_path("files") do |fin| @@ -100,10 +100,10 @@ def write_prototype_file end # generate the prototype's file list - shellout! "cd #{install_dirname} && pkgproto < #{staging_dir_path('files.clean')} > #{staging_dir_path('Prototype.files')}" + shellout! "cd #{install_dirname} && pkgproto < #{staging_dir_path("files.clean")} > #{staging_dir_path("Prototype.files")}" # fix up the user and group in the file list to root - shellout! "awk '{ $5 = \"root\"; $6 = \"root\"; print }' < #{staging_dir_path('Prototype.files')} >> #{staging_dir_path('Prototype')}" + shellout! "awk '{ $5 = \"root\"; $6 = \"root\"; print }' < #{staging_dir_path("Prototype.files")} >> #{staging_dir_path("Prototype")}" end # @@ -139,7 +139,7 @@ def write_pkginfo_file # @return [void] # def create_solaris_file - shellout! "pkgmk -o -r #{install_dirname} -d #{staging_dir} -f #{staging_dir_path('Prototype')}" + shellout! "pkgmk -o -r #{install_dirname} -d #{staging_dir} -f #{staging_dir_path("Prototype")}" shellout! "pkgchk -vd #{staging_dir} #{project.package_name}" shellout! "pkgtrans #{staging_dir} #{package_path} #{project.package_name}" end diff --git a/lib/omnibus/packagers/windows_base.rb b/lib/omnibus/packagers/windows_base.rb index 24399bb91..7773ec522 100644 --- a/lib/omnibus/packagers/windows_base.rb +++ b/lib/omnibus/packagers/windows_base.rb @@ -59,11 +59,11 @@ def signing_identity(thumbprint = NULL, params = NULL) raise InvalidValue.new(:params, "be a Hash") end - valid_keys = [:store, :timestamp_servers, :machine_store, :algorithm] + valid_keys = %i{store timestamp_servers machine_store algorithm} invalid_keys = params.keys - valid_keys unless invalid_keys.empty? - raise InvalidValue.new(:params, "contain keys from [#{valid_keys.join(', ')}]. "\ - "Found invalid keys [#{invalid_keys.join(', ')}]") + raise InvalidValue.new(:params, "contain keys from [#{valid_keys.join(", ")}]. "\ + "Found invalid keys [#{invalid_keys.join(", ")}]") end if !params[:machine_store].nil? && !( @@ -117,11 +117,11 @@ def sign_package(package_file) success = try_sign(package_file, ts) break if success end - raise FailedToSignWindowsPackage.new if !success + raise FailedToSignWindowsPackage.new unless success end def try_sign(package_file, url) - cmd = Array.new.tap do |arr| + cmd = [].tap do |arr| arr << "signtool.exe" arr << "sign /v" arr << "/t #{url}" @@ -158,8 +158,9 @@ def try_sign(package_file, url) # def certificate_subject return "CN=#{project.package_name}" unless signing_identity + store = machine_store? ? "LocalMachine" : "CurrentUser" - cmd = Array.new.tap do |arr| + cmd = [].tap do |arr| arr << "powershell.exe" arr << "-ExecutionPolicy Bypass" arr << "-NoProfile" diff --git a/lib/omnibus/project.rb b/lib/omnibus/project.rb index 09b35d80c..f5a83198d 100644 --- a/lib/omnibus/project.rb +++ b/lib/omnibus/project.rb @@ -1007,6 +1007,7 @@ def library # def dirty!(software) raise ProjectAlreadyDirty.new(self) if culprit + @culprit = software end diff --git a/lib/omnibus/publisher.rb b/lib/omnibus/publisher.rb index 099233ead..335ca7743 100644 --- a/lib/omnibus/publisher.rb +++ b/lib/omnibus/publisher.rb @@ -69,7 +69,7 @@ def initialize(pattern, options = {}) # def packages @packages ||= begin - publish_packages = Array.new + publish_packages = [] build_packages = FileSyncer.glob(@pattern).map { |path| Package.new(path) } if @options[:platform_mappings] @@ -88,7 +88,7 @@ def packages if packages.empty? log.warn(log_key) do "Could not locate a package for build platform #{build_platform}-#{build_platform_version}-#{build_architecture}. " \ - "Publishing will be skipped for: #{publish_platforms.join(', ')}" + "Publishing will be skipped for: #{publish_platforms.join(", ")}" end end diff --git a/lib/omnibus/software.rb b/lib/omnibus/software.rb index 383c061a1..2dd81c412 100644 --- a/lib/omnibus/software.rb +++ b/lib/omnibus/software.rb @@ -305,7 +305,7 @@ def source(val = NULL) "only include valid keys. Invalid keys: #{extra_keys.inspect}") end - duplicate_keys = val.keys & [:git, :file, :path, :url] + duplicate_keys = val.keys & %i{git file path url} unless duplicate_keys.size < 2 raise InvalidValue.new(:source, "not include duplicate keys. Duplicate keys: #{duplicate_keys.inspect}") @@ -509,7 +509,7 @@ def version(val = NULL, &block) # the list of currently whitelisted files # def whitelist_file(file) - file = Regexp.new(file) unless file.kind_of?(Regexp) + file = Regexp.new(file) unless file.is_a?(Regexp) whitelist_files << file whitelist_files.dup end diff --git a/lib/omnibus/templating.rb b/lib/omnibus/templating.rb index e68b2b70b..4f8c134ad 100644 --- a/lib/omnibus/templating.rb +++ b/lib/omnibus/templating.rb @@ -73,7 +73,7 @@ def render_template(source, options = {}) unless options.empty? raise ArgumentError, - "Unknown option(s): #{options.keys.map(&:inspect).join(', ')}" + "Unknown option(s): #{options.keys.map(&:inspect).join(", ")}" end # String value returned from #render_template_content diff --git a/lib/omnibus/util.rb b/lib/omnibus/util.rb index 540ad5462..62781edb2 100644 --- a/lib/omnibus/util.rb +++ b/lib/omnibus/util.rb @@ -80,7 +80,7 @@ def path_key # populated with results of the command. # def shellout(*args) - options = args.last.kind_of?(Hash) ? args.pop : {} + options = args.last.is_a?(Hash) ? args.pop : {} options = SHELLOUT_OPTIONS.merge(options) command_string = args.join(" ") @@ -158,6 +158,7 @@ def retry_block(logstr, retried_exceptions = [], retries = Omnibus::Config.fetch yield rescue Exception => e raise e unless retried_exceptions.any? { |eclass| e.is_a?(eclass) } + if retries != 0 log.info(log_key) { "Retrying failed #{logstr} due to #{e} (#{retries} retries left)..." } retries -= 1 @@ -196,7 +197,7 @@ def windows_safe_path(*pieces) # def compiler_safe_path(*pieces) path = File.join(*pieces) - path = path.sub(/^([A-Za-z]):\//, "/\\1/") if ENV["MSYSTEM"] + path = path.sub(%r{^([A-Za-z]):/}, "/\\1/") if ENV["MSYSTEM"] path end diff --git a/omnibus.gemspec b/omnibus.gemspec index 9487a5102..9c7dbd5f2 100644 --- a/omnibus.gemspec +++ b/omnibus.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new do |gem| gem.files = %w{ LICENSE README.md Rakefile Gemfile } + Dir.glob("*.gemspec") + Dir.glob("{bin,lib,resources,spec}/**/{*,.kitchen*}") gem.bindir = "bin" gem.executables = %w{omnibus} - gem.test_files = gem.files.grep(/^(test|spec|features)\//) + gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.require_paths = ["lib"] gem.add_dependency "aws-sdk-s3", "~> 1" diff --git a/spec/functional/builder_spec.rb b/spec/functional/builder_spec.rb index 7fc59af9f..f9a76cbd1 100644 --- a/spec/functional/builder_spec.rb +++ b/spec/functional/builder_spec.rb @@ -22,6 +22,7 @@ def fake_embedded_bin(name) ext = name == "ruby" ? ".exe" : ".bat" source = Bundler.which(name + ext) raise "Could not find #{name} in bundler environment" unless source + File.open(File.join(embedded_bin_dir, name + ".bat"), "w") do |f| f.write <<-EOH.gsub(/^ {12}/, "") @"#{source}" %* @@ -221,7 +222,7 @@ def make_gemfile_lock output = capture_logging { subject.build } appbundler_path = File.join(embedded_bin_dir, "appbundler") - appbundler_path.gsub!(/\//, '\\') if windows? + appbundler_path.gsub!(%r{/}, '\\') if windows? expect(output).to include("#{appbundler_path} '#{project_dir}' '#{bin_dir}'") end end diff --git a/spec/functional/fetchers/file_fetcher_spec.rb b/spec/functional/fetchers/file_fetcher_spec.rb index fc855f5a5..134893e41 100644 --- a/spec/functional/fetchers/file_fetcher_spec.rb +++ b/spec/functional/fetchers/file_fetcher_spec.rb @@ -13,10 +13,10 @@ module Omnibus let(:manifest_entry) do double(Omnibus::ManifestEntry, - name: "pathelogical", - locked_version: nil, - described_version: nil, - locked_source: source) + name: "pathelogical", + locked_version: nil, + described_version: nil, + locked_source: source) end subject { described_class.new(manifest_entry, project_dir, build_dir) } diff --git a/spec/functional/fetchers/git_fetcher_spec.rb b/spec/functional/fetchers/git_fetcher_spec.rb index d985edc66..84f71dffc 100644 --- a/spec/functional/fetchers/git_fetcher_spec.rb +++ b/spec/functional/fetchers/git_fetcher_spec.rb @@ -110,10 +110,10 @@ module Omnibus let(:remote) { remote_git_repo("zlib", annotated_tags: [version]) } let(:manifest_entry) do double(ManifestEntry, - name: "software", - locked_version: "efde208366abd0f91419d8a54b45e3f6e0540105", - described_version: version, - locked_source: source) + name: "software", + locked_version: "efde208366abd0f91419d8a54b45e3f6e0540105", + described_version: version, + locked_source: source) end subject { described_class.new(manifest_entry, project_dir, build_dir) } diff --git a/spec/functional/fetchers/net_fetcher_spec.rb b/spec/functional/fetchers/net_fetcher_spec.rb index 15bc48b83..503e33a52 100644 --- a/spec/functional/fetchers/net_fetcher_spec.rb +++ b/spec/functional/fetchers/net_fetcher_spec.rb @@ -4,8 +4,7 @@ module Omnibus module RSpec module OhaiHelpers # Turn off the mandatory Ohai helper. - def stub_ohai(options = {}, &block) - end + def stub_ohai(options = {}, &block); end end end @@ -29,10 +28,10 @@ def stub_ohai(options = {}, &block) let(:manifest_entry) do double(ManifestEntry, - name: "software", - locked_version: "1.2.8", - described_version: "1.2.8", - locked_source: source) + name: "software", + locked_version: "1.2.8", + described_version: "1.2.8", + locked_source: source) end subject { described_class.new(manifest_entry, project_dir, build_dir) } diff --git a/spec/functional/fetchers/path_fetcher_spec.rb b/spec/functional/fetchers/path_fetcher_spec.rb index 9af0b2332..45b55199c 100644 --- a/spec/functional/fetchers/path_fetcher_spec.rb +++ b/spec/functional/fetchers/path_fetcher_spec.rb @@ -12,10 +12,10 @@ module Omnibus let(:manifest_entry) do double(Omnibus::ManifestEntry, - name: "pathelogical", - locked_version: nil, - described_version: nil, - locked_source: source) + name: "pathelogical", + locked_version: nil, + described_version: nil, + locked_source: source) end before do diff --git a/spec/functional/licensing_spec.rb b/spec/functional/licensing_spec.rb index 787d4d479..674de8115 100644 --- a/spec/functional/licensing_spec.rb +++ b/spec/functional/licensing_spec.rb @@ -37,14 +37,14 @@ module Omnibus expect(project_license).to match /This product bundles private_code 1.7.2,\nwhich is available under a "Unspecified"/ expect(project_license).to match /This product bundles snoopy 1.0.0,\nwhich is available under a "GPL v2"/ expect(project_license).not_to match /preparation/ - expect(project_license).to match /LICENSES\/snoopy-artistic.html/ - expect(project_license).to match /LICENSES\/snoopy-NOTICE/ + expect(project_license).to match %r{LICENSES/snoopy-artistic.html} + expect(project_license).to match %r{LICENSES/snoopy-NOTICE} if zlib_version_override expect(project_license).to match /This product bundles zlib 1.8.0,\nwhich is available under a "Apache-2.0"/ - expect(project_license).to match /LICENSES\/zlib-APACHE/ + expect(project_license).to match %r{LICENSES/zlib-APACHE} else expect(project_license).to match /This product bundles zlib 1.7.2,\nwhich is available under a "Zlib"/ - expect(project_license).to match /LICENSES\/zlib-LICENSE/ + expect(project_license).to match %r{LICENSES/zlib-LICENSE} end end @@ -263,7 +263,7 @@ def create_licenses it "should log a warning for the missing file" do output = capture_logging { create_licenses } expect(output).to match(/Retrying failed download/) - expect(output).to match(/Can not download license file 'https:\/\/downloads.chef.io\/LICENSE' for software 'problematic'./) + expect(output).to match(%r{Can not download license file 'https://downloads.chef.io/LICENSE' for software 'problematic'.}) end end diff --git a/spec/support/examples.rb b/spec/support/examples.rb index d8d0cbc92..91613ba4f 100644 --- a/spec/support/examples.rb +++ b/spec/support/examples.rb @@ -27,8 +27,7 @@ install_dir: install_dir, project_dir: project_dir, source: source, - overridden?: false - ) + overridden?: false) end before do @@ -56,12 +55,12 @@ FileUtils.mkdir_p(embedded_bin_dir) allow(software).to receive(:with_embedded_path).and_return( - "PATH" => "#{bin_dir}:#{embedded_bin_dir}:#{ENV['PATH']}" + "PATH" => "#{bin_dir}:#{embedded_bin_dir}:#{ENV["PATH"]}" ) allow(software).to receive(:embedded_bin) do |binary| p = File.join(embedded_bin_dir, binary) - p.gsub!(/\//, '\\') if windows? + p.gsub!(%r{/}, '\\') if windows? p end end diff --git a/spec/unit/builder_spec.rb b/spec/unit/builder_spec.rb index bb9ccce2c..1565c0d65 100644 --- a/spec/unit/builder_spec.rb +++ b/spec/unit/builder_spec.rb @@ -6,8 +6,7 @@ module Omnibus double(Software, name: "chefdk", install_dir: project_dir, - project_dir: project_dir - ) + project_dir: project_dir) end let(:project_dir) { on_windows ? "C:/opscode/chefdk" : "/opt/chefdk" } @@ -238,7 +237,7 @@ def run_build_command it "appends platform host to the options" do expect(subject).to receive(:command) .with("./configure --build=x86_64-w64-mingw32 --prefix=#{project_dir}/embedded", in_msys_bash: true) - subject.configure() + subject.configure end end @@ -254,7 +253,7 @@ def run_build_command it "appends platform host to the options" do expect(subject).to receive(:command) .with("./configure --build=i686-w64-mingw32 --prefix=#{project_dir}/embedded", in_msys_bash: true) - subject.configure() + subject.configure end end @@ -305,7 +304,8 @@ def run_build_command .with("config/patches", "good_patch") .and_return( [ ["#{project_dir}/patch_location1/good_patch", "#{project_dir}/patch_location2/good_patch"], - "#{project_dir}/patch_location2/good_patch" ]) + "#{project_dir}/patch_location2/good_patch" ] + ) end it "is a DSL method" do @@ -355,10 +355,10 @@ def run_build_command let(:software) do double(Software, - name: "chefdk", - install_dir: tmp_dir, - project_dir: tmp_dir, - overridden?: false) + name: "chefdk", + install_dir: tmp_dir, + project_dir: tmp_dir, + overridden?: false) end let(:before_build_shasum) do diff --git a/spec/unit/changelogprinter_spec.rb b/spec/unit/changelogprinter_spec.rb index de64ece46..2c9dbc443 100644 --- a/spec/unit/changelogprinter_spec.rb +++ b/spec/unit/changelogprinter_spec.rb @@ -16,16 +16,18 @@ def manifest_entry_for(name, dv, lv, source_type = :local) let(:changelog) do double(ChangeLog, - changelog_entries: %w{entry1 entry2}, - authors: %w{alice bob}) end + changelog_entries: %w{entry1 entry2}, + authors: %w{alice bob}) + end let(:git_changelog) do double(ChangeLog, - changelog_entries: - %w{sub-entry1 sub-entry2}) end + changelog_entries: + %w{sub-entry1 sub-entry2}) + end let(:now) { double(Time) } let(:emptydiff) { EmptyManifestDiff.new } let(:old_manifest) do - m = Manifest.new() + m = Manifest.new m.add("updated-comp", manifest_entry_for("updated-comp", "v9", "v9")) m.add("updated-comp-2", manifest_entry_for("updated-comp-2", "someref0", "someref0", :git)) m.add("removed-comp", manifest_entry_for("removed-comp", "v9", "v9")) @@ -33,7 +35,7 @@ def manifest_entry_for(name, dv, lv, source_type = :local) m end let(:new_manifest) do - m = Manifest.new() + m = Manifest.new m.add("updated-comp", manifest_entry_for("updated-comp", "v10", "v10")) m.add("updated-comp-2", manifest_entry_for("updated-comp-2", "someotherref", "someotherref", :git)) m.add("added-comp", manifest_entry_for("added-comp", "v100", "v100")) diff --git a/spec/unit/compressor_spec.rb b/spec/unit/compressor_spec.rb index 8544da61c..d2a687d77 100644 --- a/spec/unit/compressor_spec.rb +++ b/spec/unit/compressor_spec.rb @@ -8,13 +8,13 @@ module Omnibus context "when :dmg is activated" do it "prefers dmg" do - expect(described_class.for_current_system([:tgz, :dmg])).to eq(Compressor::DMG) + expect(described_class.for_current_system(%i{tgz dmg})).to eq(Compressor::DMG) end end context "when :dmg is not activated" do it "prefers tgz" do - expect(described_class.for_current_system([:tgz, :foo])).to eq(Compressor::TGZ) + expect(described_class.for_current_system(%i{tgz foo})).to eq(Compressor::TGZ) end end @@ -30,7 +30,7 @@ module Omnibus context "when :tgz activated" do it "prefers tgz" do - expect(described_class.for_current_system([:tgz, :foo])).to eq(Compressor::TGZ) + expect(described_class.for_current_system(%i{tgz foo})).to eq(Compressor::TGZ) end end diff --git a/spec/unit/fetchers/net_fetcher_spec.rb b/spec/unit/fetchers/net_fetcher_spec.rb index d062a4efd..b569f8c14 100644 --- a/spec/unit/fetchers/net_fetcher_spec.rb +++ b/spec/unit/fetchers/net_fetcher_spec.rb @@ -11,10 +11,10 @@ module Omnibus let(:manifest_entry) do double(Omnibus::ManifestEntry, - name: "file", - locked_version: "1.2.3", - described_version: "1.2.3", - locked_source: source) + name: "file", + locked_version: "1.2.3", + described_version: "1.2.3", + locked_source: source) end let(:cache_dir) { "/cache" } @@ -331,11 +331,10 @@ def capturing_stdout context "when the file is a .#{extension}" do let(:manifest_entry) do double(Omnibus::ManifestEntry, - name: "file", - locked_version: "1.2.3", - described_version: "1.2.3", - locked_source: { url: "https://get.example.com/file.#{extension}", md5: "abcd1234" }.merge(source_options) - ) + name: "file", + locked_version: "1.2.3", + described_version: "1.2.3", + locked_source: { url: "https://get.example.com/file.#{extension}", md5: "abcd1234" }.merge(source_options)) end subject { described_class.new(manifest_entry, project_dir, build_dir) } @@ -361,10 +360,10 @@ def capturing_stdout context "when the downloaded file is a folder" do let(:manifest_entry) do double(Omnibus::ManifestEntry, - name: "file", - locked_version: "1.2.3", - described_version: "1.2.3", - locked_source: { url: "https://get.example.com/folder", md5: "abcd1234" }) + name: "file", + locked_version: "1.2.3", + described_version: "1.2.3", + locked_source: { url: "https://get.example.com/folder", md5: "abcd1234" }) end subject { described_class.new(manifest_entry, project_dir, build_dir) } @@ -382,10 +381,10 @@ def capturing_stdout context "when the downloaded file is a regular file" do let(:manifest_entry) do double(Omnibus::ManifestEntry, - name: "file", - locked_version: "1.2.3", - described_version: "1.2.3", - locked_source: { url: "https://get.example.com/file", md5: "abcd1234" }) + name: "file", + locked_version: "1.2.3", + described_version: "1.2.3", + locked_source: { url: "https://get.example.com/file", md5: "abcd1234" }) end subject { described_class.new(manifest_entry, project_dir, build_dir) } diff --git a/spec/unit/health_check_spec.rb b/spec/unit/health_check_spec.rb index 2f3f20192..8c59faf9c 100644 --- a/spec/unit/health_check_spec.rb +++ b/spec/unit/health_check_spec.rb @@ -8,9 +8,7 @@ module Omnibus name: "chefdk", install_dir: "/opt/chefdk", library: double(Library, - components: [] - ) - ) + components: [])) end def mkdump(base, size, x64 = false) @@ -19,9 +17,7 @@ def mkdump(base, size, x64 = false) x64?: x64, ioh: double(x64 ? PEdump::IMAGE_OPTIONAL_HEADER64 : PEdump::IMAGE_OPTIONAL_HEADER32, ImageBase: base, - SizeOfImage: size - ) - ) + SizeOfImage: size)) expect(dump).to receive(:pe).and_return(pe) dump end diff --git a/spec/unit/library_spec.rb b/spec/unit/library_spec.rb index a16e64023..8b5df6540 100644 --- a/spec/unit/library_spec.rb +++ b/spec/unit/library_spec.rb @@ -125,7 +125,8 @@ def generate_software(name, version, dependencies = []) erchef, # project dep chef, # project dep chefdk, # project dep - ]) + ] + ) end end end diff --git a/spec/unit/manifest_diff_spec.rb b/spec/unit/manifest_diff_spec.rb index ba049cf18..95201b90b 100644 --- a/spec/unit/manifest_diff_spec.rb +++ b/spec/unit/manifest_diff_spec.rb @@ -12,7 +12,7 @@ def manifest_entry_for(name, dv, lv) end let(:manifest_one) do - m = Omnibus::Manifest.new() + m = Omnibus::Manifest.new m.add("foo", manifest_entry_for("foo", "1.2.4", "deadbeef")) m.add("bar", manifest_entry_for("bar", "1.2.4", "deadbeef")) m.add("baz", manifest_entry_for("baz", "1.2.4", "deadbeef")) @@ -20,7 +20,7 @@ def manifest_entry_for(name, dv, lv) end let(:manifest_two) do - m = Omnibus::Manifest.new() + m = Omnibus::Manifest.new m.add("foo", manifest_entry_for("foo", "1.2.5", "deadbea0")) m.add("baz", manifest_entry_for("baz", "1.2.4", "deadbeef")) m.add("quux", manifest_entry_for("quux", "1.2.4", "deadbeef")) diff --git a/spec/unit/manifest_spec.rb b/spec/unit/manifest_spec.rb index ddce60387..974586378 100644 --- a/spec/unit/manifest_spec.rb +++ b/spec/unit/manifest_spec.rb @@ -45,7 +45,7 @@ module Omnibus second = ManifestEntry.new("wombat", {}) subject.add("foobar", first) subject.add("wombat", second) - expect(subject.entry_names).to eq([:foobar, :wombat]) + expect(subject.entry_names).to eq(%i{foobar wombat}) end end diff --git a/spec/unit/metadata_spec.rb b/spec/unit/metadata_spec.rb index b75c000bd..0736972f2 100644 --- a/spec/unit/metadata_spec.rb +++ b/spec/unit/metadata_spec.rb @@ -16,8 +16,7 @@ module Omnibus md5: "abc123", sha1: "abc123", sha256: "abcd1234", - sha512: "abcdef123456" - ) + sha512: "abcdef123456") end let(:project) do @@ -29,15 +28,13 @@ module Omnibus build_iteration: "1", license: "Apache-2.0", built_manifest: double(Manifest, - to_hash: { - manifest_format: 2, - build_version: "1.2.3", - build_git_revision: "SHA", - license: "Apache-2.0", - } - ), - license_file_path: license_path - ) + to_hash: { + manifest_format: 2, + build_version: "1.2.3", + build_git_revision: "SHA", + license: "Apache-2.0", + }), + license_file_path: license_path) end let(:data) { { foo: "bar" } } diff --git a/spec/unit/omnibus_spec.rb b/spec/unit/omnibus_spec.rb index b5a7d334d..1a392e31e 100644 --- a/spec/unit/omnibus_spec.rb +++ b/spec/unit/omnibus_spec.rb @@ -15,7 +15,7 @@ Omnibus::Config.project_root(File.join(tmp_path, "/foo/bar")) Omnibus::Config.local_software_dirs([File.join(tmp_path, "/local"), File.join(tmp_path, "/other")]) - Omnibus::Config.software_gems(["omnibus-software", "custom-omnibus-software"]) + Omnibus::Config.software_gems(%w{omnibus-software custom-omnibus-software}) end describe "#which" do diff --git a/spec/unit/packagers/bff_spec.rb b/spec/unit/packagers/bff_spec.rb index 939bf8118..ee9eedbc6 100644 --- a/spec/unit/packagers/bff_spec.rb +++ b/spec/unit/packagers/bff_spec.rb @@ -301,7 +301,7 @@ class = apply,inventory,angry-omnibus-toolchain # A note - the /opt/ here is essentially project.install_dir one level up. # There is nothing magical about 'opt' as a directory. expect(subject).to receive(:shellout!) - .with(/chown -Rh 0:0 #{staging_dir}\/opt$/) + .with(%r{chown -Rh 0:0 #{staging_dir}/opt$}) subject.create_bff_file end @@ -312,7 +312,7 @@ class = apply,inventory,angry-omnibus-toolchain it "uses the correct command" do expect(subject).to receive(:shellout!) - .with(/\/usr\/sbin\/mkinstallp -d/) + .with(%r{/usr/sbin/mkinstallp -d}) subject.create_bff_file end diff --git a/spec/unit/packagers/msi_spec.rb b/spec/unit/packagers/msi_spec.rb index ab0724671..c83e0cda0 100644 --- a/spec/unit/packagers/msi_spec.rb +++ b/spec/unit/packagers/msi_spec.rb @@ -419,7 +419,7 @@ module Omnibus end it "outputs a source.wxs file to the staging directory" do - expect(subject.candle_command).to include("#{subject.windows_safe_path(staging_dir, 'source.wxs')}") + expect(subject.candle_command).to include("#{subject.windows_safe_path(staging_dir, "source.wxs")}") end end @@ -433,7 +433,7 @@ module Omnibus end it "outputs a bundle.wxs file to the staging directory" do - expect(subject.candle_command(is_bundle: true)).to include("#{subject.windows_safe_path(staging_dir, 'bundle.wxs')}") + expect(subject.candle_command(is_bundle: true)).to include("#{subject.windows_safe_path(staging_dir, "bundle.wxs")}") end end end diff --git a/spec/unit/packagers/pkgsrc_spec.rb b/spec/unit/packagers/pkgsrc_spec.rb index 2a3f9a752..7d5ba750b 100644 --- a/spec/unit/packagers/pkgsrc_spec.rb +++ b/spec/unit/packagers/pkgsrc_spec.rb @@ -70,7 +70,7 @@ module Omnibus expect(subject).to receive(:shellout!) .with "cd #{project.install_dir} && find . -type l -or -type f | sort >> #{staging_dir}/packlist" subject.write_packlist - expect(File.read("#{staging_dir}/packlist")).to match(/@pkgdir \/opt\/project/) + expect(File.read("#{staging_dir}/packlist")).to match(%r{@pkgdir /opt/project}) end end end diff --git a/spec/unit/packagers/solaris_spec.rb b/spec/unit/packagers/solaris_spec.rb index f5979120b..7fcb1bf9f 100644 --- a/spec/unit/packagers/solaris_spec.rb +++ b/spec/unit/packagers/solaris_spec.rb @@ -139,11 +139,11 @@ module Omnibus it "uses the correct commands" do expect(subject).to receive(:shellout!) - .with("cd /opt && find project -print > #{File.join(staging_dir, 'files')}") + .with("cd /opt && find project -print > #{File.join(staging_dir, "files")}") expect(subject).to receive(:shellout!) - .with("cd /opt && pkgproto < #{File.join(staging_dir, 'files.clean')} > #{File.join(staging_dir, 'Prototype.files')}") + .with("cd /opt && pkgproto < #{File.join(staging_dir, "files.clean")} > #{File.join(staging_dir, "Prototype.files")}") expect(subject).to receive(:shellout!) - .with("awk '{ $5 = \"root\"; $6 = \"root\"; print }' < #{File.join(staging_dir, 'Prototype.files')} >> #{File.join(staging_dir, 'Prototype')}") + .with("awk '{ $5 = \"root\"; $6 = \"root\"; print }' < #{File.join(staging_dir, "Prototype.files")} >> #{File.join(staging_dir, "Prototype")}") subject.write_prototype_file end @@ -158,11 +158,11 @@ module Omnibus describe "#create_solaris_file" do it "uses the correct commands" do expect(subject).to receive(:shellout!) - .with("pkgmk -o -r /opt -d #{staging_dir} -f #{File.join(staging_dir, 'Prototype')}") + .with("pkgmk -o -r /opt -d #{staging_dir} -f #{File.join(staging_dir, "Prototype")}") expect(subject).to receive(:shellout!) .with("pkgchk -vd #{staging_dir} project") expect(subject).to receive(:shellout!) - .with("pkgtrans #{staging_dir} #{File.join(package_dir, 'project-1.2.3-1.i386.solaris')} project") + .with("pkgtrans #{staging_dir} #{File.join(package_dir, "project-1.2.3-1.i386.solaris")} project") subject.create_solaris_file end @@ -207,11 +207,11 @@ module Omnibus it "uses the correct commands" do expect(subject).to receive(:shellout!) - .with("pkgmk -o -r /opt -d #{staging_dir} -f #{File.join(staging_dir, 'Prototype')}") + .with("pkgmk -o -r /opt -d #{staging_dir} -f #{File.join(staging_dir, "Prototype")}") expect(subject).to receive(:shellout!) .with("pkgchk -vd #{staging_dir} project") expect(subject).to receive(:shellout!) - .with("pkgtrans #{staging_dir} #{File.join(package_dir, 'project-1.2.3-1.i386.solaris')} project") + .with("pkgtrans #{staging_dir} #{File.join(package_dir, "project-1.2.3-1.i386.solaris")} project") subject.create_solaris_file end diff --git a/spec/unit/project_spec.rb b/spec/unit/project_spec.rb index d1a082fa0..3c6cf307f 100644 --- a/spec/unit/project_spec.rb +++ b/spec/unit/project_spec.rb @@ -202,7 +202,7 @@ module Omnibus end describe "#build_iteration" do - let(:fauxhai_options) { Hash.new } + let(:fauxhai_options) { {} } before { stub_ohai(fauxhai_options) } @@ -340,7 +340,7 @@ module Omnibus subject.compress(:tgz) expect(Compressor).to receive(:for_current_system) - .with([:dmg, :tgz]) + .with(%i{dmg tgz}) .and_call_original subject.compressor diff --git a/spec/unit/publisher_spec.rb b/spec/unit/publisher_spec.rb index a864ca5c6..cd1ba3aad 100644 --- a/spec/unit/publisher_spec.rb +++ b/spec/unit/publisher_spec.rb @@ -133,8 +133,7 @@ class FakePublisher; end license: "Apache-2.0", }, }, - } - ) + }) end before do diff --git a/spec/unit/publishers/artifactory_publisher_spec.rb b/spec/unit/publishers/artifactory_publisher_spec.rb index 352de4439..c98dab47c 100644 --- a/spec/unit/publishers/artifactory_publisher_spec.rb +++ b/spec/unit/publishers/artifactory_publisher_spec.rb @@ -10,8 +10,7 @@ module Omnibus path: "/path/to/files/chef.deb", name: "chef.deb", content: "BINARY", - validate!: true - ) + validate!: true) end let(:metadata) do @@ -90,8 +89,7 @@ module Omnibus license: "Apache-2.0", }, }, - } - ) + }) end let(:packages) { [package] } diff --git a/spec/unit/publishers/s3_publisher_spec.rb b/spec/unit/publishers/s3_publisher_spec.rb index b5902f609..db0ff8c07 100644 --- a/spec/unit/publishers/s3_publisher_spec.rb +++ b/spec/unit/publishers/s3_publisher_spec.rb @@ -9,8 +9,7 @@ module Omnibus path: "/path/to/files/chef.deb", name: "chef.deb", content: "BINARY", - validate!: true - ) + validate!: true) end let(:metadata) do @@ -24,8 +23,7 @@ module Omnibus platform_version: "14.04", arch: "x86_64", sha1: "SHA1", - md5: "ABCDEF123456" - ) + md5: "ABCDEF123456") end let(:packages) { [package] } diff --git a/spec/unit/s3_cacher_spec.rb b/spec/unit/s3_cacher_spec.rb index 4d36ce4e2..23eedd9a7 100644 --- a/spec/unit/s3_cacher_spec.rb +++ b/spec/unit/s3_cacher_spec.rb @@ -7,9 +7,7 @@ module Omnibus name: "ruby", version: "1.9.3", fetcher: double(Fetcher, - checksum: "abcd1234" - ) - ) + checksum: "abcd1234")) end let(:python_27) do @@ -17,9 +15,7 @@ module Omnibus name: "python", version: "2.7", fetcher: double(Fetcher, - checksum: "defg5678" - ) - ) + checksum: "defg5678")) end describe ".list" do diff --git a/spec/unit/s3_helpers_spec.rb b/spec/unit/s3_helpers_spec.rb index 678146261..b69cb3442 100644 --- a/spec/unit/s3_helpers_spec.rb +++ b/spec/unit/s3_helpers_spec.rb @@ -9,12 +9,12 @@ module Omnibus describe "#client" do it "raises an error if it is not overridden" do expect { s3_configuration }.to raise_error(RuntimeError, - "You must override s3_configuration") + "You must override s3_configuration") end it "raises an error stating that s3_configuration must be overriden" do expect { client }.to raise_error(RuntimeError, - "You must override s3_configuration") + "You must override s3_configuration") end end end diff --git a/spec/unit/software_spec.rb b/spec/unit/software_spec.rb index e688d074e..99dfed0be 100644 --- a/spec/unit/software_spec.rb +++ b/spec/unit/software_spec.rb @@ -286,13 +286,13 @@ module Omnibus end it "sets the defaults" do expect(subject.with_standard_compiler_flags).to eq( - "LDFLAGS" => "-Wl,-rpath,/opt/project/embedded/lib -L/opt/project/embedded/lib", - "CFLAGS" => "-I/opt/project/embedded/include -O2", - "CXXFLAGS" => "-I/opt/project/embedded/include -O2", - "CPPFLAGS" => "-I/opt/project/embedded/include -O2", - "LD_RUN_PATH" => "/opt/project/embedded/lib", - "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig", - "OMNIBUS_INSTALL_DIR" => "/opt/project" + "LDFLAGS" => "-Wl,-rpath,/opt/project/embedded/lib -L/opt/project/embedded/lib", + "CFLAGS" => "-I/opt/project/embedded/include -O2", + "CXXFLAGS" => "-I/opt/project/embedded/include -O2", + "CPPFLAGS" => "-I/opt/project/embedded/include -O2", + "LD_RUN_PATH" => "/opt/project/embedded/lib", + "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig", + "OMNIBUS_INSTALL_DIR" => "/opt/project" ) end @@ -313,7 +313,7 @@ module Omnibus "LD_RUN_PATH" => "/opt/project/embedded/lib", "PKG_CONFIG_PATH" => "/opt/project/embedded/lib/pkgconfig", "OMNIBUS_INSTALL_DIR" => "/opt/project" - ) + ) end end end @@ -547,7 +547,7 @@ module Omnibus describe "#whitelist_file" do it "appends to the whitelist_files array" do expect(subject.whitelist_files.size).to eq(0) - subject.whitelist_file(/foo\/bar/) + subject.whitelist_file(%r{foo/bar}) expect(subject.whitelist_files.size).to eq(1) end diff --git a/spec/unit/util_spec.rb b/spec/unit/util_spec.rb index bed04e793..6f992d5fb 100644 --- a/spec/unit/util_spec.rb +++ b/spec/unit/util_spec.rb @@ -46,8 +46,7 @@ class OurTestException < StandardError; end environment: { "TICKLE_ME" => "elmo", "I_LOVE_YOU" => "barney", - } - ) + }) end context "when the command fails" do