neo4j-core 5.0.0.rc.2 → 5.0.0.rc.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: 175f153d73ec96ef88b075a88f1809e20d7b6695
4
- data.tar.gz: fdc7802630370e76f2906e0cb81318053fd7e5dc
3
+ metadata.gz: efd3a180ba80337ada8311b1ca7dbf2c9d3a1d5b
4
+ data.tar.gz: feaef1009aca073d05b6ac7e54b22a746c76d552
5
5
  SHA512:
6
- metadata.gz: 1da826e295992cd5d64c752dac4c920d555c56b2665f45172de21ed62defc871707717f4965e55a855553d84be157f745c31c6c1593f3bb26dcd1a43bb6951e2
7
- data.tar.gz: a788e681ed3c623c360882ff69dc9a341eab5d733f0bded3bf7d30cd5feb4b8e4a2c5ced2c4d6795297e08047c038983b331dbde7d558ae19139ff70c5132cbb
6
+ metadata.gz: a141d208d880c0aa0ef8ac89c9264dffc382b84ce7c9703f376bb9fb8cf87fa8d19d28e25128c9312d9174d04cf24c3d6bb00482d8cd74d168d0478a98f7bc72
7
+ data.tar.gz: 8bfa569810bcacd5d96246864570ff642d50cfa7832bff07e4f14b4bb84b1bf01d4880ed496ce3539f87df834a17856836821e36dbe63593c1096e891ab5187d
@@ -0,0 +1,35 @@
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
@@ -465,8 +465,8 @@ module Neo4j
465
465
  when String, Symbol then "#{key}:`#{value}`"
466
466
  when Hash
467
467
  if @options[:set_props]
468
- attribute_string = value.map { |k, v| "#{k}: #{v.inspect}" }.join(Clause::COMMA_SPACE)
469
- "#{key} = {#{attribute_string}}"
468
+ @params["#{key}_set_props".freeze.to_sym] = value
469
+ "#{key} = {#{key}_set_props}"
470
470
  else
471
471
  value.map { |k, v| key_value_string("#{key}.`#{k}`", v, ['setter'], true) }
472
472
  end
@@ -1,5 +1,5 @@
1
1
  module Neo4j
2
2
  module Core
3
- VERSION = '5.0.0.rc.2'
3
+ VERSION = '5.0.0.rc.3'
4
4
  end
5
5
  end
@@ -31,7 +31,7 @@ module Neo4j
31
31
  # (see Neo4j::Node#create_rel)
32
32
  def create_rel(type, other_node, props = nil)
33
33
  q = @session.query.match(:a, :b).where(a: {neo_id: neo_id}, b: {neo_id: other_node.neo_id})
34
- .create("(a)-[r:`#{type}`]->(b)").break.set(r: props).return(r: :neo_id)
34
+ .create("(a)-[r:`#{type}`]->(b)").break.set_props(r: props).return(r: :neo_id)
35
35
 
36
36
  id = @session._query_or_fail(q, true)
37
37
 
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.0.rc.2
4
+ version: 5.0.0.rc.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-05-21 00:00:00.000000000 Z
11
+ date: 2015-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -262,6 +262,7 @@ 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
265
266
  - lib/neo4j-core/hash_with_indifferent_access.rb
266
267
  - lib/neo4j-core/helpers.rb
267
268
  - lib/neo4j-core/label.rb