geoff 0.0.7 → 0.0.8

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.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- geoff (0.0.6)
4
+ geoff (0.0.8)
5
5
  activesupport (~> 3.2.3)
6
6
  json
7
7
  neo4j
@@ -31,7 +31,7 @@ GEM
31
31
  diff-lcs (1.1.3)
32
32
  erubis (2.7.0)
33
33
  hike (1.2.1)
34
- i18n (0.6.0)
34
+ i18n (0.6.1)
35
35
  journey (1.0.4)
36
36
  json (1.7.5-java)
37
37
  linecache (0.46)
data/README.md CHANGED
@@ -29,7 +29,6 @@ Prerequisites/ Caveats
29
29
  Usage
30
30
  -------
31
31
 
32
-
33
32
  ```ruby
34
33
  #Gemfile
35
34
  gem 'geoff'
@@ -84,12 +83,6 @@ before do
84
83
  end
85
84
  ```
86
85
 
87
- ###Using a ramdisk see http://neo4j.rubyforge.org/guides/configuration.html
88
-
89
- ```sh
90
- diskutil erasevolume HFS+ "ramdisk" `hdiutil attach -nomount ram://1165430`
91
- ```
92
-
93
86
  ```geoff
94
87
  (ROOT)-[:Company]->(Company)
95
88
  (ROOT)-[:Person]->(Person)
@@ -190,4 +183,92 @@ Geoff(Company, target: self) do
190
183
  end
191
184
  ```
192
185
 
186
+ #Injecting builders
187
+ ```ruby
188
+ coffee_machines_builder = Geoff do
189
+ b.large_coffee_machines = children do
190
+ coffee_machine('large_machine') { power 2300 }
191
+ coffee_machine('xxl_machine' ) { power 2600 }
192
+ end
193
+ end
194
+
195
+ tables_builder = Geoff do
196
+ b.tables = children do
197
+ table('round_table' ) { capacity 3 }
198
+ table('square_table') { capacity 4 }
199
+ end
200
+ end
201
+
202
+ Geoff(coffee_machines_builder, tables_builder) do
203
+ branch 'acme_coffee_luton_branch' do
204
+ number_of_employees 15
205
+
206
+ children do
207
+ b.small_coffee_machines type: 'uses', lease: '3 years'
208
+ b.tables type: 'has'
209
+ end
210
+ end
211
+ end
212
+ ```
213
+ Resulting graph
214
+ ```
215
+ (Branch)
216
+ acme_coffee_luton_branch---------------------(Table)
217
+ / | \ has square_table
218
+ / | \ {capacity: 4}
219
+ / | \
220
+ /uses |uses \has
221
+ / | \
222
+ / | \
223
+ / | \
224
+ (CoffeeMachine) (CoffeeMachine) (Table)
225
+ large_machine xxl_machine round_table
226
+ {power: 2300} {power: 2600} {capacity: 3}
227
+ ```
228
+
229
+ #Cloning subtrees
230
+ ```ruby
231
+ Geoff do
232
+ b.grinder = grinder 'fine_grinder'
233
+
234
+ branch 'acme_coffee_luton_branch' do
235
+ children 'uses' do
236
+ b.machine = coffee_machine('large_machine') do
237
+ power 2300
193
238
 
