bundler-stats 1.2.0 → 1.2.1
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/lib/bundler/stats/tree.rb +17 -2
- data/lib/bundler/stats/version.rb +1 -1
- data/spec/lib/bundler/stats/tree_spec.rb +10 -4
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3c6946fc4c79ee76c0201d258b8cc9e79357e9b404361011ec920d647bc40b1b
|
|
4
|
+
data.tar.gz: 2f70cf9458ca731f1582c0c95849a3279ed93aa8ae8af335e22b767479bdca59
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1743d02925583fd087a31a36788a2e2dd26c479944f9cd7062a53a24b93c704e3ee82d6335e50b0a0848ccacdcc78e78914406602d497a064a8bc070825cd2f0
|
|
7
|
+
data.tar.gz: 5a5b1d33d6f26dd6db125619a0b1715bb6d265f4477589e088b79f0e444d2d6c37632b23c3b4aad77b251cf7b5954dbd6692c9a59fd509e0127c0503b943d109
|
data/lib/bundler/stats/tree.rb
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
|
@@ -18,10 +18,13 @@ describe Bundler::Stats::Tree do
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
context "#first_level_dependencies" do
|
|
21
|
-
it "
|
|
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
|
-
|
|
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 "
|
|
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
|
|
62
|
+
expect(tree).to have_received(:warn)
|
|
57
63
|
end
|
|
58
64
|
|
|
59
65
|
it "returns empty array for bottom-level dependencies" do
|