tiny_config 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tiny_config.rb +7 -4
- data/lib/tiny_config/version.rb +1 -1
- data/spec/tiny_config_spec.rb +10 -0
- data/tiny_config.gemspec +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47e176165b14b0b1001f0fda0390f8726d8e17e2
|
4
|
+
data.tar.gz: f782832b4521a906aab935dfb1878cd252cc38a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29004940958f153abf5201eb7af317c0d74dcb684102d7b4eaf19411c400dffc539c60fd080836aa26ace48d257e64c1bd14de60405d304715dd2106203c729a
|
7
|
+
data.tar.gz: cf9c8d084d55ab156a94cf57cc6afa5b7514331af56f8c142e39dd23d8f02c9626918b2e02e778fe7f08b398c167a4c316696ef3e46d04f0753ffd22f36a53cd
|
data/lib/tiny_config.rb
CHANGED
@@ -13,14 +13,13 @@ class TinyConfig
|
|
13
13
|
|
14
14
|
define_method config_key do
|
15
15
|
v = instance_variable_get("@#{config_key}")
|
16
|
-
v.nil? ? raise(TinyConfig::ConfigKeyNillError, message) : v
|
16
|
+
v.nil? ? raise(TinyConfig::ConfigKeyNillError, message(config_key)) : v
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
def message
|
20
|
+
def message config_key
|
21
21
|
namespace = self.class.to_s.split('::').last.downcase
|
22
|
-
|
23
|
-
"#{namespace} #{required_key} is requried."
|
22
|
+
"#{namespace} #{config_key} is requried."
|
24
23
|
end
|
25
24
|
}
|
26
25
|
end
|
@@ -30,6 +29,10 @@ class TinyConfig
|
|
30
29
|
const_get(namespace.capitalize).instance
|
31
30
|
end
|
32
31
|
|
32
|
+
def self.clear!
|
33
|
+
constants.each { |c| remove_const(c) unless c =~ /Error$/ }
|
34
|
+
end
|
35
|
+
|
33
36
|
class ConfigKeyNillError < StandardError; end
|
34
37
|
class UndefinedNamespaceError < StandardError; end
|
35
38
|
end
|
data/lib/tiny_config/version.rb
CHANGED
data/spec/tiny_config_spec.rb
CHANGED
@@ -35,4 +35,14 @@ describe TinyConfig, order: :defined do
|
|
35
35
|
it { expect { TinyConfig.unregistered.key }.to raise_error TinyConfig::UndefinedNamespaceError }
|
36
36
|
end
|
37
37
|
end
|
38
|
+
|
39
|
+
context 'clear!' do
|
40
|
+
it 'deletes all const' do
|
41
|
+
TinyConfig.register(:config_d, :key)
|
42
|
+
TinyConfig.register(:config_e, :key)
|
43
|
+
TinyConfig.clear!
|
44
|
+
expect { TinyConfig.config_d.key }.to raise_error TinyConfig::UndefinedNamespaceError
|
45
|
+
expect { TinyConfig.config_e.key }.to raise_error TinyConfig::UndefinedNamespaceError
|
46
|
+
end
|
47
|
+
end
|
38
48
|
end
|
data/tiny_config.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["gon.gong.gone@gmail.com"]
|
11
11
|
spec.description = %q{simple and tiny config class for casual use}
|
12
12
|
spec.summary = %q{simple and tiny config class}
|
13
|
-
spec.homepage = "https://
|
13
|
+
spec.homepage = "https://github.com/gong023/tiny_config"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tiny_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gong023
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -71,7 +71,7 @@ files:
|
|
71
71
|
- spec/spec_helper.rb
|
72
72
|
- spec/tiny_config_spec.rb
|
73
73
|
- tiny_config.gemspec
|
74
|
-
homepage: https://
|
74
|
+
homepage: https://github.com/gong023/tiny_config
|
75
75
|
licenses:
|
76
76
|
- MIT
|
77
77
|
metadata: {}
|
@@ -98,4 +98,3 @@ summary: simple and tiny config class
|
|
98
98
|
test_files:
|
99
99
|
- spec/spec_helper.rb
|
100
100
|
- spec/tiny_config_spec.rb
|
101
|
-
has_rdoc:
|