bundle-diff 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ed4c76ee646c06c88b5bde31765fa22f76addd88db752b1dd7decfed3488658
4
- data.tar.gz: 2137ebd6d32389f7359bf9866b1b5e172443d8d351c91fa91f1ed40b11de7e7d
3
+ metadata.gz: 16627d483f7b0f3db714bd4d6f208c696d6e9cb36570a3e85d5b117af804ab5a
4
+ data.tar.gz: 0a7fe5601932249c75c5fe01b40bdcf1520fed756e5f88714cc0ed3a64fd429b
5
5
  SHA512:
6
- metadata.gz: adb81ab85d860f01b9d0b6d930343d0c619142d32c93e1b89ade252d49c05a4a223ef5d5f46aa840c13b499f7dc5afd958164b675337d736408e01a9d8cdb4d3
7
- data.tar.gz: 589a6ebdd77a1922a2d130143c5f45bb275528c75189c55d621418e645556a9abf6870bf3552d5c7daa725937786cff3965e589c7104e0128b4a141b27c2e55e
6
+ metadata.gz: 76744117e51c10b3b6dcd17f6d6e82a167cca4633e30753a2d27883a955b4b0388b66f353a65027333411104eea9e3cd56e1d6e6bde24c5d83d75431e1500415
7
+ data.tar.gz: 5c4c47d148e2eaaed21a6986d3662e5087ff5851bf51cc6dcc0dca4736577ffff94d139c3749137dec08a4556554d330d1898531569a7b1976d0723c685cfd50
data/CHANGES.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 1.2.0
2
+
3
+ * Optimized #run for when the version of the gem to diff against is installed locally
4
+
5
+
1
6
  # 1.1.0
2
7
 
3
8
  * Added version option
data/bundle-diff.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'bundle-diff'
3
- s.version = '1.1.0'
3
+ s.version = '1.2.0'
4
4
  s.license = 'GPL-3.0'
5
5
  s.platform = Gem::Platform::RUBY
6
6
  s.authors = ['Tim Craft']
@@ -17,21 +17,34 @@ module Bundler::Diff::CLI
17
17
 
18
18
  error('gem name required') unless gem_name
19
19
 
20
- installed_spec = installed_specs[gem_name]
20
+ bundled_spec = bundled_specs[gem_name]
21
21
 
22
- error('gem spec not found') unless installed_spec
22
+ error('gem spec not found') unless bundled_spec
23
+
24
+ gem_dependency = Gem::Dependency.new(gem_name, options[:version])
25
+
26
+ specs_and_sources, errors = Gem::SpecFetcher.fetcher.spec_for_dependency(gem_dependency)
27
+
28
+ gem_spec, source = specs_and_sources.max_by { |s,| s.version }
29
+
30
+ error('gem spec not found') if gem_spec.nil?
31
+
32
+ installed_spec = Gem::Specification.find { |s| s.name == gem_spec.name && s.version == gem_spec.version }
33
+
34
+ if installed_spec
35
+ Bundler::Diff::Tool.diff(bundled_spec, installed_spec)
36
+
37
+ return
38
+ end
23
39
 
24
40
  Dir.mktmpdir do |tmp_dir|
25
- gem_spec = fetch(gem_name, tmp_dir)
41
+ Dir.chdir(tmp_dir) { source.download(gem_spec) }
26
42
 
27
43
  unpack(gem_spec, tmp_dir)
28
44
 
29
- tool = Bundler::Diff::Tool.new
30
- tool.a_dir = Pathname(installed_spec.gem_dir)
31
- tool.a_output_dir = Pathname(installed_spec.full_name)
32
- tool.b_dir = Pathname(tmp_dir).join(gem_spec.full_name)
33
- tool.b_output_dir = Pathname(gem_spec.full_name)
34
- tool.diff_entries
45
+ def gem_spec.gem_dir; Pathname(tmp_dir).join(gem_spec.full_name); end
46
+
47
+ Bundler::Diff::Tool.diff(bundled_spec, gem_spec)
35
48
  end
36
49
  end
37
50
 
@@ -59,8 +72,8 @@ module Bundler::Diff::CLI
59
72
  end
60
73
  end
61
74
 
62
- def installed_specs
63
- @installed_specs ||= Bundler.load.specs.each_with_object({}) do |spec, hash|
75
+ def bundled_specs
76
+ @bundled_specs ||= Bundler.load.specs.each_with_object({}) do |spec, hash|
64
77
  next if ignore?(spec)
65
78
 
66
79
  hash[spec.name] = spec
@@ -76,20 +89,6 @@ module Bundler::Diff::CLI
76
89
  end
77
90
  end
78
91
 
79
- def fetch(name, target_dir)
80
- dependency = Gem::Dependency.new(name, options[:version])
81
-
82
- specs_and_sources, errors = Gem::SpecFetcher.fetcher.spec_for_dependency(dependency)
83
-
84
- spec, source = specs_and_sources.max_by { |s,| s.version }
85
-
86
- error('gem spec not found') if spec.nil?
87
-
88
- Dir.chdir(target_dir) { source.download(spec) }
89
-
90
- spec
91
- end
92
-
93
92
  def unpack(spec, tmp_dir)
94
93
  gem_file = File.join(tmp_dir, spec.full_name + '.gem')
95
94
 
@@ -9,6 +9,15 @@ class Bundler::Diff::Tool
9
9
  attr_accessor :b_dir
10
10
  attr_accessor :b_output_dir
11
11
 
12
+ def self.diff(a_spec, b_spec)
13
+ tool = new
14
+ tool.a_dir = Pathname(a_spec.gem_dir)
15
+ tool.a_output_dir = Pathname(a_spec.full_name)
16
+ tool.b_dir = Pathname(b_spec.gem_dir)
17
+ tool.b_output_dir = Pathname(b_spec.full_name)
18
+ tool.diff_entries
19
+ end
20
+
12
21
  def diff_entries
13
22
  a_files = file_list(a_dir)
14
23
  b_files = file_list(b_dir)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundle-diff
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Craft
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-22 00:00:00.000000000 Z
11
+ date: 2019-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler