doodle 0.0.10 → 0.1.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.
Files changed (67) hide show
  1. data/CREDITS +22 -0
  2. data/{ChangeLog → History.txt} +22 -3
  3. data/License.txt +20 -0
  4. data/Manifest.txt +61 -0
  5. data/README.txt +166 -0
  6. data/Rakefile +4 -0
  7. data/config/hoe.rb +77 -0
  8. data/config/requirements.rb +15 -0
  9. data/examples/doodle-errors.rb +25 -0
  10. data/examples/event-location.rb +3 -7
  11. data/examples/example-01.rb +1 -1
  12. data/examples/example-01.rdoc +3 -3
  13. data/examples/example-02.rb +15 -4
  14. data/examples/example-02.rdoc +17 -5
  15. data/examples/mail-datatypes.rb +104 -0
  16. data/examples/mail.rb +85 -0
  17. data/examples/parent.rb +40 -0
  18. data/examples/profile-options.rb +67 -0
  19. data/examples/smtp_tls.rb +65 -0
  20. data/examples/test-datatypes.rb +55 -0
  21. data/examples/yaml-example.rb +40 -0
  22. data/examples/yaml-example2.rb +42 -0
  23. data/lib/doodle.rb +364 -301
  24. data/lib/doodle/datatypes.rb +148 -0
  25. data/lib/doodle/rfc822.rb +31 -0
  26. data/lib/doodle/utils.rb +13 -0
  27. data/lib/doodle/version.rb +9 -0
  28. data/log/debug.log +0 -0
  29. data/script/console +10 -0
  30. data/script/destroy +14 -0
  31. data/script/generate +14 -0
  32. data/script/txt2html +82 -0
  33. data/setup.rb +1585 -0
  34. data/spec/arg_order_spec.rb +5 -5
  35. data/spec/attributes_spec.rb +66 -24
  36. data/spec/bugs_spec.rb +109 -6
  37. data/spec/class_spec.rb +7 -4
  38. data/spec/class_validation_spec.rb +46 -0
  39. data/spec/class_var_spec.rb +76 -0
  40. data/spec/collector_spec.rb +16 -30
  41. data/spec/conversion_spec.rb +8 -3
  42. data/spec/defaults_spec.rb +4 -4
  43. data/spec/doodle_context_spec.rb +3 -4
  44. data/spec/doodle_spec.rb +25 -15
  45. data/spec/extra_args_spec.rb +1 -1
  46. data/spec/factory_spec.rb +3 -3
  47. data/spec/init_spec.rb +11 -11
  48. data/spec/new_doodle_spec.rb +19 -0
  49. data/spec/required_spec.rb +1 -1
  50. data/spec/serialization_spec.rb +3 -6
  51. data/spec/singleton_spec.rb +5 -5
  52. data/spec/spec.opts +1 -0
  53. data/spec/spec_helper.rb +44 -0
  54. data/spec/superclass_spec.rb +6 -5
  55. data/spec/validation2_spec.rb +248 -0
  56. data/spec/validation_spec.rb +26 -37
  57. data/tasks/deployment.rake +34 -0
  58. data/tasks/environment.rake +7 -0
  59. data/tasks/rspec.rake +21 -0
  60. data/tasks/website.rake +17 -0
  61. metadata +76 -20
  62. data/COPYING +0 -18
  63. data/README +0 -57
  64. data/examples/event.rb +0 -39
  65. data/examples/example-03.rb +0 -45
  66. data/examples/example-03.rdoc +0 -55
  67. data/lib/semantic.cache +0 -8
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
3
3
  describe Doodle, "Simple collector" do
4
4
  temporary_constant :Foo do
5
5
  before :each do
6
- class Foo < Doodle::Base
6
+ class Foo < Doodle
7
7
  has :list, :init => [], :collect => :item
8
8
  end
9
9
  @foo = Foo do
@@ -16,7 +16,7 @@ describe Doodle, "Simple collector" do
16
16
  end
17
17
 
18
18
  it "should define a collector method :item" do
19
- @foo.methods.include?('item').should == true
19
+ @foo.methods.map{ |x| x.to_sym }.include?(:item).should == true
20
20
  end
21
21
 
22
22
  it "should collect items into attribute :list" do
