kvdag 0.1.4 → 0.1.5
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/.rubocop.yml +8 -0
- data/.rubocop_todo.yml +203 -0
- data/README.md +9 -0
- data/Rakefile +10 -3
- data/bin/console +3 -3
- data/kvdag.gemspec +10 -9
- data/lib/kvdag.rb +4 -4
- data/lib/kvdag/attrnode.rb +2 -3
- data/lib/kvdag/edge.rb +1 -2
- data/lib/kvdag/error.rb +0 -1
- data/lib/kvdag/keypathhash.rb +3 -3
- data/lib/kvdag/version.rb +1 -1
- data/lib/kvdag/vertex.rb +15 -17
- metadata +33 -40
- checksums.yaml.gz.sig +0 -1
- data.tar.gz.sig +0 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e211325e63cd6a495f0ee4eaef9bd24a8bfd4d37
|
|
4
|
+
data.tar.gz: bb7e42fab3cce3fbe13dc402b679c27c8fc20ac7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b4a184b405d977c183e13fcd194b11a90bcecf93e8d4545d137e6a978bfe610c9be3b3d255440480ca8887adc7492c74aafb33fa9422d90c5bd857226dd24d74
|
|
7
|
+
data.tar.gz: 5542014b6e65c4a78afc590a221ee49d5526fe45d813bff3e684e82d7753dd7a983544d510cf062b480b5dbb04f1b838fc3a452671198f03f8022511d93caada
|
data/.rubocop.yml
ADDED
data/.rubocop_todo.yml
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
# This configuration was generated by
|
|
2
|
+
# `rubocop --auto-gen-config`
|
|
3
|
+
# on 2017-01-30 10:17:26 +0100 using RuboCop version 0.47.1.
|
|
4
|
+
# The point is for the user to remove these configuration records
|
|
5
|
+
# one by one as the offenses are removed from the code base.
|
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
|
8
|
+
|
|
9
|
+
# Offense count: 1
|
|
10
|
+
# Cop supports --auto-correct.
|
|
11
|
+
# Configuration parameters: EnforcedStyleAlignWith, SupportedStylesAlignWith.
|
|
12
|
+
# SupportedStylesAlignWith: either, start_of_block, start_of_line
|
|
13
|
+
Lint/BlockAlignment:
|
|
14
|
+
Exclude:
|
|
15
|
+
- 'lib/kvdag/vertex.rb'
|
|
16
|
+
|
|
17
|
+
# Offense count: 1
|
|
18
|
+
Lint/ShadowingOuterLocalVariable:
|
|
19
|
+
Exclude:
|
|
20
|
+
- 'lib/kvdag/keypathhash.rb'
|
|
21
|
+
|
|
22
|
+
# Offense count: 1
|
|
23
|
+
Lint/UselessSetterCall:
|
|
24
|
+
Exclude:
|
|
25
|
+
- 'lib/kvdag/keypathhash.rb'
|
|
26
|
+
|
|
27
|
+
# Offense count: 7
|
|
28
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
|
29
|
+
Metrics/BlockLength:
|
|
30
|
+
Max: 137
|
|
31
|
+
|
|
32
|
+
# Offense count: 1
|
|
33
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
|
34
|
+
# URISchemes: http, https
|
|
35
|
+
Metrics/LineLength:
|
|
36
|
+
Max: 86
|
|
37
|
+
|
|
38
|
+
# Offense count: 1
|
|
39
|
+
# Configuration parameters: CountComments.
|
|
40
|
+
Metrics/MethodLength:
|
|
41
|
+
Max: 12
|
|
42
|
+
|
|
43
|
+
# Offense count: 3
|
|
44
|
+
# Cop supports --auto-correct.
|
|
45
|
+
# Configuration parameters: MaxKeyValuePairs.
|
|
46
|
+
Performance/RedundantMerge:
|
|
47
|
+
Exclude:
|
|
48
|
+
- 'spec/attrnode_examples.rb'
|
|
49
|
+
|
|
50
|
+
# Offense count: 4
|
|
51
|
+
# Cop supports --auto-correct.
|
|
52
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods.
|
|
53
|
+
# SupportedStyles: line_count_based, semantic, braces_for_chaining
|
|
54
|
+
# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
|
|
55
|
+
# FunctionalMethods: let, let!, subject, watch
|
|
56
|
+
# IgnoredMethods: lambda, proc, it
|
|
57
|
+
Style/BlockDelimiters:
|
|
58
|
+
Exclude:
|
|
59
|
+
- 'lib/kvdag/vertex.rb'
|
|
60
|
+
- 'spec/kvdag_spec.rb'
|
|
61
|
+
|
|
62
|
+
# Offense count: 2
|
|
63
|
+
Style/CaseEquality:
|
|
64
|
+
Exclude:
|
|
65
|
+
- 'lib/kvdag/attrnode.rb'
|
|
66
|
+
|
|
67
|
+
# Offense count: 6
|
|
68
|
+
Style/Documentation:
|
|
69
|
+
Exclude:
|
|
70
|
+
- 'spec/**/*'
|
|
71
|
+
- 'test/**/*'
|
|
72
|
+
- 'lib/kvdag.rb'
|
|
73
|
+
- 'lib/kvdag/attrnode.rb'
|
|
74
|
+
- 'lib/kvdag/edge.rb'
|
|
75
|
+
- 'lib/kvdag/keypathhash.rb'
|
|
76
|
+
- 'lib/kvdag/vertex.rb'
|
|
77
|
+
|
|
78
|
+
# Offense count: 1
|
|
79
|
+
# Cop supports --auto-correct.
|
|
80
|
+
Style/EmptyCaseCondition:
|
|
81
|
+
Exclude:
|
|
82
|
+
- 'lib/kvdag/attrnode.rb'
|
|
83
|
+
|
|
84
|
+
# Offense count: 1
|
|
85
|
+
# Cop supports --auto-correct.
|
|
86
|
+
Style/EmptyLiteral:
|
|
87
|
+
Exclude:
|
|
88
|
+
- 'lib/kvdag/keypathhash.rb'
|
|
89
|
+
|
|
90
|
+
# Offense count: 2
|
|
91
|
+
# Cop supports --auto-correct.
|
|
92
|
+
# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
|
|
93
|
+
Layout/ExtraSpacing:
|
|
94
|
+
Exclude:
|
|
95
|
+
- 'kvdag.gemspec'
|
|
96
|
+
|
|
97
|
+
# Offense count: 2
|
|
98
|
+
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
|
|
99
|
+
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
|
|
100
|
+
Style/FileName:
|
|
101
|
+
Exclude:
|
|
102
|
+
- 'spec/kvdag-edge_spec.rb'
|
|
103
|
+
- 'spec/kvdag-vertex_spec.rb'
|
|
104
|
+
|
|
105
|
+
# Offense count: 3
|
|
106
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
|
107
|
+
# SupportedStyles: format, sprintf, percent
|
|
108
|
+
Style/FormatString:
|
|
109
|
+
Exclude:
|
|
110
|
+
- 'lib/kvdag.rb'
|
|
111
|
+
- 'lib/kvdag/edge.rb'
|
|
112
|
+
- 'lib/kvdag/vertex.rb'
|
|
113
|
+
|
|
114
|
+
# Offense count: 1
|
|
115
|
+
# Configuration parameters: MinBodyLength.
|
|
116
|
+
Style/GuardClause:
|
|
117
|
+
Exclude:
|
|
118
|
+
- 'lib/kvdag/attrnode.rb'
|
|
119
|
+
|
|
120
|
+
# Offense count: 1
|
|
121
|
+
# Cop supports --auto-correct.
|
|
122
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
|
|
123
|
+
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
|
|
124
|
+
Style/HashSyntax:
|
|
125
|
+
Exclude:
|
|
126
|
+
- 'Rakefile'
|
|
127
|
+
|
|
128
|
+
# Offense count: 1
|
|
129
|
+
Style/IfInsideElse:
|
|
130
|
+
Exclude:
|
|
131
|
+
- 'lib/kvdag/keypathhash.rb'
|
|
132
|
+
|
|
133
|
+
# Offense count: 4
|
|
134
|
+
# Cop supports --auto-correct.
|
|
135
|
+
Layout/LeadingCommentSpace:
|
|
136
|
+
Exclude:
|
|
137
|
+
- 'spec/kvdag-vertex_spec.rb'
|
|
138
|
+
|
|
139
|
+
# Offense count: 1
|
|
140
|
+
Style/MultilineBlockChain:
|
|
141
|
+
Exclude:
|
|
142
|
+
- 'lib/kvdag/vertex.rb'
|
|
143
|
+
|
|
144
|
+
# Offense count: 4
|
|
145
|
+
# Cop supports --auto-correct.
|
|
146
|
+
Style/MultilineIfThen:
|
|
147
|
+
Exclude:
|
|
148
|
+
- 'lib/kvdag/attrnode.rb'
|
|
149
|
+
- 'lib/kvdag/keypathhash.rb'
|
|
150
|
+
|
|
151
|
+
# Offense count: 1
|
|
152
|
+
# Cop supports --auto-correct.
|
|
153
|
+
Style/MutableConstant:
|
|
154
|
+
Exclude:
|
|
155
|
+
- 'lib/kvdag/version.rb'
|
|
156
|
+
|
|
157
|
+
# Offense count: 1
|
|
158
|
+
# Cop supports --auto-correct.
|
|
159
|
+
Style/NegatedIf:
|
|
160
|
+
Exclude:
|
|
161
|
+
- 'lib/kvdag/keypathhash.rb'
|
|
162
|
+
|
|
163
|
+
# Offense count: 10
|
|
164
|
+
# Cop supports --auto-correct.
|
|
165
|
+
Style/NestedParenthesizedCalls:
|
|
166
|
+
Exclude:
|
|
167
|
+
- 'spec/kvdag-vertex_spec.rb'
|
|
168
|
+
|
|
169
|
+
# Offense count: 1
|
|
170
|
+
# Cop supports --auto-correct.
|
|
171
|
+
Style/Not:
|
|
172
|
+
Exclude:
|
|
173
|
+
- 'lib/kvdag/keypathhash.rb'
|
|
174
|
+
|
|
175
|
+
# Offense count: 6
|
|
176
|
+
# Cop supports --auto-correct.
|
|
177
|
+
# Configuration parameters: SupportedStyles.
|
|
178
|
+
# SupportedStyles: compact, exploded
|
|
179
|
+
Style/RaiseArgs:
|
|
180
|
+
EnforcedStyle: compact
|
|
181
|
+
|
|
182
|
+
# Offense count: 1
|
|
183
|
+
# Cop supports --auto-correct.
|
|
184
|
+
# Configuration parameters: AllowMultipleReturnValues.
|
|
185
|
+
Style/RedundantReturn:
|
|
186
|
+
Exclude:
|
|
187
|
+
- 'lib/kvdag/vertex.rb'
|
|
188
|
+
|
|
189
|
+
# Offense count: 6
|
|
190
|
+
# Cop supports --auto-correct.
|
|
191
|
+
Style/RedundantSelf:
|
|
192
|
+
Exclude:
|
|
193
|
+
- 'lib/kvdag.rb'
|
|
194
|
+
- 'lib/kvdag/attrnode.rb'
|
|
195
|
+
- 'lib/kvdag/keypathhash.rb'
|
|
196
|
+
|
|
197
|
+
# Offense count: 1
|
|
198
|
+
# Cop supports --auto-correct.
|
|
199
|
+
# Configuration parameters: IgnoredMethods.
|
|
200
|
+
# IgnoredMethods: respond_to, define_method
|
|
201
|
+
Style/SymbolProc:
|
|
202
|
+
Exclude:
|
|
203
|
+
- 'lib/kvdag/vertex.rb'
|
data/README.md
CHANGED
|
@@ -75,3 +75,12 @@ follow these guidelines to make the experience as smooth as possible:
|
|
|
75
75
|
in the first line, then paragraphs of explanatory text, line
|
|
76
76
|
wrapped.
|
|
77
77
|
|
|
78
|
+
- Test your code.
|
|
79
|
+
|
|
80
|
+
- Code shall pass [Rubocop](https://github.com/bbatsov/rubocop) tests. See [.rubocop.yml](.rubocop.yml) for configured options. Rubocop is automaticallly run with the default Rake task.
|
|
81
|
+
|
|
82
|
+
- Tests shall be written in [RSpec](http://rspec.info/).
|
|
83
|
+
|
|
84
|
+
- Library code shall have unit tests.
|
|
85
|
+
|
|
86
|
+
- Tools shall have integration and end-to-end tests.
|
data/Rakefile
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
1
|
+
require 'bundler/gem_tasks'
|
|
2
|
+
require 'rspec/core/rake_task'
|
|
3
3
|
|
|
4
4
|
RSpec::Core::RakeTask.new(:spec)
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
desc 'Run Rubocop'
|
|
7
|
+
require 'rubocop'
|
|
8
|
+
require 'rubocop/rake_task'
|
|
9
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
|
10
|
+
task.options += ['--display-cop-names']
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
task :default => [:rubocop, :spec]
|
data/bin/console
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
require 'kvdag'
|
|
5
5
|
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
|
@@ -10,5 +10,5 @@ require "kvdag"
|
|
|
10
10
|
# require "pry"
|
|
11
11
|
# Pry.start
|
|
12
12
|
|
|
13
|
-
require
|
|
13
|
+
require 'irb'
|
|
14
14
|
IRB.start
|
data/kvdag.gemspec
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
#-*- ruby -*-
|
|
2
2
|
# coding: utf-8
|
|
3
|
+
|
|
3
4
|
lib = File.expand_path('../lib', __FILE__)
|
|
4
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
6
|
require 'kvdag/version'
|
|
6
7
|
|
|
7
8
|
Gem::Specification.new do |spec|
|
|
8
9
|
spec.name = 'kvdag'
|
|
9
|
-
spec.version
|
|
10
|
+
spec.version = KVDAG::VERSION
|
|
10
11
|
spec.summary = 'Directed Acyclic Graph for Key-Value searches'
|
|
11
12
|
spec.description = spec.summary
|
|
12
13
|
spec.homepage = 'https://github.com/saab-simc-admin/keyvaluedag'
|
|
@@ -16,20 +17,20 @@ Gem::Specification.new do |spec|
|
|
|
16
17
|
|
|
17
18
|
spec.has_rdoc = true
|
|
18
19
|
|
|
19
|
-
spec.files
|
|
20
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
20
21
|
f.match(%r{^(test|spec|features)/})
|
|
21
22
|
end
|
|
22
|
-
spec.bindir =
|
|
23
|
+
spec.bindir = 'exe'
|
|
23
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
24
|
-
spec.require_paths = [
|
|
25
|
+
spec.require_paths = ['lib']
|
|
25
26
|
|
|
26
27
|
spec.platform = Gem::Platform::RUBY
|
|
27
28
|
spec.required_ruby_version = '~>2'
|
|
28
29
|
spec.add_runtime_dependency 'activesupport', '~>4'
|
|
29
30
|
|
|
30
|
-
spec.add_development_dependency
|
|
31
|
-
spec.add_development_dependency
|
|
32
|
-
spec.add_development_dependency
|
|
33
|
-
spec.add_development_dependency
|
|
34
|
-
|
|
31
|
+
spec.add_development_dependency 'bundler', '~> 1.13'
|
|
32
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
|
33
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
|
34
|
+
spec.add_development_dependency 'rspec-collection_matchers', '~> 1.1.2'
|
|
35
|
+
spec.add_development_dependency 'rubocop', '~> 0.49'
|
|
35
36
|
end
|
data/lib/kvdag.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require 'active_support'
|
|
2
|
-
require
|
|
2
|
+
require 'kvdag/version'
|
|
3
3
|
require 'kvdag/error'
|
|
4
4
|
require 'kvdag/attrnode'
|
|
5
5
|
require 'kvdag/vertex'
|
|
@@ -33,7 +33,7 @@ class KVDAG
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def inspect
|
|
36
|
-
|
|
36
|
+
'#<%s:%x(%d vertices, %d edges)>' % [self.class, self.object_id,
|
|
37
37
|
vertices.length, edges.length]
|
|
38
38
|
end
|
|
39
39
|
|
|
@@ -50,13 +50,13 @@ class KVDAG
|
|
|
50
50
|
def vertices(filter = {})
|
|
51
51
|
return @vertices if filter.empty?
|
|
52
52
|
|
|
53
|
-
Set.new(@vertices.select{|vertex| vertex.match?(filter) })
|
|
53
|
+
Set.new(@vertices.select { |vertex| vertex.match?(filter) })
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
# Return the set of all edges
|
|
57
57
|
|
|
58
58
|
def edges
|
|
59
|
-
@vertices.reduce(Set.new) {|edges,vertex| edges + vertex.edges}
|
|
59
|
+
@vertices.reduce(Set.new) { |edges, vertex| edges + vertex.edges }
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
# Enumerate all vertices in the DAG, possibly filtered
|
data/lib/kvdag/attrnode.rb
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
class KVDAG
|
|
2
|
-
|
|
3
2
|
# Mixin with common methods for managing the +attrs+ of
|
|
4
3
|
# vertices and edges in a KVDAG.
|
|
5
4
|
|
|
@@ -67,7 +66,7 @@ class KVDAG
|
|
|
67
66
|
if self.respond_to?(:to_hash_proxy) then
|
|
68
67
|
to_hash_proxy.filter(*keys)
|
|
69
68
|
else
|
|
70
|
-
raise NotImplementedError.new(
|
|
69
|
+
raise NotImplementedError.new('not implemented for plain hash')
|
|
71
70
|
end
|
|
72
71
|
end
|
|
73
72
|
|
|
@@ -97,7 +96,7 @@ class KVDAG
|
|
|
97
96
|
# node.match?(any?:{'key1' => 'this', 'key2' => 'that'})
|
|
98
97
|
# node.match?(one?:{'key1' => 'this', 'key2' => 'that'})
|
|
99
98
|
|
|
100
|
-
def match?(filter={})
|
|
99
|
+
def match?(filter = {})
|
|
101
100
|
valid_enumerators = [:none?, :one?, :any?, :all?]
|
|
102
101
|
|
|
103
102
|
filter.all? do |item|
|
data/lib/kvdag/edge.rb
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
class KVDAG
|
|
2
|
-
|
|
3
2
|
# An edge to a vertex in a KVDAG
|
|
4
3
|
|
|
5
4
|
class Edge
|
|
@@ -22,7 +21,7 @@ class KVDAG
|
|
|
22
21
|
end
|
|
23
22
|
|
|
24
23
|
def inspect
|
|
25
|
-
|
|
24
|
+
'#<%s @attr=%s @to_vertex=%s>' % [self.class, @attrs.to_hash, @to_vertex]
|
|
26
25
|
end
|
|
27
26
|
|
|
28
27
|
alias to_s inspect
|
data/lib/kvdag/error.rb
CHANGED
data/lib/kvdag/keypathhash.rb
CHANGED
|
@@ -6,14 +6,14 @@ class KVDAG
|
|
|
6
6
|
class KeyPath < Array
|
|
7
7
|
private :initialize
|
|
8
8
|
def initialize(keypath)
|
|
9
|
-
keypath = keypath.split(
|
|
9
|
+
keypath = keypath.split('.') if keypath.is_a?(String)
|
|
10
10
|
super
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
private :initialize
|
|
15
15
|
def initialize(hash = {})
|
|
16
|
-
raise TypeError.new(
|
|
16
|
+
raise TypeError.new('Must be initialized with a `hash`') unless hash.is_a?(Hash)
|
|
17
17
|
@hash = hash.deep_stringify_keys
|
|
18
18
|
super(@hash)
|
|
19
19
|
end
|
|
@@ -41,7 +41,7 @@ class KVDAG
|
|
|
41
41
|
*keysubpath, key = KeyPath.new(keypath)
|
|
42
42
|
hash = @hash
|
|
43
43
|
|
|
44
|
-
keysubpath.each {|key| hash = hash.fetch(key)}
|
|
44
|
+
keysubpath.each { |key| hash = hash.fetch(key) }
|
|
45
45
|
hash.fetch(key)
|
|
46
46
|
rescue KeyError
|
|
47
47
|
raise KeyError.new("keypath not found: #{keypath.inspect}")
|
data/lib/kvdag/version.rb
CHANGED
data/lib/kvdag/vertex.rb
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
class KVDAG
|
|
2
|
-
|
|
3
2
|
# A vertex in a KVDAG
|
|
4
3
|
|
|
5
4
|
class Vertex
|
|
@@ -25,7 +24,7 @@ class KVDAG
|
|
|
25
24
|
end
|
|
26
25
|
|
|
27
26
|
def inspect
|
|
28
|
-
|
|
27
|
+
'#<%s @attr=%s @edges=%s>' % [self.class, @attrs.to_hash, @edges.to_a]
|
|
29
28
|
end
|
|
30
29
|
|
|
31
30
|
alias to_s inspect
|
|
@@ -38,10 +37,10 @@ class KVDAG
|
|
|
38
37
|
# Returns the set of all direct parents, possibly filtered by #match?
|
|
39
38
|
# expressions. If a block is given, call it with each parent.
|
|
40
39
|
|
|
41
|
-
def parents(filter={}, &block)
|
|
42
|
-
result = Set.new(edges.map {|edge|
|
|
40
|
+
def parents(filter = {}, &block)
|
|
41
|
+
result = Set.new(edges.map { |edge|
|
|
43
42
|
edge.to_vertex
|
|
44
|
-
}.select {|parent|
|
|
43
|
+
}.select { |parent|
|
|
45
44
|
parent.match?(filter)
|
|
46
45
|
})
|
|
47
46
|
|
|
@@ -60,8 +59,8 @@ class KVDAG
|
|
|
60
59
|
# Returns the set of all direct children, possibly filtered by #match?
|
|
61
60
|
# expressions. If a block is given, call it with each child.
|
|
62
61
|
|
|
63
|
-
def children(filter={}, &block)
|
|
64
|
-
result = @child_cache.select {|child|
|
|
62
|
+
def children(filter = {}, &block)
|
|
63
|
+
result = @child_cache.select { |child|
|
|
65
64
|
child.match?(filter)
|
|
66
65
|
}
|
|
67
66
|
|
|
@@ -78,9 +77,9 @@ class KVDAG
|
|
|
78
77
|
# to different KVDAG.
|
|
79
78
|
|
|
80
79
|
def reachable?(other)
|
|
81
|
-
raise VertexError.new(
|
|
80
|
+
raise VertexError.new('Not in the same DAG') unless @dag.equal?(other.dag)
|
|
82
81
|
|
|
83
|
-
equal?(other) || parents.any? {|parent| parent.reachable?(other)}
|
|
82
|
+
equal?(other) || parents.any? { |parent| parent.reachable?(other) }
|
|
84
83
|
end
|
|
85
84
|
|
|
86
85
|
# Am I reachable from +other+ via any of its #edges?
|
|
@@ -101,11 +100,11 @@ class KVDAG
|
|
|
101
100
|
# parents, recursively, possibly filtered by #match?
|
|
102
101
|
# expressions. If a block is given, call it with each ancestor.
|
|
103
102
|
|
|
104
|
-
def ancestors(filter={}, &block)
|
|
103
|
+
def ancestors(filter = {}, &block)
|
|
105
104
|
result = Set.new
|
|
106
105
|
result << self if match?(filter)
|
|
107
106
|
|
|
108
|
-
parents.each {|p| result += p.ancestors(filter) }
|
|
107
|
+
parents.each { |p| result += p.ancestors(filter) }
|
|
109
108
|
|
|
110
109
|
if block_given?
|
|
111
110
|
result.each(&block)
|
|
@@ -123,11 +122,11 @@ class KVDAG
|
|
|
123
122
|
# children, recursively, possibly filtered by #match?
|
|
124
123
|
# expressions. If a block is given, call it with each descendant.
|
|
125
124
|
|
|
126
|
-
def descendants(filter={}, &block)
|
|
125
|
+
def descendants(filter = {}, &block)
|
|
127
126
|
result = Set.new
|
|
128
127
|
result << self if match?(filter)
|
|
129
128
|
|
|
130
|
-
children.each {|c| result += c.descendants(filter) }
|
|
129
|
+
children.each { |c| result += c.descendants(filter) }
|
|
131
130
|
|
|
132
131
|
if block_given?
|
|
133
132
|
result.each(&block)
|
|
@@ -158,8 +157,8 @@ class KVDAG
|
|
|
158
157
|
|
|
159
158
|
def edge(other, attrs = {})
|
|
160
159
|
other = other.to_vertex unless other.is_a?(Vertex)
|
|
161
|
-
raise VertexError.new(
|
|
162
|
-
raise CyclicError.new(
|
|
160
|
+
raise VertexError.new('Not in the same DAG') if @dag != other.dag
|
|
161
|
+
raise CyclicError.new('Would become cyclic') if other.reachable?(self)
|
|
163
162
|
|
|
164
163
|
edge = Edge.new(@dag, other, attrs)
|
|
165
164
|
@edges << edge
|
|
@@ -181,7 +180,7 @@ class KVDAG
|
|
|
181
180
|
result.merge!(@attrs)
|
|
182
181
|
end
|
|
183
182
|
|
|
184
|
-
|
|
183
|
+
protected
|
|
185
184
|
|
|
186
185
|
# Cache the fact that the +other+ vertex has created an edge to
|
|
187
186
|
# us.
|
|
@@ -192,6 +191,5 @@ class KVDAG
|
|
|
192
191
|
def add_child(other)
|
|
193
192
|
@child_cache << other
|
|
194
193
|
end
|
|
195
|
-
|
|
196
194
|
end
|
|
197
195
|
end
|
metadata
CHANGED
|
@@ -1,108 +1,99 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kvdag
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Calle Englund
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
|
-
cert_chain:
|
|
11
|
-
-
|
|
12
|
-
-----BEGIN CERTIFICATE-----
|
|
13
|
-
MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRYwFAYDVQQDDA1jYWxs
|
|
14
|
-
ZS5lbmdsdW5kMRkwFwYKCZImiZPyLGQBGRYJc2FhYmdyb3VwMRMwEQYKCZImiZPy
|
|
15
|
-
LGQBGRYDY29tMB4XDTE2MTEwMjA5MjYyN1oXDTE3MTEwMjA5MjYyN1owSDEWMBQG
|
|
16
|
-
A1UEAwwNY2FsbGUuZW5nbHVuZDEZMBcGCgmSJomT8ixkARkWCXNhYWJncm91cDET
|
|
17
|
-
MBEGCgmSJomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
|
|
18
|
-
ggEBAM7OxaztzD0LyOwK1mPcg3BhioX1EDVbD/qAFOAzBSGGlAhtmHMqAkyvJMvs
|
|
19
|
-
iiG7xvBidWUapxiEiBwamXiOTSrp2eW+XSXW9omdWHXjBZcwHqwb1VmAlYRDkSHf
|
|
20
|
-
dzcM/z4xlV+DJw/pFyMRWzqNdVBtWTbVXAFGjJSqQ6q21ACYJldV9U71AIpXo+oF
|
|
21
|
-
VEMf6PZS2uhB1G+FgAtnX/xmy7OM1Cy3qc/CaJbWSddpegxWJMUn2HNQxFwIe40g
|
|
22
|
-
WoEoiFA7qQg9DnR/5i3lW6QyfIaA5k9cv2su1VyjqKLbkFTTTjYw0P1BJmvfXjtc
|
|
23
|
-
rMl+3HCWYj6UunZwfZi2wDGsBkkCAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
|
|
24
|
-
DwQEAwIEsDAdBgNVHQ4EFgQUwHCMEKgrIMaiTkTVLKZn6yOD1SIwJgYDVR0RBB8w
|
|
25
|
-
HYEbY2FsbGUuZW5nbHVuZEBzYWFiZ3JvdXAuY29tMCYGA1UdEgQfMB2BG2NhbGxl
|
|
26
|
-
LmVuZ2x1bmRAc2FhYmdyb3VwLmNvbTANBgkqhkiG9w0BAQUFAAOCAQEAP9OnE0jP
|
|
27
|
-
2vRHI/vnOkgCvLFNoOqK/YB4yDVVW69Pza+xIXcmUBvl7DQ+bBdF5AK0B1A7U0rp
|
|
28
|
-
Pbdj0bpQtWxmUmMIbnE1w6iuVCXAabsyUfHY4mlztToWXMVOXc1SPlJ/S2XXaRd5
|
|
29
|
-
fiNj/nBTb0YTQA0E4pZ0Aud80qZ2WLdc6FfzHUEMW91BL3bhLeDL40noHK5Lvk52
|
|
30
|
-
phzVHIrDjCowUMTnGiPZCXEo4KZW76KwYYV6oQ6LzcrYBw5mJ4XpdgQKZgnTnRBP
|
|
31
|
-
f8wtQllq82VF0AXUYeLtTh1f+DW3WW5BO1e2OCu5eOV7dbyaVPaNK/+rHjCN8kM/
|
|
32
|
-
DGZSwUoNADmVkQ==
|
|
33
|
-
-----END CERTIFICATE-----
|
|
34
|
-
date: 2016-11-18 00:00:00.000000000 Z
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2017-09-08 00:00:00.000000000 Z
|
|
35
12
|
dependencies:
|
|
36
13
|
- !ruby/object:Gem::Dependency
|
|
37
14
|
name: activesupport
|
|
38
15
|
requirement: !ruby/object:Gem::Requirement
|
|
39
16
|
requirements:
|
|
40
|
-
- - ~>
|
|
17
|
+
- - "~>"
|
|
41
18
|
- !ruby/object:Gem::Version
|
|
42
19
|
version: '4'
|
|
43
20
|
type: :runtime
|
|
44
21
|
prerelease: false
|
|
45
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
46
23
|
requirements:
|
|
47
|
-
- - ~>
|
|
24
|
+
- - "~>"
|
|
48
25
|
- !ruby/object:Gem::Version
|
|
49
26
|
version: '4'
|
|
50
27
|
- !ruby/object:Gem::Dependency
|
|
51
28
|
name: bundler
|
|
52
29
|
requirement: !ruby/object:Gem::Requirement
|
|
53
30
|
requirements:
|
|
54
|
-
- - ~>
|
|
31
|
+
- - "~>"
|
|
55
32
|
- !ruby/object:Gem::Version
|
|
56
33
|
version: '1.13'
|
|
57
34
|
type: :development
|
|
58
35
|
prerelease: false
|
|
59
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
60
37
|
requirements:
|
|
61
|
-
- - ~>
|
|
38
|
+
- - "~>"
|
|
62
39
|
- !ruby/object:Gem::Version
|
|
63
40
|
version: '1.13'
|
|
64
41
|
- !ruby/object:Gem::Dependency
|
|
65
42
|
name: rake
|
|
66
43
|
requirement: !ruby/object:Gem::Requirement
|
|
67
44
|
requirements:
|
|
68
|
-
- - ~>
|
|
45
|
+
- - "~>"
|
|
69
46
|
- !ruby/object:Gem::Version
|
|
70
47
|
version: '10.0'
|
|
71
48
|
type: :development
|
|
72
49
|
prerelease: false
|
|
73
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
74
51
|
requirements:
|
|
75
|
-
- - ~>
|
|
52
|
+
- - "~>"
|
|
76
53
|
- !ruby/object:Gem::Version
|
|
77
54
|
version: '10.0'
|
|
78
55
|
- !ruby/object:Gem::Dependency
|
|
79
56
|
name: rspec
|
|
80
57
|
requirement: !ruby/object:Gem::Requirement
|
|
81
58
|
requirements:
|
|
82
|
-
- - ~>
|
|
59
|
+
- - "~>"
|
|
83
60
|
- !ruby/object:Gem::Version
|
|
84
61
|
version: '3.0'
|
|
85
62
|
type: :development
|
|
86
63
|
prerelease: false
|
|
87
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
88
65
|
requirements:
|
|
89
|
-
- - ~>
|
|
66
|
+
- - "~>"
|
|
90
67
|
- !ruby/object:Gem::Version
|
|
91
68
|
version: '3.0'
|
|
92
69
|
- !ruby/object:Gem::Dependency
|
|
93
70
|
name: rspec-collection_matchers
|
|
94
71
|
requirement: !ruby/object:Gem::Requirement
|
|
95
72
|
requirements:
|
|
96
|
-
- - ~>
|
|
73
|
+
- - "~>"
|
|
97
74
|
- !ruby/object:Gem::Version
|
|
98
75
|
version: 1.1.2
|
|
99
76
|
type: :development
|
|
100
77
|
prerelease: false
|
|
101
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
102
79
|
requirements:
|
|
103
|
-
- - ~>
|
|
80
|
+
- - "~>"
|
|
104
81
|
- !ruby/object:Gem::Version
|
|
105
82
|
version: 1.1.2
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: rubocop
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0.49'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0.49'
|
|
106
97
|
description: Directed Acyclic Graph for Key-Value searches
|
|
107
98
|
email:
|
|
108
99
|
- calle.englund@saabgroup.com
|
|
@@ -110,7 +101,9 @@ executables: []
|
|
|
110
101
|
extensions: []
|
|
111
102
|
extra_rdoc_files: []
|
|
112
103
|
files:
|
|
113
|
-
- .gitignore
|
|
104
|
+
- ".gitignore"
|
|
105
|
+
- ".rubocop.yml"
|
|
106
|
+
- ".rubocop_todo.yml"
|
|
114
107
|
- Gemfile
|
|
115
108
|
- LICENSE
|
|
116
109
|
- README.md
|
|
@@ -135,17 +128,17 @@ require_paths:
|
|
|
135
128
|
- lib
|
|
136
129
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
137
130
|
requirements:
|
|
138
|
-
- - ~>
|
|
131
|
+
- - "~>"
|
|
139
132
|
- !ruby/object:Gem::Version
|
|
140
133
|
version: '2'
|
|
141
134
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
135
|
requirements:
|
|
143
|
-
- -
|
|
136
|
+
- - ">="
|
|
144
137
|
- !ruby/object:Gem::Version
|
|
145
138
|
version: '0'
|
|
146
139
|
requirements: []
|
|
147
140
|
rubyforge_project:
|
|
148
|
-
rubygems_version: 2.
|
|
141
|
+
rubygems_version: 2.6.11
|
|
149
142
|
signing_key:
|
|
150
143
|
specification_version: 4
|
|
151
144
|
summary: Directed Acyclic Graph for Key-Value searches
|
checksums.yaml.gz.sig
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
����p��u��ڍ>95;4�q�POlH����5�Z���c��+�B �p��r&�yV����%b��>W5�n!��q�-��Va�c���S����m��A�u`bI�I����wi?8��uyH����fBw��q���c�}��G%�L�+N[��\(W����y߲#�.�+�4���C�Y��%�aI��ڷ�t�<��?j��(t�#�<��/��݊i�1Kd������r� Ϛ�y��I�K�M�I
|
data.tar.gz.sig
DELETED
metadata.gz.sig
DELETED
|
Binary file
|