gemlist 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/gemlist.gemspec +0 -2
- data/lib/gemlist.rb +1 -1
- data/lib/gemlist/spec_node.rb +53 -5
- data/lib/gemlist/version.rb +1 -1
- metadata +1 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 264c212ec8ff089324641d17b96c67040d2622ec
|
4
|
+
data.tar.gz: 3f83087f303792f5e5a8f7710b1df7d1e6e8fa4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ddff71153ab79b99ade0c7eb50cddfa95445b262f2eb42725e69c2ca99a5f8bd7e04e2d3330c669e234e5a879a1aca2471a0383daf055167b89e84426fee9d8
|
7
|
+
data.tar.gz: 0dc9761a23143309184bac6047064518ae68133a3633d6793cd55363de2e43d7d5382d5d77636d1efc733761350404e8330212c848d438dd7471c964e3f405c7
|
data/gemlist.gemspec
CHANGED
data/lib/gemlist.rb
CHANGED
data/lib/gemlist/spec_node.rb
CHANGED
@@ -1,11 +1,49 @@
|
|
1
|
-
require 'tree'
|
2
|
-
|
3
1
|
class Gemlist
|
4
|
-
class SpecNode
|
2
|
+
class SpecNode
|
3
|
+
include Enumerable
|
4
|
+
|
5
|
+
attr_reader :name, :content, :children
|
6
|
+
attr_accessor :parent
|
7
|
+
|
8
|
+
def initialize(name, content)
|
9
|
+
@name = name
|
10
|
+
@content = content
|
11
|
+
@children = []
|
12
|
+
@parent = nil
|
13
|
+
end
|
14
|
+
|
15
|
+
def <<(node)
|
16
|
+
@children << node
|
17
|
+
node.parent = self
|
18
|
+
node
|
19
|
+
end
|
20
|
+
|
21
|
+
def each(&block)
|
22
|
+
return to_enum unless block_given?
|
23
|
+
|
24
|
+
unvisited = [self]
|
25
|
+
|
26
|
+
until unvisited.empty?
|
27
|
+
current = unvisited.shift
|
28
|
+
|
29
|
+
if current
|
30
|
+
yield current
|
31
|
+
|
32
|
+
unvisited.unshift(*current.children)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
return self if block_given?
|
37
|
+
end
|
38
|
+
|
5
39
|
def total_dependency_count
|
6
40
|
size - 1
|
7
41
|
end
|
8
42
|
|
43
|
+
def size
|
44
|
+
to_a.size
|
45
|
+
end
|
46
|
+
|
9
47
|
def depth_first_children_first
|
10
48
|
sorted_children = children.sort_by(&:total_dependency_count)
|
11
49
|
parent = self
|
@@ -22,12 +60,22 @@ class Gemlist
|
|
22
60
|
end
|
23
61
|
|
24
62
|
def lineage
|
25
|
-
[self, *parentage].reverse.reject(&:
|
63
|
+
[self, *parentage].reverse.reject(&:root?)
|
26
64
|
end
|
27
65
|
|
28
66
|
def descends_from?(*dependencies)
|
29
|
-
!
|
67
|
+
!root? &&
|
30
68
|
dependencies.map(&:name).include?(lineage.first.name)
|
31
69
|
end
|
70
|
+
|
71
|
+
def parentage
|
72
|
+
return [] if root?
|
73
|
+
|
74
|
+
[parent] + parent.parentage
|
75
|
+
end
|
76
|
+
|
77
|
+
def root?
|
78
|
+
parent.nil?
|
79
|
+
end
|
32
80
|
end
|
33
81
|
end
|
data/lib/gemlist/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gemlist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Hoffman
|
@@ -66,20 +66,6 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rubytree
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 0.9.7
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 0.9.7
|
83
69
|
description: Get a list of gems Bundler would install under various conditions. Built
|
84
70
|
to be used in build tools.
|
85
71
|
email:
|