Class: KeepUp::Bundle
- Inherits:
-
Object
- Object
- KeepUp::Bundle
- 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 (.*))?\)/.freeze
- UPDATE_MATCHER =
/(?:Using|Installing|Fetching) ([^ ]*) ([^ ]*)(?: \(was (.*))?\)/.freeze
Instance Method Summary collapse
- #check? ⇒ Boolean
- #dependencies ⇒ Object
-
#initialize(runner:, local:) ⇒ Bundle
constructor
A new instance of Bundle.
- #update_gemfile_contents(update) ⇒ Object
- #update_gemspec_contents(update) ⇒ Object
-
#update_lockfile(update) ⇒ Object
Update lockfile and return resulting spec, or false in case of failure.
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
31 32 33 34 |
# File 'lib/keep_up/bundle.rb', line 31 def check? _, status = @runner.run2 "bundle check" status == 0 end |
#dependencies ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/keep_up/bundle.rb', line 20 def dependencies @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_gemfile_contents(update) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/keep_up/bundle.rb', line 36 def update_gemfile_contents(update) update = find_specification_update(dependencies, update) return unless update update if update_specification_contents(update, "Gemfile", GemfileFilter) end |
#update_gemspec_contents(update) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/keep_up/bundle.rb', line 43 def update_gemspec_contents(update) return unless gemspec_name update = find_specification_update(dependencies, update) return unless update update if update_specification_contents(update, gemspec_name, GemspecFilter) end |
#update_lockfile(update) ⇒ Object
Update lockfile and return resulting spec, or false in case of failure
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/keep_up/bundle.rb', line 53 def update_lockfile(update) update_name = update.name command = "bundle update#{" --local" if @local} --conservative #{update_name}" lines = run_filtered command, UPDATE_MATCHER lines.each do |name, version, old_version| next unless name == update_name && old_version current = Gem::Specification.new(name, old_version) result = Gem::Specification.new(name, version) return result if result.version > current.version end nil end |