Class: Keymaker::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/keymaker/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Configuration

Returns a new instance of Configuration.



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/keymaker/configuration.rb', line 11

def initialize(attrs={})
  self.protocol       = attrs.fetch(:protocol) {'http'}
  self.server         = attrs.fetch(:server) {'localhost'}
  self.port           = attrs.fetch(:port) {7474}
  self.data_directory = attrs.fetch(:data_directory) {'db/data'}
  self.cypher_path    = attrs.fetch(:cypher_path) {'cypher'}
  self.gremlin_path   = attrs.fetch(:gremlin_path) {'ext/GremlinPlugin/graphdb/execute_script'}
  self.authentication = attrs.fetch(:authentication) {{}}
  self.username       = attrs.fetch(:username) {nil}
  self.password       = attrs.fetch(:password) {nil}
end

Instance Attribute Details

#authenticationObject

Returns the value of attribute authentication.



6
7
8
# File 'lib/keymaker/configuration.rb', line 6

def authentication
  @authentication
end

#cypher_pathObject

Returns the value of attribute cypher_path.



6
7
8
# File 'lib/keymaker/configuration.rb', line 6

def cypher_path
  @cypher_path
end

#data_directoryObject

Returns the value of attribute data_directory.



6
7
8
# File 'lib/keymaker/configuration.rb', line 6

def data_directory
  @data_directory
end

#gremlin_pathObject

Returns the value of attribute gremlin_path.



6
7
8
# File 'lib/keymaker/configuration.rb', line 6

def gremlin_path
  @gremlin_path
end

#log_enabledObject

Returns the value of attribute log_enabled.



6
7
8
# File 'lib/keymaker/configuration.rb', line 6

def log_enabled
  @log_enabled
end

#log_fileObject

Returns the value of attribute log_file.



6
7
8
# File 'lib/keymaker/configuration.rb', line 6

def log_file
  @log_file
end

#loggerObject

Returns the value of attribute logger.



6
7
8
# File 'lib/keymaker/configuration.rb', line 6

def logger
  @logger
end

#passwordObject

Returns the value of attribute password.



6
7
8
# File 'lib/keymaker/configuration.rb', line 6

def password
  @password
end

#portObject

Returns the value of attribute port.



6
7
8
# File 'lib/keymaker/configuration.rb', line 6

def port
  @port
end

#protocolObject

Returns the value of attribute protocol.



6
7
8
# File 'lib/keymaker/configuration.rb', line 6

def protocol
  @protocol
end

#serverObject

Returns the value of attribute server.



6
7
8
# File 'lib/keymaker/configuration.rb', line 6

def server
  @server
end

#usernameObject

Returns the value of attribute username.



6
7
8
# File 'lib/keymaker/configuration.rb', line 6

def username
  @username
end

Instance Method Details

#batch_node_path(node_id) ⇒ Object



70
71
72
# File 'lib/keymaker/configuration.rb', line 70

def batch_node_path(node_id)
  ["/node", node_id.to_s].join("/")
end

#batch_pathObject



74
75
76
# File 'lib/keymaker/configuration.rb', line 74

def batch_path
  [data_directory, "batch"].join("/")
end

#connection_service_root_urlObject



39
40
41
# File 'lib/keymaker/configuration.rb', line 39

def connection_service_root_url
  Addressable::URI.new(connection_url_opts)
end

#connection_url_optsObject



43
44
45
46
47
48
# File 'lib/keymaker/configuration.rb', line 43

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_pathObject



50
51
52
# File 'lib/keymaker/configuration.rb', line 50

def full_cypher_path
  [service_root, data_directory, cypher_path].join("/")
end

#full_gremlin_pathObject



54
55
56
# File 'lib/keymaker/configuration.rb', line 54

def full_gremlin_path
  [service_root, data_directory, gremlin_path].join("/")
end

#node_full_index_path(index_name, key, value, node_id) ⇒ Object



86
87
88
# File 'lib/keymaker/configuration.rb', line 86

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



90
91
92
# File 'lib/keymaker/configuration.rb', line 90

def node_index_path(index_name)
  [data_directory, "index", "node", index_name.to_s].join("/")
end

#node_pathObject



58
59
60
# File 'lib/keymaker/configuration.rb', line 58

def node_path
  [data_directory, "node"].join("/")
end

#node_properties_path(node_id) ⇒ Object



62
63
64
# File 'lib/keymaker/configuration.rb', line 62

def node_properties_path(node_id)
  [node_path, node_id.to_s, "properties"].join("/")
end

#node_uri(node_id) ⇒ Object



94
95
96
# File 'lib/keymaker/configuration.rb', line 94

def node_uri(node_id)
  [service_root, node_path, node_id.to_s].join("/")
end

#path_traverse_node_path(node_id) ⇒ Object



66
67
68
# File 'lib/keymaker/configuration.rb', line 66

def path_traverse_node_path(node_id)
  [node_path, node_id.to_s, "traverse", "path"].join("/")
end

#relationship_path(relationship_id) ⇒ Object



78
79
80
# File 'lib/keymaker/configuration.rb', line 78

def relationship_path(relationship_id)
  [data_directory, "relationship", relationship_id.to_s].join("/")
end

#relationships_path_for_node(node_id) ⇒ Object



82
83
84
# File 'lib/keymaker/configuration.rb', line 82

def relationships_path_for_node(node_id)
  [node_path, node_id.to_s, "relationships"].join("/")
end

#service_rootObject



23
24
25
# File 'lib/keymaker/configuration.rb', line 23

def service_root
  service_root_url.to_s
end

#service_root_urlObject



27
28
29
# File 'lib/keymaker/configuration.rb', line 27

def service_root_url
  Addressable::URI.new(url_opts)
end

#url_optsObject



31
32
33
34
35
36
37
# File 'lib/keymaker/configuration.rb', line 31

def url_opts
  {}.tap do |url_opts|
    url_opts[:scheme] = protocol
    url_opts[:host] = server
    url_opts[:port] = port
  end
end