mementus 0.5.12 → 0.5.13

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: 062513a7421592da50c105498ed8f2ea0ba1fe20
4
- data.tar.gz: 9ff80b9adb5150e584aaa7f0fb8489310af51319
3
+ metadata.gz: 370fd832daecae6063fc22be3eb5cab1ca2708cb
4
+ data.tar.gz: 783911cfac6d8d59f3393ff9376957b15610b6e7
5
5
  SHA512:
6
- metadata.gz: 801cd4a359833cba81516275719d23bde7959d9081488b34548a734fd1f3d1e8bb205140c443ae01e65596c0ee41a2d0e19e5d88d15f59de38e8d78d557fd70c
7
- data.tar.gz: f3bc38a6e68fcc0bcbef5271b639599bd5e44e744b29b2b8fc0ed0b7763b083001e8c702d65fa6b6bce88d0effdc7f69e04e05ae48b381eac9fbeabca615a2ee
6
+ metadata.gz: 62ea1f77ad1e71f6b441ff86ac928deccf75a46128dc1fe4090db668d51218c759f1c683a796baa4f85d9f50edc723187600e5bf6f1ebeba6f966a423ee5584b
7
+ data.tar.gz: be965f81ebe52be72f30a7055518cca83f60d5f51f70ca04f54f966508fcc9f1e18b8e45426164f54ab75d218a18783293aa3c8a96bc93a3833eb4dd059aa37f
@@ -31,10 +31,12 @@ module Mementus
31
31
  end
32
32
  end
33
33
 
34
- def has_edge?(edge, to=nil)
35
- if to
36
- return node(edge).outgoing.any? do |target_node|
37
- target_node.id == to
34
+ def has_edge?(edge, target=nil)
35
+ if target
36
+ return false unless source = node(edge)
37
+
38
+ return source.outgoing.any? do |candidate|
39
+ candidate.id == target
38
40
  end
39
41
  end
40
42
 
@@ -1,3 +1,3 @@
1
1
  module Mementus
2
- VERSION = '0.5.12'.freeze
2
+ VERSION = '0.5.13'.freeze
3
3
  end
data/spec/graph_spec.rb CHANGED
@@ -152,13 +152,25 @@ describe Mementus::Graph do
152
152
  expect(graph.has_edge?(edge_1_2)).to be true
153
153
  end
154
154
 
155
+ specify '!edge' do
156
+ expect(graph.has_edge?(Mementus::Edge.new(id: 11, from: 22, to: 33))).to be false
157
+ end
158
+
155
159
  specify 'edge.id' do
156
160
  expect(graph.has_edge?(edge_1_2.id)).to be true
157
161
  end
158
162
 
159
- specify 'from.id, to.id' do
163
+ specify '!edge.id' do
164
+ expect(graph.has_edge?(4)).to be false
165
+ end
166
+
167
+ specify 'from.id -> to.id' do
160
168
  expect(graph.has_edge?(1, 2)).to be true
161
169
  end
170
+
171
+ specify '!from.id -> !to.id' do
172
+ expect(graph.has_edge?(12, 21)).to be false
173
+ end
162
174
  end
163
175
 
164
176
  specify '#node(id)' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mementus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.12
4
+ version: 0.5.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - maetl