configatron 4.0.2 → 4.0.3

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.
data/.gitignore CHANGED
@@ -15,6 +15,7 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .ruby-version
18
19
 
19
20
  .DS_Store
20
21
  *.rbc
data/.travis.yml CHANGED
@@ -4,5 +4,5 @@ rvm:
4
4
  - 2.0.0
5
5
  - 2.1.0
6
6
  - 2.1.1
7
- install: bundle install
7
+ install: travis_retry bundle install
8
8
  script: bundle exec rake test
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  Configatron makes configuring your applications and scripts incredibly easy. No longer is a there a need to use constants or global variables. Now you can use a simple and painless system to configure your life. And, because it's all Ruby, you can do any crazy thing you would like to!
5
5
 
6
- One of the more important changes to V3 is that it now resembles more a `Hash` style interface. You can use `[]`, `fetch`, `each`, etc...
6
+ One of the more important changes to V3 is that it now resembles more a `Hash` style interface. You can use `[]`, `fetch`, `each`, etc... Actually the hash notation is more robust since the dot notation won't work for some property names. See section "Differences between dot and hash notation" for more details.
7
7
 
8
8
  ## Installation
9
9
 
@@ -76,6 +76,12 @@ configatron.email.pop.port # => 110
76
76
  # and so on...
77
77
  ```
78
78
 
79
+ ### Method vs hash access
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.)
82
+
83
+ If you need to use keys that are themselves method names, you can just use hash access (`configatron['foo']`).
84
+
79
85
  ### Namespaces
80
86
 
81
87
  The question that should be on your lips is what I need to have namespaced configuration parameters. It's easy! Configatron allows you to create namespaces.
data/lib/configatron.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'singleton'
2
1
  require 'configatron/version'
3
2
 
4
3
  require 'configatron/deep_clone'
@@ -1,7 +1,9 @@
1
+ require 'singleton'
2
+
1
3
  # This is the root configatron object, and contains methods which
2
4
  # operate on the entire configatron hierarchy.
3
- class Configatron::RootStore
4
- include Singleton
5
+ class Configatron::RootStore < BasicObject
6
+ include ::Singleton
5
7
  extend ::Forwardable
6
8
 
7
9
  attr_reader :store
@@ -22,7 +24,7 @@ class Configatron::RootStore
22
24
  end
23
25
 
24
26
  def reset!
25
- @store = Configatron::Store.new(self)
27
+ @store = ::Configatron::Store.new(self)
26
28
  end
27
29
 
28
30
  def temp(&block)
@@ -32,7 +34,7 @@ class Configatron::RootStore
32
34
  end
33
35
 
34
36
  def temp_start
35
- @temp = Configatron::DeepClone.deep_clone(@store)
37
+ @temp = ::Configatron::DeepClone.deep_clone(@store)
36
38
  end
37
39
 
38
40
  def temp_end
@@ -1,7 +1,8 @@
1
1
  require 'forwardable'
2
2
 
3
3
  class Configatron
4
- class Store
4
+ class Store < BasicObject
5
+ include ::Kernel
5
6
  extend ::Forwardable
6
7
 
7
8
  def initialize(root_store, name='configatron')
@@ -14,16 +15,16 @@ class Configatron
14
15
  def [](key)
15
16
  val = fetch(key.to_sym) do
16
17
  if @root_store.locked?
17
- raise Configatron::UndefinedKeyError.new("Key not found: #{key} (for locked #{self})")
18
+ raise ::Configatron::UndefinedKeyError.new("Key not found: #{key} (for locked #{self})")
18
19
  end
19
- Configatron::Store.new(@root_store, "#{@name}.#{key}")
20
+ ::Configatron::Store.new(@root_store, "#{@name}.#{key}")
20
21
  end
21
22
  return val
22
23
  end
23
24
 
24
25
  def store(key, value)
25
26
  if @root_store.locked?
26
- raise Configatron::LockedError.new("Cannot set key #{key} for locked #{self}")
27
+ raise ::Configatron::LockedError.new("Cannot set key #{key} for locked #{self}")
27
28
  end
28
29
  @attributes[key.to_sym] = value
29
30
  end
@@ -38,7 +39,7 @@ class Configatron
38
39
  end
39
40
  store(key, val)
40
41
  end
41
- if val.is_a?(Configatron::Proc)
42
+ if val.is_a?(::Configatron::Proc)
42
43
  val = val.call
43
44
  end
44
45
  return val
@@ -50,7 +51,7 @@ class Configatron
50
51
 
51
52
  def configure_from_hash(hash)
52
53
  hash.each do |key, value|
53
- if value.is_a?(Hash)
54
+ if value.is_a?(::Hash)
54
55
  self[key].configure_from_hash(value)
55
56
  else
56
57
  store(key, value)
@@ -65,7 +66,7 @@ class Configatron
65
66
  def inspect
66
67
  f_out = []
67
68
  @attributes.each do |k, v|
68
- if v.is_a?(Configatron::Store)
69
+ if v.is_a?(::Configatron::Store)
69
70
  v.inspect.each_line do |line|
70
71
  if line.match(/\n/)
71
72
  line.each_line do |l|
@@ -87,13 +88,13 @@ class Configatron
87
88
  def method_missing(name, *args, &block)
88
89
  # Needed to allow 'puts'ing of a configatron.
89
90
  if name == :to_ary
90
- raise NoMethodError.new("Called :to_ary")
91
+ raise ::NoMethodError.new("Called :to_ary")
91
92
  end
92
93
 
93
94
  # In case of Configatron bugs, prevent method_missing infinite
94
95
  # loops.
95
96
  if @method_missing
96
- raise NoMethodError.new("Bug in configatron; ended up in method_missing while running: #{name.inspect}")
97
+ raise ::NoMethodError.new("Bug in configatron; ended up in method_missing while running: #{name.inspect}")
97
98
  end
98
99
  @method_missing = true
99
100
  do_lookup(name, *args, &block)
@@ -115,7 +116,7 @@ class Configatron
115
116
  if self.has_key?(key)
116
117
  return self[key]
117
118
  else
118
- raise Configatron::UndefinedKeyError.new($1)
119
+ raise ::Configatron::UndefinedKeyError.new($1)
119
120
  end
120
121
  else
121
122
  return self[name]
@@ -1,3 +1,3 @@
1
1
  class Configatron
2
- VERSION = "4.0.2"
2
+ VERSION = "4.0.3"
3
3
  end
@@ -14,7 +14,7 @@ class Critic::Unit::RootTest < Critic::Unit::Test
14
14
 
15
15
  describe 'global configatron' do
16
16
  it 'returns an instance of Configatron::RootStore' do
17
- assert_equal(true, configatron.kind_of?(Configatron::RootStore))
17
+ assert_equal(Configatron::RootStore.instance, configatron)
18
18
  end
19
19
  end
20
20
 
metadata CHANGED
@@ -1,69 +1,78 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: configatron
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.2
4
+ version: 4.0.3
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Mark Bates
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-06-13 00:00:00.000000000 Z
12
+ date: 2014-06-17 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rake
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - ">="
19
+ - - ! '>='
18
20
  - !ruby/object:Gem::Version
19
21
  version: '0'
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - ">="
27
+ - - ! '>='
25
28
  - !ruby/object:Gem::Version
26
29
  version: '0'
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: mocha
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - ">="
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: '0'
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - ">="
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: '0'
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: subprocess
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - ">="
51
+ - - ! '>='
46
52
  - !ruby/object:Gem::Version
47
53
  version: '0'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - ">="
59
+ - - ! '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0'
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: minitest
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
- - - ">="
67
+ - - ! '>='
60
68
  - !ruby/object:Gem::Version
61
69
  version: 5.2.3
62
70
  type: :development
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
- - - ">="
75
+ - - ! '>='
67
76
  - !ruby/object:Gem::Version
68
77
  version: 5.2.3
69
78
  description: A powerful Ruby configuration system.
@@ -73,9 +82,8 @@ executables: []
73
82
  extensions: []
74
83
  extra_rdoc_files: []
75
84
  files:
76
- - ".gitignore"
77
- - ".ruby-version"
78
- - ".travis.yml"
85
+ - .gitignore
86
+ - .travis.yml
79
87
  - Gemfile
80
88
  - Guardfile
81
89
  - History.txt
@@ -116,26 +124,33 @@ files:
116
124
  homepage: https://github.com/markbates/configatron
117
125
  licenses:
118
126
  - MIT
119
- metadata: {}
120
127
  post_install_message:
121
128
  rdoc_options: []
122
129
  require_paths:
123
130
  - lib
124
131
  required_ruby_version: !ruby/object:Gem::Requirement
132
+ none: false
125
133
  requirements:
126
- - - ">="
134
+ - - ! '>='
127
135
  - !ruby/object:Gem::Version
128
136
  version: '0'
137
+ segments:
138
+ - 0
139
+ hash: 418974604606994708
129
140
  required_rubygems_version: !ruby/object:Gem::Requirement
141
+ none: false
130
142
  requirements:
131
- - - ">="
143
+ - - ! '>='
132
144
  - !ruby/object:Gem::Version
133
145
  version: '0'
146
+ segments:
147
+ - 0
148
+ hash: 418974604606994708
134
149
  requirements: []
135
150
  rubyforge_project:
136
- rubygems_version: 2.2.1
151
+ rubygems_version: 1.8.25
137
152
  signing_key:
138
- specification_version: 4
153
+ specification_version: 3
139
154
  summary: A powerful Ruby configuration system.
140
155
  test_files:
141
156
  - test/_lib.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 42e2eb8bce1d430a7e733637d802f6385ef680d5
4
- data.tar.gz: 9f35fee29168a663d1f0c6b57d526a54f54e276b
5
- SHA512:
6
- metadata.gz: d9434069be9ce0666a151ef6882bee3e893f3e6842f2371edf510c88c7e8b9b8c48f8d397d6f9a3ba72c898af7891724607913d31e9e530a08720dbf43fc1469
7
- data.tar.gz: c2b2d51eab684d3b54bc226b021c6da58a801e98cd65d37d8f479ab854f4c54d3d46b6c169eed0f9dc301d1d1a4895cd8a930a91b2b5cfb4780fcda35d0a3e16
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.1.0