config_context 0.7.7 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +11 -0
- data/Gemfile.lock +22 -0
- data/LICENSE.txt +20 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/config_context.gemspec +65 -0
- data/test/fixtures/test.json +5 -0
- data/test/fixtures/test.yml +10 -0
- data/test/helper.rb +14 -0
- data/test/test_config_context.rb +15 -20
- metadata +45 -23
- data/lib/version.rb +0 -24
- data/test/unit_extensions.rb +0 -23
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
git (1.2.5)
|
5
|
+
jeweler (1.6.4)
|
6
|
+
bundler (~> 1.0)
|
7
|
+
git (>= 1.2.5)
|
8
|
+
rake
|
9
|
+
json (1.5.3)
|
10
|
+
rake (0.9.2)
|
11
|
+
rcov (0.9.9)
|
12
|
+
shoulda (2.11.3)
|
13
|
+
|
14
|
+
PLATFORMS
|
15
|
+
ruby
|
16
|
+
|
17
|
+
DEPENDENCIES
|
18
|
+
bundler (~> 1.0.0)
|
19
|
+
jeweler (~> 1.6.4)
|
20
|
+
json
|
21
|
+
rcov
|
22
|
+
shoulda
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Javier Juarez
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
|
17
|
+
gem.name = "config_context"
|
18
|
+
gem.homepage = "http://github.com/jjuarez/config_context"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{My configuration DSL}
|
21
|
+
gem.description = %Q{A library for help to configure applications}
|
22
|
+
gem.email = "javier.juarez@gmail.com"
|
23
|
+
gem.authors = ["Javier Juarez"]
|
24
|
+
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
require 'rcov/rcovtask'
|
36
|
+
Rcov::RcovTask.new do |test|
|
37
|
+
test.libs << 'test'
|
38
|
+
test.pattern = 'test/**/test_*.rb'
|
39
|
+
test.verbose = true
|
40
|
+
test.rcov_opts << '--exclude "gems/*"'
|
41
|
+
end
|
42
|
+
|
43
|
+
task :default => :test
|
44
|
+
|
45
|
+
require 'rake/rdoctask'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "gema #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.8.1
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{config_context}
|
8
|
+
s.version = "0.8.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = [%q{Javier Juarez}]
|
12
|
+
s.date = %q{2011-07-11}
|
13
|
+
s.description = %q{A library for help to configure applications}
|
14
|
+
s.email = %q{javier.juarez@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"LICENSE.txt",
|
18
|
+
"README.rdoc"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
"Gemfile",
|
22
|
+
"Gemfile.lock",
|
23
|
+
"LICENSE",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"config_context.gemspec",
|
29
|
+
"lib/config_context.rb",
|
30
|
+
"test/fixtures/test.json",
|
31
|
+
"test/fixtures/test.yml",
|
32
|
+
"test/helper.rb",
|
33
|
+
"test/test_config_context.rb"
|
34
|
+
]
|
35
|
+
s.homepage = %q{http://github.com/jjuarez/config_context}
|
36
|
+
s.licenses = [%q{MIT}]
|
37
|
+
s.require_paths = [%q{lib}]
|
38
|
+
s.rubygems_version = %q{1.8.5}
|
39
|
+
s.summary = %q{My configuration DSL}
|
40
|
+
|
41
|
+
if s.respond_to? :specification_version then
|
42
|
+
s.specification_version = 3
|
43
|
+
|
44
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
45
|
+
s.add_runtime_dependency(%q<json>, [">= 0"])
|
46
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
47
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
48
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
49
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
50
|
+
else
|
51
|
+
s.add_dependency(%q<json>, [">= 0"])
|
52
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
53
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
54
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
55
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
56
|
+
end
|
57
|
+
else
|
58
|
+
s.add_dependency(%q<json>, [">= 0"])
|
59
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
60
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
61
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
62
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
data/test/helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
data/test/test_config_context.rb
CHANGED
@@ -1,9 +1,4 @@
|
|
1
|
-
|
2
|
-
$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
|
3
|
-
|
4
|
-
|
5
|
-
require 'rubygems'
|
6
|
-
require 'test/unit_extensions'
|
1
|
+
require 'helper'
|
7
2
|
require 'config_context'
|
8
3
|
|
9
4
|
|
@@ -33,7 +28,7 @@ class TestConfigContext < Test::Unit::TestCase
|
|
33
28
|
end
|
34
29
|
|
35
30
|
|
36
|
-
|
31
|
+
should "configure properties" do
|
37
32
|
|
38
33
|
assert_equal(ConfigContext.mysymbol, TEST_SYMBOL)
|
39
34
|
assert_equal(ConfigContext.mylist, TEST_LIST)
|
@@ -42,7 +37,7 @@ class TestConfigContext < Test::Unit::TestCase
|
|
42
37
|
end
|
43
38
|
|
44
39
|
|
45
|
-
|
40
|
+
should "check the presence of some properties" do
|
46
41
|
|
47
42
|
assert(ConfigContext.mysymbol?)
|
48
43
|
assert(ConfigContext.mylist?)
|
@@ -51,7 +46,7 @@ class TestConfigContext < Test::Unit::TestCase
|
|
51
46
|
end
|
52
47
|
|
53
48
|
|
54
|
-
|
49
|
+
should "retrive all properties" do
|
55
50
|
|
56
51
|
assert_equal(ConfigContext.to_hash, {
|
57
52
|
:mysymbol =>TEST_SYMBOL,
|
@@ -61,7 +56,7 @@ class TestConfigContext < Test::Unit::TestCase
|
|
61
56
|
end
|
62
57
|
|
63
58
|
|
64
|
-
|
59
|
+
should "retrive all properties with defaults" do
|
65
60
|
|
66
61
|
assert(!ConfigContext.fetch(:mysymbol_))
|
67
62
|
|
@@ -75,7 +70,7 @@ class TestConfigContext < Test::Unit::TestCase
|
|
75
70
|
end
|
76
71
|
|
77
72
|
|
78
|
-
|
73
|
+
should "retrieve all property keys" do
|
79
74
|
|
80
75
|
[:mysymbol, :mylist, :myhash].each do |key|
|
81
76
|
|
@@ -83,7 +78,7 @@ class TestConfigContext < Test::Unit::TestCase
|
|
83
78
|
end
|
84
79
|
end
|
85
80
|
|
86
|
-
|
81
|
+
should "update properties" do
|
87
82
|
|
88
83
|
assert_equal(ConfigContext.mysymbol, TEST_SYMBOL)
|
89
84
|
ConfigContext.mysymbol = "A"
|
@@ -101,7 +96,7 @@ class TestConfigContext < Test::Unit::TestCase
|
|
101
96
|
end
|
102
97
|
|
103
98
|
|
104
|
-
|
99
|
+
should "configure from a hash" do
|
105
100
|
|
106
101
|
config_hash = {
|
107
102
|
:mysymbol =>TEST_SYMBOL,
|
@@ -114,7 +109,7 @@ class TestConfigContext < Test::Unit::TestCase
|
|
114
109
|
end
|
115
110
|
|
116
111
|
|
117
|
-
|
112
|
+
should "configuration from a file that not exist" do
|
118
113
|
|
119
114
|
['json', 'yaml', 'yml'].each do |extension|
|
120
115
|
|
@@ -123,7 +118,7 @@ class TestConfigContext < Test::Unit::TestCase
|
|
123
118
|
end
|
124
119
|
|
125
120
|
|
126
|
-
|
121
|
+
should "configuration from a bad format file" do
|
127
122
|
|
128
123
|
['foo', 'bar', 'bazz'].each do |extension|
|
129
124
|
|
@@ -143,7 +138,7 @@ class TestConfigContext < Test::Unit::TestCase
|
|
143
138
|
end
|
144
139
|
|
145
140
|
|
146
|
-
|
141
|
+
should "configure from a yaml file" do
|
147
142
|
|
148
143
|
ConfigContext.configure(TEST_FILE_YAML)
|
149
144
|
assert_equal(ConfigContext.to_hash, {
|
@@ -157,7 +152,7 @@ class TestConfigContext < Test::Unit::TestCase
|
|
157
152
|
end
|
158
153
|
|
159
154
|
|
160
|
-
|
155
|
+
should "configure from a yaml file in a context" do
|
161
156
|
|
162
157
|
ConfigContext.configure(TEST_FILE_YAML, :context=>:yaml)
|
163
158
|
|
@@ -180,7 +175,7 @@ class TestConfigContext < Test::Unit::TestCase
|
|
180
175
|
end
|
181
176
|
|
182
177
|
|
183
|
-
|
178
|
+
should "configure from a json file" do
|
184
179
|
|
185
180
|
ConfigContext.configure(TEST_FILE_JSON)
|
186
181
|
|
@@ -195,7 +190,7 @@ class TestConfigContext < Test::Unit::TestCase
|
|
195
190
|
end
|
196
191
|
|
197
192
|
|
198
|
-
|
193
|
+
should "configure from a json file in a context" do
|
199
194
|
|
200
195
|
ConfigContext.configure(TEST_FILE_JSON, :context=>:json)
|
201
196
|
|
@@ -216,4 +211,4 @@ class TestConfigContext < Test::Unit::TestCase
|
|
216
211
|
"myhash" =>TEST_HASH
|
217
212
|
})
|
218
213
|
end
|
219
|
-
end
|
214
|
+
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.
|
4
|
+
version: 0.8.1
|
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-11 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
16
|
-
requirement: &
|
16
|
+
requirement: &2157466920 !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: *2157466920
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
27
|
-
requirement: &
|
26
|
+
name: shoulda
|
27
|
+
requirement: &2157466240 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,43 +32,62 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2157466240
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
38
|
-
requirement: &
|
37
|
+
name: bundler
|
38
|
+
requirement: &2157465760 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
|
-
- -
|
41
|
+
- - ~>
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
43
|
+
version: 1.0.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2157465760
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
49
|
-
requirement: &
|
48
|
+
name: jeweler
|
49
|
+
requirement: &2157465260 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.6.4
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *2157465260
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rcov
|
60
|
+
requirement: &2157464780 !ruby/object:Gem::Requirement
|
50
61
|
none: false
|
51
62
|
requirements:
|
52
63
|
- - ! '>='
|
53
64
|
- !ruby/object:Gem::Version
|
54
65
|
version: '0'
|
55
|
-
type: :
|
66
|
+
type: :development
|
56
67
|
prerelease: false
|
57
|
-
version_requirements: *
|
58
|
-
description:
|
68
|
+
version_requirements: *2157464780
|
69
|
+
description: A library for help to configure applications
|
59
70
|
email: javier.juarez@gmail.com
|
60
71
|
executables: []
|
61
72
|
extensions: []
|
62
73
|
extra_rdoc_files:
|
63
74
|
- LICENSE
|
75
|
+
- LICENSE.txt
|
64
76
|
- README.rdoc
|
65
77
|
files:
|
66
|
-
-
|
67
|
-
-
|
68
|
-
- test/test_config_context.rb
|
69
|
-
- test/unit_extensions.rb
|
78
|
+
- Gemfile
|
79
|
+
- Gemfile.lock
|
70
80
|
- LICENSE
|
81
|
+
- LICENSE.txt
|
71
82
|
- README.rdoc
|
83
|
+
- Rakefile
|
84
|
+
- VERSION
|
85
|
+
- config_context.gemspec
|
86
|
+
- lib/config_context.rb
|
87
|
+
- test/fixtures/test.json
|
88
|
+
- test/fixtures/test.yml
|
89
|
+
- test/helper.rb
|
90
|
+
- test/test_config_context.rb
|
72
91
|
homepage: http://github.com/jjuarez/config_context
|
73
92
|
licenses:
|
74
93
|
- MIT
|
@@ -82,6 +101,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
82
101
|
- - ! '>='
|
83
102
|
- !ruby/object:Gem::Version
|
84
103
|
version: '0'
|
104
|
+
segments:
|
105
|
+
- 0
|
106
|
+
hash: -1645213854342472309
|
85
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
108
|
none: false
|
87
109
|
requirements:
|
@@ -89,9 +111,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
111
|
- !ruby/object:Gem::Version
|
90
112
|
version: '0'
|
91
113
|
requirements: []
|
92
|
-
rubyforge_project:
|
114
|
+
rubyforge_project:
|
93
115
|
rubygems_version: 1.8.5
|
94
116
|
signing_key:
|
95
117
|
specification_version: 3
|
96
|
-
summary:
|
118
|
+
summary: My configuration DSL
|
97
119
|
test_files: []
|
data/lib/version.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
module ConfigContext
|
2
|
-
class Version
|
3
|
-
|
4
|
-
INFO = {
|
5
|
-
:major =>0,
|
6
|
-
:minor =>7,
|
7
|
-
:patch =>7
|
8
|
-
}
|
9
|
-
|
10
|
-
def self.number(version_info=INFO)
|
11
|
-
|
12
|
-
if RUBY_VERSION =~ /1\.8\.\d/
|
13
|
-
[version_info[:major], version_info[:minor],version_info[:patch]].join('.')
|
14
|
-
else
|
15
|
-
version_info.values.join('.')
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
NAME = 'config_context'
|
21
|
-
NUMBER = "#{number()}"
|
22
|
-
VERSION = [INFO[:major], INFO[:minor], INFO[:patch]].join( '.' )
|
23
|
-
end
|
24
|
-
end
|
data/test/unit_extensions.rb
DELETED
@@ -1,23 +0,0 @@
|
|
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
|