keep_up 0.10.0 → 0.10.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f7cf0d8f661622facd6330ca2b0185be3b4e307750f498a8d7a5fe5e426b2d4
4
- data.tar.gz: d4b93a7ecde478f08fe746582af8aafcae56edb2c32932f37a5e324ee39fc811
3
+ metadata.gz: a77e5f8cb4c411d576d9f5fc4953649bcbfff6a5660ed80d3ee6479381009706
4
+ data.tar.gz: 1d7b27d5487b6fce85a4b5e675ef426909bf79651963e543c958f48bd1256e71
5
5
  SHA512:
6
- metadata.gz: 2636dc31ad91af4460b38804925e078161cce26c86041683022a8a11f6932d615ec61bcded0db14e25d9b0d255481a7bc1ede9a1de0bb5f6fb7067d93fc2471a
7
- data.tar.gz: 559e8a41d53d847156b468e8cf28ae49183ac839ead216fc0440d4c28c4a3a7fc42d753dd1fdf52733fae7fd1749388449bf843943cc1193b461ee6f18f9dc9e
6
+ metadata.gz: ca2d2e5f203e28dc17dfb55eea2f4a528415facf18b347e6cf6eeed5555ff926644927b30d05fed1fccc2e79c5392bb2a1cb8111d745d1b830be94bf3f4504cb
7
+ data.tar.gz: 380256f06a826011bff4f36ed62341687b5e36082a5b652c1f0e955d3c01bc2354c6e64c554a3bc5c495201f4f7e9545980ae6f1266a8a1e477b2b79b50ea42f
data/CHANGELOG.md CHANGED
@@ -1,8 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.2 / 2022-09-23
4
+
5
+ * Detect version update even if `bundle update` does not print old version
6
+
7
+ ## 0.10.1 / 2022-05-20
8
+
9
+ * Adjust commit message to match update specificity
10
+
3
11
  ## 0.10.0 / 2022-01-23
4
12
 
5
- * Drop support for Ruby 2.5 and 2.6
13
+ * Drop support for Ruby 2.5
6
14
  * Add support for Ruby 3.0 and 3.1
7
15
  * Avoid interrupting half-printed lines when bundle update fails
8
16
 
data/bin/keep_up CHANGED
@@ -2,7 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "optparse"
5
- require_relative "../lib/keep_up"
5
+ require "keep_up"
6
6
 