@@ -29,10 +29,10 @@ end
29
29
  describe Doodle, "Typed collector with default collector name" do
30
30
  temporary_constant :Event, :Location do
31
31
  before :each do
32
- class Location < Doodle::Base
32
+ class Location < Doodle
33
33
  has :name, :kind => String
34
34
  end
35
- class Event < Doodle::Base
35
+ class Event < Doodle
36
36
  has :locations, :init => [], :collect => Location
37
37
  end
38
38
  @event = Event do
@@ -45,7 +45,7 @@ describe Doodle, "Typed collector with default collector name" do
45
45
  end
46
46
 
47
47
  it "should define a collector method :location" do
48
- @event.methods.include?('location').should == true
48
+ @event.methods.map{ |x| x.to_sym }.include?(:location).should == true
49
49
  end
50
50
 
51
51
  it "should collect items into attribute :list" do
@@ -58,15 +58,15 @@ end
58
58
  describe Doodle, "Typed collector with specified collector name" do
59
59
  temporary_constant :Location, :Event do
60
60
  before :each do
61
- class Location < Doodle::Base
61
+ class Location < Doodle
62
62
  has :name, :kind => String
63
63
  end
64
- class Event < Doodle::Base
64
+ class Event < Doodle
65
65
  has :locations, :init => [], :collect => { :place => :Location }
66
66
  end
67
67
  end
68
68
  it "should define a collector method :place" do
69
- Event.instance_methods.include?('place').should == true
69
+ Event.instance_methods.map{ |x| x.to_sym}.include?(:place).should == true
70
70
  end
71
71
  end
72
72
  end
@@ -74,10 +74,10 @@ end
74
74
  describe Doodle, "typed collector with specified collector name" do
75
75
  temporary_constant :Location, :Event do
76
76
  before :each do
77
- class Location < Doodle::Base
77
+ class Location < Doodle
78
78
  has :name, :kind => String
79
79
  end
80
- class Event < Doodle::Base
80
+ class Event < Doodle
81
81
  has :locations, :init => [], :collect => { :place => Location }
82
82
  end
83
83
  end
@@ -98,11 +98,11 @@ end
98
98
  describe Doodle, "typed collector with specified collector name initialized from hash (with default :init param)" do
99
99
  temporary_constant :Location, :Event do
100
100
  before :each do
101
- class Location < Doodle::Base
101
+ class Location < Doodle
102
102
  has :name, :kind => String
103
103
  has :events, :collect => :Event
104
104
  end
105
- class Event < Doodle::Base
105
+ class Event < Doodle
106
106
  has :name, :kind => String
107
107
  has :locations, :collect => :Location
108
108
  end
@@ -113,26 +113,12 @@ describe Doodle, "typed collector with specified collector name initialized from
113
113
  :name => 'RAR',
114
114
  :locations =>
115
115
  [
116
- {
117
- :name => "Stage 1",
118
- :events =>
116
+ { :name => "Stage 1", :events =>
119
117
  [
120
- {
121
- :name => 'Foobars',
118
+ { :name => 'Foobars',
122
119
  :locations =>
123
- [
124
- {
125
- :name => 'Backstage'
126
- }
127
- ]
128
- }
129
- ]
130
- },
131
- {
132
- :name => "Stage 2"
133
- }
134
- ]
135
- }
120
+ [ { :name => 'Backstage' } ] } ] }, { :name => "Stage 2" } ] }
121
+ # note: wierd formatting above simply to pass coverage
136
122
  proc {
137
123
  event = Event(data)
138
124
  }.should_not raise_error
@@ -1,13 +1,13 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
  require 'date'
3
3
 
4
- describe Doodle, 'defaults which have not been set' do
4
+ describe Doodle, 'conversions' do
5
5
  after :each do
6
6
  undefine_const(:Foo)
7
7
  end
8
8
  before(:each) do
9
9
  raise_if_defined(:Foo)
10
- class Foo < Doodle::Base
10
+ class Foo < Doodle
11
11
  has :start do
12
12
  default { Date.today }
13
13
  from String do |s|
@@ -16,7 +16,7 @@ describe Doodle, 'defaults which have not been set' do
16
16
  end
17
17
  from Integer do |jd|
