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
- #dependency_set ⇒ Object
-
#initialize(runner:, local:) ⇒ Bundle
constructor
A new instance of Bundle.
- #update_gemfile_contents(update) ⇒ Object
- #update_gemspec_contents(update) ⇒ Object
-
#update_lockfile(update, old_version) ⇒ 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.
16 17 18 19 |
# File 'lib/keep_up/bundle.rb', line 16 def initialize(runner:, local:) @runner = runner @local = local end |
Instance Method Details
#check? ⇒ Boolean
36 37 38 39 |
# File 'lib/keep_up/bundle.rb', line 36 def check? _, status = @runner.run2 "bundle check" status == 0 end |
#dependencies ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/keep_up/bundle.rb', line 21 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 |
#dependency_set ⇒ Object
32 33 34 |
# File 'lib/keep_up/bundle.rb', line 32 def dependency_set @dependency_set ||= DependencySet.new(dependencies) end |
#update_gemfile_contents(update) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/keep_up/bundle.rb', line 41 def update_gemfile_contents(update) update = dependency_set.find_specification_update(update) return unless update update if GemfileFilter.apply_to_file("Gemfile", update) end |
#update_gemspec_contents(update) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/keep_up/bundle.rb', line 48 def update_gemspec_contents(update) return unless gemspec_name update = dependency_set.find_specification_update(update) return unless update update if GemspecFilter.apply_to_file(gemspec_name, update) end |
#update_lockfile(update, old_version) ⇒ Object
Update lockfile and return resulting spec, or false in case of failure
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/keep_up/bundle.rb', line 58 def update_lockfile(update, old_version) 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 |