Class: AllegroGraph::Server
- Inherits:
-
Object
- Object
- AllegroGraph::Server
- Defined in:
- lib/allegro_graph/server.rb
Overview
The Server class provides methods to retrieve informations about a AllegroGraph server.
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#root_catalog ⇒ Object
readonly
Returns the value of attribute root_catalog.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #catalogs ⇒ Object
-
#initialize(options = { }) ⇒ Server
constructor
A new instance of Server.
- #request_http(http_method, path, options = { }) ⇒ Object
- #request_json(http_method, path, options = { }) ⇒ Object
- #url ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(options = { }) ⇒ Server
Returns a new instance of Server.
14 15 16 17 18 19 20 21 |
# File 'lib/allegro_graph/server.rb', line 14 def initialize( = { }) @host = [:host] || "localhost" @port = [:port] || "10035" @username = [:username] @password = [:password] @root_catalog = Catalog.new self, "root", :root => true end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
8 9 10 |
# File 'lib/allegro_graph/server.rb', line 8 def host @host end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
11 12 13 |
# File 'lib/allegro_graph/server.rb', line 11 def password @password end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
9 10 11 |
# File 'lib/allegro_graph/server.rb', line 9 def port @port end |
#root_catalog ⇒ Object (readonly)
Returns the value of attribute root_catalog.
12 13 14 |
# File 'lib/allegro_graph/server.rb', line 12 def root_catalog @root_catalog end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
10 11 12 |
# File 'lib/allegro_graph/server.rb', line 10 def username @username end |
Instance Method Details
#==(other) ⇒ Object
23 24 25 |
# File 'lib/allegro_graph/server.rb', line 23 def ==(other) other.is_a?(self.class) && @host == other.host && @port == other.port end |
#catalogs ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/allegro_graph/server.rb', line 43 def catalogs result = [ @root_catalog ] catalogs = self.request_json :get, "/catalogs", :expected_status_code => 200 catalogs.each do |catalog| id = catalog["id"] result << Catalog.new(self, id.sub(/^\//, "")) unless id == "/" end result end |
#request_http(http_method, path, options = { }) ⇒ Object
27 28 29 |
# File 'lib/allegro_graph/server.rb', line 27 def request_http(http_method, path, = { }) ::Transport::HTTP.request http_method, (self.url + path), credentials.merge() end |
#request_json(http_method, path, options = { }) ⇒ Object
31 32 33 |
# File 'lib/allegro_graph/server.rb', line 31 def request_json(http_method, path, = { }) ::Transport::JSON.request http_method, self.url + path, credentials.merge().merge(:logger => Logger.new(STDOUT)) end |
#url ⇒ Object
53 54 55 |
# File 'lib/allegro_graph/server.rb', line 53 def url "http://#{@host}:#{@port}" end |
#version ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/allegro_graph/server.rb', line 35 def version { :version => self.request_http(:get, "/version", :expected_status_code => 200), :date => self.request_http(:get, "/version/date", :expected_status_code => 200), :revision => self.request_http(:get, "/version/revision", :expected_status_code => 200) } end |