neography 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- neography (0.0.6)
5
- httparty (~> 0.6.1)
4
+ neography (0.0.7)
5
+ httparty (~> 0.7.3)
6
6
  json
7
7
 
8
8
  GEM
@@ -11,7 +11,7 @@ GEM
11
11
  crack (0.1.8)
12
12
  diff-lcs (1.1.2)
13
13
  fakeweb (1.3.0)
14
- httparty (0.6.1)
14
+ httparty (0.7.3)
15
15
  crack (= 0.1.8)
16
16
  json (1.4.6)
17
17
  json (1.4.6-java)
@@ -33,7 +33,7 @@ PLATFORMS
33
33
 
34
34
  DEPENDENCIES
35
35
  fakeweb (~> 1.3.0)
36
- httparty (~> 0.6.1)
36
+ httparty (~> 0.7.3)
37
37
  json
38
38
  neography!
39
39
  net-http-spy (~> 0.2.1)
data/README.rdoc CHANGED
@@ -46,12 +46,16 @@ Just add gem 'neography' to your Gemfile and run bundle install
46
46
 
47
47
  A thin ruby wrapper Neography::Rest which tries to mirror the Neo4j Rest API and returns JSON or Nil:
48
48
 
49
- # protocol, server, port, log_file, log_enabled, max_threads
50
- @neo = Neography::Rest.new ('http://', '192.168.10.1', 7479, 'log/neography.log', true, 50)
51
-
52
- Default Parameters are:
53
-
54
- @neo = Neography::Rest.new ('http://', 'localhost', 7474, '/neography.log', false, 20)
49
+ @neo = Neography::Rest.new({:protocol => 'http://',
50
+ :server => 'localhost',
51
+ :port => 7474,
52
+ :directory => '', # use '/<my directory>' or leave out for default
53
+ :authentication => 'basic', # 'basic', 'digest' or leave out for default
54
+ :username => 'your username', #leave out for default
55
+ :password => 'your password', #leave out for default
56
+ :log_file => 'neography.log',
57
+ :log_enabled => false,
58
+ :max_threads => 20})
55
59
 
56
60
  To Use:
57
61
 
@@ -136,7 +140,7 @@ Trying to mimic the Neo4j.rb API.
136
140
  Now we are returning full objects. The properties of the node or relationship can be accessed directly (node.name).
137
141
  The Neo4j ID is available by using node.neo_id .
138
142
 
139
- @neo2 = Neography::Rest.new ('http://', '192.168.10.1')
143
+ @neo2 = Neography::Rest.new ({:server => '192.168.10.1'})
140
144
 
141
145
  Neography::Node.create # Create an empty node
142
146
  Neography::Node.create("age" => 31, "name" => "Max") # Create a node with some properties
@@ -228,13 +232,20 @@ See Neo4j API for:
228
232
 
229
233
  === Examples
230
234
 
231
- A couple of examples borrowed from Matthew Deiters's Neo4jr-social
235
+ A couple of examples borrowed from Matthew Deiters's Neo4jr-social:
232
236
 
