diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8925ddbfc92..4cdb0752b2b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -75,17 +75,6 @@ Style/AndOr: Style/BlockDelimiters: Enabled: false -# Offense count: 1 -# Cop supports --auto-correct. -Style/BlockEndNewline: - Enabled: false - -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/BracesAroundHashParameters: - Enabled: false - # Offense count: 3 Style/CaseEquality: Enabled: false @@ -101,39 +90,6 @@ Style/CaseIndentation: Style/ClassAndModuleChildren: Enabled: false -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/ClassCheck: - Enabled: false - -# Offense count: 3 -# Cop supports --auto-correct. -Style/ClosingParenthesisIndentation: - Enabled: false - -# Offense count: 1 -# Cop supports --auto-correct. -Style/ColonMethodCall: - Enabled: false - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerBackticks. -Style/CommandLiteral: - Enabled: false - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: Keywords. -Style/CommentAnnotation: - Enabled: false - -# Offense count: 3 -# Cop supports --auto-correct. -Style/DeprecatedHashMethods: - Enabled: false - # Offense count: 153 Style/Documentation: Enabled: false @@ -144,32 +100,17 @@ Style/Documentation: Style/EmptyElse: Enabled: false -# Offense count: 1 -# Cop supports --auto-correct. -Style/EmptyLinesAroundMethodBody: - Enabled: false - # Offense count: 9 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. Style/EmptyLinesAroundModuleBody: Enabled: false -# Offense count: 2 -# Cop supports --auto-correct. -Style/EmptyLiteral: - Enabled: false - # Offense count: 1 # Configuration parameters: Exclude. Style/FileName: Enabled: false -# Offense count: 3 -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/For: - Enabled: false - # Offense count: 4 # Configuration parameters: AllowedVariables. Style/GlobalVars: @@ -186,49 +127,6 @@ Style/GuardClause: Style/IfUnlessModifier: Enabled: false -# Offense count: 3 -# Cop supports --auto-correct. -Style/IndentArray: - Enabled: false - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/IndentationConsistency: - Enabled: false - -# Offense count: 5 -# Cop supports --auto-correct. -# Configuration parameters: Width. -Style/IndentationWidth: - Enabled: false - -# Offense count: 2 -# Cop supports --auto-correct. -Style/InfiniteLoop: - Enabled: false - -# Offense count: 4 -# Cop supports --auto-correct. -Style/LeadingCommentSpace: - Enabled: false - -# Offense count: 4 -# Cop supports --auto-correct. -Style/LineEndConcatenation: - Enabled: false - -# Offense count: 1 -# Cop supports --auto-correct. -Style/MethodCallParentheses: - Enabled: false - -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/MethodDefParentheses: - Enabled: false - # Offense count: 2 Style/ModuleFunction: Enabled: false @@ -237,64 +135,17 @@ Style/ModuleFunction: Style/MultilineBlockChain: Enabled: false -# Offense count: 3 -# Cop supports --auto-correct. -Style/MultilineBlockLayout: - Enabled: false - -# Offense count: 2 -# Cop supports --auto-correct. -Style/MultilineIfThen: - Enabled: false - # Offense count: 13 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. Style/MultilineOperationIndentation: Enabled: false -# Offense count: 4 -Style/MultilineTernaryOperator: - Enabled: false - -# Offense count: 5 -# Cop supports --auto-correct. -Style/NegatedIf: - Enabled: false - -# Offense count: 1 -Style/NestedTernaryOperator: - Enabled: false - # Offense count: 10 # Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles. Style/Next: Enabled: false -# Offense count: 1 -# Cop supports --auto-correct. -Style/Not: - Enabled: false - -# Offense count: 3 -# Cop supports --auto-correct. -Style/NumericLiterals: - MinDigits: 8 - -# Offense count: 1 -Style/OneLineConditional: - Enabled: false - -# Offense count: 5 -Style/OpMethod: - Enabled: false - -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: AllowSafeAssignment. -Style/ParenthesesAroundCondition: - Enabled: false - # Offense count: 63 # Cop supports --auto-correct. # Configuration parameters: PreferredDelimiters. @@ -311,27 +162,11 @@ Style/PerlBackrefs: Style/PredicateName: Enabled: false -# Offense count: 3 -# Cop supports --auto-correct. -Style/Proc: - Enabled: false - # Offense count: 8 # Configuration parameters: EnforcedStyle, SupportedStyles. Style/RaiseArgs: Enabled: false -# Offense count: 1 -# Cop supports --auto-correct. -Style/RedundantBegin: - Enabled: false - -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: AllowMultipleReturnValues. -Style/RedundantReturn: - Enabled: false - # Offense count: 7 # Cop supports --auto-correct. Style/RedundantSelf: @@ -361,19 +196,3 @@ Style/SpaceInsideStringInterpolation: # Cop supports --auto-correct. Style/TrailingUnderscoreVariable: Enabled: false - -# Offense count: 2 -# Cop supports --auto-correct. -Style/UnneededPercentQ: - Enabled: false - -# Offense count: 1 -# Cop supports --auto-correct. -Style/WhileUntilDo: - Enabled: false - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: MaxLineLength. -Style/WhileUntilModifier: - Enabled: false diff --git a/bundler.gemspec b/bundler.gemspec index 52f65b2a03b..8fc65647d5a 100644 --- a/bundler.gemspec +++ b/bundler.gemspec @@ -10,8 +10,8 @@ Gem::Specification.new do |s| s.authors = ["André Arko", "Terence Lee", "Carl Lerche", "Yehuda Katz"] s.email = ["andre.arko+terence.lee@gmail.com"] s.homepage = "http://bundler.io" - s.summary = %q{The best way to manage your application's dependencies} - s.description = %q{Bundler manages an application's dependencies through its entire life, across many machines, systematically and repeatably} + s.summary = "The best way to manage your application's dependencies" + s.description = "Bundler manages an application's dependencies through its entire life, across many machines, systematically and repeatably" s.required_ruby_version = ">= 1.8.7" s.required_rubygems_version = ">= 1.3.6" diff --git a/lib/bundler.rb b/lib/bundler.rb index 143d49e9cf9..9a46dede491 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -222,9 +222,11 @@ def root end def app_config_path - ENV["BUNDLE_APP_CONFIG"] ? - Pathname.new(ENV["BUNDLE_APP_CONFIG"]).expand_path(root) : + if ENV["BUNDLE_APP_CONFIG"] + Pathname.new(ENV["BUNDLE_APP_CONFIG"]).expand_path(root) + else root.join(".bundle") + end end def app_cache(custom_path = nil) @@ -259,7 +261,7 @@ def with_clean_env with_original_env do ENV["MANPATH"] = ENV["BUNDLE_ORIG_MANPATH"] ENV.delete_if {|k, _| k[0, 7] == "BUNDLE_" } - if ENV.has_key? "RUBYOPT" + if ENV.key? "RUBYOPT" ENV["RUBYOPT"] = ENV["RUBYOPT"].sub "-rbundler/setup", "" ENV["RUBYOPT"] = ENV["RUBYOPT"].sub "-I#{File.expand_path("..", __FILE__)}", "" end diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index c481ac73228..150df56c7f6 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -48,15 +48,15 @@ def help(cli = nil) end manpages = %w( - bundle - bundle-config - bundle-exec - bundle-gem - bundle-install - bundle-package - bundle-update - bundle-platform - gemfile.5) + bundle + bundle-config + bundle-exec + bundle-gem + bundle-install + bundle-package + bundle-update + bundle-platform + gemfile.5) if manpages.include?(command) root = File.expand_path("../man", __FILE__) @@ -411,24 +411,24 @@ def env private - # Automatically invoke `bundle install` and resume if - # Bundler.settings[:auto_install] exists. This is set through config cmd - # `bundle config auto_install 1`. - # - # Note that this method `nil`s out the global Definition object, so it - # should be called first, before you instantiate anything like an - # `Installer` that'll keep a reference to the old one instead. - def auto_install - return unless Bundler.settings[:auto_install] - - begin - Bundler.definition.specs - rescue GemNotFound - Bundler.ui.info "Automatically installing missing gems." - Bundler.reset! - invoke :install, [] - Bundler.reset! - end + # Automatically invoke `bundle install` and resume if + # Bundler.settings[:auto_install] exists. This is set through config cmd + # `bundle config auto_install 1`. + # + # Note that this method `nil`s out the global Definition object, so it + # should be called first, before you instantiate anything like an + # `Installer` that'll keep a reference to the old one instead. + def auto_install + return unless Bundler.settings[:auto_install] + + begin + Bundler.definition.specs + rescue GemNotFound + Bundler.ui.info "Automatically installing missing gems." + Bundler.reset! + invoke :install, [] + Bundler.reset! end + end end end diff --git a/lib/bundler/cli/gem.rb b/lib/bundler/cli/gem.rb index de673fa69d7..2704bbec7c5 100644 --- a/lib/bundler/cli/gem.rb +++ b/lib/bundler/cli/gem.rb @@ -195,7 +195,7 @@ def bundler_dependency_version req.join(".") end - def ensure_safe_gem_name name, constant_array + def ensure_safe_gem_name(name, constant_array) if name =~ /^\d/ Bundler.ui.error "Invalid gem name #{name} Please give a name which does not start with numbers." exit 1 diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb index 2245f9585a7..1f5337d46ee 100644 --- a/lib/bundler/cli/install.rb +++ b/lib/bundler/cli/install.rb @@ -50,8 +50,8 @@ def run exit 1 end - if (options["trust-policy"]) - unless (Bundler.rubygems.security_policies.keys.include?(options["trust-policy"])) + if options["trust-policy"] + unless Bundler.rubygems.security_policies.keys.include?(options["trust-policy"]) Bundler.ui.error "Rubygems doesn't know about trust policy '#{options["trust-policy"]}'. " \ "The known policies are: #{Bundler.rubygems.security_policies.keys.join(", ")}." exit 1 diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb index 640e4f7ca7d..4c777df6e6a 100644 --- a/lib/bundler/cli/outdated.rb +++ b/lib/bundler/cli/outdated.rb @@ -32,7 +32,7 @@ def run out_count = 0 # Loop through the current specs - gemfile_specs, dependency_specs = current_specs.partition {|spec| current_dependencies.has_key? spec.name } + gemfile_specs, dependency_specs = current_specs.partition {|spec| current_dependencies.key? spec.name } [gemfile_specs.sort_by(&:name), dependency_specs.sort_by(&:name)].flatten.each do |current_spec| next if !gems.empty? && !gems.include?(current_spec.name) diff --git a/lib/bundler/cli/show.rb b/lib/bundler/cli/show.rb index 44b5894a615..50cf0a97d55 100644 --- a/lib/bundler/cli/show.rb +++ b/lib/bundler/cli/show.rb @@ -23,7 +23,7 @@ def run spec = Bundler::CLI::Common.select_spec(gem_name, :regex_match) return unless spec path = spec.full_gem_path - if !File.directory?(path) + unless File.directory?(path) Bundler.ui.warn "The gem #{gem_name} has been deleted. It was installed at:" end end diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 4f68c2248ed..85e82b4c77b 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -310,12 +310,10 @@ def to_lock out << "DEPENDENCIES\n" handled = [] - dependencies. - sort_by(&:to_s). - each do |dep| - next if handled.include?(dep.name) - out << dep.to_lock - handled << dep.name + dependencies.sort_by(&:to_s).each do |dep| + next if handled.include?(dep.name) + out << dep.to_lock + handled << dep.name end # Record the version of Bundler that was used to create the lockfile @@ -480,7 +478,7 @@ def converge_sources changes = false # Get the Rubygems sources from the Gemfile.lock - locked_gem_sources = @locked_sources.select {|s| s.kind_of?(Source::Rubygems) } + locked_gem_sources = @locked_sources.select {|s| s.is_a?(Source::Rubygems) } # Get the Rubygems remotes from the Gemfile actual_remotes = sources.rubygems_remotes @@ -645,7 +643,7 @@ def source_requirements def pinned_spec_names(specs) names = [] specs.each do |s| - # TODO when two sources without blocks is an error, we can change + # TODO: when two sources without blocks is an error, we can change # this check to !s.source.is_a?(Source::LocalRubygems). For now, # we need to ask every Rubygems for every gem name. if s.source.is_a?(Source::Git) || s.source.is_a?(Source::Path) diff --git a/lib/bundler/dep_proxy.rb b/lib/bundler/dep_proxy.rb index 378cefa1940..4efd99c9bbc 100644 --- a/lib/bundler/dep_proxy.rb +++ b/lib/bundler/dep_proxy.rb @@ -11,8 +11,8 @@ def hash @hash ||= dep.hash end - def ==(o) - dep == o.dep && __platform == o.__platform + def ==(other) + dep == other.dep && __platform == other.__platform end alias_method :eql?, :== diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index 5d7dfddf227..9df01fb905f 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -280,7 +280,7 @@ def normalize_options(name, version, opts) end # Save sources passed in a key - if opts.has_key?("source") + if opts.key?("source") source = normalize_source(opts["source"]) opts["source"] = @sources.add_rubygems_source("remotes" => source) end diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb index 829b709c381..6236bee7b60 100644 --- a/lib/bundler/fetcher.rb +++ b/lib/bundler/fetcher.rb @@ -223,7 +223,7 @@ def connection end # cached gem specification path, if one exists - def gemspec_cached_path spec_file_name + def gemspec_cached_path(spec_file_name) paths = Bundler.rubygems.spec_cache_dirs.map {|dir| File.join(dir, spec_file_name) } paths = paths.select {|path| File.file? path } paths.first diff --git a/lib/bundler/gem_helper.rb b/lib/bundler/gem_helper.rb index 33576bbdc82..ab7bcc27a0d 100644 --- a/lib/bundler/gem_helper.rb +++ b/lib/bundler/gem_helper.rb @@ -158,7 +158,11 @@ def name def sh(cmd, &block) out, code = sh_with_code(cmd, &block) - code == 0 ? out : raise(out.empty? ? "Running `#{cmd}' failed. Run this command directly for more detailed output." : out) + if code == 0 + out + else + raise(out.empty? ? "Running `#{cmd}' failed. Run this command directly for more detailed output." : out) + end end def sh_with_code(cmd, &block) diff --git a/lib/bundler/graph.rb b/lib/bundler/graph.rb index e815f7dae98..cf5913ec707 100644 --- a/lib/bundler/graph.rb +++ b/lib/bundler/graph.rb @@ -95,15 +95,15 @@ def _patching_gem_dependency_class # method borrow from rubygems/dependency.rb # redefinition of matching_specs will also redefine to_spec and to_specs Gem::Dependency.class_eval do - def matching_specs platform_only = false + def matching_specs(platform_only = false) matches = Bundler.load.specs.select { |spec| self.name == spec.name and requirement.satisfied_by? spec.version } if platform_only - matches.reject! { |spec| - not Gem::Platform.match spec.platform + matches.select! { |spec| + Gem::Platform.match spec.platform } end @@ -124,7 +124,7 @@ def initialize(graph_instance) end def g - @g ||= ::GraphViz.digraph(@graph_name, { :concentrate => true, :normalize => true, :nodesep => 0.55 }) do |g| + @g ||= ::GraphViz.digraph(@graph_name, :concentrate => true, :normalize => true, :nodesep => 0.55) do |g| g.edge[:weight] = 2 g.edge[:fontname] = g.node[:fontname] = "Arial, Helvetica, SansSerif" g.edge[:fontsize] = 12 diff --git a/lib/bundler/index.rb b/lib/bundler/index.rb index 6c4ed3996c7..b9897199093 100644 --- a/lib/bundler/index.rb +++ b/lib/bundler/index.rb @@ -16,7 +16,7 @@ def self.build def initialize @sources = [] @cache = {} - @specs = Hash.new {|h, k| h[k] = Hash.new } + @specs = Hash.new {|h, k| h[k] = {} } @all_specs = Hash.new {|h, k| h[k] = [] } end @@ -24,7 +24,7 @@ def initialize_copy(o) super @sources = @sources.dup @cache = {} - @specs = Hash.new {|h, k| h[k] = Hash.new } + @specs = Hash.new {|h, k| h[k] = {} } @all_specs = Hash.new {|h, k| h[k] = [] } o.specs.each do |name, hash| @@ -127,9 +127,9 @@ def size end end - def ==(o) + def ==(other) all? do |spec| - other_spec = o[spec].first + other_spec = other[spec].first (spec.dependencies & other_spec.dependencies).empty? && spec.source == other_spec.source end end diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb index e4a9a8c9fe8..00bd2158ebb 100644 --- a/lib/bundler/installer.rb +++ b/lib/bundler/installer.rb @@ -123,7 +123,7 @@ def generate_bundler_executable_stubs(spec, options = {}) options[dep.name] = bins unless bins.empty? end if options.any? - Bundler.ui.warn "#{spec.name} has no executables, but you may want " + + Bundler.ui.warn "#{spec.name} has no executables, but you may want " \ "one from a gem it depends on." options.each {|name, bins| Bundler.ui.warn " #{name} has: #{bins.join(", ")}" } else @@ -264,7 +264,7 @@ def install_in_parallel(size, standalone, force = false) def create_bundle_path Bundler.mkdir_p(Bundler.bundle_path.to_s) unless Bundler.bundle_path.exist? rescue Errno::EEXIST - raise PathError, "Could not install to path `#{Bundler.settings[:path]}` " + + raise PathError, "Could not install to path `#{Bundler.settings[:path]}` " \ "because of an invalid symlink. Remove the symlink so the directory can be created." end diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb index 43d9dc993d5..f0efbc448f9 100644 --- a/lib/bundler/lazy_specification.rb +++ b/lib/bundler/lazy_specification.rb @@ -19,7 +19,7 @@ def initialize(name, version, platform, source = nil) end def full_name - if platform == Gem::Platform::RUBY or platform.nil? then + if platform == Gem::Platform::RUBY or platform.nil? "#{@name}-#{@version}" else "#{@name}-#{@version}-#{platform}" diff --git a/lib/bundler/remote_specification.rb b/lib/bundler/remote_specification.rb index 5a32bd24355..3050c373715 100644 --- a/lib/bundler/remote_specification.rb +++ b/lib/bundler/remote_specification.rb @@ -27,7 +27,7 @@ def fetch_platform end def full_name - if platform == Gem::Platform::RUBY or platform.nil? then + if platform == Gem::Platform::RUBY or platform.nil? "#{@name}-#{@version}" else "#{@name}-#{@version}-#{platform}" diff --git a/lib/bundler/retry.rb b/lib/bundler/retry.rb index 85bff788075..4b0fff4bd5d 100644 --- a/lib/bundler/retry.rb +++ b/lib/bundler/retry.rb @@ -25,9 +25,7 @@ def attempt(&block) @current_run = 0 @failed = false @error = nil - while keep_trying? do - run(&block) - end + run(&block) while keep_trying? @result end alias_method :attempts, :attempt diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb index eddd1fa191d..9e4ce5ac17f 100644 --- a/lib/bundler/rubygems_ext.rb +++ b/lib/bundler/rubygems_ext.rb @@ -22,15 +22,19 @@ class Specification alias_method :rg_loaded_from, :loaded_from def full_gem_path - source.respond_to?(:path) ? - Pathname.new(loaded_from).dirname.expand_path(Bundler.root).to_s.untaint : + if source.respond_to?(:path) + Pathname.new(loaded_from).dirname.expand_path(Bundler.root).to_s.untaint + else rg_full_gem_path + end end def loaded_from - relative_loaded_from ? - source.path.join(relative_loaded_from).to_s : + if relative_loaded_from + source.path.join(relative_loaded_from).to_s + else rg_loaded_from + end end def load_paths @@ -48,9 +52,11 @@ def load_paths if method_defined?(:extension_dir) alias_method :rg_extension_dir, :extension_dir def extension_dir - @extension_dir ||= source.respond_to?(:extension_dir_name) ? - File.expand_path(File.join(extensions_dir, source.extension_dir_name)) : + @extension_dir ||= if source.respond_to?(:extension_dir_name) + File.expand_path(File.join(extensions_dir, source.extension_dir_name)) + else rg_extension_dir + end end end diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb index b33d76b1151..b5ae60d5ed7 100644 --- a/lib/bundler/rubygems_integration.rb +++ b/lib/bundler/rubygems_integration.rb @@ -186,7 +186,7 @@ def fetch_all_remote_specs # Then fetch the prerelease specs fetch_prerelease_specs.each {|k, v| spec_list[k] += v } - return spec_list + spec_list end def with_build_args(args) @@ -229,7 +229,7 @@ def build(spec, skip_validation = false) end def build_gem(gem_dir, spec) - build(spec) + build(spec) end def download_gem(spec, uri, path) @@ -594,7 +594,7 @@ def gem_from_path(path, policy = nil) require "rubygems/package" p = Gem::Package.new(path) p.security_policy = policy if policy - return p + p end def build(spec, skip_validation = false) @@ -625,7 +625,7 @@ def backport_ext_builder_monitor require "rubygems/ext" Gem::Ext::Builder.class_eval do - if !const_defined?(:CHDIR_MONITOR) + unless const_defined?(:CHDIR_MONITOR) const_set(:CHDIR_MONITOR, EXT_LOCK) end diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb index 28767af5e24..5f340a3e646 100644 --- a/lib/bundler/runtime.rb +++ b/lib/bundler/runtime.rb @@ -61,7 +61,7 @@ def require(*groups) @definition.dependencies.each do |dep| # Skip the dependency if it is not in any of the requested # groups - next unless ((dep.groups & groups).any? && dep.current_platform?) + next unless (dep.groups & groups).any? && dep.current_platform? required_file = nil diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index 0ebde20c71b..bf465f8eec8 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -199,7 +199,7 @@ def get_array(key) end def set_array(key, array) - self[key] = (array.empty? ? nil : array.join(":")) if array + self[key] = (array.empty? ? nil : array.join(":")) if array end def set_key(key, value, hash, file) diff --git a/lib/bundler/similarity_detector.rb b/lib/bundler/similarity_detector.rb index de2de05992d..624238552c1 100644 --- a/lib/bundler/similarity_detector.rb +++ b/lib/bundler/similarity_detector.rb @@ -38,20 +38,19 @@ def levenshtein_distance(this, that, ins = 2, del = 2, sub = 1) fill = [0] * (this.length - 1) # Initialize first column values - for i in 1..that.length + (1..that.length).each do |i| dm[i] = [i * del, fill.flatten] end # populate matrix - for i in 1..that.length - for j in 1..this.length + (1..that.length).each do |i| + (1..this.length).each do |j| # critical comparison dm[i][j] = [ - dm[i - 1][j - 1] + - (this[j - 1] == that[i - 1] ? 0 : sub), - dm[i][j - 1] + ins, - dm[i - 1][j] + del - ].min + dm[i - 1][j - 1] + (this[j - 1] == that[i - 1] ? 0 : sub), + dm[i][j - 1] + ins, + dm[i - 1][j] + del + ].min end end diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb index 7c0abc5637f..c18341d17e5 100644 --- a/lib/bundler/source/git.rb +++ b/lib/bundler/source/git.rb @@ -49,9 +49,10 @@ def hash [self.class, uri, ref, branch, name, version, submodules].hash end - def eql?(o) - o.is_a?(Git) && uri == o.uri && ref == o.ref && branch == o.branch && name == o.name && version == o.version && - submodules == o.submodules + def eql?(other) + other.is_a?(Git) && uri == other.uri && ref == other.ref && + branch == other.branch && name == other.name && + version == other.version && submodules == other.submodules end alias_method :==, :eql? diff --git a/lib/bundler/source/git/git_proxy.rb b/lib/bundler/source/git/git_proxy.rb index bc6513bcea9..f7de1a0a568 100644 --- a/lib/bundler/source/git/git_proxy.rb +++ b/lib/bundler/source/git/git_proxy.rb @@ -122,7 +122,7 @@ def git_retry(command) def git(command, check_errors = true) raise GitNotAllowedError.new(command) unless allow? - out = SharedHelpers.with_clean_git_env { %x{git #{command}} } + out = SharedHelpers.with_clean_git_env { `git #{command}` } raise GitCommandError.new(command, path) if check_errors && !$?.success? out end diff --git a/lib/bundler/source/path.rb b/lib/bundler/source/path.rb index 1772a819c9a..b2c2f8c9783 100644 --- a/lib/bundler/source/path.rb +++ b/lib/bundler/source/path.rb @@ -56,10 +56,10 @@ def hash [self.class, expanded_path, version].hash end - def eql?(o) - o.instance_of?(Path) && - expanded_path == expand(o.path) && - version == o.version + def eql?(other) + other.instance_of?(Path) && + expanded_path == expand(other.path) && + version == other.version end alias_method :==, :eql? diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb index a9b10f59365..26c1e7cd177 100644 --- a/lib/bundler/source/rubygems.rb +++ b/lib/bundler/source/rubygems.rb @@ -37,8 +37,8 @@ def hash @remotes.hash end - def eql?(o) - o.is_a?(Rubygems) && o.credless_remotes == credless_remotes + def eql?(other) + other.is_a?(Rubygems) && other.credless_remotes == credless_remotes end alias_method :==, :eql? @@ -132,7 +132,8 @@ def install(spec, opts = {}) installed_spec = nil Bundler.rubygems.preserve_paths do - installed_spec = Bundler::GemInstaller.new(path, + installed_spec = Bundler::GemInstaller.new( + path, :install_dir => install_path.to_s, :bin_dir => bin_path.to_s, :ignore_dependencies => true, @@ -287,18 +288,18 @@ def installed_specs # Always have bundler locally unless have_bundler - # We're running bundler directly from the source - # so, let's create a fake gemspec for it (it's a path) - # gemspec - bundler = Gem::Specification.new do |s| - s.name = "bundler" - s.version = VERSION - s.platform = Gem::Platform::RUBY - s.source = self - s.authors = ["bundler team"] - s.loaded_from = File.expand_path("..", __FILE__) - end - idx << bundler + # We're running bundler directly from the source + # so, let's create a fake gemspec for it (it's a path) + # gemspec + bundler = Gem::Specification.new do |s| + s.name = "bundler" + s.version = VERSION + s.platform = Gem::Platform::RUBY + s.source = self + s.authors = ["bundler team"] + s.loaded_from = File.expand_path("..", __FILE__) + end + idx << bundler end idx end @@ -345,7 +346,7 @@ def remote_specs api_fetchers.each do |f| Bundler.ui.info "Fetching gem metadata from #{f.uri}", Bundler.ui.debug? idx.use f.specs(dependency_names, self) - Bundler.ui.info "" if !Bundler.ui.debug? # new line now that the dots are over + Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over end # Suppose the gem Foo depends on the gem Bar. Foo exists in Source A. Bar has some versions that exist in both @@ -358,7 +359,7 @@ def remote_specs api_fetchers.each do |f| Bundler.ui.info "Fetching version metadata from #{f.uri}", Bundler.ui.debug? idx.use f.specs(idx.dependency_names, self), true - Bundler.ui.info "" if !Bundler.ui.debug? # new line now that the dots are over + Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over end break if idxcount == idx.size end @@ -373,7 +374,7 @@ def remote_specs api_fetchers.each do |f| Bundler.ui.info "Fetching dependency metadata from #{f.uri}", Bundler.ui.debug? idx.use f.specs(unmet, self) - Bundler.ui.info "" if !Bundler.ui.debug? # new line now that the dots are over + Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over end if unmet.any? else allow_api = false diff --git a/spec/bundler/dsl_spec.rb b/spec/bundler/dsl_spec.rb index 169843bbe51..fc315316029 100644 --- a/spec/bundler/dsl_spec.rb +++ b/spec/bundler/dsl_spec.rb @@ -33,7 +33,7 @@ end it "converts numeric :gist to :git" do - subject.gem("not-really-a-gem", :gist => 2859988) + subject.gem("not-really-a-gem", :gist => 2_859_988) github_uri = "https://gist.github.com/2859988.git" expect(subject.dependencies.first.source.uri).to eq(github_uri) end diff --git a/spec/bundler/fetcher_spec.rb b/spec/bundler/fetcher_spec.rb index fd72f457c58..622c25d2876 100644 --- a/spec/bundler/fetcher_spec.rb +++ b/spec/bundler/fetcher_spec.rb @@ -19,14 +19,14 @@ describe "include CI information" do it "from one CI" do - with_env_vars({ "JENKINS_URL" => "foo" }) do + with_env_vars("JENKINS_URL" => "foo") do ci_part = fetcher.user_agent.split(" ").find {|x| x.match(%r{\Aci/}) } expect(ci_part).to match("jenkins") end end it "from many CI" do - with_env_vars({ "TRAVIS" => "foo", "CI_NAME" => "my_ci" }) do + with_env_vars("TRAVIS" => "foo", "CI_NAME" => "my_ci") do ci_part = fetcher.user_agent.split(" ").find {|x| x.match(%r{\Aci/}) } expect(ci_part).to match("travis") expect(ci_part).to match("my_ci") diff --git a/spec/bundler/gem_helper_spec.rb b/spec/bundler/gem_helper_spec.rb index ff41f04fb35..0dbd1d8e20e 100644 --- a/spec/bundler/gem_helper_spec.rb +++ b/spec/bundler/gem_helper_spec.rb @@ -103,9 +103,10 @@ def remove_push_guard(gemspec_content) end context "defines Rake tasks" do - let(:task_names) { %w[build install release - release:guard_clean release:source_control_push - release:rubygem_push] } + let(:task_names) { + %w[build install release release:guard_clean + release:source_control_push release:rubygem_push] + } context "before installation" do it "raises an error with appropriate message" do diff --git a/spec/bundler/retry_spec.rb b/spec/bundler/retry_spec.rb index 23e66684387..03f74cd5110 100644 --- a/spec/bundler/retry_spec.rb +++ b/spec/bundler/retry_spec.rb @@ -12,7 +12,7 @@ end it "returns the first valid result" do - jobs = [Proc.new { raise "foo" }, Proc.new { :bar }, Proc.new { raise "foo" }] + jobs = [proc { raise "foo" }, proc { :bar }, proc { raise "foo" }] attempts = 0 result = Bundler::Retry.new(nil, nil, 3).attempt do attempts += 1 diff --git a/spec/install/binstubs_spec.rb b/spec/install/binstubs_spec.rb index 6442ad74cbf..1b34e62567b 100644 --- a/spec/install/binstubs_spec.rb +++ b/spec/install/binstubs_spec.rb @@ -5,7 +5,7 @@ # On OS X, Gem.bindir defaults to /usr/bin, so system_bindir is useful if # you want to avoid sudo installs for system gems with OS X's default ruby it "overrides Gem.bindir" do - expect(Pathname.new("/usr/bin")).not_to be_writable unless Process::euid == 0 + expect(Pathname.new("/usr/bin")).not_to be_writable unless Process.euid == 0 gemfile <<-G require 'rubygems' def Gem.bindir; "/usr/bin"; end diff --git a/spec/install/bundler_spec.rb b/spec/install/bundler_spec.rb index 4bbfb135c12..a5278ef2f89 100644 --- a/spec/install/bundler_spec.rb +++ b/spec/install/bundler_spec.rb @@ -134,7 +134,6 @@ G simulate_bundler_version "10.0.0" - #simulate_new_machine bundle "check" expect(out).to include("The Gemfile's dependencies are satisfied") diff --git a/spec/install/gems/dependency_api_spec.rb b/spec/install/gems/dependency_api_spec.rb index 97b1c6fc9e8..55eba014815 100644 --- a/spec/install/gems/dependency_api_spec.rb +++ b/spec/install/gems/dependency_api_spec.rb @@ -290,7 +290,7 @@ def require(*args) build_repo4 do build_gem "activesupport", "1.2.0" build_gem "somegem", "1.0.0" do |s| - s.add_dependency "activesupport", "1.2.3" #This version exists only in repo1 + s.add_dependency "activesupport", "1.2.3" # This version exists only in repo1 end end diff --git a/spec/lock/lockfile_spec.rb b/spec/lock/lockfile_spec.rb index 5204e86092f..bcca03983ce 100644 --- a/spec/lock/lockfile_spec.rb +++ b/spec/lock/lockfile_spec.rb @@ -1243,7 +1243,8 @@ def set_lockfile_mtime_to_known_value context "when nothing changes" do it "preserves Gemfile.lock \\n line endings" do - expect { ruby <<-RUBY + expect { + ruby <<-RUBY require 'rubygems' require 'bundler' Bundler.setup @@ -1256,7 +1257,8 @@ def set_lockfile_mtime_to_known_value File.open(bundled_app("Gemfile.lock"), "wb") {|f| f.puts(win_lock) } set_lockfile_mtime_to_known_value - expect { ruby <<-RUBY + expect { + ruby <<-RUBY require 'rubygems' require 'bundler' Bundler.setup diff --git a/spec/realworld/dependency_api_spec.rb b/spec/realworld/dependency_api_spec.rb index dd03907093d..ac551992a88 100644 --- a/spec/realworld/dependency_api_spec.rb +++ b/spec/realworld/dependency_api_spec.rb @@ -19,7 +19,7 @@ def wait_for_server(port, seconds = 15) require "rack" ENV["GEM_HOME"] = old_gem_home - port = 21453 + port = 21_453 port += 1 while TCPSocket.new("127.0.0.1", port) rescue false @server_uri = "http://127.0.0.1:#{port}" diff --git a/spec/runtime/executable_spec.rb b/spec/runtime/executable_spec.rb index 4ddb330ae07..a0abee27f56 100644 --- a/spec/runtime/executable_spec.rb +++ b/spec/runtime/executable_spec.rb @@ -37,8 +37,8 @@ end it "uses the default ruby install name when shebang is not specified" do - bundle "install --binstubs" - expect(File.open("bin/rackup").gets).to eq("#!/usr/bin/env #{RbConfig::CONFIG["ruby_install_name"]}\n") + bundle "install --binstubs" + expect(File.open("bin/rackup").gets).to eq("#!/usr/bin/env #{RbConfig::CONFIG["ruby_install_name"]}\n") end it "allows the name of the shebang executable to be specified" do @@ -105,7 +105,6 @@ bundle "install --binstubs \"\"" expect(bundled_app("bin/rackup")).not_to exist - #expect(bundled_app("rackup")).not_to exist bundle "config bin" expect(out).to include("You have not configured a value for `bin`") diff --git a/spec/runtime/load_spec.rb b/spec/runtime/load_spec.rb index 1ba79adc851..950e8e9b18a 100644 --- a/spec/runtime/load_spec.rb +++ b/spec/runtime/load_spec.rb @@ -32,7 +32,7 @@ expect { ENV["BUNDLE_GEMFILE"] = "" Bundler.load - }.not_to raise_error() + }.not_to raise_error end end diff --git a/spec/runtime/with_clean_env_spec.rb b/spec/runtime/with_clean_env_spec.rb index 1c6114c0334..13dd629a166 100644 --- a/spec/runtime/with_clean_env_spec.rb +++ b/spec/runtime/with_clean_env_spec.rb @@ -27,8 +27,8 @@ gemfile "" bundle "install --path vendor/bundle" - code = "Bundler.with_clean_env do;" + - " print ENV['GEM_PATH'] != '';" + + code = "Bundler.with_clean_env do;" \ + " print ENV['GEM_PATH'] != '';" \ "end" result = bundle "exec ruby -e #{code.inspect}" diff --git a/spec/support/builders.rb b/spec/support/builders.rb index b5e044b67dd..2c02327b3d4 100644 --- a/spec/support/builders.rb +++ b/spec/support/builders.rb @@ -293,7 +293,6 @@ def build_security_repo s.cert_chain = [cert] end end - end def build_repo(path, &blk) diff --git a/spec/support/indexes.rb b/spec/support/indexes.rb index dff5138733e..387d100d360 100644 --- a/spec/support/indexes.rb +++ b/spec/support/indexes.rb @@ -38,12 +38,10 @@ def should_resolve_and_include(specs) end def should_conflict_on(names) - begin - got = resolve - flunk "The resolve succeeded with: #{got.map(&:full_name).sort.inspect}" - rescue Bundler::VersionConflict => e - expect(Array(names).sort).to eq(e.conflicts.sort) - end + got = resolve + flunk "The resolve succeeded with: #{got.map(&:full_name).sort.inspect}" + rescue Bundler::VersionConflict => e + expect(Array(names).sort).to eq(e.conflicts.sort) end def gem(*args, &blk) diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb index d41ac964f5e..6c585ddae4e 100644 --- a/spec/support/matchers.rb +++ b/spec/support/matchers.rb @@ -18,8 +18,6 @@ module Matchers args = args.flatten args = args.first.split(/\s+/) if args.size == 1 - #failure_message_for_should "Expected RUBYOPT to have options #{args.join(" ")}. It was #{ENV["RUBYOPT"]}" - match do |actual| actual = actual.split(/\s+/) if actual.is_a?(String) args.all? {|arg| actual.include?(arg) } && actual.uniq.size == actual.size diff --git a/spec/support/ruby_ext.rb b/spec/support/ruby_ext.rb index b70fb7bf829..59f428aa11c 100644 --- a/spec/support/ruby_ext.rb +++ b/spec/support/ruby_ext.rb @@ -1,5 +1,5 @@ class IO - def read_available_bytes(chunk_size = 16384, select_timeout = 0.02) + def read_available_bytes(chunk_size = 16_384, select_timeout = 0.02) buffer = [] return "" if closed? || eof? @@ -15,6 +15,6 @@ def read_available_bytes(chunk_size = 16384, select_timeout = 0.02) end end - return buffer.join + buffer.join end end diff --git a/spec/support/rubygems_ext.rb b/spec/support/rubygems_ext.rb index 8456de163f2..1e0d3d5ee02 100644 --- a/spec/support/rubygems_ext.rb +++ b/spec/support/rubygems_ext.rb @@ -42,7 +42,7 @@ def gem_command(command, args = "", options = {}) args = %["#{args}"] end lib = File.join(File.dirname(__FILE__), "..", "..", "lib") - %x{#{Gem.ruby} -I#{lib} -rubygems -S gem --backtrace #{command} #{args}}.strip + `#{Gem.ruby} -I#{lib} -rubygems -S gem --backtrace #{command} #{args}`.strip end end diff --git a/spec/support/sometimes.rb b/spec/support/sometimes.rb index 99fc9e9444e..0ab15d974f0 100644 --- a/spec/support/sometimes.rb +++ b/spec/support/sometimes.rb @@ -29,7 +29,7 @@ def run_with_retries(example_to_run, retries) end config.after(:suite) do - message = Proc.new do |color, text| + message = proc do |color, text| colored = RSpec::Core::Formatters::ConsoleCodes.wrap(text, color) notification = RSpec::Core::Notifications::MessageNotification.new(colored) RSpec.configuration.formatters.first.message(notification)