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.
- #path ⇒ Object
- #request_http(http_method, path, options = { }) ⇒ Object
- #request_json(http_method, path, options = { }) ⇒ Object
- #server ⇒ Object
- #url ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(options = { }) ⇒ Server
Returns a new instance of Server.
13 14 15 16 17 18 19 20 |
# File 'lib/allegro_graph/server.rb', line 13 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.
7 8 9 |
# File 'lib/allegro_graph/server.rb', line 7 def host @host end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
10 11 12 |
# File 'lib/allegro_graph/server.rb', line 10 def password @password end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
8 9 10 |
# File 'lib/allegro_graph/server.rb', line 8 def port @port end |
#root_catalog ⇒ Object (readonly)
Returns the value of attribute root_catalog.
11 12 13 |
# File 'lib/allegro_graph/server.rb', line 11 def root_catalog @root_catalog end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
9 10 11 |
# File 'lib/allegro_graph/server.rb', line 9 def username @username end |
Instance Method Details
#==(other) ⇒ Object
22 23 24 |
# File 'lib/allegro_graph/server.rb', line 22 def ==(other) other.is_a?(self.class) && @host == other.host && @port == other.port end |
#catalogs ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'lib/allegro_graph/server.rb', line 54 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 |
#path ⇒ Object
30 31 32 |
# File 'lib/allegro_graph/server.rb', line 30 def path "" end |
#request_http(http_method, path, options = { }) ⇒ Object
38 39 40 |
# File 'lib/allegro_graph/server.rb', line 38 def request_http(http_method, path, = { }) ::Transport::HTTP.request http_method, (self.url + path), credentials.merge() end |
#request_json(http_method, path, options = { }) ⇒ Object
42 43 44 |
# File 'lib/allegro_graph/server.rb', line 42 def request_json(http_method, path, = { }) ::Transport::JSON.request http_method, self.url + path, credentials.merge() end |
#server ⇒ Object
34 35 36 |
# File 'lib/allegro_graph/server.rb', line 34 def server self end |
#url ⇒ Object
26 27 28 |
# File 'lib/allegro_graph/server.rb', line 26 def url "http://#{@host}:#{@port}" end |
#version ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/allegro_graph/server.rb', line 46 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 |