traversal 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/traversal/description.rb +6 -6
- data/lib/traversal/iterator.rb +4 -4
- data/lib/traversal/version.rb +1 -1
- metadata +38 -59
@@ -156,22 +156,22 @@ module Traversal
|
|
156
156
|
(type == :after ? @stop_after : @stop_before).any? { |cond| cond[node] }
|
157
157
|
end
|
158
158
|
|
159
|
-
def
|
159
|
+
def include_node?(node) #:nodoc:
|
160
160
|
@include_only.all? { |cond| cond[node] } &&
|
161
161
|
@exclude.none? { |cond| cond[node] }
|
162
162
|
end
|
163
163
|
|
164
|
-
def
|
165
|
-
!
|
164
|
+
def exclude_node?(node) #:nodoc:
|
165
|
+
!include_node?(node)
|
166
166
|
end
|
167
167
|
|
168
|
-
def
|
168
|
+
def expand_node?(node) #:nodoc:
|
169
169
|
@expand_only.all? { |cond| cond[node] } &&
|
170
170
|
@prune.none? { |cond| cond[node] }
|
171
171
|
end
|
172
172
|
|
173
|
-
def
|
174
|
-
!
|
173
|
+
def prune_node?(node) #:nodoc:
|
174
|
+
!expand_node?(node)
|
175
175
|
end
|
176
176
|
|
177
177
|
def breadth_first? #:nodoc:
|
data/lib/traversal/iterator.rb
CHANGED
@@ -31,7 +31,7 @@ module Traversal
|
|
31
31
|
begin
|
32
32
|
yield_node(start_node)
|
33
33
|
|
34
|
-
expand_node(start_node) if @description.
|
34
|
+
expand_node(start_node) if @description.expand_node?(start_node)
|
35
35
|
rescue StopIteration
|
36
36
|
# ignore
|
37
37
|
end
|
@@ -55,7 +55,7 @@ module Traversal
|
|
55
55
|
raise StopIteration if @description.stop?(node, :before)
|
56
56
|
|
57
57
|
# do yield
|
58
|
-
push(node) unless @description.
|
58
|
+
push(node) unless @description.exclude_node?(node) || visited?(node)
|
59
59
|
|
60
60
|
# check stop post-condition
|
61
61
|
raise StopIteration if @description.stop?(node, :after)
|
@@ -75,7 +75,7 @@ module Traversal
|
|
75
75
|
relations_for(node).each do |rel|
|
76
76
|
yield_node(rel)
|
77
77
|
|
78
|
-
expand_node(rel) unless @description.
|
78
|
+
expand_node(rel) unless @description.prune_node?(rel)
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
@@ -88,7 +88,7 @@ module Traversal
|
|
88
88
|
yield_node(rel)
|
89
89
|
|
90
90
|
# memoize relation for next iteration
|
91
|
-
cached_relations << rel unless @description.
|
91
|
+
cached_relations << rel unless @description.prune_node?(rel)
|
92
92
|
end
|
93
93
|
|
94
94
|
# 2. dig deeper
|
data/lib/traversal/version.rb
CHANGED
metadata
CHANGED
@@ -1,94 +1,73 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: traversal
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
version: 0.0.2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Alexey Mikhaylov
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-01-26 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: rspec
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &19851520 !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
- 0
|
30
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
31
22
|
type: :development
|
32
|
-
version_requirements: *id001
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: simplecov
|
35
23
|
prerelease: false
|
36
|
-
|
24
|
+
version_requirements: *19851520
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: simplecov
|
27
|
+
requirement: &19846880 !ruby/object:Gem::Requirement
|
37
28
|
none: false
|
38
|
-
requirements:
|
39
|
-
- -
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
|
42
|
-
- 0
|
43
|
-
version: "0"
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
44
33
|
type: :development
|
45
|
-
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *19846880
|
46
36
|
description:
|
47
|
-
email:
|
37
|
+
email:
|
48
38
|
- amikhailov83@gmail.com
|
49
39
|
executables: []
|
50
|
-
|
51
40
|
extensions: []
|
52
|
-
|
53
41
|
extra_rdoc_files: []
|
54
|
-
|
55
|
-
files:
|
42
|
+
files:
|
56
43
|
- lib/traversal.rb
|
57
44
|
- lib/traversal/acts_as_traversable.rb
|
58
45
|
- lib/traversal/description.rb
|
59
46
|
- lib/traversal/iterator.rb
|
60
47
|
- lib/traversal/version.rb
|
61
|
-
has_rdoc: true
|
62
48
|
homepage: https://github.com/take-five/traversal
|
63
49
|
licenses: []
|
64
|
-
|
65
50
|
post_install_message:
|
66
51
|
rdoc_options: []
|
67
|
-
|
68
|
-
require_paths:
|
52
|
+
require_paths:
|
69
53
|
- lib
|
70
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
55
|
none: false
|
72
|
-
requirements:
|
73
|
-
- -
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
|
76
|
-
|
77
|
-
version: "0"
|
78
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
61
|
none: false
|
80
|
-
requirements:
|
81
|
-
- -
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
|
84
|
-
- 0
|
85
|
-
version: "0"
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
86
66
|
requirements: []
|
87
|
-
|
88
67
|
rubyforge_project: traversal
|
89
|
-
rubygems_version: 1.
|
68
|
+
rubygems_version: 1.8.10
|
90
69
|
signing_key:
|
91
70
|
specification_version: 3
|
92
71
|
summary: Simple traversal API for pure Ruby objects
|
93
72
|
test_files: []
|
94
|
-
|
73
|
+
has_rdoc:
|