7
7
  options = {
8
8
  local: false,
@@ -3,6 +3,7 @@
3
3
  require_relative "gemfile_filter"
4
4
  require_relative "gemspec_filter"
5
5
  require_relative "dependency"
6
+ require_relative "dependency_set"
6
7
 
7
8
  module KeepUp
8
9
  # A Gemfile with its current set of locked dependencies.
@@ -10,7 +11,7 @@ module KeepUp
10
11
  OUTDATED_MATCHER =
11
12
  /([^ ]*) \(newest ([^,]*), installed ([^,]*)(?:, requested (.*))?\)/.freeze
12
13
  UPDATE_MATCHER =
13
- /(?:Using|Installing|Fetching) ([^ ]*) ([^ ]*)(?: \(was (.*))?\)/.freeze
14
+ /(?:Using|Installing|Fetching) ([^ ]*) ([^ ]*)(?: \(was (.*)\))?/.freeze
14
15
 
15
16
  def initialize(runner:, local:)
16
17
  @runner = runner
@@ -28,33 +29,37 @@ module KeepUp
28
29
  end
29
30
  end
30
31
 
32
+ def dependency_set
33
+ @dependency_set ||= DependencySet.new(dependencies)
34
+ end
35
+
31
36
  def check?
32
37
  _, status = @runner.run2 "bundle check"
33
38
  status == 0
34
39
  end
35
40
 
36
41
  def update_gemfile_contents(update)
37
- update = find_specification_update(dependencies, update)
42
+ update = dependency_set.find_specification_update(update)
38
43
  return unless update
39
44
 
40
- update_specification_contents(update, "Gemfile", GemfileFilter)
45
+ update if GemfileFilter.apply_to_file("Gemfile", update)
41
46
  end
42
47
 
43
48
  def update_gemspec_contents(update)
44
49
  return unless gemspec_name
45
50
 
46
- update = find_specification_update(dependencies, update)
51
+ update = dependency_set.find_specification_update(update)
47
52
  return unless update
48
53
 
49
- update_specification_contents(update, gemspec_name, GemspecFilter)
54
+ update if GemspecFilter.apply_to_file(gemspec_name, update)
50
55
  end
51
56
 
52
57
  # Update lockfile and return resulting spec, or false in case of failure
53
- def update_lockfile(update)
58
+ def update_lockfile(update, old_version)
54
59
  update_name = update.name
55
60
  command = "bundle update#{" --local" if @local} --conservative #{update_name}"
56
61
  lines = run_filtered command, UPDATE_MATCHER
57
- lines.each do |name, version, old_version|
62
+ lines.each do |name, version, _old_version|
58
63
  next unless name == update_name && old_version
59
64
 
60
65
  current = Gem::Specification.new(name, old_version)
@@ -103,17 +108,6 @@ module KeepUp
103
108
  dep.requirements_list
104
109
  end
105
110
 
106
- def find_specification_update(current_dependencies, update)
107
- current_dependency = current_dependencies.find { |it| it.name == update.name }
108
- return if !current_dependency || current_dependency.matches_spec?(update)
109
-
110
- current_dependency.generalize_specification(update)
111
- end
112
-
113
- def update_specification_contents(update, file, filter)
114
- File.write file, filter.apply(File.read(file), update)
115
- end
116
-
117
111
  def gemspec_name
118
112
  @gemspec_name ||= Dir.glob("*.gemspec").first
119
113
  end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KeepUp
4
+ # Set of dependencies with their current locked versions.
5
+ class DependencySet
6
+ attr_reader :dependencies
7
+
8
+ def initialize(dependencies)
9
+ @dependencies = dependencies
10
+ end
11
+
12
+ def find_specification_update(update)
13
+ current_dependency = dependencies.find { |it| it.name == update.name }
14
+ return if !current_dependency || current_dependency.matches_spec?(update)
15
+
16
+ current_dependency.generalize_specification(update)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KeepUp
4
+ # Base class for file filters
5
+ class FileFilter
6
+ def self.apply_to_file(file, dependency)
7
+ contents = File.read(file)
8
+ updated_contents = apply(contents, dependency)
9
+ if contents == updated_contents
10
+ false
11
+ else
12
+ File.write file, updated_contents
13
+ true
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,8 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "file_filter"
4
+
3
5
  module KeepUp
4
6
  # Filter to update dependency information in a Gemfile.
5
- module GemfileFilter
7
+ class GemfileFilter < FileFilter
6
8
  def self.apply(contents, dependency)
7
9
  matcher = dependency_matcher(dependency)
8
10
  contents.each_line.map do |line|
@@ -1,8 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "file_filter"
4
+
3
5
  module KeepUp
4
6
  # Filter to update dependency information in a Gemspec.
5
- module GemspecFilter
7
+ class GemspecFilter < FileFilter
6
8
  def self.apply(contents, dependency)
7
9
  matcher = dependency_matcher(dependency)
8
10
  contents.each_line.map do |line|
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KeepUp
4
- # Simple filter that acccepts everything.
4
+ # Simple dependency filter that acccepts everything.
5
5
  class NullFilter
6
6
  def call(_dep)
7
7
  true
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KeepUp
4
- # Filter that skips dependencies if their name is on the list of things to be skipped.
4
+ # Dependency filter that skips dependencies if their name is on the list of
5
+ # things to be skipped.
5
6
  class SkipFilter
6
7
  def initialize(skip_list)
7
8
  @skip_list = skip_list
@@ -28,18 +28,22 @@ module KeepUp
28
28
  def possible_updates
29
29
  bundle.dependencies
30
30
  .select { |dep| filter.call dep }
31
- .map { |dep| updated_dependency_for dep }.compact.uniq
31
+ .select { |dep| updateable_dependency? dep }.uniq
32
32
  end
33
33
 
34
34
  private
35
35
 
36
36
  def apply_updated_dependency(dependency)
37
37
  report_intent dependency
38
- bundle.update_gemfile_contents(dependency)
39
- bundle.update_gemspec_contents(dependency)
40
- result = bundle.update_lockfile(dependency)
41
- report_result dependency, result
42
- result
38
+
39
+ specification = updated_specification_for(dependency)
40
+
41
+ update = bundle.update_gemspec_contents(specification)
42
+ update2 = bundle.update_gemfile_contents(specification)
43
+ update ||= update2
44
+ result = bundle.update_lockfile(specification, dependency.locked_version)
45
+ report_result specification, result
46
+ update || result if result
43
47
  end
44
48
 
45
49
  def report_intent(dependency)
@@ -54,12 +58,14 @@ module KeepUp
54
58
  end
55
59
  end
56
60
 
57
- def updated_dependency_for(dependency)
61
+ def updateable_dependency?(dependency)
58
62
  locked_version = dependency.locked_version
59
63
  newest_version = dependency.newest_version
60
- return unless newest_version > locked_version
64
+ newest_version > locked_version
65
+ end
61
66
 
62
- Gem::Specification.new(dependency.name, newest_version)
67
+ def updated_specification_for(dependency)
68
+ Gem::Specification.new(dependency.name, dependency.newest_version)
63
69
  end
64
70
  end
65
71
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KeepUp
4
- VERSION = "0.10.0"
4
+ VERSION = "0.10.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keep_up
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matijs van Zuijlen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-23 00:00:00.000000000 Z
11
+ date: 2022-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -50,14 +50,14 @@ dependencies:
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '7.0'
53
+ version: '8.0'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '7.0'
60
+ version: '8.0'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rake
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -106,14 +106,28 @@ dependencies:
106
106
  requirements:
107
107
  - - "~>"
108
108
  - !ruby/object:Gem::Version
109
- version: '1.25'
109
+ version: '1.32'
110
110
  type: :development
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - "~>"
115
115
  - !ruby/object:Gem::Version
116
- version: '1.25'
116
+ version: '1.32'
117
+ - !ruby/object:Gem::Dependency
118
+ name: rubocop-packaging
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: 0.5.1
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: 0.5.1
117
131
  - !ruby/object:Gem::Dependency
118
132
  name: rubocop-performance
119
133
  requirement: !ruby/object:Gem::Requirement
@@ -174,6 +188,8 @@ files:
174
188
  - lib/keep_up/application.rb
175
189
  - lib/keep_up/bundle.rb
176
190
  - lib/keep_up/dependency.rb
191
+ - lib/keep_up/dependency_set.rb
192
+ - lib/keep_up/file_filter.rb
177
193
  - lib/keep_up/gemfile_filter.rb
178
194
  - lib/keep_up/gemspec_filter.rb
179
195
  - lib/keep_up/null_filter.rb
@@ -203,7 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
203
219
  - !ruby/object:Gem::Version
204
220
  version: '0'
205
221
  requirements: []
206
- rubygems_version: 3.3.3
222
+ rubygems_version: 3.3.7
207
223
  signing_key:
208
224
  specification_version: 4
209
225
  summary: Automatically update your dependencies