architect4r 0.3.4 → 0.3.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- architect4r (0.3.3.1)
4
+ architect4r (0.3.4)
5
5
  activemodel (~> 3.0)
6
6
  json (~> 1.5)
7
7
  typhoeus (~> 0.2)
data/ReleaseNotes.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Release Notes
2
2
 
3
+ ## v0.3.4.1
4
+
5
+ * Make source and destination of relationships accessible
6
+
3
7
  ## v0.3.4
4
8
 
5
9
  * Allow fetching items, such as nodes and relationships in one query
@@ -67,6 +67,10 @@ module Architect4r
67
67
  def root
68
68
  get_node(get('/')['reference_node'])
69
69
  end
70
+
71
+ def node_id(input)
72
+ node_url(input).match(/node\/(\d+)$/i)[1].to_i
73
+ end
70
74
  end
71
75
  end
72
76
  end
@@ -100,6 +100,45 @@ module Architect4r
100
100
  end
101
101
  end
102
102
 
103
+
104
+ def source
105
+ @source ||= begin
106
+ if raw_data && raw_data['start']
107
+ start_node_id = connection.node_id(raw_data['start'])
108
+ if result = connection.cypher_query("start n=node(#{start_node_id}) return n")
109
+ result.first['n']
110
+ end
111
+ end
112
+ end
113
+ end
114
+
115
+ def destination
116
+ @destination ||= begin
117
+ if raw_data && raw_data['end']
118
+ start_node_id = connection.node_id(raw_data['end'])
119
+ if result = connection.cypher_query("start n=node(#{start_node_id}) return n")
120
+ result.first['n']
121
+ end
122
+ end
123
+ end
124
+ end
125
+
126
+
127
+ #
128
+ # Class methods
129
+ #
130
+
131
+
132
+ def self.find(id)
133
+ data = connection.execute_cypher("start r=relationship(#{id}) return r")
134
+ data &&= data['data'] && data['data'].flatten.first
135
+ self.build_from_database(data)
136
+ end
137
+
138
+ def self.find!(id)
139
+ self.find(id) || raise(Architect4r::RecordNotFound.new("Could not find the #{self.name} with id #{id}!"))
140
+ end
141
+
103
142
  end
104
143
  end
105
144
  end
@@ -1,3 +1,3 @@
1
1
  module Architect4r
2
- VERSION = "0.3.4"
2
+ VERSION = "0.3.4.1"
3
3
  end
@@ -60,4 +60,36 @@ describe Architect4r::Model::Relationship do
60
60
 
61
61
  end
62
62
 
63
+ describe "Retrieve records from the store" do
64
+
65
+ it "should allow fetching a record by its id" do
66
+ CrewMembership.should respond_to(:find)
67
+ end
68
+
69
+ it "should instantiate a relationship model" do
70
+ ms = CrewMembership.create(ship, person, { :rank => 'Captain' })
71
+ CrewMembership.find(ms.id).should be_a(CrewMembership)
72
+ end
73
+
74
+ end
75
+
76
+ describe "Should populate source and destination after retrieval from storage" do
77
+
78
+ let(:membership) { CrewMembership.create(ship, person, { :rank => 'Captain' }) }
79
+
80
+ subject { CrewMembership.find(membership.id) }
81
+
82
+ it { should respond_to(:source) }
83
+ it { should respond_to(:destination) }
84
+
85
+ it "should populate the source after retrieval" do
86
+ subject.source.id.should == ship.id
87
+ end
88
+
89
+ it "should populate the destination after retrieval" do
90
+ subject.destination.id.should == person.id
91
+ end
92
+
93
+ end
94
+
63
95
  end
data/spec/spec_helper.rb CHANGED
@@ -28,7 +28,7 @@ RSpec.configure do |config|
28
28
  end
29
29
 
30
30
  config.after(:suite) do
31
- neo_manager.stop
31
+ #neo_manager.stop
32
32
  end
33
33
  end
34
34
 
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: architect4r
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 69
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
9
  - 4
10
- version: 0.3.4
10
+ - 1
11
+ version: 0.3.4.1
11
12
  platform: ruby
12
13
  authors:
13
14
  - Maximilian Schulz
@@ -15,7 +16,7 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2011-10-27 00:00:00 Z
19
+ date: 2011-11-18 00:00:00 Z
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: activemodel