bundler-stats 1.2.0 → 1.2.1

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: 7cd8533d8297a0407a8129eaf08f5a9e7f603e388851b9baff7a85d0e3e6141b
4
- data.tar.gz: ec911653587fbc4ed603a6f7ceb034a6c8bf659b149bd0432d8cf95a3cf5a2d6
3
+ metadata.gz: 3c6946fc4c79ee76c0201d258b8cc9e79357e9b404361011ec920d647bc40b1b
4
+ data.tar.gz: 2f70cf9458ca731f1582c0c95849a3279ed93aa8ae8af335e22b767479bdca59
5
5
  SHA512:
6
- metadata.gz: 0edb13c6c5a1bf249498ea5c06d6edf56b5134835d0ee4b453b71cc97dc2bc16dace85e7313d22c4a15d2634ee885679586ac307df7a29acfa5951642bf8668e
7
- data.tar.gz: 98008d13c6fd82f3e64431e7fdd88ccb7a45e34fe2a9e573345d0ea3aaa54a11da1d9d93c87333a43a360c6e0e66953b6c07386510d02da20b268a6b83bcd6a3
6
+ metadata.gz: 1743d02925583fd087a31a36788a2e2dd26c479944f9cd7062a53a24b93c704e3ee82d6335e50b0a0848ccacdcc78e78914406602d497a064a8bc070825cd2f0
7
+ data.tar.gz: 5a5b1d33d6f26dd6db125619a0b1715bb6d265f4477589e088b79f0e444d2d6c37632b23c3b4aad77b251cf7b5954dbd6692c9a59fd509e0127c0503b943d109
@@ -1,6 +1,10 @@
1
1
  class Bundler::Stats::Tree
2
2
  attr_accessor :tree
3
3
 
4
+ ERR_MESSAGE = "The dependency `%s` wasn't found. It may not be present in " \
5
+ "your Gemfile.lock. This often happens when a dependency isn't " \
6
+ "installed on your platform."
7
+
4
8
  def initialize(parser, skiplist: [])
5
9
  raise ArgumentError unless parser.respond_to?(:specs)
6
10
 
@@ -30,12 +34,19 @@ class Bundler::Stats::Tree
30
34
  end
31
35
 
32
36
  def first_level_dependencies(target)
33
- raise ArgumentError, "Unknown gem #{target}" unless @tree.has_key? target
37
+ unless @tree.has_key? target
38
+ warn(ERR_MESSAGE % [target])
39
+ return []
40
+ end
41
+
34
42
  @tree[target].dependencies
35
43
  end
36
44
 
37
45
  def transitive_dependencies(target)
38
- raise ArgumentError, "Unknown gem #{target}" unless @tree.has_key? target
46
+ unless @tree.has_key? target
47
+ warn(ERR_MESSAGE % [target])
48
+ return []
49
+ end
39
50
 
40
51
  top_level = @tree[target].dependencies
41
52
  all_level = top_level + top_level.inject([]) do |arr, dep|
@@ -78,6 +89,10 @@ class Bundler::Stats::Tree
78
89
 
79
90
  private
80
91
 
92
+ def warn(str)
93
+ STDERR.puts(str)
94
+ end
95
+
81
96
  def specs_as_tree(specs)
82
97
  specs.each_with_object({}) do |spec, hash|
83
98
  hash[spec.name] = spec
@@ -1,6 +1,6 @@
1
1
  module Bundler
2
2
  module Stats
3
3
  # bundler-stats version
4
- VERSION = '1.2.0'
4
+ VERSION = '1.2.1'
5
5
  end
6
6
  end
@@ -18,10 +18,13 @@ describe Bundler::Stats::Tree do
18
18
  end
19
19
 
20
20
  context "#first_level_dependencies" do
21
- it "errors for non-existent dependencies" do
21
+ it "warns you of missing dependencies from other platforms" do
22
22
  tree = subject.new(parser)
23
+ allow(tree).to receive(:warn)
23
24
 
24
- expect { tree.first_level_dependencies("none") }.to raise_error(ArgumentError)
25
+ tree.first_level_dependencies("none")
26
+
27
+ expect(tree).to have_received(:warn)
25
28
  end
26
29
 
27
30
  it "returns empty array for bottom-level dependencies" do
@@ -50,10 +53,13 @@ describe Bundler::Stats::Tree do
50
53
  end
51
54
 
52
55
  context "#transitive_dependencies" do
53
- it "errors for non-existent dependencies" do
56
+ it "warns you of missing dependencies from other platforms" do
54
57
  tree = subject.new(parser)
58
+ allow(tree).to receive(:warn)
59
+
60
+ tree.transitive_dependencies("none")
55
61
 
56
- expect { tree.transitive_dependencies("none") }.to raise_error(ArgumentError)
62
+ expect(tree).to have_received(:warn)
57
63
  end
58
64
 
59
65
  it "returns empty array for bottom-level dependencies" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundler-stats
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph Mastey