18
18
  Doodle::Debug.d { [:converting_from, Integer, jd] }
19
- Date.new(*Date.jd_to_civil(jd))
19
+ Date.new(*Date.send(:jd_to_civil, jd))
20
20
  end
21
21
  end
22
22
  from String do |s|
@@ -45,5 +45,10 @@ describe Doodle, 'defaults which have not been set' do
45
45
  foo = Foo.from("2007-12-31")
46
46
  foo.start.should == Date.new(2007, 12, 31)
47
47
  end
48
+
49
+ it 'should return class_conversions' do
50
+ Foo.conversions.keys.should == [String]
51
+ end
52
+
48
53
  end
49
54
 
@@ -4,7 +4,7 @@ describe Doodle, 'attributes with defaults' do
4
4
  temporary_constant :Foo do
5
5
  before(:each) do
6
6
  class Foo
7
- include Doodle::Helper
7
+ include Doodle::Core
8
8
  has :name, :default => 'D1'
9
9
  class << self
10
10
  has :metadata, :default => 'D2'
@@ -62,7 +62,7 @@ end
62
62
  describe Doodle, 'defaults which have not been set' do
63
63
  temporary_constant :Foo do
64
64
  before :each do
65
- class Foo < Doodle::Base
65
+ class Foo < Doodle
66
66
  has :baz
67
67
  end
68
68
  end
@@ -80,7 +80,7 @@ end
80
80
  describe Doodle, 'defaults which have been set' do
81
81
  temporary_constant :Foo do
82
82
  before :each do
83
- class Foo < Doodle::Base
83
+ class Foo < Doodle
84
84
  has :baz, :default => 'Hi!'
85
85
  has :start do
86
86
  default { Date.today }
@@ -102,7 +102,7 @@ end
102
102
  describe Doodle, "overriding inherited defaults" do
103
103
  temporary_constant :Text, :Text2, :KeyValue do
104
104
  before :each do
105
- class KeyValue < Doodle::Base
105
+ class KeyValue < Doodle
106
106
  has :name
107
107
  has :value
108
108
  end
@@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), 'spec_helper')
3
3
  describe Doodle, "doodle_context" do
4
4
  temporary_constants :Foo, :Bar do
5
5
  before :each do
6
- class Child < Doodle::Base
6
+ class Child < Doodle
7
7
  has :name
8
8
  has :dad do
9
9
  # there is an important difference between a block argument
@@ -20,9 +20,7 @@ describe Doodle, "doodle_context" do
20
20
  # during initialization - this is a way to capture that
21
21
  # value for ues later
22
22
 
23
- init {
24
- Doodle.parent
25
- }
23
+ init { parent }
26
24
  end
27
25
  end
28
26
 
@@ -40,6 +38,7 @@ describe Doodle, "doodle_context" do
40
38
 
41
39
  sean = dad.children[0]
42
40
  sean.dad.name.should == 'Conn'
41
+ sean.parent.name.should == 'Conn'
43
42
  end
44
43
  end
45
44
  end
@@ -4,7 +4,7 @@ describe Doodle, 'instance attributes' do
4
4
  temporary_constant :Foo do
5
5
  before(:each) do
6
6
  class Foo
7
- include Doodle::Helper
7
+ include Doodle::Core
8
8
  has :name, :default => nil
9
9
  end
10
10
  @foo = Foo.new
@@ -41,7 +41,7 @@ describe Doodle, 'class attributes(false)' do
41
41
  temporary_constant :Foo do
42
42
  before(:each) do
43
43
  class Foo
44
- include Doodle::Helper
44
+ include Doodle::Core
45
45
  class << self
46
46
  has :metadata
47
47
  end
@@ -81,7 +81,7 @@ describe Doodle, 'inherited class attributes(false)' do
81
81
  temporary_constant :Foo, :Bar do
82
82
  before(:each) do
83
83
  class Foo
84
- include Doodle::Helper
84
+ include Doodle::Core
85
85
  has :name, :default => nil
86
86
  class << self
87
87
  has :metadata
@@ -148,10 +148,14 @@ describe Doodle, 'inherited class attributes(false)' do
148
148
  Bar.singleton_class.attributes(false).keys.should == [:doc]
149
149
  end
150
150
 
