doodle 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,38 @@
1
+ require 'rubygems'
2
+ require 'date'
3
+ require 'pp'
4
+ require 'doodle'
5
+
6
+ class Location < Doodle::Base
7
+ has :name, :kind => String
8
+ has :events, :init => [], :collect => :Event
9
+ end
10
+
11
+ class Event
12
+ # or if you want to inherit from another class
13
+ include Doodle::Helper
14
+ include Doodle::Factory
15
+
16
+ has :name, :kind => String
17
+ has :date do
18
+ kind Date
19
+ default { Date.today }
20
+ must 'be >= today' do |value|
21
+ value >= Date.today
22
+ end
23
+ from String do |s|
24
+ Date.parse(s)
25
+ end
26
+ end
27
+ has :locations, :init => [], :collect => {:place => "Location"}
28
+ end
29
+
30
+ event = Event "Festival" do
31
+ date '2008-04-01'
32
+ place "The muddy field"
33
+ place "Beer tent" do
34
+ event "Drinking"
35
+ end
36
+ end
37
+
38
+ pp event
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'doodle'
3
+
4
+ class Foo < Doodle::Base
5
+ has :name, :kind => String
6
+ end
7
+
8
+ foo = Foo "Bar"
9
+ foo # =>
10
+ baz = Foo 1
@@ -1,6 +1,6 @@
1
- $:.unshift(File.join(File.dirname(__FILE__), '../.'))
2
-
3
- require 'lib/doodle'
1
+ $:.unshift(File.join(File.dirname(__FILE__), '../lib'))
2
+ require 'molic_orderedhash'
3
+ require 'doodle'
4
4
  require 'date'
5
5
 
6
6
  def undefine_const(*consts)
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.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean O'Halpin
@@ -26,6 +26,7 @@ files:
26
26
  - lib/doodle.rb
27
27
  - lib/molic_orderedhash.rb
28
28
  - lib/spec_helper.rb
29
+ - examples/event-location.rb
29
30
  - examples/event.rb
30
31
  - examples/event1.rb
31
32
  - examples/event2.rb
@@ -33,6 +34,7 @@ files:
33
34
  - examples/example-01.rdoc
34
35
  - examples/example-02.rb
35
36
  - examples/example-02.rdoc
37
+ - examples/foo.rb
36
38
  - README
37
39
  - COPYING
38
40
  has_rdoc: true