gem_updater 0.3.2 → 0.4.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/bin/gem_update +15 -5
- data/lib/gem_updater.rb +24 -11
- data/lib/gem_updater/gem_file.rb +3 -3
- data/lib/gem_updater/ruby_gems_fetcher.rb +1 -1
- data/lib/gem_updater/source_page_parser.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fee227f190228ac253e48a0ae55f3149c811b04b
|
4
|
+
data.tar.gz: d5e4a27a8c8173afad0bcdff99d653330c849e90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8caa264e1614513e77fce435e9e606f950f255c8bce3865103c751ebcc3dd544b2362c4601fa6751de80469395fbe08965eb53589f6ca1e78cab1e1440c1da4
|
7
|
+
data.tar.gz: 6cd3bb667a5bf9123d52695ac1c1be946f6a45c63e6288deabd214f9adb51ee1e483ac04656846271f804a5bb729b026d421ae27e2185070325f02eb0ba5d0ee
|
data/bin/gem_update
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
require 'optparse'
|
2
3
|
|
3
4
|
# Exit cleanly from an early interrupt
|
4
5
|
Signal.trap("INT") { exit 1 }
|
@@ -6,11 +7,20 @@ Signal.trap("INT") { exit 1 }
|
|
6
7
|
$:.unshift File.expand_path( '../../lib', __FILE__ )
|
7
8
|
require 'gem_updater'
|
8
9
|
|
10
|
+
Bundler.ui = Bundler::UI::Shell.new
|
11
|
+
|
12
|
+
options = {}
|
13
|
+
OptionParser.new do |opts|
|
14
|
+
opts.on( "-c", "--commit", "Auto commit" ) do |v|
|
15
|
+
options[ :commit ] = v
|
16
|
+
end
|
17
|
+
end.parse!
|
18
|
+
|
9
19
|
gems = GemUpdater::Updater.new
|
10
|
-
gems.update!
|
20
|
+
gems.update!( ARGV )
|
11
21
|
|
12
22
|
if gems.gemfile.changes.any?
|
13
|
-
if
|
23
|
+
if options[ :commit ]
|
14
24
|
require 'tempfile'
|
15
25
|
file = Tempfile.new( 'gem_updater' )
|
16
26
|
file.write "UPDATE gems\n\n"
|
@@ -22,10 +32,10 @@ if gems.gemfile.changes.any?
|
|
22
32
|
system %(git add #{gemfile} #{gemfile}.lock && git commit -t #{file.path} --allow-empty-message)
|
23
33
|
file.unlink
|
24
34
|
else
|
25
|
-
|
26
|
-
|
35
|
+
Bundler.ui.confirm "\nHere are your changes:"
|
36
|
+
Bundler.ui.confirm '------------------------'
|
27
37
|
gems.output_diff
|
28
38
|
end
|
29
39
|
else
|
30
|
-
|
40
|
+
Bundler.ui.confirm "\nCongratulations, your Gemfile was already up-to-date!"
|
31
41
|
end
|
data/lib/gem_updater.rb
CHANGED
@@ -17,23 +17,18 @@ module GemUpdater
|
|
17
17
|
# This will:
|
18
18
|
# 1. update gemfile
|
19
19
|
# 2. find changelogs for updated gems
|
20
|
-
|
21
|
-
|
20
|
+
#
|
21
|
+
# @param gems [Array] list of gems to update
|
22
|
+
def update!( gems )
|
23
|
+
gemfile.update!( gems )
|
22
24
|
gemfile.compute_changes
|
23
25
|
|
24
|
-
|
25
|
-
gemfile.changes.each do |gem_name, details|
|
26
|
-
if source_uri = find_source( gem_name, details[ :source ] )
|
27
|
-
source_page = GemUpdater::SourcePageParser.new( url: source_uri, version: details[ :versions ][ :new ] )
|
28
|
-
|
29
|
-
gemfile.changes[ gem_name ][ :changelog ] = source_page.changelog if source_page.changelog
|
30
|
-
end
|
31
|
-
end
|
26
|
+
fill_changelogs
|
32
27
|
end
|
33
28
|
|
34
29
|
# Print formatted diff
|
35
30
|
def output_diff
|
36
|
-
|
31
|
+
Bundler.ui.info format_diff.join
|
37
32
|
end
|
38
33
|
|
39
34
|
# Format the diff to get human readable information
|
@@ -46,6 +41,24 @@ module GemUpdater
|
|
46
41
|
|
47
42
|
private
|
48
43
|
|
44
|
+
# For each gem, retrieve its changelog
|
45
|
+
def fill_changelogs
|
46
|
+
threads = []
|
47
|
+
|
48
|
+
gemfile.changes.each do |gem_name, details|
|
49
|
+
threads << Thread.new do
|
50
|
+
if source_uri = find_source( gem_name, details[ :source ] )
|
51
|
+
source_page = GemUpdater::SourcePageParser.new( url: source_uri, version: details[ :versions ][ :new ] )
|
52
|
+
|
53
|
+
gemfile.changes[ gem_name ][ :changelog ] = source_page.changelog if source_page.changelog
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
threads.each( &:join )
|
59
|
+
end
|
60
|
+
|
61
|
+
|
49
62
|
# Find where is hosted the source of a gem
|
50
63
|
#
|
51
64
|
# @param gem [String] the name of the gem
|
data/lib/gem_updater/gem_file.rb
CHANGED
@@ -12,9 +12,9 @@ module GemUpdater
|
|
12
12
|
end
|
13
13
|
|
14
14
|
# Run `bundle update` to update gems.
|
15
|
-
def update!
|
16
|
-
|
17
|
-
Bundler::CLI.start( [ 'update' ] )
|
15
|
+
def update!( gems )
|
16
|
+
Bundler.ui.warn "Updating gems..."
|
17
|
+
Bundler::CLI.start( [ 'update' ] + gems )
|
18
18
|
end
|
19
19
|
|
20
20
|
# Compute the diffs between two `Gemfile.lock`.
|
@@ -55,7 +55,7 @@ module GemUpdater
|
|
55
55
|
when 'rails-assets.org'
|
56
56
|
uri_from_railsassets
|
57
57
|
else
|
58
|
-
|
58
|
+
Bundler.ui.error "Source #{remote} is not supported, feel free to open a PR or an issue on https://github.com/MaximeD/gem_updater"
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -19,15 +19,15 @@ module GemUpdater
|
|
19
19
|
# @return [String, nil] URL of changelog
|
20
20
|
def changelog
|
21
21
|
@changelog ||= begin
|
22
|
-
|
22
|
+
Bundler.ui.warn "Looking for a changelog in #{@uri}"
|
23
23
|
doc = Nokogiri::HTML( open( @uri ) )
|
24
24
|
|
25
25
|
find_changelog( doc )
|
26
26
|
|
27
27
|
rescue OpenURI::HTTPError # Uri points to nothing
|
28
|
-
|
28
|
+
Bundler.ui.error "Cannot find #{@uri}"
|
29
29
|
rescue Errno::ETIMEDOUT # timeout
|
30
|
-
|
30
|
+
Bundler.ui.error "#{@uri} is down"
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gem_updater
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maxime Demolin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|