Class: KeepUp::Bundle

Inherits:
Object
  • Object
show all
Defined in:
lib/keep_up/bundle.rb

Overview

A Gemfile with its current set of locked dependencies.

Constant Summary collapse

OUTDATED_MATCHER =
/([^ ]*) \(newest ([^,]*), installed ([^,]*)(?:, requested (.*))?\)/
UPDATE_MATCHER =
/(?:Using|Installing|Fetching) ([^ ]*) ([^ ]*)(?: \(was (.*)\))?/

Instance Method Summary collapse

Constructor Details

#initialize(runner:, local:) ⇒ Bundle

Returns a new instance of Bundle.



15
16
17
18
# File 'lib/keep_up/bundle.rb', line 15

def initialize(runner:, local:)
  @runner = runner
  @local = local
end

Instance Method Details

#check?Boolean

Returns:

  • (Boolean)


31
32
33
34
# File 'lib/keep_up/bundle.rb', line 31

def check?
  _, status = @runner.run2 "bundle check"
  status == 0
end

#outdated_dependenciesObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/keep_up/bundle.rb', line 20

def outdated_dependencies
  @outdated_dependencies ||=
    begin
      command = "bundle outdated --parseable#{" --local" if @local}"
      lines = run_filtered command, OUTDATED_MATCHER
      lines.map do |name, newest, version, requirement|
        build_dependency(name, newest, version, requirement)
      end
    end
end

#update_dependency(dependency) ⇒ Object



36
37
38
39
40
41
42
43
44
# File 'lib/keep_up/bundle.rb', line 36

def update_dependency(dependency)
  specification = updated_specification_for(dependency)
  spec_update = find_specification_update(specification)
  spec_result =
    update_gemspec_contents(spec_update) ||
    update_gemfile_contents(spec_update)
  lock_result = update_lockfile(specification, dependency.locked_version)
  [spec_result, lock_result]
end