neo 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/neo.rb +4 -12
- data/lib/neo/http_client.rb +22 -0
- data/lib/neo/version.rb +1 -1
- metadata +18 -11
- checksums.yaml +0 -7
data/lib/neo.rb
CHANGED
@@ -1,27 +1,19 @@
|
|
1
1
|
require 'neo/version'
|
2
|
-
require '
|
2
|
+
require 'neo/http_client'
|
3
|
+
require 'curb'
|
3
4
|
require 'yajl'
|
4
5
|
|
5
6
|
module Neo
|
6
7
|
extend self
|
7
8
|
|
8
9
|
def exec(cypher, params = {})
|
9
|
-
|
10
|
-
req['Accept'] = 'application/json'
|
11
|
-
req['Content-Type'] = 'application/json'
|
12
|
-
req.body = Yajl::Encoder.encode(query: cypher, params: params)
|
13
|
-
|
14
|
-
res = Net::HTTP.start(uri.hostname, uri.port) do |http|
|
15
|
-
http.request req
|
16
|
-
end
|
17
|
-
|
18
|
-
Yajl::Parser.parse res.body
|
10
|
+
HttpClient.post uri, query: cypher, params: params
|
19
11
|
end
|
20
12
|
|
21
13
|
private
|
22
14
|
|
23
15
|
def uri
|
24
|
-
|
16
|
+
'http://localhost:7474/db/data/cypher'
|
25
17
|
end
|
26
18
|
|
27
19
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module HttpClient
|
2
|
+
extend self
|
3
|
+
|
4
|
+
VERBS = %w(get post put patch delete)
|
5
|
+
|
6
|
+
VERBS.each do |verb|
|
7
|
+
define_method verb do |uri, body = {}, options = {}|
|
8
|
+
headers = merge_default_headers(options[:headers])
|
9
|
+
|
10
|
+
http = Curl.send verb, uri, body do |c|
|
11
|
+
c.headers = headers
|
12
|
+
end
|
13
|
+
|
14
|
+
Yajl::Parser.parse http.body_str
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def merge_default_headers(headers)
|
19
|
+
{ 'Content-Type' => 'application/json', 'Accept' => 'application/json' }.merge(headers || {})
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
data/lib/neo/version.rb
CHANGED
metadata
CHANGED
@@ -1,41 +1,46 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Victor Rodrigues
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-16 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: curb
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
|
-
- - '>='
|
19
|
+
- - ! '>='
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: '0'
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
|
-
- - '>='
|
27
|
+
- - ! '>='
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '0'
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: yajl-ruby
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
|
-
- - '>='
|
35
|
+
- - ! '>='
|
32
36
|
- !ruby/object:Gem::Version
|
33
37
|
version: '0'
|
34
38
|
type: :runtime
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
|
-
- - '>='
|
43
|
+
- - ! '>='
|
39
44
|
- !ruby/object:Gem::Version
|
40
45
|
version: '0'
|
41
46
|
description: Neo4j client
|
@@ -51,29 +56,31 @@ files:
|
|
51
56
|
- README.md
|
52
57
|
- Rakefile
|
53
58
|
- lib/neo.rb
|
59
|
+
- lib/neo/http_client.rb
|
54
60
|
- lib/neo/version.rb
|
55
61
|
- neo.gemspec
|
56
62
|
homepage: ''
|
57
63
|
licenses: []
|
58
|
-
metadata: {}
|
59
64
|
post_install_message:
|
60
65
|
rdoc_options: []
|
61
66
|
require_paths:
|
62
67
|
- lib
|
63
68
|
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
64
70
|
requirements:
|
65
|
-
- - '>='
|
71
|
+
- - ! '>='
|
66
72
|
- !ruby/object:Gem::Version
|
67
73
|
version: '0'
|
68
74
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
69
76
|
requirements:
|
70
|
-
- - '>='
|
77
|
+
- - ! '>='
|
71
78
|
- !ruby/object:Gem::Version
|
72
79
|
version: '0'
|
73
80
|
requirements: []
|
74
81
|
rubyforge_project:
|
75
|
-
rubygems_version:
|
82
|
+
rubygems_version: 1.8.25
|
76
83
|
signing_key:
|
77
|
-
specification_version:
|
84
|
+
specification_version: 3
|
78
85
|
summary: Neo4j client
|
79
86
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: f75d4fc5f4e3c2ee4ed61b8a59753b95093ac12b
|
4
|
-
data.tar.gz: 5b8a80aca4dd8cb38dbd62b8c7388dbce8764f98
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: cb46f773a05456d871eca3bf65f047cd6fcec80cdc02a21e82ce454ba92f4422b283bd3bc09ac9b69d2a07e67030f0b04cc845079f2961278b49a1cd7f8b9101
|
7
|
-
data.tar.gz: a2fdf4c49eb49a777ff710d1f6282d3d91e06c476ca7a3d216392f61999c8127ddb24b964a6939bf2f43638fa18eeae95708c5fca046918836639103dae2cc7f
|