151
- it "should list all inherited meta class attributes" do
152
- Bar.singleton_class.attributes.keys.should == [:metadata, :doc]
151
+ it "should list all singleton class attributes" do
152
+ Bar.singleton_class.attributes.keys.should == [:doc]
153
153
  end
154
154
 
155
+ it "should list all inherited meta class attributes" do
156
+ Bar.class_attributes.keys.should == [:metadata, :doc]
157
+ end
158
+
155
159
  it "should list all inherited class's attributes" do
156
160
  Bar.attributes.keys.should == [:name, :location]
157
161
  end
@@ -163,7 +167,7 @@ describe Doodle, 'singleton class attributes' do
163
167
  before(:each) do
164
168
 
165
169
  class Foo
166
- include Doodle::Helper
170
+ include Doodle::Core
167
171
  has :name, :default => nil
168
172
  class << self
169
173
  has :metadata
@@ -183,13 +187,18 @@ describe Doodle, 'singleton class attributes' do
183
187
  @foo.special.should == 42
184
188
  end
185
189
 
186
- it 'should list instance attributes' do
190
+ it 'should list singleton instance attributes(false)' do
187
191
  @foo.singleton_class.attributes(false).keys.should == [:special]
188
192
  end
189
193
 
194
+ it 'should list singleton instance attributes' do
195
+ @foo.singleton_class.attributes.keys.should == [:special]
196
+ end
197
+
190
198
  it 'should list instance attributes' do
191
- @foo.singleton_class.attributes.keys.should == [:metadata, :special]
199
+ @foo.attributes.keys.should == [:name, :special]
192
200
  end
201
+
193
202
  end
194
203
  end
195
204
 
@@ -197,7 +206,7 @@ describe Doodle, 'inherited singleton class attributes' do
197
206
  temporary_constant :Foo, :Bar do
198
207
  before(:each) do
199
208
  class Foo
200
- include Doodle::Helper
209
+ include Doodle::Core
201
210
  has :name, :default => nil
202
211
  class << self
203
212
  has :metadata
@@ -246,16 +255,17 @@ describe Doodle, 'inherited singleton class attributes' do
246
255
  @bar.singleton_class.attributes(false).keys.should == [:extra]
247
256
  end
248
257
 
249
- it 'should list instance attributes' do
250
- @foo.singleton_class.attributes.keys.should == [:metadata, :special]
251
- @bar.singleton_class.attributes.keys.should == [:metadata, :doc, :extra]
258
+ it 'should list singleton attributes only' do
259
+ @foo.singleton_class.attributes.keys.should == [:special]
260
+ @bar.singleton_class.attributes.keys.should == [:extra]
252
261
  end
253
262
 
254
263
  it 'should keep meta attributes separate' do
255
264
  @foo.special = 'foo special'
256
265
  @foo.special.should == 'foo special'
257
- @foo.singleton_class.metadata = 'foo meta'
258
- @foo.singleton_class.metadata.should == 'foo meta'
266
+ # @foo.singleton_class.methods.map{ |x| x.to_sym}.include?(:metadata).should == false
267
+ # @foo.singleton_class.metadata = 'foo meta'
268
+ # @foo.singleton_class.metadata.should == 'foo meta'
259
269
  # note: you cannot set any other values on @bar until you have set @bar.extra because it's defined as required
260
270
  @bar.extra = 'bar extra'
261
271
  @bar.extra.should == 'bar extra'
@@ -268,7 +278,7 @@ describe Doodle, 'inherited singleton class attributes' do
268
278
 
269
279
  # now make sure they haven't bumped each other off
270
280
  @foo.special.should == 'foo special'
271
- @foo.singleton_class.metadata.should == 'foo meta'
281
+ # @foo.singleton_class.metadata.should == 'foo meta'
272
282
  @bar.extra.should == 'bar extra'
273
283
  Foo.metadata.should == 'Foo meta'
274
284
  Bar.metadata.should == 'Bar meta'
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
3
3
  describe Doodle, ' unspecified attributes' do
4
4
  temporary_constants :Foo do
5
5
  before :each do
6
- class Foo < Doodle::Base
6
+ class Foo < Doodle
7
7
  end
8
8
  end
9
9
 
