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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fcd694c03de5bbb920692ee87085c2da39815c2b
4
- data.tar.gz: 27cac259abff49d847b099819c6c5bd7f617f69f
3
+ metadata.gz: c6478336dc213df2da26cfd9db4c8814222ea162
4
+ data.tar.gz: 7d94c3529e2e0464108f16cfa58887db58b00940
5
5
  SHA512:
6
- metadata.gz: 31203feeec0907870e2be162a47f201c78a1ab5e306119e6dd018ed711365f35b9580d87b48bfdb842b4e1f003162db2e2bf2b4bfa65ef9f1ad72a030ecd1e23
7
- data.tar.gz: 79270c702fb7e25a6c9a8a2858dc510dbad1c60a333df6ecc2e7105c431ecee60be0371bba1c6c12ac9c755f511e772e19ea9b76e0c1f5952f34b250711c017e
6
+ metadata.gz: 2435540bf31595f410aab104dd8d3d3d848cb45b03daee4d2d45233fd886234bc4de048221f5dadb6caf50452b291b83126854837072ead1d15e2444bd5ddc0d
7
+ data.tar.gz: 8e9590e796a496cf69c1c4cf11c298a67dd602ab79d8fd9a3a1ec2c7912d6df433940ff6527e9593f378f84a0da620e94faab524ba5a01fa464ebc4edb7376f8
data/.travis.yml CHANGED
@@ -1,4 +1,4 @@
1
- script: "bundle exec rake neo4j:install['enterprise','2.0.0-M06'] neo4j:start spec --trace"
1
+ script: "bundle exec rake neo4j:install['enterprise','2.0.0'] neo4j:start spec --trace"
2
2
  language: ruby
3
3
  rvm:
4
4
  - 1.9.3
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 = "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.max_threads = 20
73
- config.authentication = nil # 'basic' or 'digest'
74
- config.username = nil
75
- config.password = nil
76
- config.parser = MultiJsonParser
77
- end
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
 
@@ -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 => @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
- :max_threads => @max_threads,
26
- :authentication => @authentication,
27
- :username => @username,
28
- :password => @password,
29
- :parser => @parser
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 = "http://"
37
- @server = "localhost"
38
- @port = 7474
39
- @directory = ""
40
- @cypher_path = "/cypher"
41
- @gremlin_path = "/ext/GremlinPlugin/graphdb/execute_script"
42
- @log_file = "neography.log"
43
- @log_enabled = false
44
- @max_threads = 20
45
- @authentication = nil
46
- @username = nil
47
- @password = nil
48
- @parser = MultiJsonParser
49
- end
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
@@ -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 = 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
- @max_threads = config[:max_threads]
88
- @parser = config[:parser]
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
 
@@ -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 => "1.9.4")
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?
@@ -1,3 +1,3 @@
1
1
  module Neography
2
- VERSION = "1.2.4"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Neography do
4
- describe "ref_node" do
4
+ describe "ref_node", :reference => true do
5
5
  it "can get the reference node" do
6
6
  root_node = Neography.ref_node
7
7
  root_node.should have_key("self")
@@ -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["property-keys"].should include("name")
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["property-keys"].should include("name")
22
+ si.first["property_keys"].should include("name")
23
23
  end
24
24
  end
25
25
 
data/spec/spec_helper.rb CHANGED
@@ -17,7 +17,7 @@ def generate_text(length=8)
17
17
  end
18
18
 
19
19
  RSpec.configure do |c|
20
- c.filter_run_excluding :slow => true, :gremlin => true
20
+ c.filter_run_excluding :slow => true, :gremlin => true, :reference => true
21
21
  end
22
22
 
23
23
 
@@ -7,35 +7,37 @@ module Neography
7
7
 
8
8
  context "defaults" do
9
9
 
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(:max_threads) { should == 20 }
19
- its(:authentication) { should == nil }
20
- its(:username) { should == nil }
21
- its(:password) { should == nil }
22
- its(:parser) { should == MultiJsonParser}
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 => 'http://',
27
- :server => 'localhost',
28
- :port => 7474,
29
- :directory => '',
30
- :cypher_path => '/cypher',
31
- :gremlin_path => '/ext/GremlinPlugin/graphdb/execute_script',
32
- :log_file => 'neography.log',
33
- :log_enabled => false,
34
- :max_threads => 20,
35
- :authentication => nil,
36
- :username => nil,
37
- :password => nil,
38
- :parser => MultiJsonParser
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 => "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
- :max_threads => 10,
32
- :parser => Foo,
33
- :authentication => "foo",
34
- :username => "bar",
35
- :password => "baz"
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 == "https://"
43
- connection.server.should == "foobar"
44
- connection.port.should == 4242
45
- connection.directory.should == "/dir"
46
- connection.cypher_path.should == "/cyph"
47
- connection.gremlin_path.should == "/grem"
48
- connection.log_file.should == "neo.log"
49
- connection.log_enabled.should == false
50
- connection.max_threads.should == 10
51
- connection.parser.should == Foo
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
- connection.logger = Logger.new(nil)
212
+ @logger = Logger.new(nil)
213
+ connection.logger = @logger
211
214
  connection.log_enabled = true
212
215
  end
213
216
 
214
- let :expected_response do
215
- "expected_response"
216
- end
217
+ let(:expected_response) {"expected_response"}
217
218
 
218
- let :request_body do
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.2.4
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-05 00:00:00.000000000 Z
11
+ date: 2013-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec