activegraph 10.0.0.pre.beta.1 → 10.0.0.pre.beta.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f490d36cc6732adb06aca4752e589f4dfc689d307cd33e54fe912a2273d30160
4
- data.tar.gz: 61c9355e4403e04dc723071b70b1cc0e27ebb92fae5e27ba6c6c9a349d1dce38
3
+ metadata.gz: 3c6ef6e85cad5ae83d519bf7c5d781f70f39d9528bf79722e3913a5edfdc0ca2
4
+ data.tar.gz: 8a75e8976bcb65c734db47024d84f55dad7897ee7e0eb6e08a2e3a60571f441c
5
5
  SHA512:
6
- metadata.gz: d51a94b8d915e1815913d28ffb96602c3ca8aa74328313bb5d838af00cb8c77ff2bf9f0d6e70289fcbf12061e6d3665980442193ed0818fd9d41684d571287f3
7
- data.tar.gz: 5dacdeb85d6b9bff6dbf7ad76e041a98117fa49e36feb702dcac3995c8d573c68af89c413d80f7f9f1c3a52b360d8166858660e4bea99e18072e3982d9bd24b7
6
+ metadata.gz: ead910dc52bdd93b39b274fc766f376972a16b284a79ba7b8b25b52dab54508927ea7e0ed857f6c416500f283210d659dec1c8fe955cf2ec417dc13d0b5ecc08
7
+ data.tar.gz: 53d4531aaa3afa01b813f9b4e40adda8ffc3a69b6d0c9f23606d9ef98d184126952909166d17d57e7e3fa372772bf17ce0bf36651cff11c17124a5556d6057ca
@@ -28,10 +28,10 @@ module ActiveGraph
28
28
  @establish_driver_block.call if @establish_driver_block
29
29
  end
30
30
 
31
- def new_driver(url, options = {})
31
+ def new_driver(url, auth_token, options = {})
32
32
  verbose_query_logs = ActiveGraph::Config.fetch(:verbose_query_logs, false)
33
33
  ActiveGraph::Core::Driver
34
- .new(url, options, verbose_query_logs: verbose_query_logs)
34
+ .new(url, auth_token, options, verbose_query_logs: verbose_query_logs)
35
35
  end
36
36
 
37
37
  def transaction
@@ -1,42 +1,25 @@
1
1
  require 'active_support/core_ext/module/attribute_accessors'
2
2
  require 'active_graph/core/logging'
3
- require 'active_graph/core/has_uri'
4
3
  require 'active_graph/version'
5
4
 
6
5
  module ActiveGraph
7
6
  module Core
8
7
  class Driver
9
- include HasUri
10
-
11
- USER_AGENT_STRING = "neo4j-gem/#{::ActiveGraph::VERSION} (https://github.com/neo4jrb/neo4j)"
8
+ USER_AGENT_STRING = "activegraph-gem/#{::ActiveGraph::VERSION} (https://github.com/neo4jrb/activegraph)"
12
9
 
13
10
  attr_accessor :wrap_level
14
- attr_reader :options, :driver
11
+ attr_reader :options, :driver, :url
15
12
  delegate :close, to: :driver
16
13
 
17
- default_url('bolt://neo4:neo4j@localhost:7687')
18
-
19
- validate_uri do |uri|
20
- uri.scheme == 'bolt'
21
- end
22
-
23
14
  class << self
24
- def new_instance(url, options = {})
25
- uri = URI(url)
26
- user = uri.user
27
- password = uri.password
28
- auth_token = if user
29
- Neo4j::Driver::AuthTokens.basic(user, password)
30
- else
31
- Neo4j::Driver::AuthTokens.none
32
- end
15
+ def new_instance(url, auth_token, options = {})
33
16
  Neo4j::Driver::GraphDatabase.driver(url, auth_token, options)
34
17
  end
35
18
  end
36
19
 
37
- def initialize(url, options = {}, extended_options = {})
38
- self.url = url
39
- @driver = self.class.new_instance(url, options)
20
+ def initialize(url, auth_token = Neo4j::Driver::AuthTokens.none, options = {}, extended_options = {})
21
+ @url = url
22
+ @driver = self.class.new_instance(url, auth_token, options)
40
23
  @options = extended_options
41
24
  end
42
25
 
@@ -14,7 +14,7 @@ module ActiveGraph
14
14
  def subscribe_to_request