233
237
  * {Facebook}[https://github.com/maxdemarzi/neography/blob/master/examples/facebook.rb]
234
238
  * {Linked In}[https://github.com/maxdemarzi/neography/blob/master/examples/linkedin.rb]
235
239
 
240
+ Phase 2 way of doing these:
241
+
242
+ * {Facebook}[https://github.com/maxdemarzi/neography/blob/master/examples/facebook_v2.rb]
243
+ * {Linked In}[https://github.com/maxdemarzi/neography/blob/master/examples/linkedin_v2.rb]
244
+
245
+
236
246
  === To Do
237
247
 
248
+ * Phase 2 Index functionality
238
249
  * More Tests
239
250
  * More Examples
240
251
  * Mixins ?
@@ -1,14 +1,15 @@
1
1
  module Neography
2
2
  class Config
3
- class << self; attr_accessor :protocol, :server, :port, :log_file, :log_enabled, :logger, :max_threads end
3
+ class << self; attr_accessor :protocol, :server, :port, :directory, :log_file, :log_enabled, :logger, :max_threads, :authentication end
4
4
 
5
5
  @protocol = 'http://'
6
6
  @server = 'localhost'
7
7
  @port = 7474
8
+ @directory = ''
8
9
  @log_file = 'neography.log'
9
10
  @log_enabled = false
10
11
  @logger = Logger.new(@log_file) if @log_enabled
11
12
  @max_threads = 20
12
-
13
+ @authentication = {}
13
14
  end
14
15
  end
@@ -1,31 +1,41 @@
1
1
  module Neography
2
2
  class Rest
3
3
  include HTTParty
4
- attr_accessor :protocol, :server, :port, :log_file, :log_enabled, :logger, :max_threads
5
-
6
- def initialize(protocol=Neography::Config.protocol,
7
- server=Neography::Config.server,
8
- port=Neography::Config.port,
9
- log_file=Neography::Config.log_file,
10
- log_enabled=Neography::Config.log_enabled,
11
- max_threads=Neography::Config.max_threads)
12
- @protocol = protocol
13
- @server = server
14
- @port = port
15
- @log_file = log_file
16
- @log_enabled = log_enabled
17
- @logger = Logger.new(@log_file) if @log_enabled
18
- @max_threads = max_threads
19
- end
20
4
 
21
- def configure(protocol, server, port)
5
+ attr_accessor :protocol, :server, :port, :directory, :log_file, :log_enabled, :logger, :max_threads, :authentication, :username, :password
6
+
7
+ def initialize(options={})
8
+ init = {:protocol => Neography::Config.protocol,
9
+ :server => Neography::Config.server,
10
+ :port => Neography::Config.port,
11
+ :directory => Neography::Config.directory,
12
+ :log_file => Neography::Config.log_file,
13
+ :log_enabled => Neography::Config.log_enabled,
14
+ :max_threads => Neography::Config.max_threads,
15
+ :authentication => Neography::Config.authentication}
16
+ init.merge!(options)
17
+
18
+ @protocol = init[:protocol]
19
+ @server = init[:server]
20
+ @port = init[:port]
21
+ @directory = init[:directory]
22
+ @log_file = init[:log_file]
23
+ @log_enabled = init[:log_enabled]
24
+ @logger = Logger.new(@log_file) if @log_enabled
25
+ @max_threads = init[:max_threads]
26
+ @authentication = Hash.new
27
+ @authentication = {"#{init[:authentication]}_auth".to_sym => {:username => init[:username], :password => init[:password]}} unless init[:authentication].empty?
28
+ end
29
+
30
+ def configure(protocol, server, port, directory)
22
31
  @protocol = protocol
23
32
  @server = server
24
33
  @port = port
34
+ @directory = directory
25
35
  end
26
36
 
27
37
  def configuration
28
- @protocol + @server + ':' + @port.to_s + "/db/data"
38
+ @protocol + @server + ':' + @port.to_s + @directory + "/db/data"
29
39
  end
30
40
 
31
41
  def get_root
@@ -277,19 +287,19 @@ module Neography
277
287
  end
278
288
 
279
289
  def get(path,options={})
280
- evaluate_response(HTTParty.get(configuration + path, options))
290
+ evaluate_response(HTTParty.get(configuration + path, options.merge!(@authentication)))
281
291
  end
282
292
 
283
293
  def post(path,options={})
284
- evaluate_response(HTTParty.post(configuration + path, options))
294
+ evaluate_response(HTTParty.post(configuration + path, options.merge!(@authentication)))
285
295
  end
286
296
 
287
297
  def put(path,options={})
288
- evaluate_response(HTTParty.put(configuration + path, options))
298
+ evaluate_response(HTTParty.put(configuration + path, options.merge!(@authentication)))
289
299
  end
290
300
 
291
301
  def delete(path,options={})
292
- evaluate_response(HTTParty.delete(configuration + path, options))
302
+ evaluate_response(HTTParty.delete(configuration + path, options.merge!(@authentication)))
293
303
  end
294
304
 
295
305
  def get_id(id)
@@ -1,3 +1,3 @@
1
1
  module Neography
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
data/neography.gemspec CHANGED
@@ -22,6 +22,6 @@ Gem::Specification.new do |s|
22
22
  s.add_development_dependency "rspec", "~> 2.0.0.beta.22"
23
23
  s.add_development_dependency "net-http-spy", "~> 0.2.1"
24
24
  s.add_development_dependency "fakeweb", "~> 1.3.0"
25
- s.add_dependency "httparty", "~> 0.6.1"
25
+ s.add_dependency "httparty", "~> 0.7.3"
26
26
  s.add_dependency "json"
27
27
  end
@@ -0,0 +1,21 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
+
3
+ describe Neography::Rest do
4
+ before(:each) do
5
+ @neo = Neography::Rest.new({:server => '4c36b641.neo4j.atns.de', :port => 7474, :directory => '/9dc1fda5be8b5cde29621e21cae5adece3de0f37', :authentication => 'basic', :username => "abbe3c012", :password => "34d7b22eb"})
6
+ end
7
+
8
+ describe "get_root" do
9
+ it "can get the root node" do
10
+ root_node = @neo.get_root
11
+ root_node.should have_key("reference_node")
12
+ end
13
+ end
14
+
15
+ describe "create_node" do
16
+ it "can create an empty node" do
17
+ new_node = @neo.create_node
18
+ new_node.should_not be_nil
19
+ end
20
+ end
21
+ end
@@ -7,6 +7,10 @@ describe Neography::Rest do
7
7
 
8
8
  describe "list indexes" do
9
9
  it "can get a listing of indexes" do
10
+ new_node = @neo.create_node
11
+ key = generate_text(6)
12
+ value = generate_text
13
+ @neo.add_to_index("test_index", key, value, new_node)
10
14
  @neo.list_indexes.should_not be_nil
11
15
  end
12
16
  end
@@ -16,10 +20,10 @@ describe Neography::Rest do
16
20
  new_node = @neo.create_node
17
21
  key = generate_text(6)
18
22
  value = generate_text
19
- @neo.add_to_index(key, value, new_node)
20
- new_index = @neo.get_index(key, value)
23
+ @neo.add_to_index("test_index", key, value, new_node)
24
+ new_index = @neo.get_index("test_index", key, value)
21
25
  new_index.should_not be_nil
22
- @neo.remove_from_index(key, value, new_node)
26
+ @neo.remove_from_index("test_index", key, value, new_node)
23
27
  end
24
28
  end
25
29
 
@@ -28,11 +32,11 @@ describe Neography::Rest do
28
32
  new_node = @neo.create_node
29
33
  key = generate_text(6)
30
34
  value = generate_text
31
- @neo.add_to_index(key, value, new_node)
32
- new_index = @neo.get_index(key, value)
35
+ @neo.add_to_index("test_index", key, value, new_node)
36
+ new_index = @neo.get_index("test_index", key, value)
33
37
  new_index.should_not be_nil
34
- @neo.remove_from_index(key, value, new_node)
35
- new_index = @neo.get_index(key, value)
38
+ @neo.remove_from_index("test_index", key, value, new_node)
39
+ new_index = @neo.get_index("test_index", key, value)
36
40
  new_index.should be_nil
37
41
  end
38
42
  end
@@ -42,10 +46,10 @@ describe Neography::Rest do
42
46
  new_node = @neo.create_node
43
47
  key = generate_text(6)
44
48
  value = generate_text
45
- @neo.add_to_index(key, value, new_node)
46
- new_index = @neo.get_index(key, value)
49
+ @neo.add_to_index("test_index", key, value, new_node)
50
+ new_index = @neo.get_index("test_index", key, value)
47
51
  new_index.should_not be_nil
48
- @neo.remove_from_index(key, value, new_node)
52
+ @neo.remove_from_index("test_index", key, value, new_node)
49
53
  end
50
54
  end
51
55
 
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neography
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 13
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 8
9
- version: 0.0.8
9
+ - 9
10
+ version: 0.0.9
10
11
  platform: ruby
11
12
  authors:
12
13
  - Max De Marzi
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2011-01-07 00:00:00 -08:00
18
+ date: 2011-02-04 00:00:00 -08:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
@@ -25,6 +26,7 @@ dependencies:
25
26
  requirements:
26
27
  - - ~>
27
28
  - !ruby/object:Gem::Version
29
+ hash: 62196431
28
30
  segments:
29
31
  - 2
30
32
  - 0
@@ -42,6 +44,7 @@ dependencies:
42
44
  requirements:
43
45
  - - ~>
44
46
  - !ruby/object:Gem::Version
47
+ hash: 21
45
48
  segments:
46
49
  - 0
47
50
  - 2
@@ -57,6 +60,7 @@ dependencies:
57
60
  requirements:
58
61
  - - ~>
59
62
  - !ruby/object:Gem::Version
63
+ hash: 27
60
64
  segments:
61
65
  - 1
62
66
  - 3
@@ -72,11 +76,12 @@ dependencies:
72
76
  requirements:
73
77
  - - ~>
74
78
  - !ruby/object:Gem::Version
79
+ hash: 5
75
80
  segments:
76
81
  - 0
77
- - 6
78
- - 1
79
- version: 0.6.1
82
+ - 7
83
+ - 3
84
+ version: 0.7.3
80
85
  type: :runtime
81
86
  version_requirements: *id004
82
87
  - !ruby/object:Gem::Dependency
@@ -87,6 +92,7 @@ dependencies:
87
92
  requirements:
88
93
  - - ">="
89
94
  - !ruby/object:Gem::Version
95
+ hash: 3
90
96
  segments:
91
97
  - 0
92
98
  version: "0"
@@ -129,6 +135,7 @@ files:
129
135
  - lib/neography/rest.rb
130
136
  - lib/neography/version.rb
131
137
  - neography.gemspec
138
+ - spec/integration/heroku_spec.rb
132
139
  - spec/integration/neography_spec.rb
133
140
  - spec/integration/node_path_spec.rb
134
141
  - spec/integration/node_relationship_spec.rb
@@ -157,6 +164,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
157
164
  requirements:
158
165
  - - ">="
159
166
  - !ruby/object:Gem::Version
167
+ hash: 3
160
168
  segments:
161
169
  - 0
162
170
  version: "0"
@@ -165,6 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
173
  requirements:
166
174
  - - ">="
167
175
  - !ruby/object:Gem::Version
176
+ hash: 3
168
177
  segments:
169
178
  - 0
170
179
  version: "0"