cantango-config 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cantango-config}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Kristian Mandrup}]
12
- s.date = %q{2011-12-12}
12
+ s.date = %q{2011-12-20}
13
13
  s.description = %q{Configuration DSL for configuring CanTango}
14
14
  s.email = %q{kmandrup@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -5,7 +5,8 @@ module CanTango
5
5
 
6
6
  def [] label
7
7
  models = super
8
- raise "Category '#{label}' either not exists or invalid!" if !models.kind_of?(Array)
8
+ return [] unless models.kind_of?(Array)
9
+ # raise "Category '#{label}' either not exists or invalid!" if !models.kind_of?(Array)
9
10
  models
10
11
  end
11
12
 
@@ -52,7 +52,7 @@ module CanTango
52
52
  def all
53
53
  CanTango.config.orms.registered.compact.inject([]) do |result, orm|
54
54
  adapter = adapter_for(orm)
55
- result << (adapter.models.map(&:name) if adapter)
55
+ result << (adapter.available_models if adapter)
56
56
  result
57
57
  end.flatten.compact
58
58
  end
@@ -68,13 +68,18 @@ module CanTango
68
68
  end
69
69
 
70
70
  def try_model model_string
71
- model = find_first_class(model_string.singularize, model_string)
72
- raise "No model #{model_string} defined!" if !model
71
+ model = find_first_class(models_to_finds model_string)
72
+ raise "No model: #{models_to_finds model_string} defined!" if !model
73
73
  model
74
74
  end
75
75
 
76
+ def models_to_finds model_string
77
+ (model_string.singularize == model_string) ? model_string : [model_string.singularize, model_string]
78
+ end
79
+
80
+ # from adapter
76
81
  def grep reg_exp
77
- available_models.grep reg_exp
82
+ available.grep reg_exp
78
83
  end
79
84
 
80
85
  def categories
@@ -13,16 +13,16 @@ describe CanTango::Config::Categories do
13
13
  end
14
14
 
15
15
  describe 'get index []' do
16
- specify {
16
+ before do
17
17
  subject.register(:w => 'something non-array!')
18
- lambda { subject.category('w') }.should raise_error
19
- }
18
+ end
19
+
20
+ specify { subject.category(:w).should_not be_empty }
21
+ specify { subject.category('w').should be_empty }
20
22
  end
21
23
 
22
24
  describe 'category_has_subject?' do
23
- specify {
24
- subject.category('a').has_any?('B').should be_true
25
- }
25
+ specify { subject.category('a').has_any?('B').should be_true }
26
26
  end
27
27
 
28
28
  describe 'has_subject?' do
@@ -6,6 +6,13 @@ CanTango.debug!
6
6
  connect_db
7
7
  migrate
8
8
 
9
+ class Wheat
10
+ end
11
+
12
+ class Barley
13
+ end
14
+
15
+
9
16
  describe CanTango::Configuration::Models do
10
17
  let(:models) { CanTango.config.models }
11
18
  let(:orms) { CanTango.config.orms }
@@ -24,7 +31,10 @@ describe CanTango::Configuration::Models do
24
31
 
25
32
  subject { models }
26
33
 
27
- describe 'available_models' do
34
+ describe '#actions' do
35
+ end
36
+
37
+ describe '#available' do
28
38
  before do
29
39
  orms.register :active_record
30
40
  end
@@ -33,22 +43,46 @@ describe CanTango::Configuration::Models do
33
43
  specify { subject.available.should include('Project') }
34
44
  end
35
45
 
36
- describe 'use :guest_user' do
46
+ describe '#use :guest_user' do
37
47
  before do
38
48
  subject.use :guest_user
39
49
  end
40
50
  specify { defined?(CanTango::Model::Guest).should be_true }
41
51
  end
42
52
 
43
- describe 'by_reg_exp' do
53
+ describe '#by_reg_exp' do
54
+ it 'should get matching models' do
55
+ pending
56
+ # subject.by_regexp(/Item$/).should include('Item', 'ProductItem')
57
+ end
44
58
  end
45
59
 
46
- describe 'by_category' do
47
- end
60
+ describe '#by_category' do
61
+ context 'Category grains wit Wheat and Barley are registered' do
62
+ before do
63
+ CanTango.config.categories.register :grains => ['Wheat', 'Barley']
64
+ end
65
+
66
+ it 'should find models of :grains' do
67
+ subject.by_category(:grains).should include(Wheat, Barley)
68
+ end
48
69
 
49
- describe 'exclude' do
70
+ it 'should not find models of unknown' do
71
+ subject.by_category(:unknown).should be_empty
72
+ end
73
+ end
50
74
  end
51
75
 
52
- describe 'excluded' do
76
+ describe '#exclude' do
77
+ before do
78
+ subject.exclude 'Item'
79
+ end
80
+ it 'should have Item in excluded list' do
81
+ subject.excluded.should include('Item')
82
+ end
83
+
84
+ it 'should exclude Item from available' do
85
+ subject.available.include?('Item').should be_false
86
+ end
53
87
  end
54
88
  end
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.2.0
4
+ version: 0.2.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-12-12 00:00:00.000000000Z
12
+ date: 2011-12-20 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70360657089040 !ruby/object:Gem::Requirement
16
+ requirement: &70140253600760 !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: *70360657089040
24
+ version_requirements: *70140253600760
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: sugar-high
27
- requirement: &70360657088280 !ruby/object:Gem::Requirement
27
+ requirement: &70140253599200 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.6.1
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70360657088280
35
+ version_requirements: *70140253599200
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: sweetloader
38
- requirement: &70360657087400 !ruby/object:Gem::Requirement
38
+ requirement: &70140253597980 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.1.6
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70360657087400
46
+ version_requirements: *70140253597980
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: hashie
49
- requirement: &70360657086900 !ruby/object:Gem::Requirement
49
+ requirement: &70140253590020 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '1.2'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70360657086900
57
+ version_requirements: *70140253590020
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: cantango-core
60
- requirement: &70360657034900 !ruby/object:Gem::Requirement
60
+ requirement: &70140253589180 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 0.1.9
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70360657034900
68
+ version_requirements: *70140253589180
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
- requirement: &70360657034380 !ruby/object:Gem::Requirement
71
+ requirement: &70140253588080 !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: *70360657034380
79
+ version_requirements: *70140253588080
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: jeweler
82
- requirement: &70360657033860 !ruby/object:Gem::Requirement
82
+ requirement: &70140253587180 !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: *70360657033860
90
+ version_requirements: *70140253587180
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rcov
93
- requirement: &70360657033300 !ruby/object:Gem::Requirement
93
+ requirement: &70140253586440 !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: *70360657033300
101
+ version_requirements: *70140253586440
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rspec
104
- requirement: &70360657032760 !ruby/object:Gem::Requirement
104
+ requirement: &70140253585440 !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: *70360657032760
112
+ version_requirements: *70140253585440
113
113
  description: Configuration DSL for configuring CanTango
114
114
  email: kmandrup@gmail.com
115
115
  executables: []
@@ -229,7 +229,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
229
229
  version: '0'
230
230
  segments:
231
231
  - 0
232
- hash: -3106832740323077134
232
+ hash: 2466227934103881117
233
233
  required_rubygems_version: !ruby/object:Gem::Requirement
234
234
  none: false
235
235
  requirements: