runo 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -118
- data/bin/runo +4 -29
- data/lib/dummy.rb +0 -0
- metadata +12 -278
- data/lib/_error.rb +0 -14
- data/lib/_field.rb +0 -260
- data/lib/_i18n.rb +0 -144
- data/lib/_parser.rb +0 -256
- data/lib/_path.rb +0 -86
- data/lib/_storage/_storage.rb +0 -215
- data/lib/_storage/file.rb +0 -201
- data/lib/_storage/sequel.rb +0 -174
- data/lib/_storage/temp.rb +0 -73
- data/lib/_widget/action_create.rb +0 -23
- data/lib/_widget/action_login.rb +0 -22
- data/lib/_widget/action_signup.rb +0 -16
- data/lib/_widget/action_update.rb +0 -16
- data/lib/_widget/crumb.rb +0 -24
- data/lib/_widget/done.rb +0 -16
- data/lib/_widget/login.rb +0 -25
- data/lib/_widget/me.rb +0 -31
- data/lib/_widget/message.rb +0 -51
- data/lib/_widget/navi.rb +0 -88
- data/lib/_widget/submit.rb +0 -49
- data/lib/_widget/view_ym.rb +0 -77
- data/lib/_workflow/_workflow.rb +0 -89
- data/lib/_workflow/attachment.rb +0 -50
- data/lib/_workflow/blog.rb +0 -28
- data/lib/_workflow/contact.rb +0 -23
- data/lib/_workflow/forum.rb +0 -26
- data/lib/_workflow/register.rb +0 -39
- data/lib/meta/_meta.rb +0 -20
- data/lib/meta/group.rb +0 -19
- data/lib/meta/id.rb +0 -59
- data/lib/meta/owner.rb +0 -21
- data/lib/meta/timestamp.rb +0 -118
- data/lib/runo.rb +0 -396
- data/lib/scalar/checkbox.rb +0 -68
- data/lib/scalar/file.rb +0 -144
- data/lib/scalar/img.rb +0 -112
- data/lib/scalar/password.rb +0 -58
- data/lib/scalar/radio.rb +0 -47
- data/lib/scalar/select.rb +0 -47
- data/lib/scalar/text.rb +0 -38
- data/lib/scalar/textarea.rb +0 -35
- data/lib/scalar/textarea_pre.rb +0 -14
- data/lib/scalar/textarea_wiki.rb +0 -173
- data/lib/set/_set.rb +0 -196
- data/lib/set/dynamic.rb +0 -177
- data/lib/set/static.rb +0 -102
- data/lib/set/static_folder.rb +0 -96
- data/locale/en/index.po +0 -242
- data/locale/index.pot +0 -243
- data/locale/ja/index.po +0 -242
- data/locale/lazy_parser.rb +0 -54
- data/skel/config.ru +0 -27
- data/skel/skin/_users/00000000_frank-avatar.jpg +0 -0
- data/skel/skin/_users/00000000_frank-avatar_small.jpg +0 -0
- data/skel/skin/_users/00000000_frank.yaml +0 -12
- data/skel/skin/_users/00000000_root-avatar.jpg +0 -0
- data/skel/skin/_users/00000000_root-avatar_small.jpg +0 -0
- data/skel/skin/_users/00000000_root.yaml +0 -11
- data/skel/skin/_users/css/users.css +0 -21
- data/skel/skin/_users/css/users.less +0 -25
- data/skel/skin/_users/done.html +0 -42
- data/skel/skin/_users/index.html +0 -46
- data/skel/skin/_users/index.yaml +0 -3
- data/skel/skin/_users/summary.html +0 -40
- data/skel/skin/css/base.css +0 -93
- data/skel/skin/css/base.less +0 -139
- data/skel/skin/css/coax.css +0 -199
- data/skel/skin/css/coax.less +0 -244
- data/skel/skin/examples/blog/20091214_0001.yaml +0 -8
- data/skel/skin/examples/blog/20100630_0001.yaml +0 -8
- data/skel/skin/examples/blog/20100630_0002.yaml +0 -14
- data/skel/skin/examples/blog/20100701_0001.yaml +0 -8
- data/skel/skin/examples/blog/20100701_0002-a-20100701_0001-f.jpg +0 -0
- data/skel/skin/examples/blog/20100701_0002-a-20100701_0001-f_small.jpg +0 -0
- data/skel/skin/examples/blog/20100701_0002.yaml +0 -19
- data/skel/skin/examples/blog/frank/20100701_0001.yaml +0 -10
- data/skel/skin/examples/blog/frank/index.yaml +0 -4
- data/skel/skin/examples/blog/index.html +0 -51
- data/skel/skin/examples/blog/rss.xml +0 -18
- data/skel/skin/examples/contact/20100701_0001-file.txt +0 -1
- data/skel/skin/examples/contact/20100701_0001.yaml +0 -15
- data/skel/skin/examples/contact/20100701_0002.yaml +0 -8
- data/skel/skin/examples/contact/20100701_0003.yaml +0 -9
- data/skel/skin/examples/contact/index.html +0 -47
- data/skel/skin/examples/contact/js/contact.js +0 -13
- data/skel/skin/examples/contact/summary.html +0 -54
- data/skel/skin/examples/forum/20100701_0001.yaml +0 -41
- data/skel/skin/examples/forum/20100701_0002.yaml +0 -25
- data/skel/skin/examples/forum/index.html +0 -68
- data/skel/skin/examples/forum/summary.html +0 -47
- data/skel/skin/examples/index.html +0 -73
- data/skel/skin/index.html +0 -39
- data/skel/skin/js/base.js +0 -50
- data/t/locale/de/index.po +0 -19
- data/t/locale/en-GB/index.po +0 -25
- data/t/locale/ja/index.po +0 -30
- data/t/skin/_users/00000000_test.yaml +0 -3
- data/t/skin/_users/index.html +0 -13
- data/t/skin/foo/20091120_0001.yaml +0 -7
- data/t/skin/foo/bar/20091120_0001.yaml +0 -5
- data/t/skin/foo/bar/index.yaml +0 -5
- data/t/skin/foo/baz/css/baz.css +0 -1
- data/t/skin/foo/css/foo.css +0 -1
- data/t/skin/foo/index.html +0 -14
- data/t/skin/foo/index.yaml +0 -7
- data/t/skin/foo/not_css/foo.css +0 -1
- data/t/skin/foo/qux/index.html +0 -8
- data/t/skin/foo/qux/moo/index.html +0 -6
- data/t/skin/foo/sub-20100306_0001.yaml +0 -3
- data/t/skin/index.yaml +0 -3
- data/t/skin/t_attachment/index.html +0 -13
- data/t/skin/t_contact/done.html +0 -6
- data/t/skin/t_contact/index.html +0 -9
- data/t/skin/t_file/index.html +0 -16
- data/t/skin/t_img/index.html +0 -14
- data/t/skin/t_img/test.jpg +0 -0
- data/t/skin/t_select/index.html +0 -9
- data/t/skin/t_store/index.html +0 -9
- data/t/skin/t_summary/20100326_0001.yaml +0 -3
- data/t/skin/t_summary/create.html +0 -9
- data/t/skin/t_summary/index.html +0 -9
- data/t/skin/t_summary/summary.html +0 -9
- data/t/t.rb +0 -27
- data/t/test_checkbox.rb +0 -273
- data/t/test_field.rb +0 -330
- data/t/test_file.rb +0 -900
- data/t/test_id.rb +0 -215
- data/t/test_img.rb +0 -328
- data/t/test_meta.rb +0 -57
- data/t/test_parser.rb +0 -1516
- data/t/test_password.rb +0 -188
- data/t/test_radio.rb +0 -226
- data/t/test_role.rb +0 -249
- data/t/test_runo.rb +0 -768
- data/t/test_runo_call.rb +0 -1281
- data/t/test_runo_i18n.rb +0 -325
- data/t/test_select.rb +0 -182
- data/t/test_set_complex.rb +0 -527
- data/t/test_set_dynamic.rb +0 -1504
- data/t/test_set_folder.rb +0 -515
- data/t/test_set_permit.rb +0 -246
- data/t/test_set_static.rb +0 -468
- data/t/test_storage.rb +0 -915
- data/t/test_text.rb +0 -125
- data/t/test_textarea.rb +0 -138
- data/t/test_timestamp.rb +0 -473
- data/t/test_workflow.rb +0 -367
data/t/skin/t_img/index.html
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
<html>
|
2
|
-
<head><title>@(label)</title></head>
|
3
|
-
<body>
|
4
|
-
<h1>@(label)</h1>
|
5
|
-
<ul id="main" class="app-blog">
|
6
|
-
<li>
|
7
|
-
$(foo = img 32*32 1..5000 crop)
|
8
|
-
<ul id="baz" class="app-attachment">
|
9
|
-
$(qux = img 16*16 1..5000 crop)
|
10
|
-
</ul>
|
11
|
-
</li>
|
12
|
-
</ul>
|
13
|
-
</body>
|
14
|
-
</html>
|
data/t/skin/t_img/test.jpg
DELETED
Binary file
|
data/t/skin/t_select/index.html
DELETED
data/t/skin/t_store/index.html
DELETED
data/t/skin/t_summary/index.html
DELETED
data/t/t.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: UTF-8
|
3
|
-
|
4
|
-
# Author:: Akira FUNAI
|
5
|
-
# Copyright:: Copyright (c) 2009 Akira FUNAI
|
6
|
-
|
7
|
-
require 'test/unit'
|
8
|
-
require 'rubygems'
|
9
|
-
require 'mocha'
|
10
|
-
require 'rack'
|
11
|
-
|
12
|
-
t_dir = ::File.dirname __FILE__
|
13
|
-
|
14
|
-
$LOAD_PATH.unshift t_dir
|
15
|
-
$LOAD_PATH.unshift(::File.expand_path('../lib', t_dir))
|
16
|
-
require 'runo'
|
17
|
-
|
18
|
-
Runo.config(
|
19
|
-
'skin_dir' => './t/skin',
|
20
|
-
'storage' => {
|
21
|
-
'default' => 'File',
|
22
|
-
'File' => {'data_dir' => './t/data'},
|
23
|
-
'Sequel' => {'uri' => 'sqlite:/'},
|
24
|
-
}
|
25
|
-
)
|
26
|
-
|
27
|
-
Runo::I18n.bindtextdomain('index', ::File.join(t_dir, 'locale'))
|
data/t/test_checkbox.rb
DELETED
@@ -1,273 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
# Author:: Akira FUNAI
|
4
|
-
# Copyright:: Copyright (c) 2009 Akira FUNAI
|
5
|
-
|
6
|
-
require "#{::File.dirname __FILE__}/t"
|
7
|
-
|
8
|
-
class TC_Checkbox < Test::Unit::TestCase
|
9
|
-
|
10
|
-
def setup
|
11
|
-
meta = nil
|
12
|
-
Runo::Parser.gsub_scalar("$(foo checkbox bar, baz, qux :'baz' mandatory)") {|id, m|
|
13
|
-
meta = m
|
14
|
-
''
|
15
|
-
}
|
16
|
-
@f = Runo::Field.instance meta
|
17
|
-
end
|
18
|
-
|
19
|
-
def teardown
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_meta
|
23
|
-
assert_equal(
|
24
|
-
['bar', 'baz', 'qux'],
|
25
|
-
@f[:options],
|
26
|
-
'Checkbox#initialize should set :options from the csv token'
|
27
|
-
)
|
28
|
-
assert_equal(
|
29
|
-
true,
|
30
|
-
@f[:mandatory],
|
31
|
-
'Checkbox#initialize should set :mandatory from the misc token'
|
32
|
-
)
|
33
|
-
assert_equal(
|
34
|
-
'baz',
|
35
|
-
@f[:default],
|
36
|
-
'Checkbox#initialize should set :default from the token'
|
37
|
-
)
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_meta_single_option
|
41
|
-
meta = nil
|
42
|
-
Runo::Parser.gsub_scalar("$(foo checkbox baz :on mandatory)") {|id, m|
|
43
|
-
meta = m
|
44
|
-
''
|
45
|
-
}
|
46
|
-
f = Runo::Field.instance meta
|
47
|
-
|
48
|
-
assert_equal(
|
49
|
-
['baz'],
|
50
|
-
f[:options],
|
51
|
-
'Checkbox#initialize should set :options from the misc token if csv is not provided'
|
52
|
-
)
|
53
|
-
assert_equal(
|
54
|
-
false,
|
55
|
-
f[:mandatory],
|
56
|
-
'Checkbox#initialize should not set :mandatory if there is only one option'
|
57
|
-
)
|
58
|
-
assert_equal(
|
59
|
-
'baz',
|
60
|
-
f[:default],
|
61
|
-
'Checkbox#initialize should set :default to the first option if the token is provided'
|
62
|
-
)
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_meta_no_options
|
66
|
-
meta = nil
|
67
|
-
Runo::Parser.gsub_scalar("$(foo checkbox :yes mandatory)") {|id, m|
|
68
|
-
meta = m
|
69
|
-
''
|
70
|
-
}
|
71
|
-
f = Runo::Field.instance meta
|
72
|
-
|
73
|
-
assert_equal(
|
74
|
-
['_on'],
|
75
|
-
f[:options],
|
76
|
-
'Checkbox#initialize should set :options from the misc token if csv is not provided'
|
77
|
-
)
|
78
|
-
assert_equal(
|
79
|
-
false,
|
80
|
-
f[:mandatory],
|
81
|
-
'Checkbox#initialize should not set :mandatory if there is only one option'
|
82
|
-
)
|
83
|
-
assert_equal(
|
84
|
-
'_on',
|
85
|
-
f[:default],
|
86
|
-
'Checkbox#initialize should set :default to the first option if the token is provided'
|
87
|
-
)
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_val_cast
|
91
|
-
assert_equal(
|
92
|
-
[],
|
93
|
-
@f.val,
|
94
|
-
'Checkbox#val_cast should cast the given val to String'
|
95
|
-
)
|
96
|
-
|
97
|
-
@f.load 123
|
98
|
-
assert_equal(
|
99
|
-
['123'],
|
100
|
-
@f.val,
|
101
|
-
'Checkbox#val_cast should cast the given val to String'
|
102
|
-
)
|
103
|
-
|
104
|
-
@f.load ['', 123, 456]
|
105
|
-
assert_equal(
|
106
|
-
['123', '456'],
|
107
|
-
@f.val,
|
108
|
-
'Checkbox#val_cast should ignore empty vals'
|
109
|
-
)
|
110
|
-
end
|
111
|
-
|
112
|
-
def test_get
|
113
|
-
@f.load ''
|
114
|
-
assert_equal(
|
115
|
-
'',
|
116
|
-
@f.get,
|
117
|
-
'Checkbox#get should return proper string'
|
118
|
-
)
|
119
|
-
assert_equal(
|
120
|
-
<<_html,
|
121
|
-
<span class="checkbox">
|
122
|
-
<input type="hidden" name="[]" value="" />
|
123
|
-
<span class="item">
|
124
|
-
<input type="checkbox" id="checkbox_-bar" name="[]" value="bar" />
|
125
|
-
<label for="checkbox_-bar">bar</label>
|
126
|
-
</span>
|
127
|
-
<span class="item">
|
128
|
-
<input type="checkbox" id="checkbox_-baz" name="[]" value="baz" />
|
129
|
-
<label for="checkbox_-baz">baz</label>
|
130
|
-
</span>
|
131
|
-
<span class="item">
|
132
|
-
<input type="checkbox" id="checkbox_-qux" name="[]" value="qux" />
|
133
|
-
<label for="checkbox_-qux">qux</label>
|
134
|
-
</span>
|
135
|
-
</span>
|
136
|
-
_html
|
137
|
-
@f.get(:action => :create),
|
138
|
-
'Checkbox#get should return proper string'
|
139
|
-
)
|
140
|
-
|
141
|
-
@f.load ['baz', 'qux']
|
142
|
-
assert_equal(
|
143
|
-
'baz, qux',
|
144
|
-
@f.get,
|
145
|
-
'Checkbox#get should return proper string'
|
146
|
-
)
|
147
|
-
assert_equal(
|
148
|
-
<<_html,
|
149
|
-
<span class="checkbox">
|
150
|
-
<input type="hidden" name="[]" value="" />
|
151
|
-
<span class="item">
|
152
|
-
<input type="checkbox" id="checkbox_-bar" name="[]" value="bar" />
|
153
|
-
<label for="checkbox_-bar">bar</label>
|
154
|
-
</span>
|
155
|
-
<span class="item">
|
156
|
-
<input type="checkbox" id="checkbox_-baz" name="[]" value="baz" checked />
|
157
|
-
<label for="checkbox_-baz">baz</label>
|
158
|
-
</span>
|
159
|
-
<span class="item">
|
160
|
-
<input type="checkbox" id="checkbox_-qux" name="[]" value="qux" checked />
|
161
|
-
<label for="checkbox_-qux">qux</label>
|
162
|
-
</span>
|
163
|
-
</span>
|
164
|
-
_html
|
165
|
-
@f.get(:action => :update),
|
166
|
-
'Checkbox#get should return proper string'
|
167
|
-
)
|
168
|
-
|
169
|
-
@f.load 'non-exist'
|
170
|
-
assert_equal(
|
171
|
-
<<_html,
|
172
|
-
<span class="checkbox error">
|
173
|
-
<input type="hidden" name="[]" value="" />
|
174
|
-
<span class="item">
|
175
|
-
<input type="checkbox" id="checkbox_-bar" name="[]" value="bar" />
|
176
|
-
<label for="checkbox_-bar">bar</label>
|
177
|
-
</span>
|
178
|
-
<span class="item">
|
179
|
-
<input type="checkbox" id="checkbox_-baz" name="[]" value="baz" />
|
180
|
-
<label for="checkbox_-baz">baz</label>
|
181
|
-
</span>
|
182
|
-
<span class="item">
|
183
|
-
<input type="checkbox" id="checkbox_-qux" name="[]" value="qux" />
|
184
|
-
<label for="checkbox_-qux">qux</label>
|
185
|
-
</span>
|
186
|
-
<span class=\"error_message\">no such option</span>
|
187
|
-
</span>
|
188
|
-
_html
|
189
|
-
@f.get(:action => :update),
|
190
|
-
'Checkbox#get should return proper string'
|
191
|
-
)
|
192
|
-
end
|
193
|
-
|
194
|
-
def test_get_single_option
|
195
|
-
meta = nil
|
196
|
-
Runo::Parser.gsub_scalar("$(foo checkbox 'ok?' mandatory)") {|id, m|
|
197
|
-
meta = m
|
198
|
-
''
|
199
|
-
}
|
200
|
-
f = Runo::Field.instance meta
|
201
|
-
|
202
|
-
f.load ''
|
203
|
-
assert_equal(
|
204
|
-
'',
|
205
|
-
f.get,
|
206
|
-
'Checkbox#get should return proper string'
|
207
|
-
)
|
208
|
-
assert_equal(
|
209
|
-
<<_html,
|
210
|
-
<span class="checkbox">
|
211
|
-
<input type="hidden" name="[]" value="" />
|
212
|
-
<span class="item">
|
213
|
-
<input type="checkbox" id="checkbox_-ok?" name="[]" value="ok?" />
|
214
|
-
<label for="checkbox_-ok?">ok?</label>
|
215
|
-
</span>
|
216
|
-
</span>
|
217
|
-
_html
|
218
|
-
f.get(:action => :create),
|
219
|
-
'Checkbox#get should not include the label if no options is defined'
|
220
|
-
)
|
221
|
-
end
|
222
|
-
|
223
|
-
def test_get_no_options
|
224
|
-
meta = nil
|
225
|
-
Runo::Parser.gsub_scalar("$(foo checkbox :yes mandatory)") {|id, m|
|
226
|
-
meta = m
|
227
|
-
''
|
228
|
-
}
|
229
|
-
f = Runo::Field.instance meta
|
230
|
-
|
231
|
-
f.load ''
|
232
|
-
assert_equal(
|
233
|
-
'',
|
234
|
-
f.get,
|
235
|
-
'Checkbox#get should return proper string'
|
236
|
-
)
|
237
|
-
assert_equal(
|
238
|
-
<<_html,
|
239
|
-
<span class="checkbox">
|
240
|
-
<input type="hidden" name="[]" value="" />
|
241
|
-
<input type="checkbox" name="[]" value="_on" />
|
242
|
-
</span>
|
243
|
-
_html
|
244
|
-
f.get(:action => :create),
|
245
|
-
'Checkbox#get should not include the label if no options is defined'
|
246
|
-
)
|
247
|
-
end
|
248
|
-
|
249
|
-
def test_errors
|
250
|
-
@f.load ''
|
251
|
-
@f[:mandatory] = nil
|
252
|
-
assert_equal(
|
253
|
-
[],
|
254
|
-
@f.errors,
|
255
|
-
'Checkbox#errors should return the errors of the current val'
|
256
|
-
)
|
257
|
-
@f[:mandatory] = true
|
258
|
-
assert_equal(
|
259
|
-
['mandatory'],
|
260
|
-
@f.errors,
|
261
|
-
'Checkbox#errors should return the errors of the current val'
|
262
|
-
)
|
263
|
-
|
264
|
-
@f.load 'non-exist'
|
265
|
-
@f[:mandatory] = nil
|
266
|
-
assert_equal(
|
267
|
-
['no such option'],
|
268
|
-
@f.errors,
|
269
|
-
'Checkbox#errors should return the errors of the current val'
|
270
|
-
)
|
271
|
-
end
|
272
|
-
|
273
|
-
end
|
data/t/test_field.rb
DELETED
@@ -1,330 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
# Author:: Akira FUNAI
|
4
|
-
# Copyright:: Copyright (c) 2009 Akira FUNAI
|
5
|
-
|
6
|
-
require "#{::File.dirname __FILE__}/t"
|
7
|
-
|
8
|
-
class Runo::Foo < Runo::Field
|
9
|
-
DEFAULT_META = {:foo => 'foo foo'}
|
10
|
-
class Bar < Runo::Field
|
11
|
-
def _g_test(arg)
|
12
|
-
'just a test.'
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
class TC_Field < Test::Unit::TestCase
|
18
|
-
|
19
|
-
def setup
|
20
|
-
@f = Runo::Field.instance(
|
21
|
-
:klass => 'foo-bar',
|
22
|
-
:baz => 1234,
|
23
|
-
:default => 'bar bar'
|
24
|
-
)
|
25
|
-
end
|
26
|
-
|
27
|
-
def teardown
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_instance
|
31
|
-
assert_instance_of(
|
32
|
-
Runo::Foo::Bar,
|
33
|
-
@f,
|
34
|
-
'Field#instance should return an instance of the class specified by :klass'
|
35
|
-
)
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_wrong_instance
|
39
|
-
assert_nil(
|
40
|
-
Runo::Field.instance(:klass => 'set'),
|
41
|
-
'Field#instance should not return an instance of other than Field'
|
42
|
-
)
|
43
|
-
assert_nil(
|
44
|
-
Runo::Field.instance(:klass => 'storage'),
|
45
|
-
'Field#instance should not return an instance of other than Field'
|
46
|
-
)
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_meta
|
50
|
-
assert_equal(
|
51
|
-
{:klass => 'foo-bar', :baz => 1234, :default => 'bar bar'},
|
52
|
-
@f.instance_variable_get(:@meta),
|
53
|
-
'Field#instance should load @meta of the instance'
|
54
|
-
)
|
55
|
-
assert_nothing_raised('Field#[]= should set the item in @meta') {
|
56
|
-
@f[:baz] = 'new value'
|
57
|
-
}
|
58
|
-
assert_equal(
|
59
|
-
'new value',
|
60
|
-
@f[:baz],
|
61
|
-
'Field#[] should get the item in @meta'
|
62
|
-
)
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_meta_name
|
66
|
-
item = Runo::Set::Static::Folder.root.item('foo', 'bar', 'main')
|
67
|
-
assert_equal(
|
68
|
-
'main',
|
69
|
-
item[:name],
|
70
|
-
'Field#[:name] should return the path name from the nearest folder'
|
71
|
-
)
|
72
|
-
item = Runo::Set::Static::Folder.root.item('foo', 'bar')
|
73
|
-
assert_equal(
|
74
|
-
'bar',
|
75
|
-
item[:name],
|
76
|
-
'Field#[:name] should return the path name from the nearest folder'
|
77
|
-
)
|
78
|
-
end
|
79
|
-
|
80
|
-
def test_meta_full_name
|
81
|
-
item = Runo::Set::Static::Folder.root.item('foo', 'bar', 'main')
|
82
|
-
assert_equal(
|
83
|
-
'-foo-bar-main',
|
84
|
-
item[:full_name],
|
85
|
-
'Field#[:full_name] should return the path name from the root folder'
|
86
|
-
)
|
87
|
-
item = Runo::Set::Static::Folder.root.item('foo', 'bar')
|
88
|
-
assert_equal(
|
89
|
-
'-foo-bar',
|
90
|
-
item[:full_name],
|
91
|
-
'Field#[:full_name] should return the path name from the root folder'
|
92
|
-
)
|
93
|
-
end
|
94
|
-
|
95
|
-
def test_meta_short_name
|
96
|
-
item = Runo::Set::Static::Folder.root.item(
|
97
|
-
'foo', 'bar', 'main', '20091120_0001', 'replies', '20091208_0001', 'reply'
|
98
|
-
)
|
99
|
-
|
100
|
-
Runo.current[:base] = nil
|
101
|
-
assert_equal(
|
102
|
-
'reply',
|
103
|
-
item[:short_name],
|
104
|
-
'Field#[:short_name] should return [:id] if no base SD is defined'
|
105
|
-
)
|
106
|
-
|
107
|
-
Runo.current[:base] = Runo::Set::Static::Folder.root.item('foo', 'bar', 'main')
|
108
|
-
assert_equal(
|
109
|
-
'20091120_0001-replies-20091208_0001-reply',
|
110
|
-
item[:short_name],
|
111
|
-
'Field#[:short_name] should return the path name from the base SD'
|
112
|
-
)
|
113
|
-
|
114
|
-
Runo.current[:base] = Runo::Set::Static::Folder.root.item(
|
115
|
-
'foo', 'bar', 'main', '20091120_0001', 'replies'
|
116
|
-
)
|
117
|
-
assert_equal(
|
118
|
-
'20091208_0001-reply',
|
119
|
-
item[:short_name],
|
120
|
-
'Field#[:short_name] should return the path name from the base SD'
|
121
|
-
)
|
122
|
-
|
123
|
-
Runo.current[:base] = Runo::Set::Static::Folder.root.item('foo', 'bar', 'main')
|
124
|
-
assert_equal(
|
125
|
-
'',
|
126
|
-
Runo::Set::Static::Folder.root.item('foo', 'bar', 'main')[:short_name],
|
127
|
-
'Field#[:short_name] should return empty string for the base SD itself'
|
128
|
-
)
|
129
|
-
end
|
130
|
-
|
131
|
-
def test_meta_sd
|
132
|
-
sd = Runo::Set::Static::Folder.root.item('foo', 'bar', 'main')
|
133
|
-
assert_equal(
|
134
|
-
sd,
|
135
|
-
sd[:sd],
|
136
|
-
'Field#[:sd] should return the nearest set_dynamic'
|
137
|
-
)
|
138
|
-
assert_equal(
|
139
|
-
sd,
|
140
|
-
sd.item('20091120_0001')[:sd],
|
141
|
-
'Field#[:sd] should return the nearest set_dynamic'
|
142
|
-
)
|
143
|
-
assert_equal(
|
144
|
-
sd,
|
145
|
-
sd.item('20091120_0001', 'name')[:sd],
|
146
|
-
'Field#[:sd] should return the nearest set_dynamic'
|
147
|
-
)
|
148
|
-
assert_nil(
|
149
|
-
Runo::Set::Static::Folder.root[:sd],
|
150
|
-
'Field#[:sd] should return nil if there is no set_dynamic in the ancestors'
|
151
|
-
)
|
152
|
-
end
|
153
|
-
|
154
|
-
def test_meta_client
|
155
|
-
Runo.client = 'frank'
|
156
|
-
assert_equal(
|
157
|
-
'frank',
|
158
|
-
Runo::Field.new[:client],
|
159
|
-
'Field#[:client] should return the client of the current thread'
|
160
|
-
)
|
161
|
-
end
|
162
|
-
|
163
|
-
def test_empty?
|
164
|
-
@f.load 'foo'
|
165
|
-
assert(
|
166
|
-
!@f.empty?,
|
167
|
-
'Field#empty? should return false if the field has a value'
|
168
|
-
)
|
169
|
-
|
170
|
-
@f.load nil
|
171
|
-
assert(
|
172
|
-
@f.empty?,
|
173
|
-
'Field#empty? should return true if the field has no value'
|
174
|
-
)
|
175
|
-
end
|
176
|
-
|
177
|
-
def test_default_meta
|
178
|
-
f = Runo::Field.instance(:klass => 'foo')
|
179
|
-
assert_equal(
|
180
|
-
'foo foo',
|
181
|
-
f[:foo],
|
182
|
-
'Field#[] should look for the default value in DEFAULT_META'
|
183
|
-
)
|
184
|
-
|
185
|
-
f = Runo::Field.instance(:klass => 'foo', :foo => 'bar')
|
186
|
-
assert_equal(
|
187
|
-
'bar',
|
188
|
-
f[:foo],
|
189
|
-
'Field.DEFAULT_META should be eclipsed by @meta'
|
190
|
-
)
|
191
|
-
|
192
|
-
f = Runo::Field.instance(:klass => 'foo')
|
193
|
-
def f.meta_foo
|
194
|
-
'abc'
|
195
|
-
end
|
196
|
-
assert_equal(
|
197
|
-
'abc',
|
198
|
-
f[:foo],
|
199
|
-
'Field.DEFAULT_META should be eclipsed by meta_*()'
|
200
|
-
)
|
201
|
-
end
|
202
|
-
|
203
|
-
def test_get
|
204
|
-
@f.instance_variable_set(:@val, 'hello')
|
205
|
-
assert_equal(
|
206
|
-
'hello',
|
207
|
-
@f.get,
|
208
|
-
'Field#get should return @val by default'
|
209
|
-
)
|
210
|
-
|
211
|
-
assert_equal(
|
212
|
-
'just a test.',
|
213
|
-
@f.get(:action => :test),
|
214
|
-
'Field#get should relay the result of _g_*()'
|
215
|
-
)
|
216
|
-
|
217
|
-
@f[:tmpl] = {:foo => 'foo foo'}
|
218
|
-
assert_equal(
|
219
|
-
'hello',
|
220
|
-
@f.get(:action => :foo),
|
221
|
-
'Field#get should not use [:tmpl][*]'
|
222
|
-
)
|
223
|
-
end
|
224
|
-
|
225
|
-
def test_post
|
226
|
-
@f.post(:create, 999)
|
227
|
-
assert_equal(
|
228
|
-
999,
|
229
|
-
@f.val,
|
230
|
-
'Field#post should set @val'
|
231
|
-
)
|
232
|
-
assert_equal(
|
233
|
-
:create,
|
234
|
-
@f.action,
|
235
|
-
'Field#post should set @action'
|
236
|
-
)
|
237
|
-
|
238
|
-
@f.commit
|
239
|
-
assert_equal(
|
240
|
-
:create,
|
241
|
-
@f.result,
|
242
|
-
'Field#commit should set @result'
|
243
|
-
)
|
244
|
-
|
245
|
-
@f.post(:update, 111)
|
246
|
-
assert_nil(
|
247
|
-
@f.result,
|
248
|
-
'Field#post should reset @result'
|
249
|
-
)
|
250
|
-
assert_equal(
|
251
|
-
111,
|
252
|
-
@f.val,
|
253
|
-
'Field#post should set @val'
|
254
|
-
)
|
255
|
-
assert_equal(
|
256
|
-
:update,
|
257
|
-
@f.action,
|
258
|
-
'Field#post should set @action'
|
259
|
-
)
|
260
|
-
end
|
261
|
-
|
262
|
-
def test_load_default
|
263
|
-
@f.load_default
|
264
|
-
assert_equal(
|
265
|
-
'bar bar',
|
266
|
-
@f.val,
|
267
|
-
'Field#load_default should set @val to [:default]'
|
268
|
-
)
|
269
|
-
assert_nil(
|
270
|
-
@f.action,
|
271
|
-
'Field#load_default should not set @action'
|
272
|
-
)
|
273
|
-
end
|
274
|
-
|
275
|
-
def test_load
|
276
|
-
@f.load 'baz baz'
|
277
|
-
assert_equal(
|
278
|
-
'baz baz',
|
279
|
-
@f.val,
|
280
|
-
'Field#load should set @val'
|
281
|
-
)
|
282
|
-
assert_nil(
|
283
|
-
@f.action,
|
284
|
-
'Field#load should not set @action'
|
285
|
-
)
|
286
|
-
end
|
287
|
-
|
288
|
-
def test_create
|
289
|
-
@f.create 'baz baz'
|
290
|
-
assert_equal(
|
291
|
-
'baz baz',
|
292
|
-
@f.val,
|
293
|
-
'Field#create should set @val'
|
294
|
-
)
|
295
|
-
assert_equal(
|
296
|
-
:create,
|
297
|
-
@f.action,
|
298
|
-
'Field#create should set @action'
|
299
|
-
)
|
300
|
-
end
|
301
|
-
|
302
|
-
def test_update
|
303
|
-
@f.update 'baz baz'
|
304
|
-
assert_equal(
|
305
|
-
'baz baz',
|
306
|
-
@f.val,
|
307
|
-
'Field#update should set @val'
|
308
|
-
)
|
309
|
-
assert_equal(
|
310
|
-
:update,
|
311
|
-
@f.action,
|
312
|
-
'Field#update should set @action'
|
313
|
-
)
|
314
|
-
end
|
315
|
-
|
316
|
-
def test_delete
|
317
|
-
@f.delete
|
318
|
-
assert_equal(
|
319
|
-
nil,
|
320
|
-
@f.val,
|
321
|
-
'Field#delete should not set @val'
|
322
|
-
)
|
323
|
-
assert_equal(
|
324
|
-
:delete,
|
325
|
-
@f.action,
|
326
|
-
'Field#delete should set @action'
|
327
|
-
)
|
328
|
-
end
|
329
|
-
|
330
|
-
end
|