config_context 0.7.4 → 0.7.5
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/README.rdoc +9 -0
- data/lib/version.rb +1 -1
- data/test/test_config_context.rb +16 -15
- data/test/unit_extensions.rb +23 -0
- metadata +11 -10
data/README.rdoc
CHANGED
@@ -63,6 +63,15 @@ The latest stable version is published in rubygems.
|
|
63
63
|
|
64
64
|
puts ConfigContext.ContextA[:property]
|
65
65
|
|
66
|
+
##
|
67
|
+
# Retrive with default values
|
68
|
+
ConfigContext.fetch(:donotexist, "default value") -> "default value"
|
69
|
+
ConfigContext.donotexist? -> false
|
70
|
+
|
71
|
+
ConfigContext.fetch!(:donotexist, "default value") -> "default value"
|
72
|
+
ConfigContext.donotexist? -> true
|
73
|
+
|
74
|
+
|
66
75
|
== TODO
|
67
76
|
|
68
77
|
* Sugestions are wellcome guys
|
data/lib/version.rb
CHANGED
data/test/test_config_context.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..'))
|
1
2
|
$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
|
2
3
|
|
3
4
|
|
4
5
|
require 'rubygems'
|
5
|
-
require 'test/
|
6
|
+
require 'test/unit_extensions'
|
6
7
|
require 'config_context'
|
7
8
|
|
8
9
|
|
@@ -14,7 +15,7 @@ class TestConfigContext < Test::Unit::TestCase
|
|
14
15
|
TEST_LIST = [1, 2, 3]
|
15
16
|
TEST_HASH = { "a"=>1, "b"=>2, "c"=>3 }
|
16
17
|
|
17
|
-
|
18
|
+
|
18
19
|
def setup
|
19
20
|
|
20
21
|
ConfigContext.configure do |config|
|
@@ -32,7 +33,7 @@ class TestConfigContext < Test::Unit::TestCase
|
|
32
33
|
end
|
33
34
|
|
34
35
|
|
35
|
-
|
36
|
+
must "configure properties" do
|
36
37
|
|
37
38
|
assert_equal(ConfigContext.mysymbol, TEST_SYMBOL)
|
38
39
|
assert_equal(ConfigContext.mylist, TEST_LIST)
|
@@ -41,7 +42,7 @@ class TestConfigContext < Test::Unit::TestCase
|
|
41
42
|
end
|
42
43
|
|
43
44
|
|
44
|
-
|
45
|
+
must "check the presence of some properties" do
|
45
46
|
|
46
47
|
assert(ConfigContext.mysymbol?)
|
47
48
|
assert(ConfigContext.mylist?)
|
@@ -50,7 +51,7 @@ class TestConfigContext < Test::Unit::TestCase
|
|
50
51
|
end
|
51
52
|
|
52
53
|
|
53
|
-
|
54
|
+
must "retrive all properties" do
|
54
55
|
|
55
56
|
assert_equal(ConfigContext.to_hash, {
|
56
57
|
:mysymbol =>TEST_SYMBOL,
|
@@ -60,7 +61,7 @@ class TestConfigContext < Test::Unit::TestCase
|
|
60
61
|
end
|
61
62
|
|
62
63
|
|
63
|
-
|
64
|
+
must "retrive all properties with defaults" do
|
64
65
|
|
65
66
|
assert(!ConfigContext.fetch(:mysymbol_))
|
66
67
|
|
@@ -74,7 +75,7 @@ class TestConfigContext < Test::Unit::TestCase
|
|
74
75
|
end
|
75
76
|
|
76
77
|
|
77
|
-
|
78
|
+
must "retrieve all property keys" do
|
78
79
|
|
79
80
|
[:mysymbol, :mylist, :myhash].each do |key|
|
80
81
|
|
@@ -82,7 +83,7 @@ class TestConfigContext < Test::Unit::TestCase
|
|
82
83
|
end
|
83
84
|
end
|
84
85
|
|
85
|
-
|
86
|
+
must "update properties" do
|
86
87
|
|
87
88
|
assert_equal(ConfigContext.mysymbol, TEST_SYMBOL)
|
88
89
|
ConfigContext.mysymbol = "A"
|
@@ -100,7 +101,7 @@ class TestConfigContext < Test::Unit::TestCase
|
|
100
101
|
end
|
101
102
|
|
102
103
|
|
103
|
-
|
104
|
+
must "configure from a hash" do
|
104
105
|
|
105
106
|
config_hash = {
|
106
107
|
:mysymbol =>TEST_SYMBOL,
|
@@ -113,7 +114,7 @@ class TestConfigContext < Test::Unit::TestCase
|
|
113
114
|
end
|
114
115
|
|
115
116
|
|
116
|
-
|
117
|
+
must "configuration from a file that not exist" do
|
117
118
|
|
118
119
|
['json', 'yaml', 'yml'].each do |extension|
|
119
120
|
|
@@ -122,7 +123,7 @@ class TestConfigContext < Test::Unit::TestCase
|
|
122
123
|
end
|
123
124
|
|
124
125
|
|
125
|
-
|
126
|
+
must "configuration from a bad format file" do
|
126
127
|
|
127
128
|
['foo', 'bar', 'bazz'].each do |extension|
|
128
129
|
|
@@ -142,7 +143,7 @@ class TestConfigContext < Test::Unit::TestCase
|
|
142
143
|
end
|
143
144
|
|
144
145
|
|
145
|
-
|
146
|
+
must "configure from a yaml file" do
|
146
147
|
|
147
148
|
ConfigContext.configure(TEST_FILE_YAML)
|
148
149
|
assert_equal(ConfigContext.to_hash, {
|
@@ -156,7 +157,7 @@ class TestConfigContext < Test::Unit::TestCase
|
|
156
157
|
end
|
157
158
|
|
158
159
|
|
159
|
-
|
160
|
+
must "configure from a yaml file in a context" do
|
160
161
|
|
161
162
|
ConfigContext.configure(TEST_FILE_YAML, :context=>:yaml)
|
162
163
|
|
@@ -179,7 +180,7 @@ class TestConfigContext < Test::Unit::TestCase
|
|
179
180
|
end
|
180
181
|
|
181
182
|
|
182
|
-
|
183
|
+
must "configure from a json file" do
|
183
184
|
|
184
185
|
ConfigContext.configure(TEST_FILE_JSON)
|
185
186
|
|
@@ -194,7 +195,7 @@ class TestConfigContext < Test::Unit::TestCase
|
|
194
195
|
end
|
195
196
|
|
196
197
|
|
197
|
-
|
198
|
+
must "configure from a json file in a context" do
|
198
199
|
|
199
200
|
ConfigContext.configure(TEST_FILE_JSON, :context=>:json)
|
200
201
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require'test/unit'
|
3
|
+
|
4
|
+
|
5
|
+
module Test::Unit
|
6
|
+
|
7
|
+
class TestCase
|
8
|
+
|
9
|
+
def self.must(name, &block)
|
10
|
+
|
11
|
+
test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
|
12
|
+
defined = instance_method(test_name) rescue false
|
13
|
+
|
14
|
+
raise "#{test_name} is already defined in #{self}" if defined
|
15
|
+
|
16
|
+
if block_given?
|
17
|
+
define_method(test_name, &block)
|
18
|
+
else
|
19
|
+
define_method(test_name) { flunk "No implementation provided for #{name}" }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: config_context
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-07-
|
12
|
+
date: 2011-07-03 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
16
|
-
requirement: &
|
16
|
+
requirement: &2152005220 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2152005220
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: jeweler
|
27
|
-
requirement: &
|
27
|
+
requirement: &2152003920 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2152003920
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rcov
|
38
|
-
requirement: &
|
38
|
+
requirement: &2151944680 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2151944680
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: json
|
49
|
-
requirement: &
|
49
|
+
requirement: &2151943040 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2151943040
|
58
58
|
description: My config DSL
|
59
59
|
email: javier.juarez@gmail.com
|
60
60
|
executables: []
|
@@ -66,6 +66,7 @@ files:
|
|
66
66
|
- lib/config_context.rb
|
67
67
|
- lib/version.rb
|
68
68
|
- test/test_config_context.rb
|
69
|
+
- test/unit_extensions.rb
|
69
70
|
- LICENSE
|
70
71
|
- README.rdoc
|
71
72
|
homepage: http://github.com/jjuarez/config_context
|