neo4j-core 5.0.2 → 5.0.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: b74f69f9b3d8758405b41493b43eb58c9d7113fb
4
- data.tar.gz: bca8ba4bdf95e2caef2d07d396da5e47c5f7d41f
3
+ metadata.gz: d2160daa8962ca2c3473801e1a9bd5aa69d49f3f
4
+ data.tar.gz: b2dd9812b8e775c8e827376dd753d6d3fe20aaf8
5
5
  SHA512:
6
- metadata.gz: be6fa6687915b5ab2974d3f8089d21732cf58b5d75981e0b7a979fa3beff6e3d5f2ca23e84ce5527e6409df4cc5e2f21f3e5b295d7fcc2a81446f18afd50f419
7
- data.tar.gz: d60a1cf05c0e317d61d468bc5e7641d1c48e57ba8a3f94214126430ba747458ef22f0962d645d03dc1b3b06ea1165f7f6be34ba5254ae60182ae872d881a83b0
6
+ metadata.gz: d6b5547d132c434f796e912cb14978bb33df054d3d8d203ac99a50b765984cb5a4003ebea17a0308e498a7fe38af9fa3d5a8200ace05cbd7e75fb68d36edd4ab
7
+ data.tar.gz: df6d567989bef93a58e05133de6e73fa6c419e8b46ca581aede542ac0b46889b45c765f59be171ff58787418289546ccf310133288c9ff584debe6422916daaa
@@ -148,13 +148,31 @@ module Neo4j
148
148
  param.tr_s!('^a-zA-Z0-9', UNDERSCORE)
149
149
  param.gsub!(/^_+|_+$/, '')
150
150
 
151
- value = value.first if !is_set && value.is_a?(Array) && value.size == 1
152
- @params[param.to_sym] = value
151
+ if value.is_a?(Range)
152
+ add_params("#{param}_range_min" => value.min, "#{param}_range_max" => value.max)
153
153
 
154
- if !value.is_a?(Array) || is_set
155
- "#{key} = {#{param}}"
154
+ "#{key} IN RANGE({#{param}_range_min}, {#{param}_range_max})"
156
155
  else
157
- "#{key} IN {#{param}}"
156
+ value = value.first if array_value?(value, is_set) && value.size == 1
157
+ operator = array_value?(value, is_set) ? 'IN' : '='
158
+
159
+ add_param(param, value)
160
+
161
+ "#{key} #{operator} {#{param}}"
162
+ end
163
+ end
164
+
165
+ def array_value?(value, is_set)
166
+ value.is_a?(Array) && !is_set
167
+ end
168
+
169
+ def add_param(key, value)
170
+ @params[key.freeze.to_sym] = value
171
+ end
172
+
173
+ def add_params(params)
174
+ params.each do |key, value|
175
+ add_param(key, value)
158
176
  end
159
177
  end
160
178
 
@@ -180,7 +198,7 @@ module Neo4j
180
198
  "#{key}: #{value}"
181
199
  else
182
200
  param_key = "#{prefix}#{key}".gsub('::', '_')
183
- @params[param_key.to_sym] = value
201
+ add_param(param_key, value)
184
202
  "#{key}: {#{param_key}}"
185
203
  end
186
204
  end.join(Clause::COMMA_SPACE)
@@ -220,7 +238,7 @@ module Neo4j
220
238
  when Hash then hash_key_value_string(key, value, previous_keys)
221
239
  when NilClass then "#{key} IS NULL"
222
240
  when Regexp then regexp_key_value_string(key, value)
223
- when Array then key_value_string(key, value, previous_keys)
241
+ when Array, Range then key_value_string(key, value, previous_keys)
224
242
  else
225
243
  key_value_string(key, value, previous_keys)
226
244
  end
@@ -418,13 +436,13 @@ module Neo4j
418
436
 
419
437
  def from_string(value)
420
438
  clause_id = "#{self.class.keyword_downcase}_#{value}"
421
- @params[clause_id.to_sym] = value.to_i
439
+ add_param(clause_id, value.to_i)
422
440
  "{#{clause_id}}"
423
441
  end
424
442
 
425
443
  def from_integer(value)
