bumpit 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f67d72f391fc1463961ff849e3931208554723114f4044087167af711759188d
4
- data.tar.gz: 46e643d64311e2b0fb0cf7ba6ee07f616799f0dc070cf4fcd83170c700ea4c3d
3
+ metadata.gz: 61dc3fe86a1ce8d55b8cd34773cfff73c8beb459bc4964d7beb2dd008506745b
4
+ data.tar.gz: 8f12b7cf3e4128b9ec0f7a5776779d89bf31b3fd31c450f552d814f75b7fb67d
5
5
  SHA512:
6
- metadata.gz: 3e68c01e733fa581d817daa9c0750885f209d54019630522596ec2110e9648f890d3827335c80b80f157188c82bc37b6245feae33e000e5ddae2c3d2eb24bd4a
7
- data.tar.gz: e3ccc2bdc203ef83eefd192f9f4422d4433ba6bbe2769b569c54e3000bce856dfd5500a82650e92fe100ac447e45c90b046b563e9e96e9910b6a9e27a419c644
6
+ metadata.gz: 0a8bbfd7d4cf366219f71f0de32ea6b3e08fa029326095e45cf8b30281fdb304429fe2f2fe30e9ddc65001f1063b925e044bfe048707eea7372028aeb60b1409
7
+ data.tar.gz: d4ae18ad6a77baa29373022fe79ec62b0627428a0742533fd5439d0fc77de15c03eae97a623c3b6421036ac43f9f1ec1b999b677b9224cba8196b14076d421a1
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "bundler"
4
4
 
5
- # :nocov:
5
+ # simplecov:disable
6
6
  class Bumpit
7
7
  module Managers
8
8
  class Base
@@ -50,4 +50,4 @@ class Bumpit
50
50
  end
51
51
  end
52
52
  end
53
- # :nocov:
53
+ # simplecov:enable
@@ -6,14 +6,16 @@ require "pathname"
6
6
  class Bumpit
7
7
  module Managers
8
8
  class Bundler < Base
9
- BUNDLE_VERSION_COMMAND = "bundle info bundler --version"
10
- BUNDLER_UPDATE_COMMAND = "bundle update --bundler"
9
+ BUNDLED_WITH_MATCHER = /^BUNDLED WITH\n\s+(.+)$/
10
+ BUNDLER_UPDATE_COMMAND = "bundle update --bundler=%s"
11
11
  DEPENDENCY_MATCHER = /^\s*gem\s+['"]([^'"]+)['"].*$/
12
- FILENAMES = %w(Gemfile Gemfile.lock).freeze
12
+ GEMFILE = "Gemfile"
13
+ GEMFILE_LOCK = "Gemfile.lock"
14
+ FILENAMES = [GEMFILE, GEMFILE_LOCK].freeze
13
15
  GEM_INFO_COMMAND = "gem info --exact --remote --no-prerelease --no-verbose bundler"
14
16
  INFO_MATCHER = /bundler \(([^)]+)\)/
15
17
  OUTDATED_COMMAND = "bundle outdated --only-explicit --parseable 2>/dev/null"
16
- OUTDATED_MATCHER = /\A(.+) \(newest (.+), installed (.+), requested = (.+)\)\z/
18
+ OUTDATED_MATCHER = /\A(\S+) \(newest ([^,)]+), installed ([^,)]+), requested = ([^,)]+)/
17
19
 
18
20
  # Determine if the manager is valid.
19
21
  #
@@ -29,7 +31,7 @@ class Bumpit
29
31
  #
30
32
  # @return [void]
31
33
  def bump
32
- if outdated.any?
34
+ if outdated?
33
35
  write_contents
34
36
  bundle_update
35
37
  end
@@ -68,7 +70,7 @@ class Bumpit
68
70
  #
69
71
  # @return [String] The contents of the Gemfile.
70
72
  def contents
71
- @contents ||= File.read("Gemfile")
73
+ @contents ||= File.read(GEMFILE)
72
74
  end
73
75
 
74
76
  # Return the modified contents of the Gemfile.
@@ -87,6 +89,13 @@ class Bumpit
87
89
  end
88
90
  end
89
91
 
92
+ # Return the latest released version of Bundler.
93
+ #
94
+ # @return [String]
95
+ def latest_bundler_version
96
+ @latest_bundler_version ||= INFO_MATCHER.match(`#{GEM_INFO_COMMAND}`).to_a.last.to_s
97
+ end
98
+
90
99
  # Return the outdated dependencies.
91
100
  #
92
101
  # @return [Hash]
@@ -100,12 +109,22 @@ class Bumpit
100
109
  end
101
110
  end
102
111
 
112
+ # Determine if there are outdated dependencies, including Bundler.
113
+ #
114
+ # Checks update_bundler? first to cache the result before bundle_update
115
+ # modifies the lock file.
116
+ #
117
+ # @return [Boolean]
118
+ def outdated?
119
+ update_bundler? || outdated.any?
120
+ end
121
+
103
122
  # Update Bundler in the lock file.
104
123
  #
105
124
  # @return [void]
106
125
  def update_bundler
107
126
  if update_bundler?
108
- `#{BUNDLER_UPDATE_COMMAND}`
127
+ `#{format(BUNDLER_UPDATE_COMMAND, latest_bundler_version)}`
109
128
  end
110
129
  end
111
130
 
@@ -116,10 +135,9 @@ class Bumpit
116
135
  return @update_bundler if defined?(@update_bundler)
117
136
 
118
137
  @update_bundler = begin
119
- _, latest = INFO_MATCHER.match(`#{GEM_INFO_COMMAND}`).to_a
120
- current = `#{BUNDLE_VERSION_COMMAND}`
138
+ _, current = BUNDLED_WITH_MATCHER.match(File.read(GEMFILE_LOCK)).to_a
121
139
 
122
- Gem::Version.new(latest.to_s) > Gem::Version.new(current.to_s)
140
+ Gem::Version.new(latest_bundler_version) > Gem::Version.new(current.to_s)
123
141
  end
124
142
  end
125
143
 
@@ -127,7 +145,7 @@ class Bumpit
127
145
  #
128
146
  # @return [void]
129
147
  def write_contents
130
- File.write("Gemfile", "#{modified_contents.join("\n")}\n")
148
+ File.write(GEMFILE, "#{modified_contents.join("\n")}\n")
131
149
  end
132
150
  end
133
151
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Bumpit
4
- VERSION = "0.3.1"
4
+ VERSION = "0.3.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bumpit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tristan Dunn
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  requirements: []
76
- rubygems_version: 4.0.4
76
+ rubygems_version: 4.0.23
77
77
  specification_version: 4
78
78
  summary: Automatically bump dependencies in multiple package managers.
79
79
  test_files: []