doodle 0.1.7 → 0.1.8
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/History.txt +38 -0
- data/lib/doodle.rb +192 -212
- data/lib/doodle/version.rb +1 -1
- data/spec/attributes_spec.rb +25 -24
- data/spec/bugs_spec.rb +2 -2
- data/spec/class_spec.rb +5 -5
- data/spec/conversion_spec.rb +1 -1
- data/spec/defaults_spec.rb +8 -8
- data/spec/doodle_context_spec.rb +2 -2
- data/spec/doodle_spec.rb +22 -22
- data/spec/from_spec.rb +43 -0
- data/spec/has_spec.rb +15 -6
- data/spec/inheritance_spec.rb +11 -12
- data/spec/init_spec.rb +6 -6
- data/spec/kind_spec.rb +17 -0
- data/spec/singleton_spec.rb +12 -12
- data/spec/specialized_attribute_class_spec.rb +4 -4
- data/spec/superclass_spec.rb +6 -6
- data/spec/validation2_spec.rb +4 -4
- data/spec/validation_spec.rb +5 -5
- metadata +4 -2
data/spec/init_spec.rb
CHANGED
@@ -17,22 +17,22 @@ describe Doodle, 'init' do
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
it 'should have instance attribute init via class' do
|
20
|
-
Foo.
|
20
|
+
Foo.doodle.attributes[:moniker].init.should == 'D1'
|
21
21
|
end
|
22
22
|
it 'should have instance attribute init via instance' do
|
23
|
-
@foo.
|
23
|
+
@foo.doodle.attributes[:moniker].init.should == 'D1'
|
24
24
|
end
|
25
25
|
it 'should have class attribute init via class.singleton_class' do
|
26
|
-
Foo.singleton_class.
|
26
|
+
Foo.singleton_class.doodle.attributes(false)[:metadata].init.should == 'D2'
|
27
27
|
end
|
28
28
|
it 'should have class attribute init via class.singleton_class' do
|
29
|
-
Foo.singleton_class.
|
29
|
+
Foo.singleton_class.doodle.attributes[:metadata].init.should == 'D2'
|
30
30
|
end
|
31
31
|
it 'should have singleton attribute init via instance.singleton_class' do
|
32
|
-
@foo.singleton_class.
|
32
|
+
@foo.singleton_class.doodle.attributes(false)[:special].init.should == 'D3'
|
33
33
|
end
|
34
34
|
it 'should have singleton attribute init via instance.singleton_class' do
|
35
|
-
@foo.singleton_class.
|
35
|
+
@foo.singleton_class.doodle.attributes[:special].init.should == 'D3'
|
36
36
|
end
|
37
37
|
it 'should have an attribute :moniker from init' do
|
38
38
|
@foo.moniker.should == 'D1'
|
data/spec/kind_spec.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe 'Doodle', 'kind' do
|
4
|
+
temporary_constant :Foo do
|
5
|
+
before :each do
|
6
|
+
class Foo < Doodle
|
7
|
+
has :var1, :kind => [String, Symbol]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should allow multiple kinds' do
|
12
|
+
proc { Foo 'hi' }.should_not raise_error
|
13
|
+
proc { Foo :hi }.should_not raise_error
|
14
|
+
proc { Foo 1 }.should raise_error(Doodle::ValidationError)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/spec/singleton_spec.rb
CHANGED
@@ -8,9 +8,9 @@ describe Doodle, "singletons" do
|
|
8
8
|
has :c1
|
9
9
|
end
|
10
10
|
end
|
11
|
-
Foo.
|
12
|
-
Foo.singleton_class.
|
13
|
-
Foo.singleton_class.
|
11
|
+
Foo.doodle.attributes.should_be OrderedHash.new
|
12
|
+
Foo.singleton_class.doodle.attributes.should_not_be OrderedHash.new
|
13
|
+
Foo.singleton_class.doodle.attributes.map{ |name, attr| name }.should_be [:c1]
|
14
14
|
Foo.c1 = 1
|
15
15
|
Foo.c1.should_be 1
|
16
16
|
end
|
@@ -22,9 +22,9 @@ describe Doodle, "singletons" do
|
|
22
22
|
has :c2
|
23
23
|
end
|
24
24
|
end
|
25
|
-
Foo.
|
26
|
-
Foo.singleton_class.
|
27
|
-
Foo.singleton_class.
|
25
|
+
Foo.doodle.attributes.should_be OrderedHash.new
|
26
|
+
Foo.singleton_class.doodle.attributes.should_not_be OrderedHash.new
|
27
|
+
Foo.singleton_class.doodle.attributes.map{ |name, attr| name }.should_be [:c2]
|
28
28
|
Foo.c2 = 1
|
29
29
|
Foo.c2.should_be 1
|
30
30
|
end
|
@@ -36,9 +36,9 @@ describe Doodle, "singletons" do
|
|
36
36
|
class << foo
|
37
37
|
has :i1
|
38
38
|
end
|
39
|
-
foo.
|
40
|
-
foo.singleton_class.
|
41
|
-
foo.singleton_class.
|
39
|
+
foo.doodle.attributes.keys.should_be [:i1]
|
40
|
+
foo.singleton_class.doodle.attributes.should_not_be OrderedHash.new
|
41
|
+
foo.singleton_class.doodle.attributes.map{ |name, attr| name }.should_be [:i1]
|
42
42
|
foo.i1 = 1
|
43
43
|
foo.i1.should_be 1
|
44
44
|
end
|
@@ -53,9 +53,9 @@ describe Doodle, "singletons" do
|
|
53
53
|
has :i2
|
54
54
|
end
|
55
55
|
end
|
56
|
-
foo.
|
57
|
-
foo.singleton_class.singleton_class.
|
58
|
-
foo.singleton_class.singleton_class.
|
56
|
+
foo.doodle.attributes.should_be OrderedHash.new
|
57
|
+
foo.singleton_class.singleton_class.doodle.attributes.should_not_be OrderedHash.new
|
58
|
+
foo.singleton_class.singleton_class.doodle.attributes.map{ |name, attr| name }.should_be [:i2]
|
59
59
|
foo.singleton_class.i2 = 1
|
60
60
|
foo.singleton_class.i2.should_be 1
|
61
61
|
end
|
@@ -55,9 +55,9 @@ describe 'Doodle', 'specialized attributes' do
|
|
55
55
|
rv.class.should_be SpecializedAttribute
|
56
56
|
rv.flag.should_be 'sflag'
|
57
57
|
end
|
58
|
-
Foo.
|
58
|
+
Foo.doodle.attributes[:ivar1].flag.should_be "sflag"
|
59
59
|
foo = Foo.new('hi')
|
60
|
-
foo.
|
60
|
+
foo.doodle.attributes[:ivar1].flag.should_be "sflag"
|
61
61
|
end
|
62
62
|
|
63
63
|
it 'should allow using datatypes in additional directives invoking specialized attribute of correct class' do
|
@@ -79,9 +79,9 @@ describe 'Doodle', 'specialized attributes' do
|
|
79
79
|
rv.class.should_be SpecializedAttribute
|
80
80
|
rv.flag.should_be 'x'
|
81
81
|
end
|
82
|
-
Foo.
|
82
|
+
Foo.doodle.attributes[:ivar1].flag.should_be "x"
|
83
83
|
foo = Foo.new('hi')
|
84
|
-
foo.
|
84
|
+
foo.doodle.attributes[:ivar1].flag.should_be "x"
|
85
85
|
end
|
86
86
|
|
87
87
|
it 'should allow using datatypes in additional directives invoking specialized attribute of correct class and raise error if incorrect value supplied' do
|
data/spec/superclass_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
2
|
|
3
|
-
describe 'Doodle', '
|
3
|
+
describe 'Doodle', 'doodle.parents' do
|
4
4
|
temporary_constant :Foo do
|
5
5
|
before :each do
|
6
6
|
class Foo < Doodle
|
@@ -12,13 +12,13 @@ describe 'Doodle', 'doodle_parents' do
|
|
12
12
|
@sclass_foo = class << @foo; class << self; self; end; end
|
13
13
|
end
|
14
14
|
|
15
|
-
it 'should have no singleton
|
16
|
-
@sc.
|
15
|
+
it 'should have no singleton doodle.parents ' do
|
16
|
+
@sc.doodle.parents.should == []
|
17
17
|
end
|
18
18
|
|
19
|
-
# it "should have singleton class's singleton class
|
20
|
-
#
|
21
|
-
# @scc.
|
19
|
+
# it "should have singleton class's singleton class doodle.parents == []" do
|
20
|
+
# expected_doodle.parents = RUBY_VERSION <= "1.8.6" ? [] : [Module, Object, BasicObject]
|
21
|
+
# @scc.doodle.parents.should == expected_doodle.parents
|
22
22
|
# end
|
23
23
|
end
|
24
24
|
end
|
data/spec/validation2_spec.rb
CHANGED
@@ -202,17 +202,17 @@ end
|
|
202
202
|
@dr.end_date.should == @dr.start_date
|
203
203
|
end
|
204
204
|
|
205
|
-
it "should not raise an error when changing start_date and changing end_date using defer_validation" do
|
205
|
+
it "should not raise an error when changing start_date and changing end_date using doodle.defer_validation" do
|
206
206
|
proc {
|
207
|
-
@dr.defer_validation do
|
207
|
+
@dr.doodle.defer_validation do
|
208
208
|
self.start_date = self.start_date + 1
|
209
209
|
self.end_date = self.start_date
|
210
210
|
end
|
211
211
|
}.should_not raise_error
|
212
212
|
end
|
213
213
|
|
214
|
-
it "should allow changing start_date and changing end_date using defer_validation" do
|
215
|
-
@dr.defer_validation do
|
214
|
+
it "should allow changing start_date and changing end_date using doodle.defer_validation" do
|
215
|
+
@dr.doodle.defer_validation do
|
216
216
|
start_date start_date + 1
|
217
217
|
end_date start_date
|
218
218
|
end
|
data/spec/validation_spec.rb
CHANGED
@@ -58,19 +58,19 @@ describe :DateRange, 'validation & conversions' do
|
|
58
58
|
|
59
59
|
it 'should have start_date kind == Date' do
|
60
60
|
d = DateRange.new
|
61
|
-
d.
|
61
|
+
d.doodle.attributes[:start_date].kind == Date
|
62
62
|
end
|
63
63
|
|
64
64
|
it 'should have two validations' do
|
65
65
|
d = DateRange.new
|
66
|
-
d.
|
67
|
-
d.
|
66
|
+
d.doodle.attributes[:start_date].doodle.validations.size.should_be 2
|
67
|
+
d.doodle.attributes[:start_date].doodle.validations(false).size.should_be 2
|
68
68
|
end
|
69
69
|
|
70
70
|
it 'should have two conversions' do
|
71
71
|
d = DateRange.new
|
72
|
-
d.
|
73
|
-
d.
|
72
|
+
d.doodle.attributes[:start_date].doodle.conversions.size.should_be 3
|
73
|
+
d.doodle.attributes[:start_date].doodle.conversions(false).size.should_be 3
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'should convert from Array' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: doodle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean O'Halpin
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-05-
|
12
|
+
date: 2008-05-16 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -130,6 +130,8 @@ test_files:
|
|
130
130
|
- spec/flatten_first_level_spec.rb
|
131
131
|
- spec/new_doodle_spec.rb
|
132
132
|
- spec/attributes_spec.rb
|
133
|
+
- spec/kind_spec.rb
|
134
|
+
- spec/from_spec.rb
|
133
135
|
- spec/arg_order_spec.rb
|
134
136
|
- spec/serialization_spec.rb
|
135
137
|
- spec/singleton_spec.rb
|