cypher_builder 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/cypher_builder.gemspec +1 -0
- data/lib/cypher_builder/adapter/neography.rb +5 -5
- data/lib/cypher_builder/runner.rb +4 -0
- data/lib/cypher_builder/version.rb +1 -1
- data/lib/cypher_builder.rb +4 -1
- data/spec/cypher_builder/adapter/neography_spec.rb +14 -0
- data/spec/cypher_builder/cypher_spec.rb +10 -1
- metadata +17 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab4195a4df744da8eb1f73ce1a4fd4572ba6dc52
|
4
|
+
data.tar.gz: 15140e002d3c33d9fbbefa43d44b9a65f1c27188
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7458389e9d48d6c078a84338707f755397ed93f76260dd48c633d2c8eb1169b36cb89d6a2d50ad025226d68bc3345d819828a74719e24e4d71ad602a1388160
|
7
|
+
data.tar.gz: fbb03ca65fe4c12ee72b037c703e6e0a6444e8d13b0b93c0c67ae537000567cc5f1993d41a9eb1048740b35fabd584380333fe3fc55ebd35c899542ffd1285fc
|
data/cypher_builder.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
class CypherBuilder::Adapter::Neography
|
2
|
-
def initialize
|
3
|
-
@neo =
|
2
|
+
def initialize(neo = ::Neography::Rest.new)
|
3
|
+
@neo = neo
|
4
4
|
end
|
5
5
|
|
6
6
|
# @param query [#to_s]
|
7
7
|
# @param params [#to_h]
|
8
|
-
# @return [
|
8
|
+
# @return [Array<Hash{Symbol => Object}>]
|
9
9
|
def execute(query, params)
|
10
|
-
result = @neo.
|
11
|
-
columns = result['columns']
|
10
|
+
result = @neo.execute_query(query.to_s, params.to_h)
|
11
|
+
columns = result['columns'].map { |it| it.to_sym }
|
12
12
|
data = result['data']
|
13
13
|
data.map { |values| columns.zip(values).to_h }
|
14
14
|
end
|
data/lib/cypher_builder.rb
CHANGED
@@ -6,7 +6,10 @@ module CypherBuilder
|
|
6
6
|
end
|
7
7
|
|
8
8
|
require 'cypher_builder/adapter/neography'
|
9
|
-
|
9
|
+
require 'neography' rescue nil
|
10
|
+
if defined?(::Neography)
|
11
|
+
CypherBuilder::Adapter::DEFAULT = CypherBuilder::Adapter::Neography.new
|
12
|
+
end
|
10
13
|
|
11
14
|
require 'cypher_builder/payload'
|
12
15
|
require 'cypher_builder/resolver'
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Adapter::Neography do
|
4
|
+
let(:neo) { instance_spy(Neography::Rest, execute_query: {'columns' => ['c1', 'c2'], 'data' => [['abc', 1], ['def', 2]]}) }
|
5
|
+
let(:adapter) { Adapter::Neography.new(neo) }
|
6
|
+
it 'calls Neography' do
|
7
|
+
adapter.execute('blah', {some_param: 'test'})
|
8
|
+
expect(neo).to have_received(:execute_query).with('blah', {some_param: 'test'})
|
9
|
+
end
|
10
|
+
it 'transforms result' do
|
11
|
+
result = adapter.execute('blah', {some_param: 'test'})
|
12
|
+
expect(result).to eq [{c1: 'abc', c2: 1}, {c1: 'def', c2: 2}]
|
13
|
+
end
|
14
|
+
end
|
@@ -1,8 +1,17 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Cypher do
|
4
|
+
let(:adapter) { instance_spy(Adapter::Neography) }
|
5
|
+
describe '.exec' do
|
6
|
+
it 'executes with default adapter' do
|
7
|
+
c = Node('c')
|
8
|
+
cypher_class = Cypher(Match(c),
|
9
|
+
Return(c.name))
|
10
|
+
cypher_class.exec(adapter)
|
11
|
+
expect(adapter).to have_received(:execute).with('MATCH (c) RETURN c.name', {})
|
12
|
+
end
|
13
|
+
end
|
4
14
|
describe '#execute' do
|
5
|
-
let(:adapter) { instance_spy('Adapter') }
|
6
15
|
it 'executes an empty query' do
|
7
16
|
cypher_class = Cypher()
|
8
17
|
cypher_class.new(adapter).execute
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cypher_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ronie Uliana
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '4.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: neography
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.6'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.6'
|
55
69
|
description: Build Cypher query classes (Neo4j).
|
56
70
|
email:
|
57
71
|
- ronie.uliana@gmail.com
|
@@ -87,6 +101,7 @@ files:
|
|
87
101
|
- lib/cypher_builder/runner.rb
|
88
102
|
- lib/cypher_builder/version.rb
|
89
103
|
- lib/cypher_builder/where.rb
|
104
|
+
- spec/cypher_builder/adapter/neography_spec.rb
|
90
105
|
- spec/cypher_builder/cypher_spec.rb
|
91
106
|
- spec/cypher_builder/node_spec.rb
|
92
107
|
- spec/spec_helper.rb
|
@@ -115,6 +130,7 @@ signing_key:
|
|
115
130
|
specification_version: 4
|
116
131
|
summary: Build Cypher query classes (Neo4j).
|
117
132
|
test_files:
|
133
|
+
- spec/cypher_builder/adapter/neography_spec.rb
|
118
134
|
- spec/cypher_builder/cypher_spec.rb
|
119
135
|
- spec/cypher_builder/node_spec.rb
|
120
136
|
- spec/spec_helper.rb
|