mementus 0.3.2 → 0.3.3

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: a0126b1888b05fb3dd49b14c39ba3cadfe20cbe2
4
- data.tar.gz: a67cd6c07c156e995837918d0a9267c6230dd7a1
3
+ metadata.gz: 13343725a3e1defe38d65c9938c53a95755d223b
4
+ data.tar.gz: 683c929e1e9cc54529498afefb199c005a75868f
5
5
  SHA512:
6
- metadata.gz: 88b26e50130d2ebddf6d58ecff8d5925f237fddbe4b218e7b2270a53152c33092d1dd41ed03140d8c23eb2614c5506f1d0c1292654814b8ddc3fd589383e5345
7
- data.tar.gz: 63630f975adab34a760e7127795eabe30b756e74bf84fa3cfc68280fc0c6c34a3ef4900e6b7da8c8bc25637e0e6d2e63661126d877a5eebfecd3adfde7aefc86
6
+ metadata.gz: 854588aedd67735d623bd05e92107b7ace162ebe81690f32cb35110316894f0e320b38eb4845ca620dfa7e3013398c0711ab10ee9df09f31cb92a81d502e65e2
7
+ data.tar.gz: b0290808513880dba332a7c5f59c2471a0a11177d7bbe48d7ef6eab97fd295eacf157817e5ddb22e704e7c572fca9b2d8da7ad8981d4d8d627e504e9e5cab9ed
@@ -36,7 +36,12 @@ module Mementus
36
36
  end
37
37
 
38
38
  def out
39
- append_next(Pipes::Out.new)
39
+ append_next(Pipes::Outgoing.new)
40
+ self
41
+ end
42
+
43
+ def in
44
+ append_next(Pipes::Incoming.new)
40
45
  self
41
46
  end
42
47
  end
@@ -52,12 +57,26 @@ module Mementus
52
57
  end
53
58
  end
54
59
 
55
- class Out
60
+ class Outgoing
56
61
  def process(graph, node)
57
62
  graph.each_adjacent(node.id).map do |id|
58
63
  Mementus::NodeProxy.new(id, graph)
59
64
  end
60
65
  end
61
66
  end
67
+
68
+ class Incoming
69
+ def process(graph, node)
70
+ incoming = []
71
+
72
+ graph.each_node do |n|
73
+ graph.each_adjacent(n.id) do |id|
74
+ incoming << Mementus::NodeProxy.new(n.id, graph) if id == node.id
75
+ end
76
+ end
77
+
78
+ incoming
79
+ end
80
+ end
62
81
  end
63
82
  end
@@ -1,3 +1,3 @@
1
1
  module Mementus
2
- VERSION = '0.3.2'.freeze
2
+ VERSION = '0.3.3'.freeze
3
3
  end
data/mementus.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Mementus::VERSION
9
9
  spec.authors = ["maetl"]
10
10
  spec.email = ["me@maetl.net"]
11
- spec.description = %q{In-memory data model}
12
- spec.summary = %q{In-memory data model}
11
+ spec.description = "Graph data structure toolkit."
12
+ spec.summary = "Graph data structure toolkit for Ruby applications."
13
13
  spec.homepage = "https://github.com/maetl/mementus"
14
14
  spec.license = "MIT"
15
15
 
@@ -22,15 +22,21 @@ describe 'pipeline api' do
22
22
  end
23
23
  end
24
24
 
25
- it 'starts a traversal from the given node' do
25
+ it 'traverses from the given node' do
26
26
  pipeline = graph.n(1)
27
27
  expect(pipeline.id).to eq(1)
28
28
  expect(pipeline.one.id).to eq(1)
29
29
  end
30
30
 
31
- it 'traverses to adjacent nodes' do
31
+ it 'traverses to outgoing nodes' do
32
32
  pipeline = graph.n(1).out
33
33
  expect(pipeline.all.count).to eq(1)
34
34
  expect(pipeline.all.first.id).to eq(2)
35
35
  end
36
+
37
+ it 'traverses to incoming nodes' do
38
+ pipeline = graph.n(2).in
39
+ expect(pipeline.all.count).to eq(1)
40
+ expect(pipeline.all.first.id).to eq(1)
41
+ end
36
42
  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.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - maetl
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-04 00:00:00.000000000 Z
11
+ date: 2016-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.4'
55
- description: In-memory data model
55
+ description: Graph data structure toolkit.
56
56
  email:
57
57
  - me@maetl.net
58
58
  executables: []
@@ -116,7 +116,7 @@ rubyforge_project:
116
116
  rubygems_version: 2.4.5
117
117
  signing_key:
118
118
  specification_version: 4
119
- summary: In-memory data model
119
+ summary: Graph data structure toolkit for Ruby applications.
120
120
  test_files:
121
121
  - spec/direction_spec.rb
122
122
  - spec/graph_spec.rb