keep_up 0.10.1 → 0.11.0

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: 97d3f75d5a76fc8ce0a3d1c0c9d93df3d7d1f7790108b7166012c12e83eb824a
4
- data.tar.gz: 850cd7426571713d51c058b068a31c9abd72de6713bdbdd721baf596d9363d6c
3
+ metadata.gz: f982817574ba0a2dc2a74ea68776912ceb896a30a88461c7f5b89bd11d77dae7
4
+ data.tar.gz: 8f4b736dd3f0389915b501c2c0de2f97d28719c9a9a5783b838604eb403e3a70
5
5
  SHA512:
6
- metadata.gz: '049e14f64bd4dd799dcabac41e0141fb682f81b6a933817f182d1b07c9365f38da42fa0c2dd4a79a1e19512420cb29fa81325030e4d149538198b9c447dcb344'
7
- data.tar.gz: 41bd81924f216a3957bdaf627ebe4cf3f878e7668b953af977b6467cc272ff5ff8203b9f60748febb4cda97ef42cc4613d47a584ead02d899bd30d36bbd59bbc
6
+ metadata.gz: b84d4c38eb78a3c2be0924d1e2ea2359b21748885e19f024bee5e8451454218b5e1023e54da6a28f7c096bf47ecc7e3aa2a51b96c7df3d90e04d8c1bf4ae3204
7
+ data.tar.gz: '050589501a228b59a809b50f2a9d36e3df7aa479ef4411ce606cba6c119697d8f1c02d828a3535ab98e13adfb60efc3fd146dd8195486c157461a4cf2eb9ea14'
data/CHANGELOG.md CHANGED
@@ -1,12 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.11.0 / 2023-09-22
4
+
5
+ * Drop support for Ruby 2.6 ([#102] by [mvz])
6
+ * Add support for Ruby 3.2 ([#103] by [mvz])
7
+
8
+ [mvz]: https://github.com/mvz
9
+ [#102]: https://github.com/mvz/keep_up/pull/102
10
+ [#103]: https://github.com/mvz/keep_up/pull/103
11
+
12
+ ## 0.10.2 / 2022-09-23
13
+
14
+ * Detect version update even if `bundle update` does not print old version
15
+
3
16
  ## 0.10.1 / 2022-05-20
4
17
 
5
18
  * Adjust commit message to match update specificity
6
19
 
7
20
  ## 0.10.0 / 2022-01-23
8
21
 
9
- * Drop support for Ruby 2.5 and 2.6
22
+ * Drop support for Ruby 2.5
10
23
  * Add support for Ruby 3.0 and 3.1
11
24
  * Avoid interrupting half-printed lines when bundle update fails
12
25
 
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 if 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 if 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,24 +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
- contents = File.read(file)
115
- updated_contents = filter.apply(contents, update)
116
- if contents == updated_contents
117
- false
118
- else
119
- File.write file, updated_contents
120
- true
121
- end
122
- end
123
-
124
111
  def gemspec_name
125
112
  @gemspec_name ||= Dir.glob("*.gemspec").first
126
113
  end
@@ -128,12 +115,12 @@ module KeepUp
128
115
  def run_filtered(command, regexp)
129
116
  result = @runner.run command
130
117
  lines = result.split("\n").reject(&:empty?)
131
- lines.map do |line|
118
+ lines.filter_map do |line|
132
119
  matchdata = regexp.match line
133
120
  next unless matchdata
134
121
 
135
122
  matchdata.to_a[1..]
136
- end.compact
123
+ end
137
124
  end
138
125
  end
139
126
  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,21 @@ 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
- update = bundle.update_gemspec_contents(dependency)
39
- update2 = bundle.update_gemfile_contents(dependency)
38
+
39
+ specification = updated_specification_for(dependency)
40
+
41
+ update = bundle.update_gemspec_contents(specification)
42
+ update2 = bundle.update_gemfile_contents(specification)
40
43
  update ||= update2
41
- result = bundle.update_lockfile(dependency)
42
- report_result dependency, result
44
+ result = bundle.update_lockfile(specification, dependency.locked_version)
45
+ report_result specification, result
43
46
  update || result if result
44
47
  end
45
48
 
@@ -55,12 +58,14 @@ module KeepUp
55
58
  end
56
59
  end
57
60
 
58
- def updated_dependency_for(dependency)
61
+ def updateable_dependency?(dependency)
59
62
  locked_version = dependency.locked_version
60
63
  newest_version = dependency.newest_version
61
- return unless newest_version > locked_version
64
+ newest_version > locked_version
65
+ end
62
66
 
63
- Gem::Specification.new(dependency.name, newest_version)
67
+ def updated_specification_for(dependency)
68
+ Gem::Specification.new(dependency.name, dependency.newest_version)
64
69
  end
65
70
  end
66
71
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KeepUp
4
- VERSION = "0.10.1"
4
+ VERSION = "0.11.0"
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.1
4
+ version: 0.11.0
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-05-20 00:00:00.000000000 Z
11
+ date: 2023-09-22 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: '9.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: '9.0'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rake
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -106,56 +106,70 @@ dependencies:
106
106
  requirements:
107
107
  - - "~>"
108
108
  - !ruby/object:Gem::Version
109
- version: '1.25'
109
+ version: '1.52'
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.52'
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.2
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.2
117
131
  - !ruby/object:Gem::Dependency
118
132
  name: rubocop-performance
119
133
  requirement: !ruby/object:Gem::Requirement
120
134
  requirements:
121
135
  - - "~>"
122
136
  - !ruby/object:Gem::Version
123
- version: '1.13'
137
+ version: '1.18'
124
138
  type: :development
125
139
  prerelease: false
126
140
  version_requirements: !ruby/object:Gem::Requirement
127
141
  requirements:
128
142
  - - "~>"
129
143
  - !ruby/object:Gem::Version
130
- version: '1.13'
144
+ version: '1.18'
131
145
  - !ruby/object:Gem::Dependency
132
146
  name: rubocop-rspec
133
147
  requirement: !ruby/object:Gem::Requirement
134
148
  requirements:
135
149
  - - "~>"
136
150
  - !ruby/object:Gem::Version
137
- version: '2.7'
151
+ version: '2.22'
138
152
  type: :development
139
153
  prerelease: false
140
154
  version_requirements: !ruby/object:Gem::Requirement
141
155
  requirements:
142
156
  - - "~>"
143
157
  - !ruby/object:Gem::Version
144
- version: '2.7'
158
+ version: '2.22'
145
159
  - !ruby/object:Gem::Dependency
146
160
  name: simplecov
147
161
  requirement: !ruby/object:Gem::Requirement
148
162
  requirements:
149
163
  - - "~>"
150
164
  - !ruby/object:Gem::Version
151
- version: 0.21.0
165
+ version: 0.22.0
152
166
  type: :development
153
167
  prerelease: false
154
168
  version_requirements: !ruby/object:Gem::Requirement
155
169
  requirements:
156
170
  - - "~>"
157
171
  - !ruby/object:Gem::Version
158
- version: 0.21.0
172
+ version: 0.22.0
159
173
  description: Automatically update the dependencies listed in your Gemfile, Gemfile.lock,
160
174
  and gemspec.
161
175
  email:
@@ -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
@@ -196,14 +212,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
196
212
  requirements:
197
213
  - - ">="
198
214
  - !ruby/object:Gem::Version
199
- version: 2.6.0
215
+ version: 2.7.0
200
216
  required_rubygems_version: !ruby/object:Gem::Requirement
201
217
  requirements:
202
218
  - - ">="
203
219
  - !ruby/object:Gem::Version
204
220
  version: '0'
205
221
  requirements: []
206
- rubygems_version: 3.3.7
222
+ rubygems_version: 3.4.19
207
223
  signing_key:
208
224
  specification_version: 4
209
225
  summary: Automatically update your dependencies