neography 1.2.4 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/README.md +16 -15
- data/lib/neography/config.rb +30 -28
- data/lib/neography/connection.rb +13 -12
- data/lib/neography/tasks.rb +1 -1
- data/lib/neography/version.rb +1 -1
- data/spec/integration/neography_spec.rb +1 -1
- data/spec/integration/rest_node_spec.rb +1 -1
- data/spec/integration/rest_plugin_spec.rb +1 -1
- data/spec/integration/rest_schema_index_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/config_spec.rb +28 -26
- data/spec/unit/connection_spec.rb +53 -30
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6478336dc213df2da26cfd9db4c8814222ea162
|
4
|
+
data.tar.gz: 7d94c3529e2e0464108f16cfa58887db58b00940
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2435540bf31595f410aab104dd8d3d3d848cb45b03daee4d2d45233fd886234bc4de048221f5dadb6caf50452b291b83126854837072ead1d15e2444bd5ddc0d
|
7
|
+
data.tar.gz: 8e9590e796a496cf69c1c4cf11c298a67dd602ab79d8fd9a3a1ec2c7912d6df433940ff6527e9593f378f84a0da620e94faab524ba5a01fa464ebc4edb7376f8
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -61,21 +61,22 @@ Configure Neography as follows:
|
|
61
61
|
```ruby
|
62
62
|
# these are the default values:
|
63
63
|
Neography.configure do |config|
|
64
|
-
config.protocol
|
65
|
-
config.server
|
66
|
-
config.port
|
67
|
-
config.directory
|
68
|
-
config.cypher_path
|
69
|
-
config.gremlin_path
|
70
|
-
config.log_file
|
71
|
-
config.log_enabled
|
72
|
-
config.
|
73
|
-
config.
|
74
|
-
config.
|
75
|
-
config.
|
76
|
-
config.
|
77
|
-
|
78
|
-
|
64
|
+
config.protocol = "http://"
|
65
|
+
config.server = "localhost"
|
66
|
+
config.port = 7474
|
67
|
+
config.directory = "" # prefix this path with '/'
|
68
|
+
config.cypher_path = "/cypher"
|
69
|
+
config.gremlin_path = "/ext/GremlinPlugin/graphdb/execute_script"
|
70
|
+
config.log_file = "neography.log"
|
71
|
+
config.log_enabled = false
|
72
|
+
config.slow_log_threshold = 0 # time in ms for query logging
|
73
|
+
config.max_threads = 20
|
74
|
+
config.authentication = nil # 'basic' or 'digest'
|
75
|
+
config.username = nil
|
76
|
+
config.password = nil
|
77
|
+
config.parser = MultiJsonParser
|
78
|
+
end
|
79
|
+
```
|
79
80
|
|
80
81
|
Then initialize a `Rest` instance:
|
81
82
|
|
data/lib/neography/config.rb
CHANGED
@@ -3,7 +3,7 @@ module Neography
|
|
3
3
|
|
4
4
|
attr_accessor :protocol, :server, :port, :directory,
|
5
5
|
:cypher_path, :gremlin_path,
|
6
|
-
:log_file, :log_enabled,
|
6
|
+
:log_file, :log_enabled, :slow_log_threshold,
|
7
7
|
:max_threads,
|
8
8
|
:authentication, :username, :password,
|
9
9
|
:parser
|
@@ -14,39 +14,41 @@ module Neography
|
|
14
14
|
|
15
15
|
def to_hash
|
16
16
|
{
|
17
|
-
:protocol
|
18
|
-
:server
|
19
|
-
:port
|
20
|
-
:directory
|
21
|
-
:cypher_path
|
22
|
-
:gremlin_path
|
23
|
-
:log_file
|
24
|
-
:log_enabled
|
25
|
-
:
|
26
|
-
:
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
17
|
+
:protocol => @protocol,
|
18
|
+
:server => @server,
|
19
|
+
:port => @port,
|
20
|
+
:directory => @directory,
|
21
|
+
:cypher_path => @cypher_path,
|
22
|
+
:gremlin_path => @gremlin_path,
|
23
|
+
:log_file => @log_file,
|
24
|
+
:log_enabled => @log_enabled,
|
25
|
+
:slow_log_threshold => @slow_log_threshold,
|
26
|
+
:max_threads => @max_threads,
|
27
|
+
:authentication => @authentication,
|
28
|
+
:username => @username,
|
29
|
+
:password => @password,
|
30
|
+
:parser => @parser
|
30
31
|
}
|
31
32
|
end
|
32
33
|
|
33
34
|
private
|
34
35
|
|
35
36
|
def set_defaults
|
36
|
-
@protocol
|
37
|
-
@server
|
38
|
-
@port
|
39
|
-
@directory
|
40
|
-
@cypher_path
|
41
|
-
@gremlin_path
|
42
|
-
@log_file
|
43
|
-
@log_enabled
|
44
|
-
@
|
45
|
-
@
|
46
|
-
@
|
47
|
-
@
|
48
|
-
@
|
49
|
-
|
37
|
+
@protocol = "http://"
|
38
|
+
@server = "localhost"
|
39
|
+
@port = 7474
|
40
|
+
@directory = ""
|
41
|
+
@cypher_path = "/cypher"
|
42
|
+
@gremlin_path = "/ext/GremlinPlugin/graphdb/execute_script"
|
43
|
+
@log_file = "neography.log"
|
44
|
+
@log_enabled = false
|
45
|
+
@slow_log_threshold = 0
|
46
|
+
@max_threads = 20
|
47
|
+
@authentication = nil
|
48
|
+
@username = nil
|
49
|
+
@password = nil
|
50
|
+
@parser = MultiJsonParser
|
51
|
+
end
|
50
52
|
|
51
53
|
end
|
52
54
|
end
|
data/lib/neography/connection.rb
CHANGED
@@ -7,7 +7,7 @@ module Neography
|
|
7
7
|
|
8
8
|
attr_accessor :protocol, :server, :port, :directory,
|
9
9
|
:cypher_path, :gremlin_path,
|
10
|
-
:log_file, :log_enabled, :logger,
|
10
|
+
:log_file, :log_enabled, :logger, :slow_log_threshold,
|
11
11
|
:max_threads,
|
12
12
|
:authentication, :username, :password,
|
13
13
|
:parser, :client
|
@@ -54,7 +54,7 @@ module Neography
|
|
54
54
|
start_time = Time.now
|
55
55
|
response = yield
|
56
56
|
time = ((Time.now - start_time) * 1000).round(2)
|
57
|
-
@logger.info "[Neography::Query] #{path} #{body} [#{time}ms]"
|
57
|
+
@logger.info "[Neography::Query] #{path} #{body} [#{time}ms]" if time >= slow_log_threshold
|
58
58
|
response
|
59
59
|
else
|
60
60
|
yield
|
@@ -76,16 +76,17 @@ module Neography
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def save_local_configuration(config)
|
79
|
-
@protocol
|
80
|
-
@server
|
81
|
-
@port
|
82
|
-
@directory
|
83
|
-
@cypher_path
|
84
|
-
@gremlin_path
|
85
|
-
@log_file
|
86
|
-
@log_enabled
|
87
|
-
@
|
88
|
-
@
|
79
|
+
@protocol = config[:protocol]
|
80
|
+
@server = config[:server]
|
81
|
+
@port = config[:port]
|
82
|
+
@directory = config[:directory]
|
83
|
+
@cypher_path = config[:cypher_path]
|
84
|
+
@gremlin_path = config[:gremlin_path]
|
85
|
+
@log_file = config[:log_file]
|
86
|
+
@log_enabled = config[:log_enabled]
|
87
|
+
@slow_log_threshold = config[:slow_log_threshold]
|
88
|
+
@max_threads = config[:max_threads]
|
89
|
+
@parser = config[:parser]
|
89
90
|
|
90
91
|
@user_agent = { "User-Agent" => USER_AGENT }
|
91
92
|
|
data/lib/neography/tasks.rb
CHANGED
@@ -7,7 +7,7 @@ require 'net/http'
|
|
7
7
|
namespace :neo4j do
|
8
8
|
desc "Install Neo4j"
|
9
9
|
task :install, :edition, :version do |t, args|
|
10
|
-
args.with_defaults(:edition => "community", :version => "
|
10
|
+
args.with_defaults(:edition => "community", :version => "2.0.0")
|
11
11
|
puts "Installing Neo4j-#{args[:edition]}-#{args[:version]}"
|
12
12
|
|
13
13
|
if OS::Underlying.windows?
|
data/lib/neography/version.rb
CHANGED
@@ -8,7 +8,7 @@ describe Neography::Rest do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
describe "get_root" do
|
11
|
-
it "can get the root node" do
|
11
|
+
it "can get the root node", :reference => true do
|
12
12
|
root_node = @neo.get_root
|
13
13
|
root_node.should have_key("self")
|
14
14
|
root_node["self"].split('/').last.should == "0"
|
@@ -141,7 +141,7 @@ describe Neography::Rest do
|
|
141
141
|
end
|
142
142
|
|
143
143
|
|
144
|
-
it "can delete everything but start node" do
|
144
|
+
it "can delete everything but start node", :reference => true do
|
145
145
|
@neo.execute_query("START n=node(*) MATCH n-[r?]-() WHERE ID(n) <> 0 DELETE n,r")
|
146
146
|
expect {
|
147
147
|
@neo.execute_query("start n=node({id}) return n", {:id => 1})
|
@@ -9,7 +9,7 @@ describe Neography::Rest do
|
|
9
9
|
it "can create a schema index" do
|
10
10
|
si = @neo.create_schema_index("person", ["name"])
|
11
11
|
si.should_not be_nil
|
12
|
-
si["
|
12
|
+
si["property_keys"].should include("name")
|
13
13
|
end
|
14
14
|
|
15
15
|
end
|
@@ -19,7 +19,7 @@ describe Neography::Rest do
|
|
19
19
|
si = @neo.get_schema_index("person")
|
20
20
|
si.should_not be_nil
|
21
21
|
si.first["label"].should include("person")
|
22
|
-
si.first["
|
22
|
+
si.first["property_keys"].should include("name")
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
data/spec/spec_helper.rb
CHANGED
data/spec/unit/config_spec.rb
CHANGED
@@ -7,35 +7,37 @@ module Neography
|
|
7
7
|
|
8
8
|
context "defaults" do
|
9
9
|
|
10
|
-
its(:protocol)
|
11
|
-
its(:server)
|
12
|
-
its(:port)
|
13
|
-
its(:directory)
|
14
|
-
its(:cypher_path)
|
15
|
-
its(:gremlin_path)
|
16
|
-
its(:log_file)
|
17
|
-
its(:log_enabled)
|
18
|
-
its(:
|
19
|
-
its(:
|
20
|
-
its(:
|
21
|
-
its(:
|
22
|
-
its(:
|
10
|
+
its(:protocol) { should == 'http://' }
|
11
|
+
its(:server) { should == 'localhost' }
|
12
|
+
its(:port) { should == 7474 }
|
13
|
+
its(:directory) { should == '' }
|
14
|
+
its(:cypher_path) { should == '/cypher' }
|
15
|
+
its(:gremlin_path) { should == '/ext/GremlinPlugin/graphdb/execute_script' }
|
16
|
+
its(:log_file) { should == 'neography.log' }
|
17
|
+
its(:log_enabled) { should == false }
|
18
|
+
its(:slow_log_threshold) { should == 0 }
|
19
|
+
its(:max_threads) { should == 20 }
|
20
|
+
its(:authentication) { should == nil }
|
21
|
+
its(:username) { should == nil }
|
22
|
+
its(:password) { should == nil }
|
23
|
+
its(:parser) { should == MultiJsonParser}
|
23
24
|
|
24
25
|
it "has a hash representation" do
|
25
26
|
expected_hash = {
|
26
|
-
:protocol
|
27
|
-
:server
|
28
|
-
:port
|
29
|
-
:directory
|
30
|
-
:cypher_path
|
31
|
-
:gremlin_path
|
32
|
-
:log_file
|
33
|
-
:log_enabled
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
27
|
+
:protocol => 'http://',
|
28
|
+
:server => 'localhost',
|
29
|
+
:port => 7474,
|
30
|
+
:directory => '',
|
31
|
+
:cypher_path => '/cypher',
|
32
|
+
:gremlin_path => '/ext/GremlinPlugin/graphdb/execute_script',
|
33
|
+
:log_file => 'neography.log',
|
34
|
+
:log_enabled => false,
|
35
|
+
:slow_log_threshold => 0,
|
36
|
+
:max_threads => 20,
|
37
|
+
:authentication => nil,
|
38
|
+
:username => nil,
|
39
|
+
:password => nil,
|
40
|
+
:parser => MultiJsonParser
|
39
41
|
}
|
40
42
|
config.to_hash.should == expected_hash
|
41
43
|
end
|
@@ -20,35 +20,37 @@ module Neography
|
|
20
20
|
context "hash options" do
|
21
21
|
let(:options) do
|
22
22
|
{
|
23
|
-
:protocol
|
24
|
-
:server
|
25
|
-
:port
|
26
|
-
:directory
|
27
|
-
:cypher_path
|
28
|
-
:gremlin_path
|
29
|
-
:log_file
|
30
|
-
:log_enabled
|
31
|
-
:
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
23
|
+
:protocol => "https://",
|
24
|
+
:server => "foobar",
|
25
|
+
:port => 4242,
|
26
|
+
:directory => "/dir",
|
27
|
+
:cypher_path => "/cyph",
|
28
|
+
:gremlin_path => "/grem",
|
29
|
+
:log_file => "neo.log",
|
30
|
+
:log_enabled => false,
|
31
|
+
:slow_log_threshold => 0,
|
32
|
+
:max_threads => 10,
|
33
|
+
:parser => Foo,
|
34
|
+
:authentication => "foo",
|
35
|
+
:username => "bar",
|
36
|
+
:password => "baz"
|
36
37
|
}
|
37
38
|
end
|
38
39
|
|
39
40
|
it "accepts all options in a hash" do
|
40
41
|
connection.configuration.should == "https://foobar:4242/dir/db/data"
|
41
42
|
|
42
|
-
connection.protocol.should
|
43
|
-
connection.server.should
|
44
|
-
connection.port.should
|
45
|
-
connection.directory.should
|
46
|
-
connection.cypher_path.should
|
47
|
-
connection.gremlin_path.should
|
48
|
-
connection.log_file.should
|
49
|
-
connection.log_enabled.should
|
50
|
-
connection.
|
51
|
-
connection.
|
43
|
+
connection.protocol.should == "https://"
|
44
|
+
connection.server.should == "foobar"
|
45
|
+
connection.port.should == 4242
|
46
|
+
connection.directory.should == "/dir"
|
47
|
+
connection.cypher_path.should == "/cyph"
|
48
|
+
connection.gremlin_path.should == "/grem"
|
49
|
+
connection.log_file.should == "neo.log"
|
50
|
+
connection.log_enabled.should == false
|
51
|
+
connection.slow_log_threshold.should == 0
|
52
|
+
connection.max_threads.should == 10
|
53
|
+
connection.parser.should == Foo
|
52
54
|
|
53
55
|
connection.authentication.should == {
|
54
56
|
:foo_auth => {
|
@@ -207,17 +209,14 @@ module Neography
|
|
207
209
|
|
208
210
|
context "query logging" do
|
209
211
|
before do
|
210
|
-
|
212
|
+
@logger = Logger.new(nil)
|
213
|
+
connection.logger = @logger
|
211
214
|
connection.log_enabled = true
|
212
215
|
end
|
213
216
|
|
214
|
-
let
|
215
|
-
"expected_response"
|
216
|
-
end
|
217
|
+
let(:expected_response) {"expected_response"}
|
217
218
|
|
218
|
-
let
|
219
|
-
{key1: :val1}
|
220
|
-
end
|
219
|
+
let(:request_body) { {key1: :val1} }
|
221
220
|
|
222
221
|
it "should log query" do
|
223
222
|
connection.should_receive(:log).with("/foo/bar", request_body).once
|
@@ -228,6 +227,30 @@ module Neography
|
|
228
227
|
connection.stub(:evaluate_response).and_return expected_response
|
229
228
|
connection.get("/foo/bar").should eq expected_response
|
230
229
|
end
|
230
|
+
|
231
|
+
describe "slow_log_threshold" do
|
232
|
+
before do
|
233
|
+
connection.stub(:evaluate_response).and_return expected_response
|
234
|
+
end
|
235
|
+
|
236
|
+
context "default value" do
|
237
|
+
it "should have output" do
|
238
|
+
@logger.should_receive(:info).once
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
context "high value" do
|
243
|
+
before { connection.slow_log_threshold = 100_000 }
|
244
|
+
it "should not have output" do
|
245
|
+
@logger.should_not_receive(:info)
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
after do
|
250
|
+
connection.get("/foo/bar", {body: request_body})
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
231
254
|
end
|
232
255
|
end
|
233
256
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: neography
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max De Marzi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|