thief 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -7
- data/lib/thief/version.rb +1 -1
- data/lib/thief.rb +15 -34
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3707be4b98fe35a4f8083306437c3eb0ee6cbd23
|
4
|
+
data.tar.gz: 8a3e6aba2464701d438157779f3b1b76e41af86d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 984186af46edb2bf4261b36ec1b72349296bd415594d6f5119c16573c4ad4dbea26d955d8308966166476f1be1b13d994b31c3dbc33af048da66345f328ca849
|
7
|
+
data.tar.gz: 7e0dc4816bdecc1262effacc514a8b66cb8f0e55a424a9cba393a83888763adf2c7c717e06d6a6b56b74cccb1bf23d279dc153ab0ee2d6efd93784da5851c4e6
|
data/README.md
CHANGED
@@ -3,23 +3,20 @@
|
|
3
3
|
Thief is a hack and slash alternative for installing Gemfile contents as fast as possible. It
|
4
4
|
operates in following way:
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
It leaves a mess, but does the majority of work that Bundler is notoriously slow at. Run Bundler
|
10
|
-
afterwards to have a clean finish.
|
6
|
+
1. Runs `bundle check` which usually returns list of missing gems with versions quickly.
|
7
|
+
2. Runs optimized `gem install` for each gem using as many parallel processes as you have CPUs.
|
11
8
|
|
12
9
|
## Installation
|
13
10
|
|
14
11
|
Install using the command line:
|
15
12
|
|
16
|
-
|
13
|
+
$ gem install thief
|
17
14
|
|
18
15
|
## Usage
|
19
16
|
|
20
17
|
Recommended usage for CI builds or production installs is in combination with [Bundler](http://bundler.io/):
|
21
18
|
|
22
|
-
$ bundle check ||
|
19
|
+
$ thief; bundle check || bundle install
|
23
20
|
|
24
21
|
Execute somewhere where Gemfile is present
|
25
22
|
|
data/lib/thief/version.rb
CHANGED
data/lib/thief.rb
CHANGED
@@ -7,8 +7,13 @@ module Thief
|
|
7
7
|
def install
|
8
8
|
gemfile = resolve_gemfile
|
9
9
|
gems = parse_gemfile(gemfile)
|
10
|
-
|
11
|
-
|
10
|
+
if gems.size > 0
|
11
|
+
puts "Getting #{gems.size} missing gems"
|
12
|
+
Parallel.map(gems, in_processes: cpu_count, progress: 'Getting missing gems') do |gem|
|
13
|
+
install_gem(gem)
|
14
|
+
end
|
15
|
+
else
|
16
|
+
puts 'You have all the gems you need'
|
12
17
|
end
|
13
18
|
end
|
14
19
|
|
@@ -22,39 +27,16 @@ module Thief
|
|
22
27
|
end
|
23
28
|
|
24
29
|
def parse_gemfile(gemfile)
|
30
|
+
missing = `bundle check --gemfile=#{gemfile}`
|
31
|
+
gems = missing.split("\n").map(&:strip).select { |l| l.start_with?('*') }
|
25
32
|
result = []
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
parse_line(result, line, line_num)
|
33
|
+
gems.map do |gem|
|
34
|
+
gem, version = gem.gsub('* ', '').split(' (')
|
35
|
+
result << { gem: gem, version: version.gsub(')', '') }
|
30
36
|
end
|
31
37
|
result
|
32
38
|
end
|
33
39
|
|
34
|
-
def parse_line(result, line, num)
|
35
|
-
line = line.strip
|
36
|
-
if line.include?(':path =>') || line.include?('path: ')
|
37
|
-
puts "WARNING: Skipping local: #{line}"
|
38
|
-
return
|
39
|
-
end
|
40
|
-
if line.include?('#')
|
41
|
-
line, _ = line.split('#')
|
42
|
-
end
|
43
|
-
if line.start_with?('gem')
|
44
|
-
gem, version = line.gsub(/['"]/, '').split(',')
|
45
|
-
gem_def = { gem: gem.gsub(/^gem\s+/, '').strip }
|
46
|
-
if version && version.include?('require')
|
47
|
-
version.gsub!(/:?require.+/, '').strip
|
48
|
-
end
|
49
|
-
if version && version.strip.length > 0
|
50
|
-
gem_def[:version] = version.strip
|
51
|
-
end
|
52
|
-
result << gem_def
|
53
|
-
end
|
54
|
-
rescue => e
|
55
|
-
puts "WARNING: Could not parse line: #{num}: #{line}: #{e}"
|
56
|
-
end
|
57
|
-
|
58
40
|
def resolve_gemfile
|
59
41
|
gemfile_path = ARGV[0] || 'Gemfile'
|
60
42
|
if gemfile_path.start_with?('~') || gemfile_path.start_with?('/')
|
@@ -68,10 +50,9 @@ module Thief
|
|
68
50
|
end
|
69
51
|
|
70
52
|
def check_gemfile(gemfile)
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
end
|
53
|
+
return if File.exist?(gemfile)
|
54
|
+
puts 'Run thief in a directory that contains a Gemfile'
|
55
|
+
exit 1
|
75
56
|
end
|
76
57
|
|
77
58
|
def cpu_count
|