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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aff9aa777fa33ad8ecf66a47753c814e3c000848
4
- data.tar.gz: 4cad00730445aa56fd112026abfdc2d40ea238f0
3
+ metadata.gz: ab4195a4df744da8eb1f73ce1a4fd4572ba6dc52
4
+ data.tar.gz: 15140e002d3c33d9fbbefa43d44b9a65f1c27188
5
5
  SHA512:
6
- metadata.gz: e9d553e03ee2d52518776d8d644301e4ddcfbf5e0f723924155a10645f46259ef04289160bf877f750f7c0d80c8ac630994be642da81daf56513d804a86df720
7
- data.tar.gz: a2287427a2418fdc15cf70881f370cbc642e965f97d3dac96d309c4e26e3c09004c4a4140d146782e1c60f5961c80229380e66cf6778f2563baa7fd7a81cba23
6
+ metadata.gz: f7458389e9d48d6c078a84338707f755397ed93f76260dd48c633d2c8eb1169b36cb89d6a2d50ad025226d68bc3345d819828a74719e24e4d71ad602a1388160
7
+ data.tar.gz: fbb03ca65fe4c12ee72b037c703e6e0a6444e8d13b0b93c0c67ae537000567cc5f1993d41a9eb1048740b35fabd584380333fe3fc55ebd35c899542ffd1285fc
@@ -21,4 +21,5 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency 'bundler', '~> 1.7'
22
22
  spec.add_development_dependency 'rake', '~> 10.0'
23
23
  spec.add_development_dependency 'guard-rspec', '~> 4.3'
24
+ spec.add_development_dependency 'neography', '~> 1.6'
24
25
  end
@@ -1,14 +1,14 @@
1
1
  class CypherBuilder::Adapter::Neography
2
- def initialize
3
- @neo = ::Neography::Rest.new
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.execute(query.to_s, params.to_h)
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
@@ -3,6 +3,10 @@ module CypherBuilder
3
3
  class << self
4
4
  # @return [Cypher]
5
5
  attr_accessor :cypher
6
+
7
+ def exec(adapter = Adapter::DEFAULT, ** params)
8
+ self.new(adapter).execute(** params)
9
+ end
6
10
  end
7
11
 
8
12
  # @param adapter [Adapter]
@@ -1,3 +1,3 @@
1
1
  module CypherBuilder
2
- VERSION = "0.0.1"
2
+ VERSION = '0.0.2'
3
3
  end
@@ -6,7 +6,10 @@ module CypherBuilder
6
6
  end
7
7
 
8
8
  require 'cypher_builder/adapter/neography'
9
- CypherBuilder::Adapter::DEFAULT = CypherBuilder::Adapter::Neography.new if defined?(::Neography)
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.1
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