neography 1.3.3 → 1.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 63bed4cfc7bc257265d2d317fa6a5aeb1c79f7cd
4
- data.tar.gz: aba3524e3ce8d229cbd0ac3a666a481fc5e2563b
3
+ metadata.gz: 581fe5af6cd93c2dfeced6167fdf507c41dd508e
4
+ data.tar.gz: a2cbef7d720a7988035fc199e89516ee7acce42d
5
5
  SHA512:
6
- metadata.gz: 5f871cc995270d7f955341023e442c59747b6cd564d9919b5fc0c83a7629412b85775d24cc814748d34c51c0e37acb3e477afd56243206d35802afb962058f29
7
- data.tar.gz: f1bf27c99fe44fcdd85a992e2d3aacb0dd1afca8018d8308b6037a23d1c3fc1f221475b28e065d8c0cc23d7f5d8c63bb0b4fc31683445ad3a0dae9e789ba5d4e
6
+ metadata.gz: e51373c2a7cbe9a45b740f9ae8ac2af1d7738c5d3b4b2a00d977b6137b68df2a1fd3e15e118687ce19ac2f2d39eab7efac785697bc059ad5fc8cf998534b4082
7
+ data.tar.gz: 91544b56b7f1f4d69ce9d0fadc438f4591721654176cb586ad8ddcd9a5b98d38697ab3f75dcfcf7d1358c94c30a613c5708f76164aef14e0e6f3e17f5d129cf4
@@ -268,8 +268,8 @@ module Neography
268
268
  end
269
269
  alias_method :list_indexes, :list_node_indexes
270
270
 
271
- def create_node_index(name, type = "exact", provider = "lucene")
272
- @node_indexes.create(name, type, provider)
271
+ def create_node_index(name, type = "exact", provider = "lucene", extra_config = nil)
272
+ @node_indexes.create(name, type, provider, extra_config)
273
273
  end
274
274
 
275
275
  def create_node_auto_index(type = "exact", provider = "lucene")
@@ -54,13 +54,15 @@ module Neography
54
54
 
55
55
  # NodeIndexes
56
56
 
57
- def create_node_index(name, type = "exact", provider = "lucene")
57
+ def create_node_index(name, type = "exact", provider = "lucene", extra_config = nil)
58
+ config = {
59
+ :type => type,
60
+ :provider => provider
61
+ }
62
+ config.merge!(extra_config) unless extra_config.nil?
58
63
  post NodeIndexes.all_path do
59
64
  { :name => name,
60
- :config => {
61
- :type => type,
62
- :provider => provider
63
- }
65
+ :config => config
64
66
  }
65
67
  end
66
68
  end
@@ -112,6 +114,14 @@ module Neography
112
114
  end
113
115
  end
114
116
 
117
+ # NodeLabel
118
+
119
+ def add_label(id, body)
120
+ post build_node_uri(id) + "/labels" do
121
+ body
122
+ end
123
+ end
124
+
115
125
  # NodeRelationships
116
126
 
117
127
  def get_node_relationships(id, direction = nil, types = nil)
@@ -12,14 +12,16 @@ module Neography
12
12
  @connection.get(all_path)
13
13
  end
14
14
 