426
444
  clause_id = "#{self.class.keyword_downcase}_#{value}"
427
- @params[clause_id.to_sym] = value
445
+ add_param(clause_id, value)
428
446
  "{#{clause_id}}"
429
447
  end
430
448
 
@@ -440,13 +458,13 @@ module Neo4j
440
458
 
441
459
  def from_string(value)
442
460
  clause_id = "#{self.class.keyword_downcase}_#{value}"
443
- @params[clause_id.to_sym] = value.to_i
461
+ add_param(clause_id, value.to_i)
444
462
  "{#{clause_id}}"
445
463
  end
446
464
 
447
465
  def from_integer(value)
448
466
  clause_id = "#{self.class.keyword_downcase}_#{value}"
449
- @params[clause_id.to_sym] = value
467
+ add_param(clause_id, value)
450
468
  "{#{clause_id}}"
451
469
  end
452
470
 
@@ -465,7 +483,7 @@ module Neo4j
465
483
  when String, Symbol then "#{key}:`#{value}`"
466
484
  when Hash
467
485
  if @options[:set_props]
468
- @params["#{key}_set_props".freeze.to_sym] = value
486
+ add_param("#{key}_set_props", value)
469
487
  "#{key} = {#{key}_set_props}"
470
488
  else
471
489
  value.map { |k, v| key_value_string("#{key}.`#{k}`", v, ['setter'], true) }
@@ -1,5 +1,5 @@
1
1
  module Neo4j
2
2
  module Core
3
- VERSION = '5.0.2'
3
+ VERSION = '5.0.3'
4
4
  end
5
5
  end
@@ -237,7 +237,7 @@ module Neo4j
237
237
  clear, yellow, cyan = %W(\e[0m \e[33m \e[36m)
238
238
  ActiveSupport::Notifications.subscribe('neo4j.cypher_query') do |_, start, finish, _id, payload|
239
239
  ms = (finish - start) * 1000
240
- params_string = (payload[:params].size > 0 ? "| #{payload[:params].inspect}" : EMPTY)
240
+ params_string = (payload[:params] && payload[:params].size > 0 ? "| #{payload[:params].inspect}" : EMPTY)
241
241
  yield(" #{cyan}#{payload[:context]}#{clear} #{yellow}#{ms.round}ms#{clear} #{payload[:cypher]} #{params_string}")
242
242
  end
243
243
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neo4j-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.2
4
+ version: 5.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Ronge, Chris Grigg, Brian Underwood
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-01 00:00:00.000000000 Z
11
+ date: 2015-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -262,7 +262,6 @@ files:
262
262
  - lib/neo4j-core.rb
263
263
  - lib/neo4j-core/active_entity.rb
264
264
  - lib/neo4j-core/cypher_translator.rb
265
- - lib/neo4j-core/graph_json.rb
266
265
  - lib/neo4j-core/hash_with_indifferent_access.rb
267
266
  - lib/neo4j-core/helpers.rb
268
267
  - lib/neo4j-core/label.rb
@@ -1,35 +0,0 @@
1
- module Neo4j
2
- module Core
3
- module GraphJSON
4
- def self.to_graph_json(objects)
5
- nodes = {}
6
- edges = {}
7
-
8
- objects.each do |object|
9
- case object
10
- when Neo4j::ActiveNode, Neo4j::Server::CypherNode
11
- nodes[object.neo_id] = {
12
- id: object.neo_id,
13
- labels: (object.is_a?(Neo4j::ActiveNode) ? [object.class.name] : object.labels),
14
- properties: object.attributes
15
- }
16
- when Neo4j::ActiveRel, Neo4j::Server::CypherRelationship
17
- edges[[object.start_node.neo_id, object.end_node.neo_id]] = {
18
- source: object.start_node.neo_id,
19
- target: object.end_node.neo_id,
20
- type: object.rel_type,
21
- properties: object.props
22
- }
23
- else
24
- fail "Invalid value found: #{object.inspect}"
25
- end
26
- end
27
-
28
- {
29
- nodes: nodes.values,
30
- edges: edges.values
31
- }.to_json
32
- end
33
- end
34
- end
35
- end