boltless 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 451b84cf72d19b6d8ac3b3f392c7575d980c56588b0364a6792759b84126e8c4
4
- data.tar.gz: 569c835011a6dca3fff0fc26465ef7069931c054877133baff35f2762968e568
3
+ metadata.gz: f8b7c4416097390006b201dcec4ce9beaa8190659d079da12af5e01689670aff
4
+ data.tar.gz: 434205668e628cb4b0d12a1451a83dac804cea38c1a045f3982f8157e9e25873
5
5
  SHA512:
6
- metadata.gz: 5afae9aa76e195e244ee0ad71020b9a060005187d5ca24ff9ed7bf89e818b0928025b8090025a1e5c0927d477ff8d4b804782a82efae2a4ff260a19f55152595
7
- data.tar.gz: a93ddd308706c876facf444f8f90407fa76164a26cea90de441063da68ad26cf63b1f2e2a10cc487c1a7e65f1aa0a1cb6f444aba31dad12a491e9f9190133df1
6
+ metadata.gz: d20881d61af51e69287d45b36358c8bd35f2709e16b43439b598c542fe92a09f33a182260a2cc19360ddf3586f6c918e79957d1bb3b20b3eb5dafedfdd12273a
7
+ data.tar.gz: 163eb7a5a639a046a2801ecc002772c0eac9f0b6fe9113f9c35c0271cf41e3aee75137fd17d3c6278957caa67a29e1919e0fd7fcdfac6feb5a4939b65ddf1b59
data/Gemfile CHANGED
@@ -9,9 +9,10 @@ gemspec
9
9
 
10
10
  # Development dependencies
11
11
  gem 'appraisal', '~> 2.4'
12
+ gem 'benchmark', '>= 0.5'
12
13
  gem 'benchmark-ips', '~> 2.10'
13
14
  gem 'bundler', '~> 2.6'
14
- gem 'countless', '~> 2.0'
15
+ gem 'countless', '~> 2.2'
15
16
  gem 'guard-rspec', '~> 4.7'
16
17
  gem 'irb', '~> 1.2'
17
18
  gem 'rspec', '~> 3.12'
@@ -2,8 +2,46 @@
2
2
 
3
3
  module Boltless
4
4
  # The configuration for the Boltless gem.
5
- class Configuration
6
- include ActiveSupport::Configurable
5
+ class Configuration < ActiveSupport::OrderedOptions
6
+ # Track our configurations settings (+Symbol+ keys) and their defaults as
7
+ # lazy-loaded +Proc+'s values
8
+ class_attribute :defaults,
9
+ instance_reader: true,
10
+ instance_writer: false,
11
+ instance_predicate: false,
12
+ default: {}
13
+
14
+ # Create a new +Configuration+ instance with all settings populated with
15
+ # their respective defaults.
16
+ #
17
+ # @param args [Hash{Symbol => Mixed}] additional settings which
18
+ # overwrite the defaults
19
+ # @return [Configuration] the new configuration instance
20
+ def initialize(**args)
21
+ super()
22
+ defaults.each { |key, default| self[key] = instance_exec(&default) }
23
+ merge!(**args)
24
+ end
25
+
26
+ # A simple DSL method to define new configuration accessors/settings with
27
+ # their defaults. The defaults can be retrieved with
28
+ # +Configuration.defaults+ or +Configuration.new.defaults+.
29
+ #
30
+ # @param name [Symbol, String] the name of the configuration
31
+ # accessor/setting
32
+ # @param default [Mixed, nil] a non-lazy-loaded static value, serving as a
33
+ # default value for the setting
34
+ # @param block [Proc] when given, the default value will be lazy-loaded
35
+ # (result of the Proc)
36
+ def self.config_accessor(name, default = nil, &block)
37
+ # Save the given configuration accessor default value
38
+ defaults[name.to_sym] = block || -> { default }
39
+
40
+ # Compile reader/writer methods so we don't have to go through
41
+ # +ActiveSupport::OrderedOptions#method_missing+.
42
+ define_method(name) { self[name] }
43
+ define_method("#{name}=") { |value| self[name] = value }
44
+ end
7
45
 
8
46
  # The base URL of the neo4j HTTP API (port 7474 for HTTP, port 7473
9
47
  # for HTTPS when configured at server side)
@@ -3,7 +3,7 @@
3
3
  # The gem version details.
4
4
  module Boltless
5
5
  # The version of the +boltless+ gem
6
- VERSION = '2.0.0'
6
+ VERSION = '2.1.0'
7
7
 
8
8
  class << self
9
9
  # Returns the version of gem as a string.
data/lib/boltless.rb CHANGED
@@ -10,6 +10,8 @@ require 'colorize'
10
10
  require 'logger'
11
11
  require 'active_support'
12
12
  require 'active_support/concern'
13
+ require 'active_support/ordered_options'
14
+ require 'active_support/core_ext/class/attribute'
13
15
  require 'active_support/core_ext/module/delegation'
14
16
  require 'active_support/core_ext/numeric/time'
15
17
  require 'active_support/core_ext/enumerable'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boltless
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hermann Mayer
@@ -27,16 +27,16 @@ dependencies:
27
27
  name: base64
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
30
- - - "~>"
30
+ - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 0.2.0
32
+ version: '0.3'
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - "~>"
37
+ - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: 0.2.0
39
+ version: '0.3'
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: colorize
42
42
  requirement: !ruby/object:Gem::Requirement