Class: Keymaker::Configuration
- Inherits:
-
Object
- Object
- Keymaker::Configuration
- Defined in:
- lib/keymaker/configuration.rb
Instance Attribute Summary collapse
-
#authentication ⇒ Object
Returns the value of attribute authentication.
-
#data_directory ⇒ Object
Returns the value of attribute data_directory.
-
#password ⇒ Object
Returns the value of attribute password.
-
#port ⇒ Object
Returns the value of attribute port.
-
#protocol ⇒ Object
Returns the value of attribute protocol.
-
#server ⇒ Object
Returns the value of attribute server.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #batch_path ⇒ Object
- #connection_service_root_url ⇒ Object
- #connection_url_opts ⇒ Object
-
#full_cypher_path ⇒ Object
paths.
- #full_gremlin_path ⇒ Object
-
#initialize(attrs = {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #node_full_index_path(index_name, key, value, node_id) ⇒ Object
- #node_index_path(index_name) ⇒ Object
- #node_path ⇒ Object
- #node_properties_path(node_id) ⇒ Object
- #node_uri(node_id) ⇒ Object
- #relationship_path(relationship_id) ⇒ Object
- #relationship_types_path ⇒ Object
- #relationships_path_for_node(node_id) ⇒ Object
- #service_root ⇒ Object
- #service_root_url ⇒ Object
- #url_opts ⇒ Object
Constructor Details
#initialize(attrs = {}) ⇒ Configuration
Returns a new instance of Configuration.
9 10 11 12 13 14 15 16 17 |
# File 'lib/keymaker/configuration.rb', line 9 def initialize(attrs={}) self.protocol = attrs.fetch(:protocol) {'http'} self.server = attrs.fetch(:server) {'localhost'} self.port = attrs.fetch(:port) {7474} self.authentication = attrs.fetch(:authentication) {{}} self.username = attrs.fetch(:username) {nil} self.password = attrs.fetch(:password) {nil} self.data_directory = 'db/data' end |
Instance Attribute Details
#authentication ⇒ Object
Returns the value of attribute authentication.
6 7 8 |
# File 'lib/keymaker/configuration.rb', line 6 def authentication @authentication end |
#data_directory ⇒ Object
Returns the value of attribute data_directory.
6 7 8 |
# File 'lib/keymaker/configuration.rb', line 6 def data_directory @data_directory end |
#password ⇒ Object
Returns the value of attribute password.
6 7 8 |
# File 'lib/keymaker/configuration.rb', line 6 def password @password end |
#port ⇒ Object
Returns the value of attribute port.
6 7 8 |
# File 'lib/keymaker/configuration.rb', line 6 def port @port end |
#protocol ⇒ Object
Returns the value of attribute protocol.
6 7 8 |
# File 'lib/keymaker/configuration.rb', line 6 def protocol @protocol end |
#server ⇒ Object
Returns the value of attribute server.
6 7 8 |
# File 'lib/keymaker/configuration.rb', line 6 def server @server end |
#username ⇒ Object
Returns the value of attribute username.
6 7 8 |
# File 'lib/keymaker/configuration.rb', line 6 def username @username end |
Instance Method Details
#batch_path ⇒ Object
68 69 70 |
# File 'lib/keymaker/configuration.rb', line 68 def batch_path service_root.batch end |
#connection_service_root_url ⇒ Object
35 36 37 |
# File 'lib/keymaker/configuration.rb', line 35 def connection_service_root_url Addressable::URI.new(connection_url_opts) end |
#connection_url_opts ⇒ Object
39 40 41 42 43 44 |
# File 'lib/keymaker/configuration.rb', line 39 def connection_url_opts url_opts.tap do |url_opts| url_opts[:user] = username if username url_opts[:password] = password if password end end |
#full_cypher_path ⇒ Object
paths
48 49 50 |
# File 'lib/keymaker/configuration.rb', line 48 def full_cypher_path service_root.cypher end |
#full_gremlin_path ⇒ Object
52 53 54 |
# File 'lib/keymaker/configuration.rb', line 52 def full_gremlin_path service_root.extensions.fetch('GremlinPlugin', {}).fetch('execute_script', nil) end |
#node_full_index_path(index_name, key, value, node_id) ⇒ Object
84 85 86 |
# File 'lib/keymaker/configuration.rb', line 84 def node_full_index_path(index_name, key, value, node_id) [node_index_path(index_name), key, value, node_id].join("/") end |
#node_index_path(index_name) ⇒ Object
88 89 90 |
# File 'lib/keymaker/configuration.rb', line 88 def node_index_path(index_name) [service_root.node_index, index_name.to_s].join("/") end |
#node_path ⇒ Object
56 57 58 |
# File 'lib/keymaker/configuration.rb', line 56 def node_path service_root.node end |
#node_properties_path(node_id) ⇒ Object
60 61 62 |
# File 'lib/keymaker/configuration.rb', line 60 def node_properties_path(node_id) [node_path, node_id.to_s, 'properties'].join('/') end |
#node_uri(node_id) ⇒ Object
64 65 66 |
# File 'lib/keymaker/configuration.rb', line 64 def node_uri(node_id) [node_path, node_id.to_s].join("/") end |
#relationship_path(relationship_id) ⇒ Object
72 73 74 |
# File 'lib/keymaker/configuration.rb', line 72 def relationship_path(relationship_id) [data_directory, "relationship", relationship_id.to_s].join("/") end |
#relationship_types_path ⇒ Object
76 77 78 |
# File 'lib/keymaker/configuration.rb', line 76 def relationship_types_path service_root.relationship_types end |
#relationships_path_for_node(node_id) ⇒ Object
80 81 82 |
# File 'lib/keymaker/configuration.rb', line 80 def relationships_path_for_node(node_id) [node_path, node_id.to_s, "relationships"].join("/") end |
#service_root ⇒ Object
19 20 21 |
# File 'lib/keymaker/configuration.rb', line 19 def service_root @service_root ||= Keymaker.service.service_root_request.body end |
#service_root_url ⇒ Object
23 24 25 |
# File 'lib/keymaker/configuration.rb', line 23 def service_root_url Addressable::URI.new(url_opts) end |
#url_opts ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/keymaker/configuration.rb', line 27 def url_opts {}.tap do |url_opts| url_opts[:scheme] = protocol url_opts[:host] = server url_opts[:port] = port end end |