15
15
  ActiveSupport::Notifications.subscribe('neo4j.core.bolt.request') do |_, start, finish, _id, _payload|
16
16
  ms = (finish - start) * 1000
17
- yield " #{ANSI::BLUE}BOLT:#{ANSI::CLEAR} #{ANSI::YELLOW}#{ms.round}ms#{ANSI::CLEAR} #{Base.current_driver.url_without_password}"
17
+ yield " #{ANSI::BLUE}BOLT:#{ANSI::CLEAR} #{ANSI::YELLOW}#{ms.round}ms#{ANSI::CLEAR} #{Base.current_driver.url}"
18
18
  end
19
19
  end
20
20
 
@@ -58,11 +58,13 @@ module ActiveGraph
58
58
  end
59
59
 
60
60
  def setup!(neo4j_config = empty_config)
61
- url, path, options = final_driver_config!(neo4j_config).values_at(:url, :path, :options)
62
- options ||= {}
61
+ url, path, auth_token, username, password, config, options =
62
+ final_driver_config!(neo4j_config).values_at(:url, :path, :auth_token, :username, :password, :config, :options)
63
+ auth_token ||= username ? Neo4j::Driver::AuthTokens.basic(username, password) : Neo4j::Driver::AuthTokens.none
64
+ options ||= config || {}
63
65
  register_neo4j_cypher_logging
64
66
 
65
- ActiveGraph::Base.new_driver( url || path || default_driver_path_or_url, options)
67
+ ActiveGraph::Base.new_driver(url || path || default_driver_path_or_url, auth_token, options)
66
68
  end
67
69
 
68
70
  def final_driver_config!(neo4j_config)
@@ -1,3 +1,3 @@
1
1
  module ActiveGraph
2
- VERSION = '10.0.0-beta.1'
2
+ VERSION = '10.0.0-beta.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activegraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.0.0.pre.beta.1
4
+ version: 10.0.0.pre.beta.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Ronge, Brian Underwood, Chris Grigg, Heinrich Klobuczek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-01 00:00:00.000000000 Z
11
+ date: 2020-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -263,7 +263,6 @@ files:
263
263
  - lib/active_graph/core/connection_failed_error.rb
264
264
  - lib/active_graph/core/cypher_error.rb
265
265
  - lib/active_graph/core/driver.rb
266
- - lib/active_graph/core/has_uri.rb
267
266
  - lib/active_graph/core/instrumentable.rb
268
267
  - lib/active_graph/core/label.rb
269
268
  - lib/active_graph/core/logging.rb
@@ -1,63 +0,0 @@
1
- require 'active_support/concern'
2
-
3
- module ActiveGraph
4
- module Core
5
- # Containing the logic for dealing with adaptors which use URIs
6
- module HasUri
7
- extend ActiveSupport::Concern
8
-
9
- included do
10
- %w[scheme user password host port].each do |method|
11
- define_method(method) do
12
- (@uri && @uri.send(method)) || (self.class.default_uri && self.class.default_uri.send(method))
13
- end
14
- end
15
- end
16
-
17
- module ClassMethods
18
- attr_reader :default_uri
19
-
20
- def default_url(default_url)
21
- @default_uri = uri_from_url!(default_url)
22
- end
23
-
24
- def validate_uri(&block)
25
- @uri_validator = block
26
- end
27
-
28
- def uri_from_url!(url)
29
- validate_url!(url)
30
-
31
- @uri = url.nil? ? @default_uri : URI(url)
32
-
33
- fail ArgumentError, "Invalid URL: #{url.inspect}" if uri_valid?(@uri)
34
-
35
- @uri
36
- end
37
-
38
- private
39
-
40
- def validate_url!(url)
41
- fail ArgumentError, "Invalid URL: #{url.inspect}" if !(url.is_a?(String) || url.nil?)
42
- fail ArgumentError, 'No URL or default URL specified' if url.nil? && @default_uri.nil?
43
- end
44
-
45
- def uri_valid?(uri)
46
- @uri_validator && !@uri_validator.call(uri)
47
- end
48
- end
49
-
50
- def url
51
- @uri.to_s
52
- end
53
-
54
- def url=(url)
55
- @uri = self.class.uri_from_url!(url)
56
- end
57
-
58
- def url_without_password
59
- @url_without_password ||= "#{scheme}://#{user + ':...@' if user}#{host}:#{port}"
60
- end
61
- end
62
- end
63
- end