orientdb4r 0.2.9 → 0.2.10

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.
data/changelog.txt CHANGED
@@ -3,6 +3,8 @@
3
3
  - 'rest-client' replaced by 'excon' for HTTP communication with Keep-Alive
4
4
  - introduced support for distributed server
5
5
 
6
+ 0.2.10 /07/07/21
7
+ - experimental support for Excon HTTP library with Keep-Alive connection
6
8
 
7
9
  0.2.9 /07/07/18
8
10
  - introduced class Rid
@@ -18,12 +18,6 @@ module Orientdb4r
18
18
  end
19
19
 
20
20
 
21
- ###
22
- # Identifies technology backgound of this node implementation.
23
- def identification
24
- raise NotImplementedError, 'this should be overridden by subclass'
25
- end
26
-
27
21
  ###
28
22
  # Cleans up resources used by the node.
29
23
  def cleanup
@@ -9,17 +9,35 @@ module Orientdb4r
9
9
  before [:create_document, :get_document, :update_document, :delete_document], :assert_connected
10
10
  around [:query, :command], :time_around
11
11
 
12
- attr_reader :user, :password, :database
12
+ attr_reader :user, :password, :database, :http_lib
13
13
 
14
14
 
15
15
  def initialize(options) #:nodoc:
16
16
  super()
17
- options_pattern = { :host => 'localhost', :port => 2480, :ssl => false }
17
+ options_pattern = { :host => 'localhost', :port => 2480, :ssl => false,
18
+ :nodes => :optional,
19
+ :connection_library => :restclient}
18
20
  verify_and_sanitize_options(options, options_pattern)
19
21
 
20
- raise ArgumentError, 'no node type defined in context' unless Orientdb4r::context.include? :node_type
21
- @nodes << Orientdb4r::context[:node_type].new(options[:host], options[:port], options[:ssl])
22
- Orientdb4r::logger.debug "client with communication driver: #{a_node.identification}"
22
+ # fake nodes for single server
23
+ unless options[:nodes].nil?
24
+ options[:nodes] = [{:host => options[:host], :port => options[:port], :ssl => options[:ssl]}]
25
+ end
26
+ raise ArgumentError, 'nodes has to be arrray' unless options[:nodes].is_a? Array
27
+
28
+ node_clazz = case options[:connection_library]
29
+ when :restclient then Orientdb4r::RestClientNode
30
+ when :excon then Orientdb4r::ExconNode
31
+ else raise ArgumentError, "unknown connection library: #{options[:connection_library]}"
32
+ end
33
+ @http_lib = options[:connection_library]
34
+
35
+ options[:nodes].each do |node_options|
36
+ @nodes << node_clazz.new(options[:host], options[:port], options[:ssl])
37
+ verify_and_sanitize_options(node_options, options_pattern)
38
+ end
39
+
40
+ Orientdb4r::logger.info "client initialized, #{@nodes.size} node(s) with connection library = #{options[:connection_library]}"
23
41
  end
24
42
 
25
43
 
@@ -303,8 +321,8 @@ module Orientdb4r
303
321
  raise OrientdbError, "unexpected return code, code=#{response.code}, body=#{compose_error_message(response)}"
304
322
  end
305
323
 
306
- content_type = response.headers[:content_type] if Orientdb4r::context[:node_type] == RestClientNode
307
- content_type = response.headers['Content-Type'] if Orientdb4r::context[:node_type] == ExconNode
324
+ content_type = response.headers[:content_type] if http_lib == :restclient
325
+ content_type = response.headers['Content-Type'] if http_lib == :excon
308
326
  content_type ||= 'text/plain'
309
327
 
310
328
  rslt = case
@@ -7,12 +7,6 @@ module Orientdb4r
7
7
  # accessible view REST API and 'excon' library on the client side.
8
8
  class ExconNode < RestNode
9
9
 
10
-
11
- def identification #:nodoc:
12
- 'excon'
13
- end
14
-
15
-
16
10
  def oo_request(options) #:nodoc:
17
11
  address = "#{url}/#{options[:uri]}"
18
12
  headers = {}
@@ -7,12 +7,6 @@ module Orientdb4r
7
7
  # accessible view REST API and 'rest-client' library on the client side.
8
8
  class RestClientNode < RestNode
9
9
 
10
-
11
- def identification #:nodoc:
12
- 'rest-client'
13
- end
14
-
15
-
16
10
  def oo_request(options) #:nodoc:
17
11
  begin
18
12
  options[:url] = "#{url}/#{options[:uri]}"
@@ -23,15 +23,19 @@ module Orientdb4r
23
23
  self.document_id = ids[1].to_i
24
24
  end
25
25
 
26
+ ###
27
+ # Setter fo cluster ID.
26
28
  def cluster_id=(cid)
