grub 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/grub/cli.rb +11 -2
- data/lib/grub/spec_finder.rb +7 -5
- data/lib/grub/version.rb +1 -1
- 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: 365d41ee25f6da66f293e9020e663f0c2d97cea0
|
4
|
+
data.tar.gz: fe939a6aa56eb8a0f387a04d7034cc5096183760
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ba83c65303a136313a57e89b6cf3e97ad9ecb8ea4047777ac89f779181a6d252284e8a36972b34267c515208079fdc3f237cd5d0d59719a4959f03367ee9d3a
|
7
|
+
data.tar.gz: 6970f79bb4efb37bf974dfaa5b312ae9778cc7754c85b9f002468b6050c563ed71c57284c7b93f0d4b17fc3a34a1820d39c0f92e05f9d35d4889d2454b298856
|
data/lib/grub/cli.rb
CHANGED
@@ -16,17 +16,26 @@ module Grub
|
|
16
16
|
gemfile = Gemfile.new(Bundler.default_gemfile, options)
|
17
17
|
gemfile.parse
|
18
18
|
unless gemfile.gem_lines.empty?
|
19
|
-
SpecFinder.find_specs_for(gemfile.gem_lines)
|
19
|
+
SpecFinder.find_specs_for(gemfile.gem_lines, &self.method(:print_progress))
|
20
20
|
gemfile.write_comments
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
def run_for_gem(gem_name, options = {})
|
25
25
|
gem_line = GemLine.new(name: gem_name, options: options)
|
26
|
-
SpecFinder.find_specs_for(gem_line)
|
26
|
+
SpecFinder.find_specs_for(gem_line, &self.method(:print_progress))
|
27
|
+
|
27
28
|
info = gem_line.info
|
28
29
|
info = "No information to show" if info.strip.empty?
|
29
30
|
puts info
|
30
31
|
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def print_progress(completed, total)
|
36
|
+
print "Fetching gem metadata..." if completed.zero?
|
37
|
+
print "."
|
38
|
+
print "\n" if completed == total
|
39
|
+
end
|
31
40
|
end
|
32
41
|
end
|
data/lib/grub/spec_finder.rb
CHANGED
@@ -2,11 +2,11 @@ module Grub
|
|
2
2
|
module SpecFinder
|
3
3
|
extend self
|
4
4
|
|
5
|
-
def find_specs_for(gem_lines)
|
5
|
+
def find_specs_for(gem_lines, &block)
|
6
6
|
gem_lines = Array(gem_lines)
|
7
7
|
find_matching_specs_for(gem_lines)
|
8
8
|
gems_to_fetch = gem_lines.select { |gem_line| gem_line.spec.nil? }
|
9
|
-
fetch_specs_for(gems_to_fetch) if gems_to_fetch.any?
|
9
|
+
fetch_specs_for(gems_to_fetch, &block) if gems_to_fetch.any?
|
10
10
|
end
|
11
11
|
|
12
12
|
def find_matching_specs_for(gem_lines)
|
@@ -18,18 +18,20 @@ module Grub
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def fetch_specs_for(gem_lines)
|
21
|
-
|
21
|
+
total = gem_lines.length
|
22
|
+
completed = 0
|
23
|
+
yield completed, total if block_given?
|
22
24
|
remote = Bundler::Source::Rubygems::Remote.new(Gem.sources.first.uri)
|
23
25
|
fetcher = Bundler::Fetcher.new(remote)
|
24
26
|
dependency_fetcher = fetcher.fetchers.find {|f| Bundler::Fetcher::Dependency === f }
|
25
27
|
versions, _ = dependency_fetcher.dependency_specs(gem_lines.collect(&:name))
|
26
28
|
gem_lines.each do |gem_line|
|
27
|
-
print "."
|
28
29
|
gem_versions = versions.select { |v| v.first == gem_line.name }
|
29
30
|
version = find_latest_version(gem_versions)
|
30
31
|
gem_line.spec = fetcher.fetch_spec([gem_line.name, version])
|
32
|
+
completed += 1
|
33
|
+
yield completed, total if block_given?
|
31
34
|
end
|
32
|
-
print "\n"
|
33
35
|
end
|
34
36
|
|
35
37
|
def find_latest_version(versions)
|
data/lib/grub/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Tse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|