Class: Bumpit::Managers::Bundler

Inherits:
Base
  • Object
show all
Defined in:
lib/bumpit/managers/bundler.rb

Constant Summary collapse

BUNDLE_VERSION_COMMAND =
"bundle info bundler --version"
BUNDLER_UPDATE_COMMAND =
"bundle update --bundler"
DEPENDENCY_MATCHER =
/^\s*gem\s+['"]([^'"]+)['"].*$/
FILENAMES =
%w(Gemfile Gemfile.lock).freeze
GEM_INFO_COMMAND =
"gem info --exact --remote --no-prerelease --no-verbose bundler"
INFO_MATCHER =
/bundler \(([^)]+)\)/
OUTDATED_COMMAND =
"bundle outdated --only-explicit --parseable 2>/dev/null"
OUTDATED_MATCHER =
/\A(.+) \(newest (.+), installed (.+), requested = (.+)\)\z/

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

executable?

Class Method Details

.valid?Boolean

Determine if the manager is valid.

Returns:

  • (Boolean)


21
22
23
24
25
26
# File 'lib/bumpit/managers/bundler.rb', line 21

def self.valid?
  executable?("bundle") &&
    FILENAMES.all? do |filename|
      File.exist?(Pathname.new(Dir.pwd).join(filename))
    end
end

Instance Method Details

#bumpvoid

This method returns an undefined value.

Bump the dependencies, if there are any.



31
32
33
34
35
36
37
38
# File 'lib/bumpit/managers/bundler.rb', line 31

def bump
  if outdated.any?
    write_contents
    bundle_update
  end

  update_bundler
end

#messageString

Return a message for which dependencies were bumped.

Returns:

  • (String)


43
44
45
46
47
48
49
50
# File 'lib/bumpit/managers/bundler.rb', line 43

def message
  dependencies = outdated.keys
  dependencies << "bundler" if update_bundler?

  if dependencies.any?
    "Updates #{to_sentence(dependencies.sort)} in Ruby."
  end
end