@@ -1,9 +1,9 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe Doodle::Factory, " as part of Doodle::Base" do
3
+ describe Doodle::Factory, " as part of Doodle" do
4
4
  temporary_constant :Foo, :Bar do
5
5
  before(:each) do
6
- class Foo < Doodle::Base
6
+ class Foo < Doodle
7
7
  has :var1
8
8
  end
9
9
  class Bar < Foo
@@ -32,7 +32,7 @@ describe Doodle::Factory, " included as module" do
32
32
  temporary_constant :Baz, :Qux, :MyDate, :AnotherDate do
33
33
  before(:each) do
34
34
  class Baz
35
- include Doodle::Helper
35
+ include Doodle::Core
36
36
  has :var1
37
37
  end
38
38
  class Qux < Baz
@@ -5,7 +5,7 @@ describe Doodle, 'init' do
5
5
 
6
6
  before(:each) do
7
7
  class Foo
8
- include Doodle::Helper
8
+ include Doodle::Core
9
9
  has :moniker, :init => 'D1'
10
10
  class << self
11
11
  has :metadata, :init => 'D2'
@@ -38,17 +38,17 @@ describe Doodle, 'init' do
38
38
  @foo.moniker.should == 'D1'
39
39
  end
40
40
  it 'should have an instance_variable for attribute :moniker' do
41
- @foo.instance_variables.include?('@moniker').should == true
41
+ @foo.instance_variables.map{ |x| x.to_sym }.include?(:@moniker).should == true
42
42
  end
43
43
  it 'should have an initialized class attribute :metadata' do
44
- pending 'deciding how this should work' do
44
+ #pending 'deciding how this should work' do
45
45
  Foo.metadata.should == 'D2'
46
- end
46
+ #end
47
47
  end
48
48
  it 'should have an initialized singleton attribute :special' do
49
- pending 'deciding how this should work' do
49
+ #pending 'deciding how this should work' do
50
50
  @foo.special.should == 'D3'
51
- end
51
+ #end
52
52
  end
53
53
  end
54
54
  end
@@ -56,7 +56,7 @@ end
56
56
  describe Doodle, 'init' do
57
57
  temporary_constant :Foo do
58
58
  it 'should accept nil as :init' do
59
- class Foo < Doodle::Base
59
+ class Foo < Doodle
60
60
  has :value, :init => nil
61
61
  end
62
62
  foo = Foo.new
@@ -65,7 +65,7 @@ describe Doodle, 'init' do
65
65
  end
66
66
  temporary_constant :Foo do
67
67
  it 'should accept true as :init' do
68
- class Foo < Doodle::Base
68
+ class Foo < Doodle
69
69
  has :value, :init => true
70
70
  end
71
71
  foo = Foo.new
@@ -74,7 +74,7 @@ describe Doodle, 'init' do
74
74
  end
75
75
  temporary_constant :Foo do
76
76
  it 'should accept Fixnum as :init' do
77
- class Foo < Doodle::Base
77
+ class Foo < Doodle
78
78
  has :value, :init => 42
79
79
  end
80
80
  foo = Foo.new
@@ -83,7 +83,7 @@ describe Doodle, 'init' do
83
83
  end
84
84
  temporary_constant :Foo do
85
85
  it 'should not evaluate value when proc given as :init' do
86
- class Foo < Doodle::Base
86
+ class Foo < Doodle
87
87
  has :value, :init => proc { 42 }
88
88
  end
89
89
  foo = Foo.new
@@ -92,7 +92,7 @@ describe Doodle, 'init' do
92
92
  end
93
93
  temporary_constant :Foo do
94
94
  it 'should evaluate value when block given as :init' do
95
- class Foo < Doodle::Base
95
+ class Foo < Doodle
96
96
  has :value do
97
97
  init do
98
98
  42
@@ -0,0 +1,19 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe Doodle, 'simple' do
4
+ temporary_constant :Foo do
5
+ before :each do
6
+ class Foo < Doodle
7
+ has :var1
8
+ has :var2
9
+ has :var3
10
+ end
11
+ end
12
+ it 'should be allow instantiation' do
13
+ foo = Foo.new 1, 2, 3
14
+ foo.var1.should == 1
15
+ foo.var2.should == 2
16
+ foo.var3.should == 3
17
+ end
18
+ end
19
+ end