kvdag 0.1.3 → 0.1.4

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
  SHA1:
3
- metadata.gz: 9dc47fb88bc0c77952ce8e6f30522c7e7bc584a4
4
- data.tar.gz: 917cb05694be1c5122cf593627d43c709b76edc1
3
+ metadata.gz: 06c11321672d83aaba22773e16dca33815acf1ea
4
+ data.tar.gz: fc8aa8adacf2bdeee1ffd349457acebb49d9a434
5
5
  SHA512:
6
- metadata.gz: 5ca02a82d6c95cf6284198d2a47a77544f824054f95e828f2ffc6eb7b0ca5b359d59564ffad8f19653e96e3007321bd958815aefd3692829bdaeb5b8bb70f70a
7
- data.tar.gz: 3f75cd8ee7498d565fb53e0465b908c0ba056eb577ba8ceebf9a63a2ed44138004445456db92424936ba2f4adb6dcfa1fc9c803415bb9becb478e2c1ba4b9124
6
+ metadata.gz: 42d6fe8ecbdfe931d9c77cc61a0dbc1b7758b9fb4a4556b01efc378121ecbd45f4169db056de5dae1e73509665c9f08eac5b492c3ba3a71a0be1eb9843f402ef
7
+ data.tar.gz: fae41ebe8ae35a475d912883b64a99a777993d351b75ae7e5c90286360e328fe53d88a696d2c7bba2a388ef085a70be845fee5b81b799b36e23566a5743cfd57
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/kvdag/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class KVDAG
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
data/lib/kvdag/vertex.rb CHANGED
@@ -92,27 +92,48 @@ class KVDAG
92
92
  other.reachable?(self)
93
93
  end
94
94
 
95
- # Return the set of this object and all its parents, and their
96
- # parents, recursively
95
+ # :call-seq:
96
+ # vtx.ancestors -> all ancestors
97
+ # vtx.ancestors(filter) -> ancestors matching +filter+
98
+ # vtx.ancestors {|anc| ... } -> call block with each ancestor
97
99
  #
98
- # This is the same as all #reachable? vertices.
100
+ # Return the set of this object and all its parents, and their
101
+ # parents, recursively, possibly filtered by #match?
102
+ # expressions. If a block is given, call it with each ancestor.
99
103
 
104
+ def ancestors(filter={}, &block)
105
+ result = Set.new
106
+ result << self if match?(filter)
100
107
 
101
- def ancestors
102
- result = Set.new([self])
103
- parents.each {|p| result += p.ancestors }
104
- result
108
+ parents.each {|p| result += p.ancestors(filter) }
109
+
110
+ if block_given?
111
+ result.each(&block)
112
+ else
113
+ result
114
+ end
105
115
  end
106
116
 
107
- # Return the set of this object and all its children, and their
108
- # children, recursively
117
+ # :call-seq:
118
+ # vtx.descendants -> all descendants
119
+ # vtx.descendants(filter) -> descendants matching +filter+
120
+ # vtx.descendants {|desc| ... } -> call block with each descendant
109
121
  #
110
- # This is the same as all #reachable_from? vertices.
122
+ # Return the set of this object and all its children, and their
123
+ # children, recursively, possibly filtered by #match?
124
+ # expressions. If a block is given, call it with each descendant.
125
+
126
+ def descendants(filter={}, &block)
127
+ result = Set.new
128
+ result << self if match?(filter)
111
129
 
112
- def descendants
113
- result = Set.new([self])
114
- children.each {|c| result += c.descendants }
115
- result
130
+ children.each {|c| result += c.descendants(filter) }
131
+
132
+ if block_given?
133
+ result.each(&block)
134
+ else
135
+ result
136
+ end
116
137
  end
117
138
 
118
139
  # Comparable ordering for a DAG:
data.tar.gz.sig CHANGED
@@ -1,2 +1,2 @@
1
- r C���0�(�'���=,@���J
2
- [C�ve��R��Y"���.!�S���9�)�F
1
+ #��hb^���<�'G�����!�A���*�+��q��QQӉ��dxX��fu��>���z��a(IGLg%x�+����Vq��U��ӊ��
2
+ 6���zP��0n{��i@���yP~���}�R-���)���̟_clc鑩�4��Q,�Є���|0)F��*�uGҐ�Gg8��a�ȵ��Ŗ� x�l��I����9��K����)����0?�� ����ñ�+��xT���9�Q��{9�Đ3ԛt�˙��wD
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kvdag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Calle Englund
@@ -31,7 +31,7 @@ cert_chain:
31
31
  f8wtQllq82VF0AXUYeLtTh1f+DW3WW5BO1e2OCu5eOV7dbyaVPaNK/+rHjCN8kM/
32
32
  DGZSwUoNADmVkQ==
33
33
  -----END CERTIFICATE-----
34
- date: 2016-11-02 00:00:00.000000000 Z
34
+ date: 2016-11-18 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: activesupport
metadata.gz.sig CHANGED
Binary file