mementus 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mementus/graph.rb +8 -0
- data/lib/mementus/version.rb +1 -1
- data/mementus.gemspec +2 -2
- data/spec/graph_spec.rb +16 -0
- metadata +10 -11
- data/lib/mementus/adapter.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26dd9d077d7ad9d1747b4071a91db233131dbba3
|
4
|
+
data.tar.gz: d04e4c35b6eca0c45640cb06ba0136ab08b2453a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cf713cbafc0edd0df14e241a7c7b328948eeac489146ce96d3849fd52ffb8a75fb9f124b78beaec5828d3485a5b09099c9452bbc60a26637b67f8f30edea528
|
7
|
+
data.tar.gz: 6541ecd1725179928a9dc9c6cdafe0df633222da04bff157e5b63dc3aa0b30699ce84bdcc6a14e75a0c6afef95d6b4ea9e7bfb59beca86f2954e67f9e524c13b
|
data/lib/mementus/graph.rb
CHANGED
@@ -41,6 +41,14 @@ module Mementus
|
|
41
41
|
has_node?(edge.from) && @index[edge.from].include?(edge.to)
|
42
42
|
end
|
43
43
|
|
44
|
+
def node(id)
|
45
|
+
@index.keys.find { |node| node.id == id }
|
46
|
+
end
|
47
|
+
|
48
|
+
def nodes
|
49
|
+
@index.keys
|
50
|
+
end
|
51
|
+
|
44
52
|
def each_node(&blk)
|
45
53
|
@index.each_key(&blk)
|
46
54
|
end
|
data/lib/mementus/version.rb
CHANGED
data/mementus.gemspec
CHANGED
@@ -19,6 +19,6 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
-
spec.add_development_dependency "rake"
|
23
|
-
spec.add_development_dependency "rspec"
|
22
|
+
spec.add_development_dependency "rake", "~> 11.1"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.4"
|
24
24
|
end
|
data/spec/graph_spec.rb
CHANGED
@@ -42,4 +42,20 @@ describe Mementus::Graph do
|
|
42
42
|
expect(graph.has_edge?(edge)).to be true
|
43
43
|
expect(graph.has_edge?(edge2)).to be false
|
44
44
|
end
|
45
|
+
|
46
|
+
specify '#node(id)' do
|
47
|
+
graph = Mementus::Graph.new
|
48
|
+
edge = Mementus::Edge.new(Mementus::Node.new(1, :node), Mementus::Node.new(2, :node))
|
49
|
+
graph.add_edge(edge)
|
50
|
+
|
51
|
+
expect(graph.node(1)).to eq(edge.from)
|
52
|
+
end
|
53
|
+
|
54
|
+
specify '#nodes(filter)' do
|
55
|
+
graph = Mementus::Graph.new
|
56
|
+
edge = Mementus::Edge.new(Mementus::Node.new(1, :node), Mementus::Node.new(2, :node))
|
57
|
+
graph.add_edge(edge)
|
58
|
+
|
59
|
+
expect(graph.nodes).to eq([edge.from, edge.to])
|
60
|
+
end
|
45
61
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mementus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- maetl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -28,30 +28,30 @@ dependencies:
|
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '11.1'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '11.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '3.4'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '3.4'
|
55
55
|
description: In-memory data model
|
56
56
|
email:
|
57
57
|
- me@maetl.net
|
@@ -66,7 +66,6 @@ files:
|
|
66
66
|
- README.md
|
67
67
|
- Rakefile
|
68
68
|
- lib/mementus.rb
|
69
|
-
- lib/mementus/adapter.rb
|
70
69
|
- lib/mementus/breadth_first_search.rb
|
71
70
|
- lib/mementus/depth_first_search.rb
|
72
71
|
- lib/mementus/edge.rb
|