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 +4 -4
- data/lib/bumpit/managers/base.rb +2 -2
- data/lib/bumpit/managers/bundler.rb +29 -11
- data/lib/bumpit/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 61dc3fe86a1ce8d55b8cd34773cfff73c8beb459bc4964d7beb2dd008506745b
|
|
4
|
+
data.tar.gz: 8f12b7cf3e4128b9ec0f7a5776779d89bf31b3fd31c450f552d814f75b7fb67d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0a8bbfd7d4cf366219f71f0de32ea6b3e08fa029326095e45cf8b30281fdb304429fe2f2fe30e9ddc65001f1063b925e044bfe048707eea7372028aeb60b1409
|
|
7
|
+
data.tar.gz: d4ae18ad6a77baa29373022fe79ec62b0627428a0742533fd5439d0fc77de15c03eae97a623c3b6421036ac43f9f1ec1b999b677b9224cba8196b14076d421a1
|
data/lib/bumpit/managers/base.rb
CHANGED
|
@@ -6,14 +6,16 @@ require "pathname"
|
|
|
6
6
|
class Bumpit
|
|
7
7
|
module Managers
|
|
8
8
|
class Bundler < Base
|
|
9
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
|
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(
|
|
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
|
-
_,
|
|
120
|
-
current = `#{BUNDLE_VERSION_COMMAND}`
|
|
138
|
+
_, current = BUNDLED_WITH_MATCHER.match(File.read(GEMFILE_LOCK)).to_a
|
|
121
139
|
|
|
122
|
-
Gem::Version.new(
|
|
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(
|
|
148
|
+
File.write(GEMFILE, "#{modified_contents.join("\n")}\n")
|
|
131
149
|
end
|
|
132
150
|
end
|
|
133
151
|
end
|
data/lib/bumpit/version.rb
CHANGED
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.
|
|
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.
|
|
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: []
|