configatron 4.0.3 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,16 @@
1
+ === 4.1.0
2
+
3
+ * Fix bugs from BasicObject fallout
4
+ * Have KernelStore proxy calls using `public_send` for consistent shadowing
5
+
6
+ === 4.0.3
7
+
8
+ * Switch Store and RootStore to descend from BasicObject
9
+
10
+ === 4.0.2
11
+
12
+ * Add missing require of Rails integration
13
+
1
14
  === 4.0.1
2
15
 
3
16
  * Fix #inspect and #to_s methods on KernelStore to pass through to Store
data/README.md CHANGED
@@ -78,7 +78,7 @@ configatron.email.pop.port # => 110
78
78
 
79
79
  ### Method vs hash access
80
80
 
81
- As a note, method (`configatron.foo`) access will be shadowed by methods defined on the configatron object. (The configatron object descends from [`BasicObject`](http://apidock.com/ruby/BasicObject) and includes `Kernel`, so it should have a pretty bare set of methods.)
81
+ As a note, method (`configatron.foo`) access will be shadowed by public methods defined on the configatron object. (The configatron object descends from [`BasicObject`](http://apidock.com/ruby/BasicObject) and includes `Kernel`, so it should have a pretty bare set of methods.)
82
82
 
83
83
  If you need to use keys that are themselves method names, you can just use hash access (`configatron['foo']`).
84
84
 
data/lib/configatron.rb CHANGED
@@ -2,6 +2,7 @@ require 'configatron/version'
2
2
 
3
3
  require 'configatron/deep_clone'
4
4
  require 'configatron/errors'
5
+ require 'configatron/integrations'
5
6
  require 'configatron/root_store'
6
7
  require 'configatron/store'
7
8
 
@@ -1,7 +1,4 @@
1
- module Configatron
2
- module Integrations
3
- end
4
- end
1
+ module Configatron::Integrations; end
5
2
 
6
3
  require 'configatron/integrations/minitest'
7
4
  require 'configatron/integrations/rails'
@@ -1,4 +1,4 @@
1
- class Configatron::Integrations
1
+ module Configatron::Integrations
2
2
  # Helpful for making using configatron with Rails even easier!
3
3
  #
4
4
  # To get started you can use the generator to generate
@@ -3,6 +3,7 @@ require 'singleton'
3
3
  # This is the root configatron object, and contains methods which
4
4
  # operate on the entire configatron hierarchy.
5
5
  class Configatron::RootStore < BasicObject
6
+ include ::Kernel
6
7
  include ::Singleton
7
8
  extend ::Forwardable
8
9
 
@@ -20,7 +21,7 @@ class Configatron::RootStore < BasicObject
20
21
  end
21
22
 
22
23
  def method_missing(name, *args, &block)
23
- store.send(name, *args, &block)
24
+ store.public_send(name, *args, &block)
24
25
  end
25
26
 
26
27
  def reset!
@@ -5,11 +5,10 @@ class Configatron
5
5
  include ::Kernel
6
6
  extend ::Forwardable
7
7
 
8
- def initialize(root_store, name='configatron')
8
+ def initialize(root_store, name='configatron', attributes={})
9
9
  @root_store = root_store
10
10
  @name = name
11
-
12
- @attributes = {}
11
+ @attributes = attributes
13
12
  end
14
13
 
15
14
  def [](key)
@@ -102,6 +101,11 @@ class Configatron
102
101
  @method_missing = false
103
102
  end
104
103
 
104
+ # Needed for deep_clone to actually clone this object
105
+ def clone
106
+ self.class.new(@root_store, @name, @attributes)
107
+ end
108
+
105
109
  private
106
110
 
107
111
  def do_lookup(name, *args, &block)
@@ -1,3 +1,3 @@
1
1
  class Configatron
2
- VERSION = "4.0.3"
2
+ VERSION = "4.1.0"
3
3
  end
@@ -80,4 +80,14 @@ class Critic::Functional::ConfigatronTest < Critic::Functional::Test
80
80
  puts @kernel.hi
81
81
  end
82
82
  end
83
+
84
+ describe 'private methods on kernel' do
85
+ it 'can be accessed through method accessors' do
86
+ @kernel.catch = 'hi'
87
+ @kernel.foo.catch = 'hi'
88
+
89
+ assert_equal('hi', @kernel.catch)
90
+ assert_equal('hi', @kernel.foo.catch)
91
+ end
92
+ end
83
93
  end
@@ -0,0 +1,18 @@
1
+ require_relative '_lib'
2
+ require 'subprocess'
3
+
4
+ class Critic::Functional::MinitestTest < Critic::Functional::Test
5
+ include Configatron::Integrations::Minitest
6
+
7
+ describe 'multiple runs' do
8
+ it 'settings get reset: 1' do
9
+ assert(!configatron.key?(:my_crazy_setting))
10
+ configatron.my_crazy_setting = true
11
+ end
12
+
13
+ it 'settings get reset: 2' do
14
+ assert(!configatron.key?(:my_crazy_setting))
15
+ configatron.my_crazy_setting = true
16
+ end
17
+ end
18
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: configatron
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.3
4
+ version: 4.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -117,6 +117,7 @@ files:
117
117
  - test/functional/_lib/scripts/core.rb
118
118
  - test/functional/configatron.rb
119
119
  - test/functional/loading.rb
120
+ - test/functional/minitest.rb
120
121
  - test/unit/_lib.rb
121
122
  - test/unit/configatron/proc.rb
122
123
  - test/unit/configatron/root_store.rb
@@ -136,7 +137,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
136
137
  version: '0'
137
138
  segments:
138
139
  - 0
139
- hash: 418974604606994708
140
+ hash: 201983176826574058
140
141
  required_rubygems_version: !ruby/object:Gem::Requirement
141
142
  none: false
142
143
  requirements:
@@ -145,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
146
  version: '0'
146
147
  segments:
147
148
  - 0
148
- hash: 418974604606994708
149
+ hash: 201983176826574058
149
150
  requirements: []
150
151
  rubyforge_project:
151
152
  rubygems_version: 1.8.25
@@ -158,6 +159,7 @@ test_files:
158
159
  - test/functional/_lib/scripts/core.rb
159
160
  - test/functional/configatron.rb
160
161
  - test/functional/loading.rb
162
+ - test/functional/minitest.rb
161
163
  - test/unit/_lib.rb
162
164
  - test/unit/configatron/proc.rb
163
165
  - test/unit/configatron/root_store.rb