configatron 1.2.2 → 2.0.0
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 +61 -34
- data/doc/classes/Configatron.html +241 -0
- data/doc/classes/Configatron/ProtectedParameter.html +146 -0
- data/doc/classes/Configatron/Store.html +241 -121
- data/doc/classes/Kernel.html +13 -20
- data/doc/created.rid +1 -1
- data/doc/files/README.html +85 -43
- data/doc/files/lib/configatron/{configuration_rb.html → configatron_rb.html} +11 -4
- data/doc/files/lib/configatron/{helpers_rb.html → errors_rb.html} +4 -4
- data/doc/files/lib/configatron/kernel_rb.html +1 -1
- data/doc/files/lib/configatron/store_rb.html +1 -1
- data/doc/files/lib/configatron_rb.html +1 -2
- data/doc/fr_class_index.html +2 -4
- data/doc/fr_file_index.html +2 -3
- data/doc/fr_method_index.html +15 -21
- data/lib/configatron.rb +5 -44
- data/lib/configatron/configatron.rb +44 -0
- data/lib/configatron/errors.rb +7 -0
- data/lib/configatron/kernel.rb +3 -9
- data/lib/configatron/store.rb +148 -56
- data/spec/lib/configatron_spec.rb +293 -0
- data/spec/lib/futurama.yml +6 -0
- data/spec/spec_helper.rb +3 -2
- metadata +11 -18
- data/doc/classes/Configatron/Configuration.html +0 -402
- data/doc/classes/Configatron/Helpers.html +0 -174
- data/doc/classes/Configatron/YamlStore.html +0 -203
- data/doc/classes/Hash.html +0 -193
- data/doc/files/lib/configatron/yaml_store_rb.html +0 -101
- data/lib/configatron/configuration.rb +0 -112
- data/lib/configatron/helpers.rb +0 -27
- data/lib/configatron/yaml_store.rb +0 -33
- data/spec/unit/configuration_spec.rb +0 -299
- data/spec/unit/family_guy.yml +0 -2
- data/spec/unit/helpers_spec.rb +0 -115
- data/spec/unit/kernel_spec.rb +0 -48
- data/spec/unit/store_spec.rb +0 -91
data/spec/unit/family_guy.yml
DELETED
data/spec/unit/helpers_spec.rb
DELETED
@@ -1,115 +0,0 @@
|
|
1
|
-
require 'pathname'
|
2
|
-
require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'
|
3
|
-
|
4
|
-
describe Configatron::Helpers do
|
5
|
-
|
6
|
-
before :each do
|
7
|
-
configatron.reset!
|
8
|
-
end
|
9
|
-
|
10
|
-
describe "exists?" do
|
11
|
-
|
12
|
-
it "should return true or false if the configuration parameter exists" do
|
13
|
-
|
14
|
-
configatron.exists?(:foo).should == false
|
15
|
-
configatron.exists?(:email).should == false
|
16
|
-
|
17
|
-
configatron do |config|
|
18
|
-
config.foo = :bar
|
19
|
-
config.namespace(:email) do |email|
|
20
|
-
email.address = "mark@mackframework.com"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
configatron.exists?(:foo).should == true
|
25
|
-
configatron.exists?(:email).should == true
|
26
|
-
configatron.email.exists?(:address).should == true
|
27
|
-
configatron.email.exists?(:server).should == false
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
describe "retrieve" do
|
34
|
-
|
35
|
-
before :each do
|
36
|
-
configatron do |config|
|
37
|
-
config.foo = :bar
|
38
|
-
config.namespace(:email) do |email|
|
39
|
-
email.address = "mark@mackframework.com"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should return a valid parameter" do
|
45
|
-
configatron.retrieve(:foo).should == :bar
|
46
|
-
configatron.email.retrieve(:address).should == "mark@mackframework.com"
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should return a default value if one is specified" do
|
50
|
-
configatron.retrieve(:name, "mark").should == "mark"
|
51
|
-
configatron.email.retrieve(:server, "pop3.example.com").should == "pop3.example.com"
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should behave like a standard missing parameter if no default value is specified" do
|
55
|
-
lambda{configatron.retrieve(:name)}.should raise_error(NoMethodError)
|
56
|
-
lambda{configatron.email.retrieve(:name)}.should raise_error(NoMethodError)
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should return nil if the default value is nil" do
|
60
|
-
configatron.retrieve(:name, nil).should == nil
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should work!" do
|
64
|
-
require 'logger'
|
65
|
-
configatron do |config|
|
66
|
-
config.namespace(:mack) do |mack|
|
67
|
-
mack.render_url_timeout = 5
|
68
|
-
mack.cache_classes = true
|
69
|
-
mack.use_lint = true
|
70
|
-
mack.show_exceptions = true
|
71
|
-
mack.session_id = "_mack_session_id"
|
72
|
-
mack.cookie_values = {
|
73
|
-
"path" => "/"
|
74
|
-
}
|
75
|
-
mack.site_domain = "http://localhost:3000"
|
76
|
-
mack.use_distributed_routes = false
|
77
|
-
mack.distributed_app_name = nil
|
78
|
-
mack.drb_timeout = 1
|
79
|
-
mack.default_respository_name = "default"
|
80
|
-
end
|
81
|
-
config.namespace(:cachetastic_default_options) do |cache|
|
82
|
-
cache.debug = false
|
83
|
-
cache.adapter = :local_memory
|
84
|
-
logger = ::Logger.new(STDOUT)
|
85
|
-
logger.level = ::Logger::INFO
|
86
|
-
cache.logger = logger
|
87
|
-
end
|
88
|
-
config.namespace(:log) do |log|
|
89
|
-
log.detailed_requests = true
|
90
|
-
log.level = :info
|
91
|
-
log.console = false
|
92
|
-
log.file = true
|
93
|
-
log.console_format = "%l:\t[%d]\t%M"
|
94
|
-
log.file_format = "%l:\t[%d]\t%M"
|
95
|
-
end
|
96
|
-
end
|
97
|
-
configatron do |config|
|
98
|
-
config.namespace(:mack) do |mack|
|
99
|
-
mack.drb_timeout = 0
|
100
|
-
mack.cookie_values = {}
|
101
|
-
end
|
102
|
-
config.namespace(:log) do |log|
|
103
|
-
log.level = :error
|
104
|
-
end
|
105
|
-
config.run_remote_tests = true
|
106
|
-
end
|
107
|
-
|
108
|
-
configatron.log.retrieve(:file, false).should == true
|
109
|
-
configatron.log.file.should == true
|
110
|
-
|
111
|
-
end
|
112
|
-
|
113
|
-
end
|
114
|
-
|
115
|
-
end
|
data/spec/unit/kernel_spec.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'pathname'
|
2
|
-
require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'
|
3
|
-
|
4
|
-
describe Kernel do
|
5
|
-
|
6
|
-
it "should have a configatron method" do
|
7
|
-
configatron
|
8
|
-
end
|
9
|
-
|
10
|
-
describe "configatron" do
|
11
|
-
|
12
|
-
before :each do
|
13
|
-
configatron.reset!
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should raise NoMethodError if the parameter doesn't exist" do
|
17
|
-
lambda{configatron.i_dont_exist}.should raise_error(NoMethodError)
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should return nil if nil_for_missing is set to true" do
|
21
|
-
configatron.nil_for_missing = true
|
22
|
-
configatron.i_dont_exist.should == nil
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should take a block that allows for the configuration of the configatron system" do
|
26
|
-
lambda{configatron.foo}.should raise_error(NoMethodError)
|
27
|
-
configatron do |config|
|
28
|
-
config.foo = :bar
|
29
|
-
config.say_hello = "Hello World"
|
30
|
-
end
|
31
|
-
configatron.foo.should == :bar
|
32
|
-
configatron.say_hello == "Hello World"
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should allow previously defined parameters to be redefined" do
|
36
|
-
configatron do |config|
|
37
|
-
config.foo = :bar
|
38
|
-
end
|
39
|
-
configatron.foo.should == :bar
|
40
|
-
configatron do |config|
|
41
|
-
config.foo = "fubar"
|
42
|
-
end
|
43
|
-
configatron.foo.should == "fubar"
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
data/spec/unit/store_spec.rb
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
require 'pathname'
|
2
|
-
require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'
|
3
|
-
|
4
|
-
describe Configatron::Store do
|
5
|
-
|
6
|
-
before :each do
|
7
|
-
configatron.reset!
|
8
|
-
end
|
9
|
-
|
10
|
-
describe "namespace" do
|
11
|
-
|
12
|
-
it "should let you 'namespace' a set of configuration parameters" do
|
13
|
-
lambda{configatron.foo}.should raise_error(NoMethodError)
|
14
|
-
configatron do |config|
|
15
|
-
config.namespace(:foo) do |foo|
|
16
|
-
foo.bar = :bar
|
17
|
-
end
|
18
|
-
end
|
19
|
-
configatron.foo.bar.should == :bar
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should raise NoMethodError if nil_for_missing is set to false" do
|
23
|
-
lambda{configatron.foo}.should raise_error(NoMethodError)
|
24
|
-
configatron do |config|
|
25
|
-
config.namespace(:foo) do |foo|
|
26
|
-
foo.bar = :bar
|
27
|
-
end
|
28
|
-
end
|
29
|
-
lambda{configatron.foo.say_hello}.should raise_error(NoMethodError)
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should allow for unlimited nested namespaces" do
|
33
|
-
configatron do |config|
|
34
|
-
config.namespace(:foo) do |foo|
|
35
|
-
foo.bar = :bar
|
36
|
-
foo.namespace(:apples) do |apps|
|
37
|
-
apps.granny_smith = "Granny Smith"
|
38
|
-
apps.red = "Red"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
configatron.foo.bar.should == :bar
|
43
|
-
configatron.foo.apples.granny_smith.should == "Granny Smith"
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should not override all parameters when you namespace" do
|
47
|
-
configatron do |config|
|
48
|
-
config.namespace(:foo) do |foo|
|
49
|
-
foo.bar = :bar
|
50
|
-
foo.name = "mark"
|
51
|
-
end
|
52
|
-
end
|
53
|
-
configatron.foo.bar.should == :bar
|
54
|
-
configatron.foo.name.should == "mark"
|
55
|
-
|
56
|
-
configatron do |config|
|
57
|
-
config.namespace(:foo) do |foo|
|
58
|
-
foo.name = "mark bates"
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
configatron.foo.bar.should == :bar
|
63
|
-
configatron.foo.name.should == "mark bates"
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe 'to_hash' do
|
68
|
-
it "should convert the store to a hash" do
|
69
|
-
configatron do |config|
|
70
|
-
config.namespace :baz do |baz|
|
71
|
-
baz.foo = 'bar'
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
configatron.baz.to_hash.should == {:foo => 'bar'}
|
76
|
-
end
|
77
|
-
|
78
|
-
it 'should support multiple nesting levels in the store' do
|
79
|
-
configatron do |config|
|
80
|
-
config.namespace :baz do |baz|
|
81
|
-
baz.foo = 'bar'
|
82
|
-
baz.namespace :quux do |quux|
|
83
|
-
quux.foob = 'barbaz'
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
configatron.baz.to_hash.should == {:foo => 'bar', :quux => {:foob => 'barbaz'}}
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|