cantango-config 0.1.0 → 0.1.1
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/VERSION +1 -1
- data/cantango-config.gemspec +21 -20
- data/lib/cantango/class_methods.rb +27 -0
- data/lib/cantango/config.rb +2 -1
- data/lib/cantango/configuration/accounts.rb +1 -1
- data/lib/cantango/configuration/adapters.rb +1 -2
- data/lib/cantango/configuration/categories.rb +1 -1
- data/lib/cantango/configuration/engines.rb +1 -1
- data/lib/cantango/configuration/hooks.rb +1 -1
- data/lib/cantango/configuration/localhosts.rb +1 -1
- data/lib/cantango/configuration/models.rb +1 -1
- data/lib/cantango/configuration/orms.rb +1 -1
- data/lib/cantango/configuration/registry/base.rb +55 -0
- data/lib/cantango/configuration/registry/candidate.rb +96 -0
- data/lib/cantango/configuration/registry/hash.rb +92 -0
- data/lib/cantango/configuration/registry.rb +3 -52
- data/lib/cantango/configuration/users.rb +1 -1
- data/lib/cantango/configuration.rb +12 -2
- data/spec/cantango/configuration/accounts_spec.rb +1 -1
- data/spec/cantango/configuration/categories_spec.rb +1 -1
- data/spec/cantango/configuration/engines_spec.rb +1 -1
- data/spec/cantango/configuration/localhosts_spec.rb +1 -1
- data/spec/cantango/configuration/models_spec.rb +1 -1
- data/spec/cantango/configuration/orms_spec.rb +1 -1
- data/spec/cantango/configuration/{registry_spec.rb → registry/base_spec.rb} +2 -2
- data/spec/cantango/configuration/{candidate_registry_spec.rb → registry/candidate_spec.rb} +2 -2
- data/spec/cantango/configuration/{hash_registry_spec.rb → registry/hash_spec.rb} +2 -2
- data/spec/cantango/configuration/shared/{registry_ex.rb → registry/base_ex.rb} +0 -0
- data/spec/cantango/configuration/shared/{candidate_registry_ex.rb → registry/candidate_ex.rb} +0 -0
- data/spec/cantango/configuration/shared/{hash_registry_ex.rb → registry/hash_ex.rb} +0 -0
- data/spec/cantango/configuration/users_spec.rb +1 -1
- metadata +31 -30
- data/lib/cantango/configuration/candidate_registry.rb +0 -94
- data/lib/cantango/configuration/hash_registry.rb +0 -91
- data/spec/cantango/configuration/shared/role_registry_ex.rb +0 -22
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/cantango-config.gemspec
CHANGED
@@ -4,14 +4,14 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "0.1.
|
7
|
+
s.name = %q{cantango-config}
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = [
|
12
|
-
s.date =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
11
|
+
s.authors = [%q{Kristian Mandrup}]
|
12
|
+
s.date = %q{2011-11-25}
|
13
|
+
s.description = %q{Configuration DSL for configuring CanTango}
|
14
|
+
s.email = %q{kmandrup@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE.txt",
|
17
17
|
"README.mdown"
|
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
"cantango-config.gemspec",
|
29
29
|
"lib/cantango/adapter/compiler.rb",
|
30
30
|
"lib/cantango/adapter/moneta.rb",
|
31
|
+
"lib/cantango/class_methods.rb",
|
31
32
|
"lib/cantango/config.rb",
|
32
33
|
"lib/cantango/configuration.rb",
|
33
34
|
"lib/cantango/configuration/ability.rb",
|
@@ -35,14 +36,12 @@ Gem::Specification.new do |s|
|
|
35
36
|
"lib/cantango/configuration/accounts.rb",
|
36
37
|
"lib/cantango/configuration/adapters.rb",
|
37
38
|
"lib/cantango/configuration/autoload.rb",
|
38
|
-
"lib/cantango/configuration/candidate_registry.rb",
|
39
39
|
"lib/cantango/configuration/categories.rb",
|
40
40
|
"lib/cantango/configuration/debug.rb",
|
41
41
|
"lib/cantango/configuration/engine.rb",
|
42
42
|
"lib/cantango/configuration/engines.rb",
|
43
43
|
"lib/cantango/configuration/factory.rb",
|
44
44
|
"lib/cantango/configuration/guest.rb",
|
45
|
-
"lib/cantango/configuration/hash_registry.rb",
|
46
45
|
"lib/cantango/configuration/hooks.rb",
|
47
46
|
"lib/cantango/configuration/localhosts.rb",
|
48
47
|
"lib/cantango/configuration/models.rb",
|
@@ -56,6 +55,9 @@ Gem::Specification.new do |s|
|
|
56
55
|
"lib/cantango/configuration/modes.rb",
|
57
56
|
"lib/cantango/configuration/orms.rb",
|
58
57
|
"lib/cantango/configuration/registry.rb",
|
58
|
+
"lib/cantango/configuration/registry/base.rb",
|
59
|
+
"lib/cantango/configuration/registry/candidate.rb",
|
60
|
+
"lib/cantango/configuration/registry/hash.rb",
|
59
61
|
"lib/cantango/configuration/user.rb",
|
60
62
|
"lib/cantango/configuration/users.rb",
|
61
63
|
"spec/cantango/config_spec.rb",
|
@@ -64,7 +66,6 @@ Gem::Specification.new do |s|
|
|
64
66
|
"spec/cantango/configuration/accounts_spec.rb",
|
65
67
|
"spec/cantango/configuration/adapters_spec.rb",
|
66
68
|
"spec/cantango/configuration/autoload_spec.rb",
|
67
|
-
"spec/cantango/configuration/candidate_registry_spec.rb",
|
68
69
|
"spec/cantango/configuration/categories_spec.rb",
|
69
70
|
"spec/cantango/configuration/debug_spec.rb",
|
70
71
|
"spec/cantango/configuration/engines/engine_shared.rb",
|
@@ -72,17 +73,17 @@ Gem::Specification.new do |s|
|
|
72
73
|
"spec/cantango/configuration/factory_spec.rb",
|
73
74
|
"spec/cantango/configuration/guest/find_guest_default_way_spec.rb",
|
74
75
|
"spec/cantango/configuration/guest_spec.rb",
|
75
|
-
"spec/cantango/configuration/hash_registry_spec.rb",
|
76
76
|
"spec/cantango/configuration/localhosts_spec.rb",
|
77
77
|
"spec/cantango/configuration/models_spec.rb",
|
78
78
|
"spec/cantango/configuration/orms_spec.rb",
|
79
|
-
"spec/cantango/configuration/
|
80
|
-
"spec/cantango/configuration/
|
79
|
+
"spec/cantango/configuration/registry/base_spec.rb",
|
80
|
+
"spec/cantango/configuration/registry/candidate_spec.rb",
|
81
|
+
"spec/cantango/configuration/registry/hash_spec.rb",
|
81
82
|
"spec/cantango/configuration/shared/factory_ex.rb",
|
82
|
-
"spec/cantango/configuration/shared/hash_registry_ex.rb",
|
83
83
|
"spec/cantango/configuration/shared/modes_ex.rb",
|
84
|
-
"spec/cantango/configuration/shared/
|
85
|
-
"spec/cantango/configuration/shared/
|
84
|
+
"spec/cantango/configuration/shared/registry/base_ex.rb",
|
85
|
+
"spec/cantango/configuration/shared/registry/candidate_ex.rb",
|
86
|
+
"spec/cantango/configuration/shared/registry/hash_ex.rb",
|
86
87
|
"spec/cantango/configuration/user_spec.rb",
|
87
88
|
"spec/cantango/configuration/users_spec.rb",
|
88
89
|
"spec/cantango/configuration_spec.rb",
|
@@ -100,11 +101,11 @@ Gem::Specification.new do |s|
|
|
100
101
|
"spec/migrations/001_create_projects.rb",
|
101
102
|
"spec/spec_helper.rb"
|
102
103
|
]
|
103
|
-
s.homepage =
|
104
|
-
s.licenses = [
|
105
|
-
s.require_paths = [
|
106
|
-
s.rubygems_version =
|
107
|
-
s.summary =
|
104
|
+
s.homepage = %q{http://github.com/kristianmandrup/cantango-config}
|
105
|
+
s.licenses = [%q{MIT}]
|
106
|
+
s.require_paths = [%q{lib}]
|
107
|
+
s.rubygems_version = %q{1.8.6}
|
108
|
+
s.summary = %q{Configuration for Cantango}
|
108
109
|
|
109
110
|
if s.respond_to? :specification_version then
|
110
111
|
s.specification_version = 3
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module CanTango
|
2
|
+
module ClassMethods
|
3
|
+
# Engine hook
|
4
|
+
# Run after the initializers are ran for all Railties (including the application itself), but before eager loading and the middleware stack is built.
|
5
|
+
# More importantly, will run upon every request in development, but only once (during boot-up) in production and test.
|
6
|
+
def to_prepare
|
7
|
+
config.hook(:to_prepare).call if config.hook(:to_prepare)
|
8
|
+
end
|
9
|
+
|
10
|
+
# engine hook, run after all Rails initializations have been executed
|
11
|
+
def after_initialize
|
12
|
+
config.hook(:after_initialize).call if config.hook(:after_initialize)
|
13
|
+
end
|
14
|
+
|
15
|
+
def debug!
|
16
|
+
config.debug.set :on
|
17
|
+
end
|
18
|
+
|
19
|
+
def debug_off!
|
20
|
+
config.debug.set :off
|
21
|
+
end
|
22
|
+
|
23
|
+
def debug?
|
24
|
+
config.debug.on?
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/cantango/config.rb
CHANGED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
require 'sugar-high/kind_of'
|
3
|
+
|
4
|
+
module CanTango
|
5
|
+
class Configuration
|
6
|
+
module Registry
|
7
|
+
class Base
|
8
|
+
attr_writer :default
|
9
|
+
attr_accessor :registered
|
10
|
+
|
11
|
+
def types= *types
|
12
|
+
@types = types.select {|t| t.is_a? Class }
|
13
|
+
end
|
14
|
+
|
15
|
+
def types
|
16
|
+
@types ||= [Symbol, String]
|
17
|
+
@types
|
18
|
+
end
|
19
|
+
|
20
|
+
def clean!
|
21
|
+
@registered = []
|
22
|
+
end
|
23
|
+
|
24
|
+
alias_method :clear!, :clean!
|
25
|
+
|
26
|
+
def default!
|
27
|
+
@registered = default
|
28
|
+
end
|
29
|
+
|
30
|
+
def register *list
|
31
|
+
registered << list.select_kinds_of(*types)
|
32
|
+
@registered.flat_uniq!
|
33
|
+
end
|
34
|
+
|
35
|
+
alias_method :<<, :register
|
36
|
+
|
37
|
+
def [] index
|
38
|
+
registered[index]
|
39
|
+
end
|
40
|
+
|
41
|
+
def registered
|
42
|
+
@registered ||= default
|
43
|
+
end
|
44
|
+
|
45
|
+
def registered? label
|
46
|
+
registered.map(&:to_s).include? label.to_s
|
47
|
+
end
|
48
|
+
|
49
|
+
def default
|
50
|
+
@default ||= []
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
require 'sugar-high/kind_of'
|
3
|
+
|
4
|
+
module CanTango
|
5
|
+
class Configuration
|
6
|
+
module Registry
|
7
|
+
class Candidate
|
8
|
+
def register label, value
|
9
|
+
raise "first arg must be a label, was: #{label}" if !label.kind_of_label?
|
10
|
+
raise "second arg must be a valid Class, was: #{value}" if !valid? value
|
11
|
+
name_registry.register label.to_sym
|
12
|
+
class_registry.register value
|
13
|
+
end
|
14
|
+
alias_method :[]=, :register
|
15
|
+
|
16
|
+
def << hash
|
17
|
+
raise "Must be a hash" if !hash.is_a? Hash
|
18
|
+
hash.each_pair do |key, value|
|
19
|
+
register key, value
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def registered
|
24
|
+
name_registry.registered
|
25
|
+
end
|
26
|
+
alias_method :registered_names, :registered
|
27
|
+
|
28
|
+
def clean!
|
29
|
+
name_registry.clean!
|
30
|
+
class_registry.clean!
|
31
|
+
end
|
32
|
+
alias_method :clear!, :clean!
|
33
|
+
|
34
|
+
def registered_classes
|
35
|
+
class_registry.registered
|
36
|
+
end
|
37
|
+
|
38
|
+
def registered? name
|
39
|
+
name_registry.registered? name
|
40
|
+
end
|
41
|
+
|
42
|
+
def registered_class? name
|
43
|
+
class_registry.registered? name
|
44
|
+
end
|
45
|
+
|
46
|
+
def name_registry
|
47
|
+
NameRegistry.instance
|
48
|
+
end
|
49
|
+
|
50
|
+
def class_registry
|
51
|
+
ClassRegistry.instance
|
52
|
+
end
|
53
|
+
|
54
|
+
def value_methods
|
55
|
+
class_registry.value_methods
|
56
|
+
end
|
57
|
+
|
58
|
+
def value_types
|
59
|
+
class_registry.types
|
60
|
+
end
|
61
|
+
|
62
|
+
class NameRegistry < Registry
|
63
|
+
include Singleton
|
64
|
+
end
|
65
|
+
|
66
|
+
class ClassRegistry < Registry
|
67
|
+
include Singleton
|
68
|
+
|
69
|
+
def types
|
70
|
+
[Class]
|
71
|
+
end
|
72
|
+
|
73
|
+
def value_methods
|
74
|
+
[]
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
protected
|
79
|
+
|
80
|
+
def valid? value
|
81
|
+
valid_by_type?(value) && valid_by_methods?(value)
|
82
|
+
end
|
83
|
+
|
84
|
+
def valid_by_type? value
|
85
|
+
return true if value_types.blank?
|
86
|
+
value.any_kind_of?(*value_types)
|
87
|
+
end
|
88
|
+
|
89
|
+
def valid_by_methods? value
|
90
|
+
return true if value_methods.blank?
|
91
|
+
value_methods.all?{|m| value.respond_to(m)}
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
require 'sugar-high/kind_of'
|
3
|
+
|
4
|
+
module CanTango
|
5
|
+
class Configuration
|
6
|
+
module Registry
|
7
|
+
class Hash < Base
|
8
|
+
def types= *types
|
9
|
+
raise "This is a Hash registry!"
|
10
|
+
end
|
11
|
+
|
12
|
+
def types
|
13
|
+
[Hash]
|
14
|
+
end
|
15
|
+
|
16
|
+
def value_methods
|
17
|
+
[]
|
18
|
+
end
|
19
|
+
|
20
|
+
def value_types
|
21
|
+
[]
|
22
|
+
end
|
23
|
+
|
24
|
+
def clean!
|
25
|
+
registered = Hashie::Mash.new
|
26
|
+
end
|
27
|
+
alias_method :clear!, :clean!
|
28
|
+
|
29
|
+
def default!
|
30
|
+
@registered = default
|
31
|
+
end
|
32
|
+
|
33
|
+
def << hash
|
34
|
+
raise "Must be a hash" if !hash.is_a? Hash
|
35
|
+
registered.merge!(hash) and return if value_methods.empty? && value_types.empty?
|
36
|
+
hash.each_pair do |key, value|
|
37
|
+
registered[key] = value if value_api.all?{|m| value.respond_to(m)} && value.any_kind_of?(value_types)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def [] label
|
42
|
+
raise "Must be a label" if !label.kind_of_label?
|
43
|
+
registered[label.to_s]
|
44
|
+
end
|
45
|
+
|
46
|
+
def []= label, value
|
47
|
+
raise "Must be a label" if !label.kind_of_label?
|
48
|
+
registered[label.to_s] = value
|
49
|
+
end
|
50
|
+
|
51
|
+
def register hash
|
52
|
+
raise "Must be a hash" if !hash.is_a? Hash
|
53
|
+
registered.merge! hash
|
54
|
+
end
|
55
|
+
|
56
|
+
def unregister name
|
57
|
+
@registered = {} if name == :all
|
58
|
+
@registered.delete(name)
|
59
|
+
end
|
60
|
+
|
61
|
+
def registered
|
62
|
+
@registered ||= default
|
63
|
+
end
|
64
|
+
|
65
|
+
def registered_names
|
66
|
+
registered.keys
|
67
|
+
end
|
68
|
+
|
69
|
+
def registered_values
|
70
|
+
registered.values
|
71
|
+
end
|
72
|
+
|
73
|
+
def registered? label
|
74
|
+
registered_names.map(&:to_s).include? label.to_s
|
75
|
+
end
|
76
|
+
alias_method :registered_name, :registered?
|
77
|
+
|
78
|
+
def registered_value? value
|
79
|
+
registered_values.include? value
|
80
|
+
end
|
81
|
+
|
82
|
+
def default
|
83
|
+
@default ||= Hashie::Mash.new
|
84
|
+
end
|
85
|
+
|
86
|
+
def default= hash
|
87
|
+
@default = Hashie::Mash.new hash
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -1,56 +1,7 @@
|
|
1
|
-
require 'singleton'
|
2
|
-
require 'sugar-high/kind_of'
|
3
|
-
|
4
1
|
module CanTango
|
5
2
|
class Configuration
|
6
|
-
|
7
|
-
|
8
|
-
attr_writer :default
|
9
|
-
attr_accessor :registered
|
10
|
-
|
11
|
-
def types= *types
|
12
|
-
@types = types.select {|t| t.is_a? Class }
|
13
|
-
end
|
14
|
-
|
15
|
-
def types
|
16
|
-
@types ||= [Symbol, String]
|
17
|
-
@types
|
18
|
-
end
|
19
|
-
|
20
|
-
def clean!
|
21
|
-
@registered = []
|
22
|
-
end
|
23
|
-
|
24
|
-
alias_method :clear!, :clean!
|
25
|
-
|
26
|
-
def default!
|
27
|
-
@registered = default
|
28
|
-
end
|
29
|
-
|
30
|
-
def register *list
|
31
|
-
registered << list.select_kinds_of(*types)
|
32
|
-
@registered.flat_uniq!
|
33
|
-
end
|
34
|
-
|
35
|
-
alias_method :<<, :register
|
36
|
-
|
37
|
-
def [] index
|
38
|
-
registered[index]
|
39
|
-
end
|
40
|
-
|
41
|
-
def registered
|
42
|
-
@registered ||= default
|
43
|
-
end
|
44
|
-
|
45
|
-
def registered? label
|
46
|
-
registered.map(&:to_s).include? label.to_s
|
47
|
-
end
|
48
|
-
|
49
|
-
def default
|
50
|
-
@default ||= []
|
51
|
-
end
|
3
|
+
module Registry
|
4
|
+
autoload_modules :Base, :Hash, :Candidate
|
52
5
|
end
|
53
6
|
end
|
54
|
-
end
|
55
|
-
|
56
|
-
|
7
|
+
end
|
@@ -2,11 +2,21 @@ require 'set'
|
|
2
2
|
require 'singleton'
|
3
3
|
|
4
4
|
module CanTango
|
5
|
+
# The main entry point to configure CanTango
|
6
|
+
class << self
|
7
|
+
def configure &block
|
8
|
+
conf = CanTango::Configuration.instance
|
9
|
+
yield conf if block
|
10
|
+
conf
|
11
|
+
end
|
12
|
+
|
13
|
+
alias_method :config, :configure
|
14
|
+
end
|
15
|
+
|
5
16
|
class Configuration
|
6
17
|
autoload_modules :Categories
|
7
18
|
autoload_modules :Models, :Engines, :Ability
|
8
|
-
autoload_modules :Registry
|
9
|
-
autoload_modules :Roles, :RoleGroups, :SpecialPermits
|
19
|
+
autoload_modules :Registry
|
10
20
|
autoload_modules :Factory, :Autoload, :Adapters, :Debug, :Modes, :Orms, :Localhosts, :Hooks
|
11
21
|
autoload_modules :Account, :Accounts
|
12
22
|
autoload_modules :User, :Guest, :Users
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'cantango/configuration/shared/
|
2
|
+
require 'cantango/configuration/shared/registry/role_ex'
|
3
3
|
|
4
|
-
class MyRegi < CanTango::Configuration::Registry
|
4
|
+
class MyRegi < CanTango::Configuration::Registry::Base
|
5
5
|
end
|
6
6
|
|
7
7
|
describe MyRegi do
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'cantango/configuration/shared/
|
2
|
+
require 'cantango/configuration/shared/registry/candidate_ex'
|
3
3
|
|
4
|
-
class MyReg < CanTango::Configuration::
|
4
|
+
class MyReg < CanTango::Configuration::Registry::Candidate
|
5
5
|
end
|
6
6
|
|
7
7
|
describe MyReg do
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'cantango/configuration/shared/
|
2
|
+
require 'cantango/configuration/shared/registry/hash_ex'
|
3
3
|
|
4
|
-
class MyRegis < CanTango::Configuration::
|
4
|
+
class MyRegis < CanTango::Configuration::Registry::Hash
|
5
5
|
end
|
6
6
|
|
7
7
|
describe MyRegis do
|
File without changes
|
data/spec/cantango/configuration/shared/{candidate_registry_ex.rb → registry/candidate_ex.rb}
RENAMED
File without changes
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cantango-config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-11-25 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &70326895731020 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.1'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70326895731020
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: sugar-high
|
27
|
-
requirement: &
|
27
|
+
requirement: &70326895729600 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.6.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70326895729600
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: sweetloader
|
38
|
-
requirement: &
|
38
|
+
requirement: &70326895727800 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.1.0
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70326895727800
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: hashie
|
49
|
-
requirement: &
|
49
|
+
requirement: &70326895716440 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70326895716440
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: cantango-core
|
60
|
-
requirement: &
|
60
|
+
requirement: &70326895714540 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70326895714540
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bundler
|
71
|
-
requirement: &
|
71
|
+
requirement: &70326895713380 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 1.1.rc
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70326895713380
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: jeweler
|
82
|
-
requirement: &
|
82
|
+
requirement: &70326895712200 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: 1.6.4
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70326895712200
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: rcov
|
93
|
-
requirement: &
|
93
|
+
requirement: &70326895710700 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70326895710700
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: rspec
|
104
|
-
requirement: &
|
104
|
+
requirement: &70326895709180 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
version: 2.6.0
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *70326895709180
|
113
113
|
description: Configuration DSL for configuring CanTango
|
114
114
|
email: kmandrup@gmail.com
|
115
115
|
executables: []
|
@@ -129,6 +129,7 @@ files:
|
|
129
129
|
- cantango-config.gemspec
|
130
130
|
- lib/cantango/adapter/compiler.rb
|
131
131
|
- lib/cantango/adapter/moneta.rb
|
132
|
+
- lib/cantango/class_methods.rb
|
132
133
|
- lib/cantango/config.rb
|
133
134
|
- lib/cantango/configuration.rb
|
134
135
|
- lib/cantango/configuration/ability.rb
|
@@ -136,14 +137,12 @@ files:
|
|
136
137
|
- lib/cantango/configuration/accounts.rb
|
137
138
|
- lib/cantango/configuration/adapters.rb
|
138
139
|
- lib/cantango/configuration/autoload.rb
|
139
|
-
- lib/cantango/configuration/candidate_registry.rb
|
140
140
|
- lib/cantango/configuration/categories.rb
|
141
141
|
- lib/cantango/configuration/debug.rb
|
142
142
|
- lib/cantango/configuration/engine.rb
|
143
143
|
- lib/cantango/configuration/engines.rb
|
144
144
|
- lib/cantango/configuration/factory.rb
|
145
145
|
- lib/cantango/configuration/guest.rb
|
146
|
-
- lib/cantango/configuration/hash_registry.rb
|
147
146
|
- lib/cantango/configuration/hooks.rb
|
148
147
|
- lib/cantango/configuration/localhosts.rb
|
149
148
|
- lib/cantango/configuration/models.rb
|
@@ -157,6 +156,9 @@ files:
|
|
157
156
|
- lib/cantango/configuration/modes.rb
|
158
157
|
- lib/cantango/configuration/orms.rb
|
159
158
|
- lib/cantango/configuration/registry.rb
|
159
|
+
- lib/cantango/configuration/registry/base.rb
|
160
|
+
- lib/cantango/configuration/registry/candidate.rb
|
161
|
+
- lib/cantango/configuration/registry/hash.rb
|
160
162
|
- lib/cantango/configuration/user.rb
|
161
163
|
- lib/cantango/configuration/users.rb
|
162
164
|
- spec/cantango/config_spec.rb
|
@@ -165,7 +167,6 @@ files:
|
|
165
167
|
- spec/cantango/configuration/accounts_spec.rb
|
166
168
|
- spec/cantango/configuration/adapters_spec.rb
|
167
169
|
- spec/cantango/configuration/autoload_spec.rb
|
168
|
-
- spec/cantango/configuration/candidate_registry_spec.rb
|
169
170
|
- spec/cantango/configuration/categories_spec.rb
|
170
171
|
- spec/cantango/configuration/debug_spec.rb
|
171
172
|
- spec/cantango/configuration/engines/engine_shared.rb
|
@@ -173,17 +174,17 @@ files:
|
|
173
174
|
- spec/cantango/configuration/factory_spec.rb
|
174
175
|
- spec/cantango/configuration/guest/find_guest_default_way_spec.rb
|
175
176
|
- spec/cantango/configuration/guest_spec.rb
|
176
|
-
- spec/cantango/configuration/hash_registry_spec.rb
|
177
177
|
- spec/cantango/configuration/localhosts_spec.rb
|
178
178
|
- spec/cantango/configuration/models_spec.rb
|
179
179
|
- spec/cantango/configuration/orms_spec.rb
|
180
|
-
- spec/cantango/configuration/
|
181
|
-
- spec/cantango/configuration/
|
180
|
+
- spec/cantango/configuration/registry/base_spec.rb
|
181
|
+
- spec/cantango/configuration/registry/candidate_spec.rb
|
182
|
+
- spec/cantango/configuration/registry/hash_spec.rb
|
182
183
|
- spec/cantango/configuration/shared/factory_ex.rb
|
183
|
-
- spec/cantango/configuration/shared/hash_registry_ex.rb
|
184
184
|
- spec/cantango/configuration/shared/modes_ex.rb
|
185
|
-
- spec/cantango/configuration/shared/
|
186
|
-
- spec/cantango/configuration/shared/
|
185
|
+
- spec/cantango/configuration/shared/registry/base_ex.rb
|
186
|
+
- spec/cantango/configuration/shared/registry/candidate_ex.rb
|
187
|
+
- spec/cantango/configuration/shared/registry/hash_ex.rb
|
187
188
|
- spec/cantango/configuration/user_spec.rb
|
188
189
|
- spec/cantango/configuration/users_spec.rb
|
189
190
|
- spec/cantango/configuration_spec.rb
|
@@ -215,7 +216,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
215
216
|
version: '0'
|
216
217
|
segments:
|
217
218
|
- 0
|
218
|
-
hash:
|
219
|
+
hash: 1432741648171073841
|
219
220
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
220
221
|
none: false
|
221
222
|
requirements:
|
@@ -224,7 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
224
225
|
version: '0'
|
225
226
|
requirements: []
|
226
227
|
rubyforge_project:
|
227
|
-
rubygems_version: 1.8.
|
228
|
+
rubygems_version: 1.8.6
|
228
229
|
signing_key:
|
229
230
|
specification_version: 3
|
230
231
|
summary: Configuration for Cantango
|
@@ -1,94 +0,0 @@
|
|
1
|
-
require 'singleton'
|
2
|
-
require 'sugar-high/kind_of'
|
3
|
-
|
4
|
-
module CanTango
|
5
|
-
class Configuration
|
6
|
-
class CandidateRegistry
|
7
|
-
def register label, value
|
8
|
-
raise "first arg must be a label, was: #{label}" if !label.kind_of_label?
|
9
|
-
raise "second arg must be a valid Class, was: #{value}" if !valid? value
|
10
|
-
name_registry.register label.to_sym
|
11
|
-
class_registry.register value
|
12
|
-
end
|
13
|
-
alias_method :[]=, :register
|
14
|
-
|
15
|
-
def << hash
|
16
|
-
raise "Must be a hash" if !hash.is_a? Hash
|
17
|
-
hash.each_pair do |key, value|
|
18
|
-
register key, value
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def registered
|
23
|
-
name_registry.registered
|
24
|
-
end
|
25
|
-
alias_method :registered_names, :registered
|
26
|
-
|
27
|
-
def clean!
|
28
|
-
name_registry.clean!
|
29
|
-
class_registry.clean!
|
30
|
-
end
|
31
|
-
alias_method :clear!, :clean!
|
32
|
-
|
33
|
-
def registered_classes
|
34
|
-
class_registry.registered
|
35
|
-
end
|
36
|
-
|
37
|
-
def registered? name
|
38
|
-
name_registry.registered? name
|
39
|
-
end
|
40
|
-
|
41
|
-
def registered_class? name
|
42
|
-
class_registry.registered? name
|
43
|
-
end
|
44
|
-
|
45
|
-
def name_registry
|
46
|
-
NameRegistry.instance
|
47
|
-
end
|
48
|
-
|
49
|
-
def class_registry
|
50
|
-
ClassRegistry.instance
|
51
|
-
end
|
52
|
-
|
53
|
-
def value_methods
|
54
|
-
class_registry.value_methods
|
55
|
-
end
|
56
|
-
|
57
|
-
def value_types
|
58
|
-
class_registry.types
|
59
|
-
end
|
60
|
-
|
61
|
-
class NameRegistry < Registry
|
62
|
-
include Singleton
|
63
|
-
end
|
64
|
-
|
65
|
-
class ClassRegistry < Registry
|
66
|
-
include Singleton
|
67
|
-
|
68
|
-
def types
|
69
|
-
[Class]
|
70
|
-
end
|
71
|
-
|
72
|
-
def value_methods
|
73
|
-
[]
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
protected
|
78
|
-
|
79
|
-
def valid? value
|
80
|
-
valid_by_type?(value) && valid_by_methods?(value)
|
81
|
-
end
|
82
|
-
|
83
|
-
def valid_by_type? value
|
84
|
-
return true if value_types.blank?
|
85
|
-
value.any_kind_of?(*value_types)
|
86
|
-
end
|
87
|
-
|
88
|
-
def valid_by_methods? value
|
89
|
-
return true if value_methods.blank?
|
90
|
-
value_methods.all?{|m| value.respond_to(m)}
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
@@ -1,91 +0,0 @@
|
|
1
|
-
require 'singleton'
|
2
|
-
require 'sugar-high/kind_of'
|
3
|
-
|
4
|
-
module CanTango
|
5
|
-
class Configuration
|
6
|
-
class HashRegistry < Registry
|
7
|
-
|
8
|
-
def types= *types
|
9
|
-
raise "This is a Hash registry!"
|
10
|
-
end
|
11
|
-
|
12
|
-
def types
|
13
|
-
[Hash]
|
14
|
-
end
|
15
|
-
|
16
|
-
def value_methods
|
17
|
-
[]
|
18
|
-
end
|
19
|
-
|
20
|
-
def value_types
|
21
|
-
[]
|
22
|
-
end
|
23
|
-
|
24
|
-
def clean!
|
25
|
-
registered = Hashie::Mash.new
|
26
|
-
end
|
27
|
-
alias_method :clear!, :clean!
|
28
|
-
|
29
|
-
def default!
|
30
|
-
@registered = default
|
31
|
-
end
|
32
|
-
|
33
|
-
def << hash
|
34
|
-
raise "Must be a hash" if !hash.is_a? Hash
|
35
|
-
registered.merge!(hash) and return if value_methods.empty? && value_types.empty?
|
36
|
-
hash.each_pair do |key, value|
|
37
|
-
registered[key] = value if value_api.all?{|m| value.respond_to(m)} && value.any_kind_of?(value_types)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def [] label
|
42
|
-
raise "Must be a label" if !label.kind_of_label?
|
43
|
-
registered[label.to_s]
|
44
|
-
end
|
45
|
-
|
46
|
-
def []= label, value
|
47
|
-
raise "Must be a label" if !label.kind_of_label?
|
48
|
-
registered[label.to_s] = value
|
49
|
-
end
|
50
|
-
|
51
|
-
def register hash
|
52
|
-
raise "Must be a hash" if !hash.is_a? Hash
|
53
|
-
registered.merge! hash
|
54
|
-
end
|
55
|
-
|
56
|
-
def unregister name
|
57
|
-
@registered = {} if name == :all
|
58
|
-
@registered.delete(name)
|
59
|
-
end
|
60
|
-
|
61
|
-
def registered
|
62
|
-
@registered ||= default
|
63
|
-
end
|
64
|
-
|
65
|
-
def registered_names
|
66
|
-
registered.keys
|
67
|
-
end
|
68
|
-
|
69
|
-
def registered_values
|
70
|
-
registered.values
|
71
|
-
end
|
72
|
-
|
73
|
-
def registered? label
|
74
|
-
registered_names.map(&:to_s).include? label.to_s
|
75
|
-
end
|
76
|
-
alias_method :registered_name, :registered?
|
77
|
-
|
78
|
-
def registered_value? value
|
79
|
-
registered_values.include? value
|
80
|
-
end
|
81
|
-
|
82
|
-
def default
|
83
|
-
@default ||= Hashie::Mash.new
|
84
|
-
end
|
85
|
-
|
86
|
-
def default= hash
|
87
|
-
@default = Hashie::Mash.new hash
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'cantango/configuration/shared/registry_ex'
|
2
|
-
|
3
|
-
shared_examples_for 'Role Registry' do
|
4
|
-
it_should_behave_like "Registry"
|
5
|
-
|
6
|
-
describe 'default settings' do
|
7
|
-
its(:has_method) { should == has }
|
8
|
-
its(:list_method) { should == list }
|
9
|
-
|
10
|
-
its(:default_has_method) { should be_a Symbol }
|
11
|
-
its(:default_list_method) { should be_a Symbol }
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "exclude" do
|
15
|
-
before do
|
16
|
-
subject.exclude :admin
|
17
|
-
end
|
18
|
-
|
19
|
-
its(:excluded) { should include(:admin) }
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|