15
- def create(name, type = "exact", provider = "lucene")
15
+ def create(name, type = "exact", provider = "lucene", extra_config = nil)
16
+ config = {
17
+ :type => type,
18
+ :provider => provider
19
+ }
20
+ config.merge!(extra_config) unless extra_config.nil?
16
21
  options = {
17
22
  :body => (
18
23
  { :name => name,
19
- :config => {
20
- :type => type,
21
- :provider => provider
22
- }
24
+ :config => config
23
25
  }
24
26
  ).to_json,
25
27
  :headers => json_content_type
@@ -7,7 +7,7 @@ module Neography
7
7
  add_path :base, "/labels"
8
8
  add_path :node, "/node/:id/labels"
9
9
  add_path :nodes, "/label/:label/nodes"
10
- add_path :find, "/label/:label/nodes?:property=%22:value%22"
10
+ add_path :find, "/label/:label/nodes?:property=:value"
11
11
  add_path :delete, "/node/:id/labels/:label"
12
12
 
13
13
  def initialize(connection)
@@ -21,9 +21,19 @@ module Neography
21
21
  end
22
22
  end
23
23
 
24
+
24
25
  def build_path(path, attributes)
25
- path.gsub(/:([\w_]*)/) do
26
- encode(attributes[$1.to_sym].to_s)
26
+ p = String.new(path)
27
+ p.gsub!(/=:([\w_]*)/) do
28
+ if $1.to_sym == :value and attributes[$1.to_sym].class == String
29
+ "=%22"+encode(attributes[$1.to_sym].to_s)+"%22";
30
+ else
31
+ "="+encode(attributes[$1.to_sym].to_s)
32
+ end
33
+ end
34
+
35
+ p.gsub(/:([\w_]*)/) do
36
+ encode(attributes[$1.to_sym].to_s)
27
37
  end
28
38
  end
29
39
 
@@ -1,3 +1,3 @@
1
1
  module Neography
2
- VERSION = "1.3.3"
2
+ VERSION = "1.3.4"
3
3
  end
data/neography.gemspec CHANGED
@@ -11,7 +11,8 @@ Gem::Specification.new do |s|
11
11
  s.homepage = "http://rubygems.org/gems/neography"
12
12
  s.summary = "ruby wrapper to Neo4j Rest API"
13
13
  s.description = "A Ruby wrapper to the Neo4j Rest API see http://docs.neo4j.org/chunked/stable/rest-api.html for more details."
14
-
14
+ s.license = 'MIT'
15
+
15
16
  s.rubyforge_project = "neography"
16
17
 
17
18
  s.files = `git ls-files`.split("\n")
@@ -44,6 +44,16 @@ describe Neography::Rest do
44
44
  new_index["type"].should == "fulltext"
45
45
  end
46
46
 
47
+ it "can create a node index with extra configuration options" do
48
+ name = generate_text(6)
49
+ new_index = @neo.create_node_index(name, "fulltext","lucene", extra: 'extra-value')
50
+ new_index.should_not be_nil
51
+ new_index["template"].should == "#{@neo.configuration}/index/node/#{name}/{key}/{value}"
52
+ new_index["provider"].should == "lucene"
53
+ new_index["extra"].should == "extra-value"
54
+ new_index["type"].should == "fulltext"
55
+ end
56
+
47
57
  it "can create a relationship index" do
48
58
  name = generate_text(6)
49
59
  new_index = @neo.create_relationship_index(name)
@@ -105,6 +105,16 @@ module Neography
105
105
  [:reset_node_properties, "index2", { "key2" => "value2" } ]
106
106
  end
107
107
 
108
+ it "adds a node label" do
109
+ expected_body = [
110
+ { "id" => 0, "method" => "POST", "to" => "{0}/labels", "body" => "foo" },
111
+ { "id" => 1, "method" => "POST", "to" => "{0}/labels", "body" => "bar" },
112
+ ]
113
+ connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
114
+ subject.execute [:add_label, "{0}", "foo"],
115
+ [:add_label, "{0}", "bar"]
116
+ end
117
+
108
118
  it "gets node relationships" do
109
119
  expected_body = [
110
120
  { "id" => 0, "method" => "GET", "to" => "/node/id1/relationships/direction1" },
@@ -22,11 +22,16 @@ module Neography
22
22
  subject.get_nodes("person")
23
23
  end
24
24
 
25
- it "find nodes for labels and property" do
25
+ it "find nodes for labels and property string" do
26
26
  connection.should_receive(:get).with("/label/person/nodes?name=%22max%22")
27
27
  subject.find_nodes("person", {:name => "max"})
28
28
  end
29
29
 
30
+ it "find nodes for labels and property integer" do
31
+ connection.should_receive(:get).with("/label/person/nodes?age=26")
32
+ subject.find_nodes("person", {:age => 26})
33
+ end
34
+
30
35
  it "can add a label to a node" do
31
36
  options = {
32
37
  :body => '["Actor"]',
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.3.3
4
+ version: 1.3.4
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-26 00:00:00.000000000 Z
11
+ date: 2013-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -277,7 +277,8 @@ files:
277
277
  - spec/unit/rest/schema_index_spec.rb
278
278
  - spec/unit/rest/transactions_spec.rb
279
279
  homepage: http://rubygems.org/gems/neography
280
- licenses: []
280
+ licenses:
281
+ - MIT
281
282
  metadata: {}
282
283
  post_install_message:
283
284
  rdoc_options: []