drg 0.7.0 → 0.8.0
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/README.md +12 -13
- data/drg.gemspec +2 -2
- data/lib/drg/tasks/progressive_pinner.rb +25 -9
- data/lib/drg/tasks/updater.rb +11 -11
- data/lib/drg/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8e48ecc9dad0ef6b8aa9c7caaff1116d79ee336
|
4
|
+
data.tar.gz: 0aab8b29bb2723129fc0c6ccf2b29fa2051ab02c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06c35400aa6eecb7286b3b86ae9cc1c1cceb36151059e10bf409ff7bc0704bb446fdbb8b9d37aa52001039fe3391df53e9f31c4759edcaa9e1fcc67bc61664e7
|
7
|
+
data.tar.gz: 1e4f1d10aeb53d42ab9630a503fd07760f0ed1acc3614cde78d776666b8194d9637768f84a42964f4d0645029456f768afe3fb90485487cf081e79ad34ddbacb
|
data/README.md
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
# DRG
|
2
2
|
|
3
|
-
A Ruby utility to help automate
|
4
|
-
|
5
|
-
update your gems to the latest available version.
|
3
|
+
A Ruby utility to help automate dependency management using Bundler. You can pin Gem versions to the current or the next
|
4
|
+
available level. DRG can automatically update your gems to the latest available version, similar to Gemnasium.
|
6
5
|
|
7
6
|
## Requirements
|
8
7
|
|
@@ -50,7 +49,7 @@ or `:path` will be ignored. You can "pin" all your versions to the current versi
|
|
50
49
|
rake drg:pin
|
51
50
|
```
|
52
51
|
|
53
|
-
|
52
|
+
This task will update your Gemfile with the gem's full version. It'll change:
|
54
53
|
|
55
54
|
```ruby
|
56
55
|
gem 'rails'
|
@@ -59,7 +58,7 @@ gem 'therubyracer', '~> 0.12', platforms: :ruby
|
|
59
58
|
gem 'drg' # need this
|
60
59
|
```
|
61
60
|
|
62
|
-
|
61
|
+
to:
|
63
62
|
|
64
63
|
```ruby
|
65
64
|
gem 'rails', '4.2.3'
|
@@ -70,19 +69,19 @@ gem 'drg', '0.4.1' # need this
|
|
70
69
|
|
71
70
|
### drg:pin:minor
|
72
71
|
|
73
|
-
Want to pin gems at their
|
72
|
+
Want to pin gems at their __minor__ version?
|
74
73
|
|
75
74
|
```bash
|
76
75
|
rake drg:pin:minor
|
77
76
|
```
|
78
77
|
|
79
|
-
|
78
|
+
This task will update your Gemfile with the approximate gem's minor version. It'll change:
|
80
79
|
|
81
80
|
```ruby
|
82
81
|
gem 'rails', '4.2.3'
|
83
82
|
```
|
84
83
|
|
85
|
-
to
|
84
|
+
to:
|
86
85
|
|
87
86
|
```ruby
|
88
87
|
gem 'rails', '~> 4.2'
|
@@ -90,13 +89,13 @@ gem 'rails', '~> 4.2'
|
|
90
89
|
|
91
90
|
### drg:pin:patch
|
92
91
|
|
93
|
-
Want to pin gems at their
|
92
|
+
Want to pin gems at their __patch__ version?
|
94
93
|
|
95
94
|
```bash
|
96
95
|
rake drg:pin:minor
|
97
96
|
```
|
98
97
|
|
99
|
-
|
98
|
+
This task will update your Gemfile with the approximate gem's patch version. It'll change:
|
100
99
|
|
101
100
|
```ruby
|
102
101
|
gem 'rails', '4.2.3'
|
@@ -108,7 +107,7 @@ to
|
|
108
107
|
gem 'rails', '~> 4.2.3'
|
109
108
|
```
|
110
109
|
|
111
|
-
This can be combined with `bundle update` to quickly update all gems to the latest
|
110
|
+
This can be combined with `bundle update` to quickly update all gems to the latest version.
|
112
111
|
|
113
112
|
### drg:pin:major
|
114
113
|
|
@@ -120,7 +119,7 @@ Pins your gems at the major level:
|
|
120
119
|
|
121
120
|
### drg:pin:patch_latest
|
122
121
|
|
123
|
-
Updates the patch version for each outdated gem to the
|
122
|
+
Updates the patch version for each outdated gem to the latest version:
|
124
123
|
|
125
124
|
```bash
|
126
125
|
rake drg:pin:patch_latest #=> updates all gems in the Gemfile
|
@@ -138,7 +137,7 @@ Same as `patch_latest` except it updates the minor version to the latest
|
|
138
137
|
|
139
138
|
### drg:unpin
|
140
139
|
|
141
|
-
Remove the versions from your Gemfile.
|
140
|
+
Remove the versions from your Gemfile. A clean start!
|
142
141
|
|
143
142
|
```bash
|
144
143
|
rake drg:unpin
|
data/drg.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = DRG::VERSION
|
9
9
|
spec.authors = ["Ryan Buckley"]
|
10
10
|
spec.email = ["arebuckley@gmail.com"]
|
11
|
-
spec.summary = %q{DRG
|
12
|
-
spec.description = %q{DRG
|
11
|
+
spec.summary = %q{DRG that Gemfile! The missing bundler extension}
|
12
|
+
spec.description = %q{DRG that Gemfile! The missing bundler extension. Gem version automation with Bundler}
|
13
13
|
spec.homepage = "https://github.com/ridiculous/drg"
|
14
14
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
15
15
|
spec.bindir = "exe"
|
@@ -29,17 +29,20 @@ module DRG
|
|
29
29
|
Updater.new.perform method(:update_handler)
|
30
30
|
end
|
31
31
|
|
32
|
-
def update_handler(
|
33
|
-
|
32
|
+
def update_handler(gems)
|
33
|
+
load_versions gems.map &:name
|
34
|
+
gems.each do |gem|
|
35
|
+
update ::Bundler.locked_gems.specs.find { |spec| spec.name == gem.name }
|
36
|
+
end
|
34
37
|
end
|
35
38
|
|
39
|
+
# @note calls #latest_minor_version and #latest_patch_version
|
36
40
|
def update(spec)
|
37
41
|
gem = gemfile.find_by_name spec.name
|
38
42
|
if gem
|
39
|
-
log %Q[Searching for latest #{type} version of "#{spec.name}" (currently #{spec.version.to_s}) ...]
|
40
43
|
latest_version = public_send("latest_#{type}_version", spec.name, spec.version)
|
41
44
|
if latest_version
|
42
|
-
log
|
45
|
+
log %Q(Updating "#{spec.name}" from #{spec.version.to_s} to #{latest_version})
|
43
46
|
gemfile.update gem, latest_version
|
44
47
|
updated_gems << gem.name
|
45
48
|
else
|
@@ -79,14 +82,27 @@ module DRG
|
|
79
82
|
# @param [String] name of the gem
|
80
83
|
# @return [Array] a list of available versions (e.g. ['1.2.0', '1.1.0'])
|
81
84
|
def versions(name)
|
82
|
-
@versions[name] ||=
|
85
|
+
@versions[name] ||= begin
|
86
|
+
log %Q(Searching for latest #{type} version of "#{name}" ...)
|
87
|
+
`gem query -radn ^#{name}$`.scan(/([\d.]+),/).flatten.uniq
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def load_versions(gems)
|
92
|
+
load_gem_versions(gems).scan(/^(#{Array(gems).join('|')})\s\(([\d.\s,\w\-]+)\)$/).each do |gem_name, versions|
|
93
|
+
@versions[gem_name] = versions.to_s.split(', ')
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def load_gem_versions(gems)
|
98
|
+
log %Q(Searching for latest #{type} versions of #{gems.join(' ')} ...)
|
99
|
+
`gem query -ra #{gems.join(' ')}`
|
83
100
|
end
|
84
101
|
|
102
|
+
# @param [Array] list of a gem version's segments
|
103
|
+
# @param [Array] other_list of another gem version's segments
|
85
104
|
def higher?(list, other_list)
|
86
|
-
|
87
|
-
return true if list[1].to_i > other_list[1].to_i
|
88
|
-
return true if list[2].to_i > other_list[2].to_i
|
89
|
-
false
|
105
|
+
list[0].to_i > other_list[0].to_i || list[1].to_i > other_list[1].to_i || list[2].to_i > other_list[2].to_i
|
90
106
|
end
|
91
107
|
|
92
108
|
# @todo delete if not used
|
data/lib/drg/tasks/updater.rb
CHANGED
@@ -3,11 +3,10 @@ module DRG
|
|
3
3
|
class Updater
|
4
4
|
include Log
|
5
5
|
|
6
|
-
attr_reader :gemfile, :
|
6
|
+
attr_reader :gemfile, :bundler
|
7
7
|
|
8
8
|
def initialize
|
9
9
|
@gemfile = Gemfile.new
|
10
|
-
@failures = Set.new
|
11
10
|
@bundler = Bundler::CLI.new [], debug: true, current_command: OpenStruct.new
|
12
11
|
@versions = {}
|
13
12
|
end
|
@@ -16,7 +15,8 @@ module DRG
|
|
16
15
|
#
|
17
16
|
# @todo Cleanup old gems when finished
|
18
17
|
# @note `bundle outdated` returns lines that look like 'slop (newest 4.2.0, installed 3.6.0) in group "default"'
|
19
|
-
|
18
|
+
# @param [#call] handler needs to be a callable object that takes an array of gems [OpenStruct] (default :update_all)
|
19
|
+
def perform(handler = method(:update_all))
|
20
20
|
log 'Searching for outdated gems ....'
|
21
21
|
outdated = `bundle outdated`.scan(/\s\*\s(.+)\s/).flatten
|
22
22
|
gems = outdated.map do |item|
|
@@ -29,14 +29,18 @@ module DRG
|
|
29
29
|
gem
|
30
30
|
end.compact
|
31
31
|
if gems.any?
|
32
|
-
|
32
|
+
handler.call gems
|
33
33
|
else
|
34
34
|
log 'All gems up to date!'
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
|
39
|
-
|
38
|
+
def update_all(gems)
|
39
|
+
gems.each &method(:update)
|
40
|
+
end
|
41
|
+
|
42
|
+
# @param [#name, #current_version, #latest_version, #entry] gem is the gem to update, where #entry is a GemfileLine
|
43
|
+
def update(gem)
|
40
44
|
log(%Q[Updating "#{gem.name}" from #{gem.current_version} to #{gem.latest_version}])
|
41
45
|
gemfile.remove_version gem.entry
|
42
46
|
bundler.update(gem.name)
|
@@ -46,20 +50,16 @@ module DRG
|
|
46
50
|
log(%Q[Tests passed! Updating Gemfile entry for "#{gem.name}" to #{gem.latest_version}])
|
47
51
|
gemfile.update(gem.entry, gem.latest_version)
|
48
52
|
gemfile.write
|
49
|
-
else
|
50
|
-
failures << gem.name
|
51
53
|
end
|
52
54
|
else
|
53
55
|
fail StandardError, %Q[Failed to update "#{gem.name}"]
|
54
56
|
end
|
55
57
|
rescue Bundler::GemNotFound, Bundler::InstallError, Bundler::VersionConflict => e
|
56
|
-
# @todo retry it later
|
57
58
|
log %Q[Failed to find a compatible of "#{gem.name}" (#{gem.latest_version}): #{e.class} #{e.message}]
|
58
59
|
gemfile.rollback
|
59
|
-
failures << gem.name
|
60
60
|
rescue => e
|
61
|
-
puts "#{e.class}: #{e.message} #{e.backtrace}"
|
62
61
|
gemfile.rollback
|
62
|
+
log "#{e.class}: #{e.message}\n#{e.backtrace}"
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
data/lib/drg/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: drg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Buckley
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -86,7 +86,8 @@ dependencies:
|
|
86
86
|
- - "<"
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '4'
|
89
|
-
description: DRG
|
89
|
+
description: DRG that Gemfile! The missing bundler extension. Gem version automation
|
90
|
+
with Bundler
|
90
91
|
email:
|
91
92
|
- arebuckley@gmail.com
|
92
93
|
executables: []
|
@@ -139,5 +140,5 @@ rubyforge_project:
|
|
139
140
|
rubygems_version: 2.4.6
|
140
141
|
signing_key:
|
141
142
|
specification_version: 4
|
142
|
-
summary: DRG
|
143
|
+
summary: DRG that Gemfile! The missing bundler extension
|
143
144
|
test_files: []
|