239
+ children 'connected_to' do
240
+ b.grinder clone: false
241
+ end
242
+ end
243
+
244
+ # this branch uses two identical large coffee machines
245
+ # but they share same grinder
246
+ b.machine type: 'uses', clone: true
247
+ end
248
+ end
249
+ end
250
+ ```
251
+ Resulting graph
252
+ ```
253
+ (Branch)
254
+ acme_coffee_luton_branch
255
+ / \
256
+ / \
257
+ / \
258
+ /uses \uses
259
+ / \
260
+ / \
261
+ / \
262
+ (CoffeeMachine) (CoffeeMachine)
263
+ large_machine large_machine
264
+ {power: 2300} {power: 2300}
265
+ \ /
266
+ \ /
267
+ \ /
268
+ \connected_to /connected_to
269
+ \ /
270
+ \ /
271
+ \ /
272
+ (Grinder)
273
+ fine_grinder
274
+ ```
@@ -68,11 +68,13 @@ class Geoff
68
68
 
69
69
  def rebuild_indexes
70
70
  log 're-building indexes'
71
- types = root_node.relationships.map { |r| Kernel.const_get(r.get_type.to_s) }
71
+ if defined?(r.get_type.to_s)
72
+ types = root_node.relationships.map { |r| Kernel.const_get(r.get_type.to_s) }
72
73
 
73
- Neo4j::Transaction.run do
74
- types.each do |type|
75
- re_index(type)
74
+ Neo4j::Transaction.run do
75
+ types.each do |type|
76
+ re_index(type)
77
+ end
76
78
  end
77
79
  end
78
80
  end
data/lib/geoff/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Geoff
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -18,8 +18,8 @@ describe Geoff do
18
18
  coffee_machines_builder,
19
19
  tables_builder
20
20
  ) do
21
- branch 'starbucks_luton_branch' do
22
- delay_time 15
21
+ branch 'acme_coffee_luton_branch' do
22
+ number_of_employees 15
23
23
 
24
24
  children do
25
25
  b.small_coffee_machines type: 'uses', lease: '3 years'
@@ -27,8 +27,8 @@ describe Geoff do
27
27
  end
28
28
  end
29
29
 
30
- branch 'starbucks_reading_branch' do
31
- delay_time 10
30
+ branch 'acme_coffee_reading_branch' do
31
+ number_of_employees 10
32
32
 
33
33
  children do
34
34
  b.large_coffee_machines type: 'uses', lease: '3 years'
@@ -44,13 +44,13 @@ describe Geoff do
44
44
  let(:coffee_machines_builder) do
45
45
  Geoff(CoffeeMachine) do
46
46
  b.large_coffee_machines = children do
47
- coffee_machine('large_illy' ) { power 2300 }
48
- coffee_machine('large_gaggia') { power 2600 }
47
+ coffee_machine('large_machine') { power 2300 }
48
+ coffee_machine('xxl_machine' ) { power 2600 }
49
49
  end
50
50
 
51
51
  b.small_coffee_machines = children do
52
- coffee_machine('small_illy' ) { power 600 }
53
- coffee_machine('small_gaggia') { power 750 }
52
+ coffee_machine('xs_machine' ) { power 600 }
53
+ coffee_machine('small_machine') { power 750 }
54
54
  end
55
55
  end
56
56
  end
@@ -67,37 +67,37 @@ describe Geoff do
67
67
  let(:expected_geoff) do
68
68
  strip_whitespace <<-EOS
69
69
  (ROOT)-[:Branch]->(Branch)
70
- (starbucks_luton_branch) {"_classname":"Branch","delay_time":15}
71
- (Branch)-[:all]->(starbucks_luton_branch)
72
- (small_illy) {"_classname":"CoffeeMachine","power":600}
73
- (CoffeeMachine)-[:all]->(small_illy)
74
- (starbucks_luton_branch)-[:uses]->(small_illy) {"lease":"3 years"}
75
- (small_gaggia) {"_classname":"CoffeeMachine","power":750}
76
- (CoffeeMachine)-[:all]->(small_gaggia)
77
- (starbucks_luton_branch)-[:uses]->(small_gaggia) {"lease":"3 years"}
70
+ (acme_coffee_luton_branch) {"_classname":"Branch","number_of_employees":15}
71
+ (Branch)-[:all]->(acme_coffee_luton_branch)
72
+ (xs_machine) {"_classname":"CoffeeMachine","power":600}
73
+ (CoffeeMachine)-[:all]->(xs_machine)
74
+ (acme_coffee_luton_branch)-[:uses]->(xs_machine) {"lease":"3 years"}
75
+ (small_machine) {"_classname":"CoffeeMachine","power":750}
76
+ (CoffeeMachine)-[:all]->(small_machine)
77
+ (acme_coffee_luton_branch)-[:uses]->(small_machine) {"lease":"3 years"}
78
78
  (round_table) {"_classname":"Table","capacity":3}
79
79
  (Table)-[:all]->(round_table)
80
- (starbucks_luton_branch)-[:has]->(round_table)
80
+ (acme_coffee_luton_branch)-[:has]->(round_table)
81
81
  (square_table) {"_classname":"Table","capacity":4}
82
82
  (Table)-[:all]->(square_table)
83
- (starbucks_luton_branch)-[:has]->(square_table)
84
- (starbucks_reading_branch) {"_classname":"Branch","delay_time":10}
85
- (Branch)-[:all]->(starbucks_reading_branch)
86
- (large_illy) {"_classname":"CoffeeMachine","power":2300}
87
- (CoffeeMachine)-[:all]->(large_illy)
88
- (starbucks_reading_branch)-[:uses]->(large_illy) {"lease":"3 years"}
89
- (large_gaggia) {"_classname":"CoffeeMachine","power":2600}
90
- (CoffeeMachine)-[:all]->(large_gaggia)
91
- (starbucks_reading_branch)-[:uses]->(large_gaggia) {"lease":"3 years"}
83
+ (acme_coffee_luton_branch)-[:has]->(square_table)
84
+ (acme_coffee_reading_branch) {"_classname":"Branch","number_of_employees":10}
85
+ (Branch)-[:all]->(acme_coffee_reading_branch)
86
+ (large_machine) {"_classname":"CoffeeMachine","power":2300}
87
+ (CoffeeMachine)-[:all]->(large_machine)
88
+ (acme_coffee_reading_branch)-[:uses]->(large_machine) {"lease":"3 years"}
89
+ (xxl_machine) {"_classname":"CoffeeMachine","power":2600}
90
+ (CoffeeMachine)-[:all]->(xxl_machine)
91
+ (acme_coffee_reading_branch)-[:uses]->(xxl_machine) {"lease":"3 years"}
92
92
  (round_table) {"_classname":"Table","capacity":3}
93
93
  (Table)-[:all]->(round_table)
94
- (starbucks_reading_branch)-[:has]->(round_table)
94
+ (acme_coffee_reading_branch)-[:has]->(round_table)
95
95
  (square_table) {"_classname":"Table","capacity":4}
96
96
  (Table)-[:all]->(square_table)
97
- (starbucks_reading_branch)-[:has]->(square_table)
97
+ (acme_coffee_reading_branch)-[:has]->(square_table)
98
98
  (octagonal_table) {"_classname":"Table","capacity":8}
99
99
  (Table)-[:all]->(octagonal_table)
100
- (starbucks_reading_branch)-[:has]->(octagonal_table)
100
+ (acme_coffee_reading_branch)-[:has]->(octagonal_table)
101
101
  EOS
102
102
  end
103
103
 
@@ -127,7 +127,7 @@ describe Geoff do
127
127
  Branch,
128
128
  coffee_machines_builder
129
129
  ) do
130
- branch 'starbucks_luton_branch' do
130
+ branch 'acme_coffee_luton_branch' do
131
131
  children do
132
132
  b.coffee_machine type: 'uses', lease: '3 years'
133
133
  end
@@ -137,7 +137,7 @@ describe Geoff do
137
137
 
138
138
  let(:coffee_machines_builder) do
139
139
  Geoff(CoffeeMachine) do
140
- b.coffee_machine = coffee_machine('illy') do
140
+ b.coffee_machine = coffee_machine('machine') do
141
141
  power 2300
142
142
 
143
143
  children 'connected_to' do
@@ -150,14 +150,14 @@ describe Geoff do
150
150
  let(:expected_geoff) do
151
151
  strip_whitespace <<-EOS
152
152
  (ROOT)-[:Branch]->(Branch)
153
- (starbucks_luton_branch_1) {"_classname":"Branch"}
154
- (Branch)-[:all]->(starbucks_luton_branch_1)
155
- (illy_3) {"_classname":"CoffeeMachine","power":2300}
156
- (CoffeeMachine)-[:all]->(illy_3)
153
+ (acme_coffee_luton_branch_1) {"_classname":"Branch"}
154
+ (Branch)-[:all]->(acme_coffee_luton_branch_1)
155
+ (machine_3) {"_classname":"CoffeeMachine","power":2300}
156
+ (CoffeeMachine)-[:all]->(machine_3)
157
157
  (fine_grinder_5) {"_classname":"Grinder"}
158
158
  (Grinder)-[:all]->(fine_grinder_5)
159
- (illy_3)-[:connected_to]->(fine_grinder_5)
160
- (starbucks_luton_branch_1)-[:uses]->(illy_3) {"lease":"3 years"}
159
+ (machine_3)-[:connected_to]->(fine_grinder_5)
160
+ (acme_coffee_luton_branch_1)-[:uses]->(machine_3) {"lease":"3 years"}
161
161
  EOS
162
162
  end
163
163
 
@@ -175,9 +175,9 @@ describe Geoff do
175
175
  Geoff(Branch) do
176
176
  b.grinder = grinder 'fine_grinder'
177
177
 
178
- branch 'starbucks_luton_branch' do
178
+ branch 'acme_coffee_luton_branch' do
179
179
  children 'uses' do
180
- b.illy = coffee_machine('large_illy') do
180
+ b.machine = coffee_machine('large_machine') do
181
181
  power 2300
182
182
 
183
183
  children 'connected_to' do
@@ -185,8 +185,9 @@ describe Geoff do
185
185
  end
186
186
  end
187
187
 
188
- # this branch uses two identical large illy machines
189
- b.illy type: 'uses', clone: true
188
+ # this branch uses two identical large machine machines
189
+ # but sharing same grinder
190
+ b.machine type: 'uses', clone: true
190
191
  end
191
192
  end
192
193
  end
@@ -197,16 +198,16 @@ describe Geoff do
197
198
  (ROOT)-[:Branch]->(Branch)
198
199
  (fine_grinder) {"_classname":"Grinder"}
199
200
  (Grinder)-[:all]->(fine_grinder)
200
- (starbucks_luton_branch) {"_classname":"Branch"}
201
- (Branch)-[:all]->(starbucks_luton_branch)
202
- (large_illy) {"_classname":"CoffeeMachine","power":2300}
203
- (CoffeeMachine)-[:all]->(large_illy)
204
- (large_illy)-[:connected_to]->(fine_grinder)
205
- (starbucks_luton_branch)-[:uses]->(large_illy)
206
- (large_illy) {"_classname":"CoffeeMachine","power":2300}
207
- (CoffeeMachine)-[:all]->(large_illy)
208
- (large_illy)-[:connected_to]->(fine_grinder)
209
- (starbucks_luton_branch)-[:uses]->(large_illy)
201
+ (acme_coffee_luton_branch) {"_classname":"Branch"}
202
+ (Branch)-[:all]->(acme_coffee_luton_branch)
203
+ (large_machine) {"_classname":"CoffeeMachine","power":2300}
204
+ (CoffeeMachine)-[:all]->(large_machine)
205
+ (large_machine)-[:connected_to]->(fine_grinder)
206
+ (acme_coffee_luton_branch)-[:uses]->(large_machine)
207
+ (large_machine) {"_classname":"CoffeeMachine","power":2300}
208
+ (CoffeeMachine)-[:all]->(large_machine)
209
+ (large_machine)-[:connected_to]->(fine_grinder)
210
+ (acme_coffee_luton_branch)-[:uses]->(large_machine)
210
211
  EOS
211
212
  end
212
213
 
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geoff
3
3
  version: !ruby/object:Gem::Version
4
+ version: 0.0.8
4
5
  prerelease:
5
- version: 0.0.7
6
6
  platform: ruby
7
7
  authors:
8
8
  - David Rouchy
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2012-09-03 00:00:00.000000000 Z
16
+ date: 2012-10-04 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: neo4j
@@ -174,13 +174,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
174
174
  requirements:
175
175
  - - ! '>='
176
176
  - !ruby/object:Gem::Version
177
+ segments:
178
+ - 0
177
179
  version: '0'
180
+ hash: 2
178
181
  none: false
179
182
  required_rubygems_version: !ruby/object:Gem::Requirement
180
183
  requirements:
181
184
  - - ! '>='
182
185
  - !ruby/object:Gem::Version
186
+ segments:
187
+ - 0
183
188
  version: '0'
189
+ hash: 2
184
190
  none: false
185
191
  requirements: []
186
192
  rubyforge_project:
@@ -197,5 +203,4 @@ test_files:
197
203
  - spec/node_dsl_spec.rb
198
204
  - spec/spec_helper.rb
199
205
  - spec/support/geof_matchers.rb
200
- has_rdoc:
201
206
  ...