cantango-config 0.1.9.2 → 0.2.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.mdown +16 -0
- data/VERSION +1 -1
- data/cantango-config.gemspec +68 -62
- data/lib/cantango/category.rb +18 -0
- data/lib/cantango/class_methods.rb +10 -0
- data/lib/cantango/config.rb +43 -2
- data/lib/cantango/{configuration → config}/ability.rb +8 -3
- data/lib/cantango/config/ability/engine.rb +45 -0
- data/lib/cantango/config/ability/modes.rb +16 -0
- data/lib/cantango/config/ability/modes/execution.rb +19 -0
- data/lib/cantango/{configuration → config}/account.rb +1 -1
- data/lib/cantango/{configuration → config}/accounts.rb +2 -3
- data/lib/cantango/{configuration → config}/adapters.rb +4 -4
- data/lib/cantango/{configuration → config}/autoload.rb +1 -1
- data/lib/cantango/{configuration → config}/categories.rb +3 -4
- data/lib/cantango/config/class_methods.rb +27 -0
- data/lib/cantango/{configuration → config}/debug.rb +1 -1
- data/lib/cantango/config/engines.rb +47 -0
- data/lib/cantango/config/engines/available.rb +19 -0
- data/lib/cantango/config/engines/order.rb +48 -0
- data/lib/cantango/{configuration → config}/factory.rb +1 -1
- data/lib/cantango/{configuration → config}/guest.rb +5 -6
- data/lib/cantango/config/helpers.rb +17 -0
- data/lib/cantango/{configuration → config}/hooks.rb +3 -3
- data/lib/cantango/{configuration → config}/localhosts.rb +4 -5
- data/lib/cantango/{configuration → config}/models.rb +16 -7
- data/lib/cantango/{configuration → config}/models/actions.rb +0 -0
- data/lib/cantango/{configuration → config}/models/active_record.rb +0 -0
- data/lib/cantango/{configuration → config}/models/data_mapper.rb +0 -0
- data/lib/cantango/{configuration → config}/models/generic.rb +0 -0
- data/lib/cantango/{configuration → config}/models/mongo.rb +0 -0
- data/lib/cantango/{configuration → config}/models/mongo_mapper.rb +0 -0
- data/lib/cantango/{configuration → config}/models/mongoid.rb +0 -0
- data/lib/cantango/{configuration → config}/orms.rb +2 -2
- data/lib/cantango/{configuration → config}/user.rb +1 -1
- data/lib/cantango/{configuration → config}/users.rb +2 -2
- data/lib/cantango/registry.rb +5 -0
- data/lib/cantango/{configuration/registry → registry}/base.rb +18 -4
- data/lib/cantango/registry/clazz.rb +92 -0
- data/lib/cantango/{configuration/registry → registry}/hash.rb +8 -10
- data/spec/cantango/category_spec.rb +21 -0
- data/spec/cantango/config/ability/modes/execution_spec.rb +33 -0
- data/spec/cantango/{configuration → config/ability}/modes_spec.rb +3 -3
- data/spec/cantango/{configuration → config}/ability_spec.rb +3 -3
- data/spec/cantango/{configuration → config}/account_spec.rb +1 -1
- data/spec/cantango/{configuration → config}/accounts_spec.rb +3 -3
- data/spec/cantango/{configuration → config}/adapters_spec.rb +1 -1
- data/spec/cantango/{configuration → config}/autoload_spec.rb +1 -2
- data/spec/cantango/{configuration → config}/categories_spec.rb +2 -10
- data/spec/cantango/config/class_methods_spec.rb +12 -0
- data/spec/cantango/{configuration → config}/debug_spec.rb +2 -7
- data/spec/cantango/config/engines/available_spec.rb +29 -0
- data/spec/cantango/{configuration → config}/engines/engine_shared.rb +0 -0
- data/spec/cantango/{configuration/engines_spec.rb → config/engines/order_spec.rb} +9 -54
- data/spec/cantango/config/engines_spec.rb +59 -0
- data/spec/cantango/{configuration → config}/factory_spec.rb +3 -3
- data/spec/cantango/{configuration → config}/guest/find_guest_default_way_spec.rb +1 -1
- data/spec/cantango/{configuration → config}/guest_spec.rb +2 -2
- data/spec/cantango/config/helpers_spec.rb +15 -0
- data/spec/cantango/config/localhosts_spec.rb +8 -0
- data/spec/cantango/{configuration → config}/models_spec.rb +10 -3
- data/spec/cantango/{configuration → config}/orms_spec.rb +2 -2
- data/spec/cantango/{configuration → config}/shared/factory_ex.rb +0 -0
- data/spec/cantango/{configuration → config}/user_spec.rb +2 -2
- data/spec/cantango/{configuration → config}/users_spec.rb +4 -4
- data/spec/cantango/config_spec.rb +86 -5
- data/spec/cantango/{configuration/registry → registry}/base_spec.rb +2 -2
- data/spec/cantango/{configuration/registry/candidate_spec.rb → registry/clazz_spec.rb} +2 -2
- data/spec/cantango/{configuration/registry → registry}/hash_spec.rb +2 -2
- data/spec/cantango/{configuration/shared/registry → registry/shared}/base_ex.rb +0 -0
- data/spec/cantango/{configuration/shared/registry → registry/shared}/clazz_ex.rb +0 -0
- data/spec/cantango/{configuration/shared/registry → registry/shared}/hash_ex.rb +0 -0
- metadata +87 -81
- data/lib/cantango/configuration.rb +0 -110
- data/lib/cantango/configuration/category.rb +0 -20
- data/lib/cantango/configuration/engine.rb +0 -33
- data/lib/cantango/configuration/engines.rb +0 -95
- data/lib/cantango/configuration/execution_modes.rb +0 -21
- data/lib/cantango/configuration/modes.rb +0 -8
- data/lib/cantango/configuration/registry.rb +0 -7
- data/lib/cantango/configuration/registry/clazz.rb +0 -94
- data/spec/cantango/configuration/execution_modes_spec.rb +0 -15
- data/spec/cantango/configuration/localhosts_spec.rb +0 -9
- data/spec/cantango/configuration/shared/execution_modes_ex.rb +0 -14
- data/spec/cantango/configuration_spec.rb +0 -112
@@ -1,10 +1,7 @@
|
|
1
|
-
require 'singleton'
|
2
|
-
require 'sugar-high/kind_of'
|
3
|
-
|
4
1
|
module CanTango
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
module Registry
|
3
|
+
class Hash < Base
|
4
|
+
module InstanceMethods
|
8
5
|
def types= *types
|
9
6
|
raise "This is a Hash registry!"
|
10
7
|
end
|
@@ -86,13 +83,14 @@ module CanTango
|
|
86
83
|
def default= hash
|
87
84
|
@default = Hashie::Mash.new hash
|
88
85
|
end
|
89
|
-
|
86
|
+
|
90
87
|
protected
|
91
|
-
|
88
|
+
|
92
89
|
def hash? value
|
93
90
|
value.is_a?(::Hash)
|
94
|
-
end
|
91
|
+
end
|
95
92
|
end
|
93
|
+
include InstanceMethods
|
96
94
|
end
|
97
95
|
end
|
98
|
-
end
|
96
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CanTango::Category do
|
4
|
+
subject { CanTango::Category.new 'Wheat', 'Barley' }
|
5
|
+
|
6
|
+
describe 'subjects' do
|
7
|
+
specify { subject.subjects.should == ['Wheat', 'Barley'] }
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'has_any? name' do
|
11
|
+
specify { subject.has_any?('Wheat').should be_true }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'has_any? name, &block' do
|
15
|
+
specify {
|
16
|
+
subject.has_any?('Wheat') do
|
17
|
+
1.should == 1
|
18
|
+
end
|
19
|
+
}
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class Xaz
|
4
|
+
end
|
5
|
+
|
6
|
+
describe CanTango::Config::Ability::Modes::Execution do
|
7
|
+
subject { CanTango::Config::Ability::Modes::Execution.instance }
|
8
|
+
|
9
|
+
describe 'valid mode=' do
|
10
|
+
before do
|
11
|
+
subject.register :cache
|
12
|
+
end
|
13
|
+
specify { subject.registered.should include :cache }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'clear! and invalid mode=' do
|
17
|
+
before do
|
18
|
+
subject.clear!
|
19
|
+
subject.register Xaz
|
20
|
+
end
|
21
|
+
|
22
|
+
specify { subject.registered.should be_empty }
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'reset!' do
|
26
|
+
before do
|
27
|
+
subject.register :a, :b
|
28
|
+
subject.reset!
|
29
|
+
end
|
30
|
+
|
31
|
+
specify { subject.registered.should == subject.default }
|
32
|
+
end
|
33
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'cantango/
|
2
|
+
require 'cantango/registry/shared/clazz_ex'
|
3
3
|
|
4
4
|
class ModeA
|
5
5
|
end
|
@@ -7,8 +7,8 @@ end
|
|
7
7
|
class ModeB
|
8
8
|
end
|
9
9
|
|
10
|
-
describe CanTango::
|
11
|
-
subject { CanTango.config.modes }
|
10
|
+
describe CanTango::Config::Ability::Modes do
|
11
|
+
subject { CanTango.config.ability.modes }
|
12
12
|
|
13
13
|
it_should_behave_like "Clazz Registry" do
|
14
14
|
let(:hash1) do
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'cantango/
|
3
|
-
require 'cantango/
|
2
|
+
require 'cantango/config/shared/factory_ex'
|
3
|
+
require 'cantango/config/ability/execution_modes_ex'
|
4
4
|
|
5
5
|
class MyExecutor
|
6
6
|
end
|
7
7
|
|
8
|
-
describe CanTango::
|
8
|
+
describe CanTango::Config::Ability do
|
9
9
|
subject { CanTango.config.ability }
|
10
10
|
|
11
11
|
it_should_behave_like 'Factory'
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'cantango/
|
2
|
+
require 'cantango/registry/shared/clazz_ex'
|
3
3
|
|
4
4
|
class UserAccount
|
5
5
|
end
|
@@ -7,7 +7,7 @@ end
|
|
7
7
|
class AdminAccount
|
8
8
|
end
|
9
9
|
|
10
|
-
describe CanTango::
|
10
|
+
describe CanTango::Config::Accounts do
|
11
11
|
subject { CanTango.config.accounts }
|
12
12
|
|
13
13
|
it_should_behave_like "Clazz Registry" do
|
@@ -17,6 +17,6 @@ describe CanTango::Configuration::Accounts do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
describe 'register_account' do
|
20
|
-
specify { subject.
|
20
|
+
specify { subject.register_account(AdminAccount).registered.should include(:admin) }
|
21
21
|
end
|
22
22
|
end
|
@@ -1,15 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'cantango/
|
2
|
+
require 'cantango/registry/shared/hash_ex'
|
3
3
|
|
4
|
-
describe CanTango::
|
5
|
-
subject { CanTango::Configuration::Category.new }
|
6
|
-
specify { subject.has_any?(:x).should_not be_true }
|
7
|
-
|
8
|
-
subject { CanTango::Configuration::Category.new :a, :b }
|
9
|
-
specify { subject.has_any?(:a).should be_true }
|
10
|
-
end
|
11
|
-
|
12
|
-
describe CanTango::Configuration::Categories do
|
4
|
+
describe CanTango::Config::Categories do
|
13
5
|
subject { CanTango.config.categories }
|
14
6
|
|
15
7
|
describe 'API' do
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class Context
|
4
|
+
extend CanTango::Config::ClassMethods
|
5
|
+
end
|
6
|
+
|
7
|
+
# Note: This config feature is currently not used, but could potentially be of use in the future
|
8
|
+
describe CanTango::Config::ClassMethods do
|
9
|
+
subject { CanTango::Config::ClassMethods.new }
|
10
|
+
|
11
|
+
pending
|
12
|
+
end
|
@@ -1,13 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
class Context
|
4
|
-
include CanTango::Api::Ability::User
|
5
|
-
end
|
6
|
-
|
7
3
|
# Note: This config feature is currently not used, but could potentially be of use in the future
|
8
|
-
describe CanTango::
|
9
|
-
|
10
|
-
subject { CanTango.config.debug }
|
4
|
+
describe CanTango::Config::Debug do
|
5
|
+
subject { CanTango.config.debug }
|
11
6
|
|
12
7
|
describe 'should set debug mode :on' do
|
13
8
|
before do
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'cantango/registry/shared/hash_ex'
|
3
|
+
|
4
|
+
class MyEngine < CanTango::Engine
|
5
|
+
end
|
6
|
+
|
7
|
+
class MyOtherEngine < CanTango::Engine
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
describe CanTango::Config::Engines do
|
12
|
+
subject { CanTango.config.engines }
|
13
|
+
|
14
|
+
def available
|
15
|
+
registered_names
|
16
|
+
end
|
17
|
+
|
18
|
+
def available? name
|
19
|
+
available.include? name.to_s
|
20
|
+
end
|
21
|
+
|
22
|
+
def all state
|
23
|
+
available.each {|engine| send(engine).set state }
|
24
|
+
end
|
25
|
+
|
26
|
+
def any? state
|
27
|
+
available.any? {|engine| send(engine).send(:"#{state}?") if respond_to?(engine) }
|
28
|
+
end
|
29
|
+
end
|
File without changes
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'cantango/
|
2
|
+
require 'cantango/registry/shared/hash_ex'
|
3
3
|
|
4
4
|
class MyEngine < CanTango::Engine
|
5
5
|
end
|
@@ -8,61 +8,23 @@ class MyOtherEngine < CanTango::Engine
|
|
8
8
|
end
|
9
9
|
|
10
10
|
|
11
|
-
describe CanTango::
|
11
|
+
describe CanTango::Config::Engines do
|
12
12
|
subject { CanTango.config.engines }
|
13
13
|
|
14
|
-
|
15
|
-
let(:hash1) do
|
16
|
-
{:my_engine => MyEngine}
|
17
|
-
end
|
18
|
-
|
19
|
-
let(:hash2) do
|
20
|
-
{:my_other_engine => MyOtherEngine}
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
specify do
|
25
|
-
lambda { subject.register :my_engine => 3 }.should raise_error
|
26
|
-
end
|
27
|
-
|
28
|
-
specify do
|
29
|
-
lambda { subject.register :my_engine => MyEngine }.should_not raise_error
|
30
|
-
end
|
31
|
-
|
32
|
-
describe '#registered' do
|
33
|
-
before do
|
34
|
-
subject.register :my_engine => MyEngine
|
35
|
-
end
|
36
|
-
|
37
|
-
specify { subject.registered[:my_engine].should == MyEngine }
|
38
|
-
specify { subject.registered_names.should include('my_engine') }
|
39
|
-
specify { subject.available.should include('my_engine') }
|
40
|
-
specify { subject.available?('my_engine').should be_true }
|
41
|
-
specify { subject.available?('not_my_engine').should be_false }
|
42
|
-
end
|
43
|
-
|
44
|
-
let(:engines) do
|
45
|
-
{:my_engine => MyEngine}.merge :my_other_engine => MyOtherEngine
|
46
|
-
end
|
47
|
-
|
48
|
-
before do
|
49
|
-
subject.register engines
|
50
|
-
end
|
51
|
-
|
52
|
-
describe 'execution order' do
|
14
|
+
describe 'execution order' do
|
53
15
|
before do
|
54
16
|
subject.set_execution_order :my_other_engine, :engine, :my_engine, :my_other_engine
|
55
17
|
end
|
56
|
-
|
18
|
+
|
57
19
|
its(:execution_order) { should == ['my_other_engine', 'my_engine'] }
|
58
20
|
end
|
59
|
-
|
21
|
+
|
60
22
|
describe 'excute_first' do
|
61
23
|
before do
|
62
24
|
subject.set_execution_order :my_other_engine, :my_engine
|
63
25
|
subject.execute_first :my_engine
|
64
26
|
end
|
65
|
-
|
27
|
+
|
66
28
|
its(:execution_order) { should == ['my_engine', 'my_other_engine'] }
|
67
29
|
end
|
68
30
|
|
@@ -71,7 +33,7 @@ describe CanTango::Configuration::ExecutionModes do
|
|
71
33
|
subject.set_execution_order :my_other_engine, :my_engine
|
72
34
|
subject.execute_last :my_other_engine
|
73
35
|
end
|
74
|
-
|
36
|
+
|
75
37
|
its(:execution_order) { should == ['my_engine', 'my_other_engine'] }
|
76
38
|
end
|
77
39
|
|
@@ -80,7 +42,7 @@ describe CanTango::Configuration::ExecutionModes do
|
|
80
42
|
subject.set_execution_order :my_other_engine, :my_engine
|
81
43
|
subject.execute_before :my_other_engine, :my_engine
|
82
44
|
end
|
83
|
-
|
45
|
+
|
84
46
|
its(:execution_order) { should == ['my_engine', 'my_other_engine'] }
|
85
47
|
end
|
86
48
|
|
@@ -89,14 +51,7 @@ describe CanTango::Configuration::ExecutionModes do
|
|
89
51
|
subject.set_execution_order :my_other_engine, :my_engine
|
90
52
|
subject.execute_after :my_engine, :my_other_engine,
|
91
53
|
end
|
92
|
-
|
54
|
+
|
93
55
|
its(:execution_order) { should == ['my_engine', 'my_other_engine'] }
|
94
56
|
end
|
95
|
-
|
96
|
-
# all state
|
97
|
-
# any? state
|
98
|
-
# clear!
|
99
|
-
# each
|
100
|
-
# active? name
|
101
|
-
# active
|
102
57
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'cantango/registry/shared/hash_ex'
|
3
|
+
|
4
|
+
class MyEngine < CanTango::Engine
|
5
|
+
end
|
6
|
+
|
7
|
+
class MyOtherEngine < CanTango::Engine
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
describe CanTango::Config::Engines do
|
12
|
+
subject { CanTango.config.engines }
|
13
|
+
|
14
|
+
it_should_behave_like "Hash Registry" do
|
15
|
+
let(:hash1) do
|
16
|
+
{:my_engine => MyEngine}
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:hash2) do
|
20
|
+
{:my_other_engine => MyOtherEngine}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
specify do
|
25
|
+
lambda { subject.register :my_engine => 3 }.should raise_error
|
26
|
+
end
|
27
|
+
|
28
|
+
specify do
|
29
|
+
lambda { subject.register :my_engine => MyEngine }.should_not raise_error
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#registered' do
|
33
|
+
before do
|
34
|
+
subject.register :my_engine => MyEngine
|
35
|
+
end
|
36
|
+
|
37
|
+
specify { subject.registered[:my_engine].should == MyEngine }
|
38
|
+
specify { subject.registered_names.should include('my_engine') }
|
39
|
+
specify { subject.available.should include('my_engine') }
|
40
|
+
specify { subject.available?('my_engine').should be_true }
|
41
|
+
specify { subject.available?('not_my_engine').should be_false }
|
42
|
+
end
|
43
|
+
|
44
|
+
let(:engines) do
|
45
|
+
{:my_engine => MyEngine}.merge :my_other_engine => MyOtherEngine
|
46
|
+
end
|
47
|
+
|
48
|
+
before do
|
49
|
+
subject.register engines
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
# all state
|
54
|
+
# any? state
|
55
|
+
# clear!
|
56
|
+
# each
|
57
|
+
# active? name
|
58
|
+
# active
|
59
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'cantango/
|
2
|
+
require 'cantango/config/shared/factory_ex'
|
3
3
|
|
4
4
|
AliasedCustomFactory = CustomFactory
|
5
5
|
|
6
6
|
class MyFactory
|
7
|
-
include CanTango::
|
7
|
+
include CanTango::Config::Factory
|
8
8
|
include Singleton
|
9
9
|
|
10
10
|
def default_class
|
@@ -22,7 +22,7 @@ class MyFactory
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
describe CanTango::
|
25
|
+
describe CanTango::Config::Factory do
|
26
26
|
subject { MyFactory.instance }
|
27
27
|
|
28
28
|
it_should_behave_like 'Factory'
|