27
29
  @cluster_id = cid.to_i
28
30
  end
29
31
 
32
+ ###
33
+ # Setter fo document ID.
30
34
  def document_id=(did)
31
35
  @document_id = did.to_i
32
36
  end
33
37
 
34
- def to_s
38
+ def to_s #:nodoc:
35
39
  "##{cluster_id}:#{document_id}"
36
40
  end
37
41
 
@@ -2,22 +2,23 @@ module Orientdb4r
2
2
 
3
3
  # Version history.
4
4
  VERSION_HISTORY = [
5
- ['0.2.9', '2012-07-18', "Added feature Client#delete_database, New class Rid"],
6
- ['0.2.8', '2012-07-16', "New exception handling, added feature Client#create_class(:properties)"],
7
- ['0.2.7', '2012-07-07', "Added method Client#class_exists?"],
8
- ['0.2.6', '2012-07-03', "BF #8, BF #6"],
9
- ['0.2.5', '2012-07-01', "Added 'get_database' into database CRUD"],
5
+ ['0.2.10', '2012-07-21', "Experimental support for Excon HTTP library with Keep-Alive connection"],
6
+ ['0.2.9', '2012-07-18', "Added feature Client#delete_database, New class Rid"],
7
+ ['0.2.8', '2012-07-16', "New exception handling, added feature Client#create_class(:properties)"],
8
+ ['0.2.7', '2012-07-07', "Added method Client#class_exists?"],
9
+ ['0.2.6', '2012-07-03', "BF #8, BF #6"],
10
+ ['0.2.5', '2012-07-01', "Added 'get_database' into database CRUD"],
10
11
  # v-- https://groups.google.com/forum/?fromgroups#!topic/orient-database/5MAMCvFavTc
11
- ['0.2.4', '2012-06-26', "Added session management"],
12
- ['0.2.3', '2012-06-24', "Documents received by a query are kind of Orientdb4r::DocumentMetadata"],
12
+ ['0.2.4', '2012-06-26', "Added session management"],
13
+ ['0.2.3', '2012-06-24', "Documents received by a query are kind of Orientdb4r::DocumentMetadata"],
13
14
  # v-- https://groups.google.com/forum/?fromgroups#!topic/orient-database/jK4EZd068AE
14
15
  # v-- https://groups.google.com/forum/?fromgroups#!topic/orient-database/nJOAsgwSnKI
15
- ['0.2.2', '2012-06-23', "Added support for server version detection [r5913]"],
16
- ['0.2.1', '2012-06-19', "Fixed linked property definition"],
17
- ['0.2.0', '2012-06-12', "Introduces document's CRUD operations"],
18
- ['0.1.2', '2012-06-10', 'Introduces new OClass module'],
19
- ['0.1.1', '2012-06-08', 'First working version (including unit tests) released at github.com'],
20
- ['0.1.0', '2012-06-02', 'Initial version on Ruby-1.9.3p194 and OrientDB-1.0.0']
16
+ ['0.2.2', '2012-06-23', "Added support for server version detection [r5913]"],
17
+ ['0.2.1', '2012-06-19', "Fixed linked property definition"],
18
+ ['0.2.0', '2012-06-12', "Introduces document's CRUD operations"],
19
+ ['0.1.2', '2012-06-10', 'Introduces new OClass module'],
20
+ ['0.1.1', '2012-06-08', 'First working version (including unit tests) released at github.com'],
21
+ ['0.1.0', '2012-06-02', 'Initial version on Ruby-1.9.3p194 and OrientDB-1.0.0']
21
22
  ]
22
23
 
23
24
  # Current version.
data/lib/orientdb4r.rb CHANGED
@@ -44,7 +44,7 @@ module Orientdb4r
44
44
  RestClient.proxy = url
45
45
  end
46
46
 
47
- attr_accessor :logger, :context
47
+ attr_accessor :logger
48
48
 
49
49
  end
50
50
 
@@ -87,12 +87,6 @@ Orientdb4r::logger.info \
87
87
  "Orientdb4r #{Orientdb4r::VERSION}, running on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
88
88
 
89
89
 
90
- # Configuration of context.
91
- Orientdb4r::context = {}
92
- Orientdb4r::context[:node_type] = Orientdb4r::RestClientNode
93
- #Orientdb4r::context[:node_type] = Orientdb4r::ExconNode
94
-
95
-
96
90
  #Orientdb4r::logger.level = Logger::DEBUG
97
91
  #client = Orientdb4r.client
98
92
  #client.connect :database => 'temp', :user => 'admin', :password => 'admin'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orientdb4r
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.2.10
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: 2012-07-18 00:00:00.000000000 Z
12
+ date: 2012-07-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client