neography 1.1.4 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -3,7 +3,7 @@ Neography
3
3
 
4
4
  - [![Gem Version](https://badge.fury.io/rb/neography.png)](https://rubygems.org/gems/neography)
5
5
  - [![Build Status](https://secure.travis-ci.org/maxdemarzi/neography.png?branch=master)](http://travis-ci.org/maxdemarzi/neography)
6
- - [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/maxdemarzi/neography)
6
+ - [![Code Climate](https://codeclimate.com/github/maxdemarzi/neography.png)](https://codeclimate.com/github/maxdemarzi/neography)
7
7
  - [![Coverage Status](https://coveralls.io/repos/maxdemarzi/neography/badge.png?branch=master)](https://coveralls.io/r/maxdemarzi/neography)
8
8
 
9
9
  ## Welcome to Neography
data/lib/neography.rb CHANGED
@@ -5,7 +5,7 @@ require 'multi_json'
5
5
  require 'logger'
6
6
  require 'ostruct'
7
7
  require 'os'
8
- require 'zip/zipfilesystem'
8
+ require 'zip/filesystem'
9
9
 
10
10
  require 'neography/multi_json_parser'
11
11
 
@@ -3,7 +3,8 @@ module Neography
3
3
  end
4
4
  class Connection
5
5
  USER_AGENT = "Neography/#{Neography::VERSION}"
6
-
6
+ ACTIONS = ["get", "post", "put", "delete"]
7
+
7
8
  attr_accessor :protocol, :server, :port, :directory,
8
9
  :cypher_path, :gremlin_path,
9
10
  :log_file, :log_enabled, :logger,
@@ -27,7 +28,7 @@ module Neography
27
28
  end
28
29
 
29
30
  def configuration
30
- "#{@protocol}#{@server}:#{@port}#{@directory}/db/data"
31
+ @configuration ||= "#{@protocol}#{@server}:#{@port}#{@directory}/db/data"
31
32
  end
32
33
 
33
34
  def merge_options(options)
@@ -37,24 +38,11 @@ module Neography
37
38
  merged_options
38
39
  end
39
40
 
40
- def get(path, options={})
41
- authenticate(configuration + path)
42
- evaluate_response(@client.get(configuration + path, merge_options(options)[:body], merge_options(options)[:headers]))
43
- end
44
-
45
- def post(path, options={})
46
- authenticate(configuration + path)
47
- evaluate_response(@client.post(configuration + path, merge_options(options)[:body], merge_options(options)[:headers]))
48
- end
49
-
50
- def put(path, options={})
51
- authenticate(configuration + path)
52
- evaluate_response(@client.put(configuration + path, merge_options(options)[:body], merge_options(options)[:headers]))
53
- end
54
-
55
- def delete(path, options={})
56
- authenticate(configuration + path)
57
- evaluate_response(@client.delete(configuration + path, merge_options(options)[:body], merge_options(options)[:headers]))
41
+ ACTIONS.each do |action|
42
+ define_method(action) do |path, options = {}|
43
+ authenticate(configuration + path)
44
+ evaluate_response(@client.send(action.to_sym, configuration + path, merge_options(options)[:body], merge_options(options)[:headers]))
45
+ end
58
46
  end
59
47
 
60
48
  def authenticate(path)
@@ -172,29 +160,29 @@ module Neography
172
160
  end
173
161
 
174
162
  def raise_errors(code, exception, message, stacktrace)
163
+ error = nil
175
164
  case code
176
- when 400, 404
177
- case exception
178
- when /SyntaxException/ ; raise SyntaxException.new(message, code, stacktrace)
179
- when /this is not a query/ ; raise SyntaxException.new(message, code, stacktrace)
180
- when /PropertyValueException/ ; raise PropertyValueException.new(message, code, stacktrace)
181
- when /BadInputException/ ; raise BadInputException.new(message, code, stacktrace)
182
- when /NodeNotFoundException/ ; raise NodeNotFoundException.new(message, code, stacktrace)
183
- when /NoSuchPropertyException/ ; raise NoSuchPropertyException.new(message, code, stacktrace)
184
- when /RelationshipNotFoundException/ ; raise RelationshipNotFoundException.new(message, code, stacktrace)
185
- when /NotFoundException/ ; raise NotFoundException.new(message, code, stacktrace)
186
- when /UniquePathNotUniqueException/ ; raise UniquePathNotUniqueException.new(message, code, stacktrace)
165
+ when 401
166
+ error = UnauthorizedError
167
+ when 409
168
+ error = OperationFailureException
169
+ end
170
+
171
+ error ||= case exception
172
+ when /SyntaxException/ ; SyntaxException
173
+ when /this is not a query/ ; SyntaxException
174
+ when /PropertyValueException/ ; PropertyValueException
175
+ when /BadInputException/ ; BadInputException
176
+ when /NodeNotFoundException/ ; NodeNotFoundException
177
+ when /NoSuchPropertyException/ ; NoSuchPropertyException
178
+ when /RelationshipNotFoundException/ ; RelationshipNotFoundException
179
+ when /NotFoundException/ ; NotFoundException
180
+ when /UniquePathNotUniqueException/ ; UniquePathNotUniqueException
187
181
  else
188
- raise NeographyError.new(message, code, stacktrace)
189
- end
190
- when 401
191
- raise UnauthorizedError.new(message, code, stacktrace)
192
- when 409
193
- raise OperationFailureException.new(message, code, stacktrace)
194
- else
195
- raise NeographyError.new(message, code, stacktrace)
182
+ NeographyError
196
183
  end
197
184
 
185
+ raise error.new(message, code, stacktrace)
198
186
  end
199
187
 
200
188
  def parse_string_options(options)
@@ -1,13 +1,13 @@
1
1
  # borrowed from architect4r
2
2
  require 'os'
3
3
  require 'httpclient'
4
- require 'zip/zip'
4
+ require 'zip'
5
5
  require 'net/http'
6
6
 
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")
10
+ args.with_defaults(:edition => "community", :version => "1.9.3")
11
11
  puts "Installing Neo4j-#{args[:edition]}-#{args[:version]}"
12
12
 
13
13
  if OS::Underlying.windows?
@@ -29,7 +29,7 @@ namespace :neo4j do
29
29
 
30
30
  # Extract and move to neo4j directory
31
31
  unless File.exist?('neo4j')
32
- Zip::ZipFile.open('neo4j.zip') do |zip_file|
32
+ Zip::File.open('neo4j.zip') do |zip_file|
33
33
  zip_file.each do |f|
34
34
  f_path=File.join(".", f.name)
35
35
  FileUtils.mkdir_p(File.dirname(f_path))
@@ -1,3 +1,3 @@
1
1
  module Neography
2
- VERSION = "1.1.4"
2
+ VERSION = "1.2.0"
3
3
  end
data/neography.gemspec CHANGED
@@ -27,6 +27,6 @@ Gem::Specification.new do |s|
27
27
  s.add_dependency "rake", ">= 0.8.7"
28
28
  s.add_dependency "json", ">= 1.7.7"
29
29
  s.add_dependency "os", ">= 0.9.6"
30
- s.add_dependency "rubyzip", "~> 0.9.7"
31
- s.add_dependency "multi_json", ">= 1.3.2"
30
+ s.add_dependency "rubyzip", "~> 1.0.0"
31
+ s.add_dependency "multi_json", ">= 1.3.2"
32
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neography
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-30 00:00:00.000000000 Z
12
+ date: 2013-09-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -146,7 +146,7 @@ dependencies:
146
146
  requirements:
147
147
  - - ~>
148
148
  - !ruby/object:Gem::Version
149
- version: 0.9.7
149
+ version: 1.0.0
150
150
  type: :runtime
151
151
  prerelease: false
152
152
  version_requirements: !ruby/object:Gem::Requirement
@@ -154,7 +154,7 @@ dependencies:
154
154
  requirements:
155
155
  - - ~>
156
156
  - !ruby/object:Gem::Version
157
- version: 0.9.7
157
+ version: 1.0.0
158
158
  - !ruby/object:Gem::Dependency
159
159
  name: multi_json
160
160
  requirement: !ruby/object:Gem::Requirement