doodle 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +18 -0
- data/History.txt +9 -0
- data/Manifest.txt +16 -12
- data/PostInstall.txt +1 -0
- data/lib/doodle.rb +166 -86
- data/lib/doodle/datatypes.rb +19 -6
- data/lib/doodle/rfc822.rb +22 -15
- data/lib/doodle/version.rb +1 -1
- data/spec/arg_order_spec.rb +11 -11
- data/spec/attributes_spec.rb +8 -8
- data/spec/bugs_spec.rb +12 -12
- data/spec/class_spec.rb +21 -21
- data/spec/collector_spec.rb +87 -11
- data/spec/defaults_spec.rb +21 -21
- data/spec/doodle_context_spec.rb +2 -2
- data/spec/doodle_spec.rb +86 -70
- data/spec/factory_spec.rb +8 -8
- data/spec/inheritance_spec.rb +74 -0
- data/spec/new_doodle_spec.rb +3 -3
- data/spec/singleton_spec.rb +16 -16
- data/spec/spec_helper.rb +10 -0
- data/spec/specialized_attribute_class_spec.rb +111 -0
- data/spec/superclass_spec.rb +4 -4
- data/spec/validation_spec.rb +8 -8
- data/tasks/deployment.rake +5 -5
- metadata +21 -14
- data/tasks/website.rake +0 -17
data/spec/new_doodle_spec.rb
CHANGED
@@ -11,9 +11,9 @@ describe Doodle, 'simple' do
|
|
11
11
|
end
|
12
12
|
it 'should be allow instantiation' do
|
13
13
|
foo = Foo.new 1, 2, 3
|
14
|
-
foo.var1.
|
15
|
-
foo.var2.
|
16
|
-
foo.var3.
|
14
|
+
foo.var1.should_be 1
|
15
|
+
foo.var2.should_be 2
|
16
|
+
foo.var3.should_be 3
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
data/spec/singleton_spec.rb
CHANGED
@@ -8,11 +8,11 @@ describe Doodle, "singletons" do
|
|
8
8
|
has :c1
|
9
9
|
end
|
10
10
|
end
|
11
|
-
Foo.attributes.
|
12
|
-
Foo.singleton_class.attributes.
|
13
|
-
Foo.singleton_class.attributes.map{ |name, attr| name }.
|
11
|
+
Foo.attributes.should_be OrderedHash.new
|
12
|
+
Foo.singleton_class.attributes.should_not_be OrderedHash.new
|
13
|
+
Foo.singleton_class.attributes.map{ |name, attr| name }.should_be [:c1]
|
14
14
|
Foo.c1 = 1
|
15
|
-
Foo.c1.
|
15
|
+
Foo.c1.should_be 1
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should allow creating attributes on classes via module inclusion" do
|
@@ -22,11 +22,11 @@ describe Doodle, "singletons" do
|
|
22
22
|
has :c2
|
23
23
|
end
|
24
24
|
end
|
25
|
-
Foo.attributes.
|
26
|
-
Foo.singleton_class.attributes.
|
27
|
-
Foo.singleton_class.attributes.map{ |name, attr| name }.
|
25
|
+
Foo.attributes.should_be OrderedHash.new
|
26
|
+
Foo.singleton_class.attributes.should_not_be OrderedHash.new
|
27
|
+
Foo.singleton_class.attributes.map{ |name, attr| name }.should_be [:c2]
|
28
28
|
Foo.c2 = 1
|
29
|
-
Foo.c2.
|
29
|
+
Foo.c2.should_be 1
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should allow creating attributes on singletons via inheritance" do
|
@@ -36,11 +36,11 @@ describe Doodle, "singletons" do
|
|
36
36
|
class << foo
|
37
37
|
has :i1
|
38
38
|
end
|
39
|
-
foo.attributes.keys.
|
40
|
-
foo.singleton_class.attributes.
|
41
|
-
foo.singleton_class.attributes.map{ |name, attr| name }.
|
39
|
+
foo.attributes.keys.should_be [:i1]
|
40
|
+
foo.singleton_class.attributes.should_not_be OrderedHash.new
|
41
|
+
foo.singleton_class.attributes.map{ |name, attr| name }.should_be [:i1]
|
42
42
|
foo.i1 = 1
|
43
|
-
foo.i1.
|
43
|
+
foo.i1.should_be 1
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should allow creating attributes on a singleton's singleton via module inclusion" do
|
@@ -53,11 +53,11 @@ describe Doodle, "singletons" do
|
|
53
53
|
has :i2
|
54
54
|
end
|
55
55
|
end
|
56
|
-
foo.attributes.
|
57
|
-
foo.singleton_class.singleton_class.attributes.
|
58
|
-
foo.singleton_class.singleton_class.attributes.map{ |name, attr| name }.
|
56
|
+
foo.attributes.should_be OrderedHash.new
|
57
|
+
foo.singleton_class.singleton_class.attributes.should_not_be OrderedHash.new
|
58
|
+
foo.singleton_class.singleton_class.attributes.map{ |name, attr| name }.should_be [:i2]
|
59
59
|
foo.singleton_class.i2 = 1
|
60
|
-
foo.singleton_class.i2.
|
60
|
+
foo.singleton_class.i2.should_be 1
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -10,6 +10,16 @@ $:.unshift(File.dirname(__FILE__) + '/../lib')
|
|
10
10
|
require 'doodle'
|
11
11
|
require 'date'
|
12
12
|
|
13
|
+
class Object
|
14
|
+
# try to get rid of those annoying warnings about useless ==
|
15
|
+
def should_be(other)
|
16
|
+
should == other
|
17
|
+
end
|
18
|
+
def should_not_be(other)
|
19
|
+
should_not == other
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
13
23
|
# functions to help clean up namespace after defining classes
|
14
24
|
def undefine_const(*consts)
|
15
25
|
consts.each do |const|
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
require 'doodle/datatypes'
|
4
|
+
|
5
|
+
describe 'Doodle', 'specialized attributes' do
|
6
|
+
temporary_constant :Foo, :SpecializedAttribute do
|
7
|
+
before :each do
|
8
|
+
class SpecializedAttribute < Doodle::Attribute
|
9
|
+
end
|
10
|
+
|
11
|
+
class Foo < Doodle
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should allow :using keyword' do
|
16
|
+
proc {
|
17
|
+
Foo.class_eval do
|
18
|
+
has :ivar1, :kind => String, :using => SpecializedAttribute
|
19
|
+
end
|
20
|
+
}.should_not raise_error
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should interpret :using keyword and return a specialized attribute of correct class' do
|
24
|
+
class Foo < Doodle
|
25
|
+
rv = has(:ivar1, :kind => String, :using => SpecializedAttribute)
|
26
|
+
rv.class.should_be SpecializedAttribute
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should allow additional attributes belonging to specialized attribute of correct class' do
|
31
|
+
class SpecializedAttribute
|
32
|
+
has :flag, :kind => String
|
33
|
+
end
|
34
|
+
class Foo < Doodle
|
35
|
+
rv = has(:ivar1, :kind => String, :using => SpecializedAttribute, :flag => "sflag")
|
36
|
+
rv.class.should_be SpecializedAttribute
|
37
|
+
rv.flag.should_be 'sflag'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should allow additional directives invoking specialized attribute of correct class' do
|
42
|
+
class SpecializedAttribute
|
43
|
+
has :flag, :kind => String
|
44
|
+
end
|
45
|
+
class Foo < Doodle
|
46
|
+
class << self
|
47
|
+
def option(*args, &block)
|
48
|
+
# this is how to add extra options onto args array for has
|
49
|
+
# - all hashes get merged into one
|
50
|
+
args << { :using => SpecializedAttribute }
|
51
|
+
has(*args, &block)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
rv = option(:ivar1, :kind => String, :flag => "sflag")
|
55
|
+
rv.class.should_be SpecializedAttribute
|
56
|
+
rv.flag.should_be 'sflag'
|
57
|
+
end
|
58
|
+
Foo.attributes[:ivar1].flag.should_be "sflag"
|
59
|
+
foo = Foo.new('hi')
|
60
|
+
foo.attributes[:ivar1].flag.should_be "sflag"
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should allow using datatypes in additional directives invoking specialized attribute of correct class' do
|
64
|
+
class SpecializedAttribute
|
65
|
+
doodle do
|
66
|
+
string :flag, :max => 1
|
67
|
+
end
|
68
|
+
end
|
69
|
+
class Foo < Doodle
|
70
|
+
class << self
|
71
|
+
def option(*args, &block)
|
72
|
+
# this is how to add extra options onto args array for has
|
73
|
+
# - all hashes get merged into one
|
74
|
+
args << { :using => SpecializedAttribute }
|
75
|
+
has(*args, &block)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
rv = option(:ivar1, :kind => String, :flag => "x")
|
79
|
+
rv.class.should_be SpecializedAttribute
|
80
|
+
rv.flag.should_be 'x'
|
81
|
+
end
|
82
|
+
Foo.attributes[:ivar1].flag.should_be "x"
|
83
|
+
foo = Foo.new('hi')
|
84
|
+
foo.attributes[:ivar1].flag.should_be "x"
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should allow using datatypes in additional directives invoking specialized attribute of correct class and raise error if incorrect value supplied' do
|
88
|
+
class SpecializedAttribute
|
89
|
+
doodle do
|
90
|
+
string :flag, :max => 1
|
91
|
+
end
|
92
|
+
end
|
93
|
+
class Foo < Doodle
|
94
|
+
class << self
|
95
|
+
def option(*args, &block)
|
96
|
+
args << { :using => SpecializedAttribute }
|
97
|
+
has(*args, &block)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
proc { Foo.class_eval { option(:ivar1, :kind => String, :flag => "ab") }}.should raise_error(Doodle::ValidationError)
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'should allow specifying name as named parameter' do
|
105
|
+
class Foo < Doodle
|
106
|
+
has :name => :ivar
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
data/spec/superclass_spec.rb
CHANGED
@@ -16,10 +16,10 @@ describe 'Doodle', 'parents' do
|
|
16
16
|
@sc.parents.should == []
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
# it "should have singleton class's singleton class parents == []" do
|
20
|
+
# expected_parents = RUBY_VERSION <= "1.8.6" ? [] : [Module, Object, BasicObject]
|
21
|
+
# @scc.parents.should == expected_parents
|
22
|
+
# end
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
data/spec/validation_spec.rb
CHANGED
@@ -63,26 +63,26 @@ describe :DateRange, 'validation & conversions' do
|
|
63
63
|
|
64
64
|
it 'should have two validations' do
|
65
65
|
d = DateRange.new
|
66
|
-
d.attributes[:start_date].validations.size.
|
67
|
-
d.attributes[:start_date].validations(false).size.
|
66
|
+
d.attributes[:start_date].validations.size.should_be 2
|
67
|
+
d.attributes[:start_date].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.attributes[:start_date].conversions.size.
|
73
|
-
d.attributes[:start_date].conversions(false).size.
|
72
|
+
d.attributes[:start_date].conversions.size.should_be 3
|
73
|
+
d.attributes[:start_date].conversions(false).size.should_be 3
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'should convert from Array' do
|
77
77
|
d = DateRange.new [2007,01,01], [2007,01,02]
|
78
|
-
d.start_date.
|
79
|
-
d.end_date.
|
78
|
+
d.start_date.should_be Date.new(2007,01,01)
|
79
|
+
d.end_date.should_be Date.new(2007,01,02)
|
80
80
|
end
|
81
81
|
|
82
82
|
it 'should convert Integer representing Julian date to Date' do
|
83
83
|
d = DateRange.new 2454428, 2454429
|
84
|
-
d.start_date.
|
85
|
-
d.end_date.
|
84
|
+
d.start_date.should_be Date.new(2007,11,23)
|
85
|
+
d.end_date.should_be Date.new(2007,11,24)
|
86
86
|
end
|
87
87
|
end
|
88
88
|
end
|
data/tasks/deployment.rake
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
desc 'Release the
|
2
|
-
task :deploy => [:check_version, :
|
1
|
+
desc 'Release the new gem version'
|
2
|
+
task :deploy => [:check_version, :release] do
|
3
3
|
puts "Remember to create SVN tag:"
|
4
4
|
puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
|
5
5
|
"svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
|
@@ -7,8 +7,8 @@ task :deploy => [:check_version, :website, :release] do
|
|
7
7
|
puts "Tagging release #{CHANGES}"
|
8
8
|
end
|
9
9
|
|
10
|
-
desc 'Runs
|
11
|
-
task :local_deploy => [:
|
10
|
+
desc 'Runs task install_gem as a local deployment of the gem'
|
11
|
+
task :local_deploy => [:install_gem]
|
12
12
|
|
13
13
|
task :check_version do
|
14
14
|
unless ENV['VERSION']
|
@@ -31,4 +31,4 @@ namespace :manifest do
|
|
31
31
|
task :refresh do
|
32
32
|
`rake check_manifest | patch -p0 > Manifest.txt`
|
33
33
|
end
|
34
|
-
end
|
34
|
+
end
|
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.4
|
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-06 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -24,36 +24,39 @@ extra_rdoc_files:
|
|
24
24
|
- History.txt
|
25
25
|
- License.txt
|
26
26
|
- Manifest.txt
|
27
|
+
- PostInstall.txt
|
27
28
|
- README.txt
|
28
29
|
files:
|
30
|
+
- COPYING
|
31
|
+
- CREDITS
|
29
32
|
- History.txt
|
30
33
|
- License.txt
|
31
34
|
- Manifest.txt
|
35
|
+
- PostInstall.txt
|
32
36
|
- README.txt
|
33
|
-
- CREDITS
|
34
37
|
- Rakefile
|
35
38
|
- config/hoe.rb
|
36
39
|
- config/requirements.rb
|
37
|
-
- examples/smtp_tls.rb
|
38
|
-
- examples/example-01.rdoc
|
39
|
-
- examples/profile-options.rb
|
40
40
|
- examples/doodle-errors.rb
|
41
41
|
- examples/event-location.rb
|
42
|
-
- examples/
|
42
|
+
- examples/example-01.rb
|
43
|
+
- examples/example-01.rdoc
|
43
44
|
- examples/example-02.rb
|
44
45
|
- examples/example-02.rdoc
|
45
|
-
- examples/
|
46
|
+
- examples/mail-datatypes.rb
|
46
47
|
- examples/mail.rb
|
47
|
-
- examples/
|
48
|
-
- examples/
|
48
|
+
- examples/parent.rb
|
49
|
+
- examples/profile-options.rb
|
50
|
+
- examples/smtp_tls.rb
|
49
51
|
- examples/test-datatypes.rb
|
50
|
-
- examples/
|
52
|
+
- examples/yaml-example.rb
|
53
|
+
- examples/yaml-example2.rb
|
51
54
|
- lib/doodle.rb
|
52
|
-
- lib/molic_orderedhash.rb
|
53
55
|
- lib/doodle/datatypes.rb
|
54
56
|
- lib/doodle/rfc822.rb
|
55
57
|
- lib/doodle/utils.rb
|
56
58
|
- lib/doodle/version.rb
|
59
|
+
- lib/molic_orderedhash.rb
|
57
60
|
- log/debug.log
|
58
61
|
- script/console
|
59
62
|
- script/destroy
|
@@ -64,6 +67,7 @@ files:
|
|
64
67
|
- spec/attributes_spec.rb
|
65
68
|
- spec/bugs_spec.rb
|
66
69
|
- spec/class_spec.rb
|
70
|
+
- spec/class_validation_spec.rb
|
67
71
|
- spec/class_var_spec.rb
|
68
72
|
- spec/collector_spec.rb
|
69
73
|
- spec/conversion_spec.rb
|
@@ -73,6 +77,7 @@ files:
|
|
73
77
|
- spec/extra_args_spec.rb
|
74
78
|
- spec/factory_spec.rb
|
75
79
|
- spec/flatten_first_level_spec.rb
|
80
|
+
- spec/inheritance_spec.rb
|
76
81
|
- spec/init_spec.rb
|
77
82
|
- spec/new_doodle_spec.rb
|
78
83
|
- spec/required_spec.rb
|
@@ -80,13 +85,13 @@ files:
|
|
80
85
|
- spec/singleton_spec.rb
|
81
86
|
- spec/spec.opts
|
82
87
|
- spec/spec_helper.rb
|
88
|
+
- spec/specialized_attribute_class_spec.rb
|
83
89
|
- spec/superclass_spec.rb
|
84
|
-
- spec/validation_spec.rb
|
85
90
|
- spec/validation2_spec.rb
|
91
|
+
- spec/validation_spec.rb
|
86
92
|
- tasks/deployment.rake
|
87
93
|
- tasks/environment.rake
|
88
94
|
- tasks/rspec.rake
|
89
|
-
- tasks/website.rake
|
90
95
|
has_rdoc: true
|
91
96
|
homepage: http://doodle.rubyforge.org
|
92
97
|
post_install_message: |
|
@@ -118,7 +123,9 @@ specification_version: 2
|
|
118
123
|
summary: "Doodle is a gem for simplifying the definition of Ruby classes by making attributes and their properties more declarative. Doodle is eco-friendly: it does not globally modify Object, Class or Module."
|
119
124
|
test_files:
|
120
125
|
- spec/bugs_spec.rb
|
126
|
+
- spec/specialized_attribute_class_spec.rb
|
121
127
|
- spec/class_var_spec.rb
|
128
|
+
- spec/inheritance_spec.rb
|
122
129
|
- spec/factory_spec.rb
|
123
130
|
- spec/flatten_first_level_spec.rb
|
124
131
|
- spec/new_doodle_spec.rb
|
data/tasks/website.rake
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
desc 'Generate website files'
|
2
|
-
task :website_generate => :ruby_env do
|
3
|
-
(Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
|
4
|
-
sh %{ #{RUBY_APP} script/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
|
-
desc 'Upload website files to rubyforge'
|
9
|
-
task :website_upload do
|
10
|
-
host = "#{rubyforge_username}@rubyforge.org"
|
11
|
-
remote_dir = "/var/www/gforge-projects/#{PATH}/"
|
12
|
-
local_dir = 'website'
|
13
|
-
sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
|
14
|
-
end
|
15
|
-
|
16
|
-
desc 'Generate and upload website files'
|
17
|
-
task :website => [:website_generate, :website_upload, :publish_docs]
|