tokamak 1.1.5 → 1.2.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.
- data/lib/tokamak/builder/base.rb +7 -11
- data/lib/tokamak/builder/json.rb +10 -11
- data/lib/tokamak/builder/xml.rb +30 -39
- data/lib/tokamak/hook/rails.rb +2 -4
- data/lib/tokamak/hook/tilt.rb +5 -2
- data/lib/tokamak/version.rb +2 -2
- data/test/rails2_skel/log/development.log +330 -0
- data/test/tokamak/builder/base_test.rb +6 -1
- data/test/tokamak/builder/json_test.rb +23 -0
- data/test/tokamak/builder/xml_test.rb +1 -1
- metadata +5 -5
data/lib/tokamak/builder/base.rb
CHANGED
@@ -7,12 +7,15 @@ module Tokamak
|
|
7
7
|
class << self
|
8
8
|
def builder_for(*args)
|
9
9
|
# class instance variable to store media types handled by a builder
|
10
|
-
@media_types
|
10
|
+
@media_types ||= []
|
11
11
|
args.each do |media_type|
|
12
|
+
@media_types << media_type
|
12
13
|
@@global_media_types[media_type] = self
|
13
14
|
end
|
14
15
|
end
|
15
|
-
|
16
|
+
|
17
|
+
alias_method :add_media_type, :builder_for
|
18
|
+
|
16
19
|
def media_types
|
17
20
|
@media_types
|
18
21
|
end
|
@@ -22,11 +25,7 @@ module Tokamak
|
|
22
25
|
end
|
23
26
|
|
24
27
|
def build(obj, options = {}, &block)
|
25
|
-
|
26
|
-
recipe = block
|
27
|
-
else
|
28
|
-
recipe = options.delete(:recipe)
|
29
|
-
end
|
28
|
+
recipe = block_given? ? block : options.delete(:recipe)
|
30
29
|
|
31
30
|
unless recipe.respond_to?(:call)
|
32
31
|
recipe = Tokamak::Recipes[recipe]
|
@@ -41,10 +40,7 @@ module Tokamak
|
|
41
40
|
end
|
42
41
|
|
43
42
|
def helper
|
44
|
-
|
45
|
-
@helper_module = Tokamak::Builder.helper_module_for(self)
|
46
|
-
end
|
47
|
-
@helper_module
|
43
|
+
@helper_module ||= Tokamak::Builder.helper_module_for(self)
|
48
44
|
end
|
49
45
|
|
50
46
|
def collection_helper_default_options(options = {}, &block)
|
data/lib/tokamak/builder/json.rb
CHANGED
@@ -23,16 +23,15 @@ module Tokamak
|
|
23
23
|
raise Tokamak::BuilderError.new("Members method require a collection to execute") unless collection.respond_to?(:each)
|
24
24
|
root = options[:root] || "members"
|
25
25
|
|
26
|
-
|
26
|
+
add_to(@current, root, [])
|
27
27
|
collection.each do |member|
|
28
|
-
node = {}
|
29
28
|
|
30
29
|
parent = @current
|
31
|
-
@current =
|
30
|
+
@current = {}
|
32
31
|
block.call(self, member)
|
32
|
+
add_to(parent, root, @current)
|
33
33
|
@current = parent
|
34
34
|
|
35
|
-
add_to_current(root, node)
|
36
35
|
end
|
37
36
|
end
|
38
37
|
|
@@ -61,7 +60,7 @@ module Tokamak
|
|
61
60
|
@current = parent
|
62
61
|
end
|
63
62
|
|
64
|
-
|
63
|
+
add_to(@current, name, node)
|
65
64
|
end
|
66
65
|
|
67
66
|
def representation
|
@@ -98,15 +97,15 @@ module Tokamak
|
|
98
97
|
end
|
99
98
|
end
|
100
99
|
|
101
|
-
def
|
102
|
-
if
|
103
|
-
if
|
104
|
-
|
100
|
+
def add_to(node, name, value)
|
101
|
+
if node[name]
|
102
|
+
if node[name].kind_of?(Array)
|
103
|
+
node[name] << value
|
105
104
|
else
|
106
|
-
|
105
|
+
node[name] = [node[name], value]
|
107
106
|
end
|
108
107
|
else
|
109
|
-
|
108
|
+
node[name] = value
|
110
109
|
end
|
111
110
|
end
|
112
111
|
|
data/lib/tokamak/builder/xml.rb
CHANGED
@@ -33,11 +33,7 @@ module Tokamak
|
|
33
33
|
|
34
34
|
def values(options = {}, &block)
|
35
35
|
options.each do |key,value|
|
36
|
-
|
37
|
-
if attr =~ /^xmlns(:\w+)?$/
|
38
|
-
ns = attr.split(":", 2)[1]
|
39
|
-
@parent.add_namespace_definition(ns, value)
|
40
|
-
end
|
36
|
+
apply_namespace(@parent, key.to_s, value)
|
41
37
|
end
|
42
38
|
yield Values.new(self)
|
43
39
|
end
|
@@ -68,50 +64,45 @@ module Tokamak
|
|
68
64
|
|
69
65
|
private
|
70
66
|
|
67
|
+
def apply_namespace(node, key, value)
|
68
|
+
if key =~ /^xmlns(:\w+)?$/
|
69
|
+
ns_name = key.split(":", 2)[1]
|
70
|
+
node.add_namespace_definition(ns_name, value)
|
71
|
+
return true
|
72
|
+
end
|
73
|
+
false
|
74
|
+
end
|
75
|
+
|
71
76
|
def create_element(node, prefix, *args)
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
n.namespace = namespace
|
77
|
-
namespace = nil
|
78
|
-
end
|
77
|
+
n = @raw.create_element(node)
|
78
|
+
if prefix
|
79
|
+
if namespace = find_prefix(prefix)
|
80
|
+
n.namespace = namespace
|
79
81
|
end
|
82
|
+
end
|
80
83
|
|
81
|
-
|
82
|
-
|
84
|
+
args.each do |arg|
|
85
|
+
if arg.kind_of? Hash
|
83
86
|
# Adding XML attributes
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
n.add_namespace_definition(ns_name, v)
|
90
|
-
next
|
91
|
-
end
|
92
|
-
n[k.to_s] = v.to_s
|
93
|
-
}
|
87
|
+
arg.each { |k,v|
|
88
|
+
key = k.to_s
|
89
|
+
n[key] = v.to_s unless apply_namespace(n, key, v)
|
90
|
+
}
|
91
|
+
elsif arg.kind_of?(Time) || arg.kind_of?(DateTime)
|
94
92
|
# Adding XML node content
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
end
|
93
|
+
n.content = arg.xmlschema
|
94
|
+
else
|
95
|
+
n.content = arg
|
99
96
|
end
|
100
97
|
end
|
98
|
+
n
|
101
99
|
end
|
102
100
|
|
103
|
-
def
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
@parent.ancestors.each do |a|
|
108
|
-
next if a == @raw
|
109
|
-
ns = a.namespace_definitions.find { |x| x.prefix == prefix.to_s }
|
110
|
-
break if ns
|
111
|
-
end
|
101
|
+
def find_prefix(prefix)
|
102
|
+
all = [@parent] + @parent.ancestors
|
103
|
+
all.each do |a|
|
104
|
+
return a.namespace_definitions.find { |x| x.prefix == prefix.to_s } if a != @raw
|
112
105
|
end
|
113
|
-
|
114
|
-
return ns
|
115
106
|
end
|
116
107
|
|
117
108
|
end
|
data/lib/tokamak/hook/rails.rb
CHANGED
@@ -49,10 +49,8 @@ module Tokamak
|
|
49
49
|
extend @content_type_helpers
|
50
50
|
context = eval("(class << self; self; end)", binding)
|
51
51
|
|
52
|
-
|
53
|
-
|
54
|
-
context.send(:define_method, k.to_sym) { v }
|
55
|
-
end
|
52
|
+
caller_binding.fetch(:locals, {}).each do |k, v|
|
53
|
+
context.send(:define_method, k.to_sym) { v }
|
56
54
|
end
|
57
55
|
|
58
56
|
partial(partial_path, binding)
|
data/lib/tokamak/hook/tilt.rb
CHANGED
@@ -6,12 +6,15 @@ module Tokamak
|
|
6
6
|
|
7
7
|
class TokamakTemplate < ::Tilt::Template
|
8
8
|
def initialize_engine
|
9
|
-
return if defined?(::Tokamak)
|
10
9
|
require_template_library 'tokamak'
|
11
10
|
end
|
12
11
|
|
12
|
+
def self.engine_initialized?
|
13
|
+
defined? ::Tokamak
|
14
|
+
end
|
15
|
+
|
13
16
|
def prepare
|
14
|
-
@media_type = options[:media_type]
|
17
|
+
@media_type = options[:media_type] || @options[:media_type]
|
15
18
|
raise Tokamak::BuilderError.new("Content type required to build representation.") unless @media_type
|
16
19
|
end
|
17
20
|
|
data/lib/tokamak/version.rb
CHANGED
@@ -1273,3 +1273,333 @@ Completed in 13ms (View: 11 | 200 OK [http://www.example.com/test/feed]
|
|
1273
1273
|
Processing TestController#show (for 127.0.0.1 at 2011-02-24 08:48:44) [GET]
|
1274
1274
|
Rendering test/show
|
1275
1275
|
Completed in 4ms (View: 2 | 200 OK [http://www.example.com/test/show]
|
1276
|
+
|
1277
|
+
|
1278
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 08:56:03) [GET]
|
1279
|
+
Rendering test/show
|
1280
|
+
Completed in 7ms (View: 6 | 200 OK [http://www.example.com/test/show]
|
1281
|
+
|
1282
|
+
|
1283
|
+
Processing TestController#feed (for 127.0.0.1 at 2011-03-31 08:56:03) [GET]
|
1284
|
+
Rendering test/feed
|
1285
|
+
Completed in 13ms (View: 11 | 200 OK [http://www.example.com/test/feed]
|
1286
|
+
|
1287
|
+
|
1288
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 08:56:03) [GET]
|
1289
|
+
Rendering test/show
|
1290
|
+
Completed in 4ms (View: 2 | 200 OK [http://www.example.com/test/show]
|
1291
|
+
|
1292
|
+
|
1293
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 09:20:43) [GET]
|
1294
|
+
Rendering test/show
|
1295
|
+
Completed in 7ms (View: 6 | 200 OK [http://www.example.com/test/show]
|
1296
|
+
|
1297
|
+
|
1298
|
+
Processing TestController#feed (for 127.0.0.1 at 2011-03-31 09:20:43) [GET]
|
1299
|
+
Rendering test/feed
|
1300
|
+
Completed in 13ms (View: 11 | 200 OK [http://www.example.com/test/feed]
|
1301
|
+
|
1302
|
+
|
1303
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 09:20:43) [GET]
|
1304
|
+
Rendering test/show
|
1305
|
+
Completed in 4ms (View: 2 | 200 OK [http://www.example.com/test/show]
|
1306
|
+
|
1307
|
+
|
1308
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 09:22:10) [GET]
|
1309
|
+
Rendering test/show
|
1310
|
+
Completed in 7ms (View: 6 | 200 OK [http://www.example.com/test/show]
|
1311
|
+
|
1312
|
+
|
1313
|
+
Processing TestController#feed (for 127.0.0.1 at 2011-03-31 09:22:10) [GET]
|
1314
|
+
Rendering test/feed
|
1315
|
+
Completed in 13ms (View: 11 | 200 OK [http://www.example.com/test/feed]
|
1316
|
+
|
1317
|
+
|
1318
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 09:22:10) [GET]
|
1319
|
+
Rendering test/show
|
1320
|
+
Completed in 4ms (View: 2 | 200 OK [http://www.example.com/test/show]
|
1321
|
+
|
1322
|
+
|
1323
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 09:38:07) [GET]
|
1324
|
+
Rendering test/show
|
1325
|
+
Completed in 7ms (View: 6 | 200 OK [http://www.example.com/test/show]
|
1326
|
+
|
1327
|
+
|
1328
|
+
Processing TestController#feed (for 127.0.0.1 at 2011-03-31 09:38:07) [GET]
|
1329
|
+
Rendering test/feed
|
1330
|
+
Completed in 13ms (View: 11 | 200 OK [http://www.example.com/test/feed]
|
1331
|
+
|
1332
|
+
|
1333
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 09:38:07) [GET]
|
1334
|
+
Rendering test/show
|
1335
|
+
Completed in 4ms (View: 2 | 200 OK [http://www.example.com/test/show]
|
1336
|
+
|
1337
|
+
|
1338
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 09:40:31) [GET]
|
1339
|
+
Rendering test/show
|
1340
|
+
Completed in 7ms (View: 6 | 200 OK [http://www.example.com/test/show]
|
1341
|
+
|
1342
|
+
|
1343
|
+
Processing TestController#feed (for 127.0.0.1 at 2011-03-31 09:40:31) [GET]
|
1344
|
+
Rendering test/feed
|
1345
|
+
Completed in 14ms (View: 12 | 200 OK [http://www.example.com/test/feed]
|
1346
|
+
|
1347
|
+
|
1348
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 09:40:31) [GET]
|
1349
|
+
Rendering test/show
|
1350
|
+
Completed in 4ms (View: 2 | 200 OK [http://www.example.com/test/show]
|
1351
|
+
|
1352
|
+
|
1353
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 09:44:17) [GET]
|
1354
|
+
Rendering test/show
|
1355
|
+
Completed in 7ms (View: 6 | 200 OK [http://www.example.com/test/show]
|
1356
|
+
|
1357
|
+
|
1358
|
+
Processing TestController#feed (for 127.0.0.1 at 2011-03-31 09:44:17) [GET]
|
1359
|
+
Rendering test/feed
|
1360
|
+
Completed in 13ms (View: 11 | 200 OK [http://www.example.com/test/feed]
|
1361
|
+
|
1362
|
+
|
1363
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 09:44:17) [GET]
|
1364
|
+
Rendering test/show
|
1365
|
+
Completed in 4ms (View: 2 | 200 OK [http://www.example.com/test/show]
|
1366
|
+
|
1367
|
+
|
1368
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 09:45:06) [GET]
|
1369
|
+
Rendering test/show
|
1370
|
+
Completed in 7ms (View: 6 | 200 OK [http://www.example.com/test/show]
|
1371
|
+
|
1372
|
+
|
1373
|
+
Processing TestController#feed (for 127.0.0.1 at 2011-03-31 09:45:06) [GET]
|
1374
|
+
Rendering test/feed
|
1375
|
+
Completed in 13ms (View: 12 | 200 OK [http://www.example.com/test/feed]
|
1376
|
+
|
1377
|
+
|
1378
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 09:45:06) [GET]
|
1379
|
+
Rendering test/show
|
1380
|
+
Completed in 4ms (View: 2 | 200 OK [http://www.example.com/test/show]
|
1381
|
+
|
1382
|
+
|
1383
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 10:08:49) [GET]
|
1384
|
+
Rendering test/show
|
1385
|
+
Completed in 7ms (View: 6 | 200 OK [http://www.example.com/test/show]
|
1386
|
+
|
1387
|
+
|
1388
|
+
Processing TestController#feed (for 127.0.0.1 at 2011-03-31 10:08:49) [GET]
|
1389
|
+
Rendering test/feed
|
1390
|
+
Completed in 13ms (View: 12 | 200 OK [http://www.example.com/test/feed]
|
1391
|
+
|
1392
|
+
|
1393
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 10:08:49) [GET]
|
1394
|
+
Rendering test/show
|
1395
|
+
Completed in 4ms (View: 2 | 200 OK [http://www.example.com/test/show]
|
1396
|
+
|
1397
|
+
|
1398
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 10:11:55) [GET]
|
1399
|
+
Rendering test/show
|
1400
|
+
Completed in 7ms (View: 6 | 200 OK [http://www.example.com/test/show]
|
1401
|
+
|
1402
|
+
|
1403
|
+
Processing TestController#feed (for 127.0.0.1 at 2011-03-31 10:11:55) [GET]
|
1404
|
+
Rendering test/feed
|
1405
|
+
Completed in 13ms (View: 11 | 200 OK [http://www.example.com/test/feed]
|
1406
|
+
|
1407
|
+
|
1408
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 10:11:55) [GET]
|
1409
|
+
Rendering test/show
|
1410
|
+
Completed in 4ms (View: 2 | 200 OK [http://www.example.com/test/show]
|
1411
|
+
|
1412
|
+
|
1413
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 10:15:42) [GET]
|
1414
|
+
Rendering test/show
|
1415
|
+
Completed in 7ms (View: 6 | 200 OK [http://www.example.com/test/show]
|
1416
|
+
|
1417
|
+
|
1418
|
+
Processing TestController#feed (for 127.0.0.1 at 2011-03-31 10:15:42) [GET]
|
1419
|
+
Rendering test/feed
|
1420
|
+
Completed in 12ms (View: 11 | 200 OK [http://www.example.com/test/feed]
|
1421
|
+
|
1422
|
+
|
1423
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 10:15:42) [GET]
|
1424
|
+
Rendering test/show
|
1425
|
+
Completed in 3ms (View: 2 | 200 OK [http://www.example.com/test/show]
|
1426
|
+
|
1427
|
+
|
1428
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 10:18:38) [GET]
|
1429
|
+
Rendering test/show
|
1430
|
+
Completed in 7ms (View: 6 | 200 OK [http://www.example.com/test/show]
|
1431
|
+
|
1432
|
+
|
1433
|
+
Processing TestController#feed (for 127.0.0.1 at 2011-03-31 10:18:39) [GET]
|
1434
|
+
Rendering test/feed
|
1435
|
+
Completed in 12ms (View: 11 | 200 OK [http://www.example.com/test/feed]
|
1436
|
+
|
1437
|
+
|
1438
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 10:18:39) [GET]
|
1439
|
+
Rendering test/show
|
1440
|
+
Completed in 3ms (View: 2 | 200 OK [http://www.example.com/test/show]
|
1441
|
+
|
1442
|
+
|
1443
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 10:21:31) [GET]
|
1444
|
+
Rendering test/show
|
1445
|
+
Completed in 7ms (View: 6 | 200 OK [http://www.example.com/test/show]
|
1446
|
+
|
1447
|
+
|
1448
|
+
Processing TestController#feed (for 127.0.0.1 at 2011-03-31 10:21:31) [GET]
|
1449
|
+
Rendering test/feed
|
1450
|
+
Completed in 12ms (View: 11 | 200 OK [http://www.example.com/test/feed]
|
1451
|
+
|
1452
|
+
|
1453
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 10:21:31) [GET]
|
1454
|
+
Rendering test/show
|
1455
|
+
Completed in 3ms (View: 2 | 200 OK [http://www.example.com/test/show]
|
1456
|
+
|
1457
|
+
|
1458
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 10:28:16) [GET]
|
1459
|
+
Rendering test/show
|
1460
|
+
Completed in 7ms (View: 6 | 200 OK [http://www.example.com/test/show]
|
1461
|
+
|
1462
|
+
|
1463
|
+
Processing TestController#feed (for 127.0.0.1 at 2011-03-31 10:28:16) [GET]
|
1464
|
+
Rendering test/feed
|
1465
|
+
Completed in 12ms (View: 11 | 200 OK [http://www.example.com/test/feed]
|
1466
|
+
|
1467
|
+
|
1468
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 10:28:16) [GET]
|
1469
|
+
Rendering test/show
|
1470
|
+
Completed in 3ms (View: 2 | 200 OK [http://www.example.com/test/show]
|
1471
|
+
|
1472
|
+
|
1473
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 10:28:20) [GET]
|
1474
|
+
Rendering test/show
|
1475
|
+
Completed in 7ms (View: 6 | 200 OK [http://www.example.com/test/show]
|
1476
|
+
|
1477
|
+
|
1478
|
+
Processing TestController#feed (for 127.0.0.1 at 2011-03-31 10:28:20) [GET]
|
1479
|
+
Rendering test/feed
|
1480
|
+
Completed in 12ms (View: 11 | 200 OK [http://www.example.com/test/feed]
|
1481
|
+
|
1482
|
+
|
1483
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 10:28:20) [GET]
|
1484
|
+
Rendering test/show
|
1485
|
+
Completed in 3ms (View: 2 | 200 OK [http://www.example.com/test/show]
|
1486
|
+
|
1487
|
+
|
1488
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 11:26:20) [GET]
|
1489
|
+
Rendering test/show
|
1490
|
+
Completed in 7ms (View: 6 | 200 OK [http://www.example.com/test/show]
|
1491
|
+
|
1492
|
+
|
1493
|
+
Processing TestController#feed (for 127.0.0.1 at 2011-03-31 11:26:20) [GET]
|
1494
|
+
Rendering test/feed
|
1495
|
+
Completed in 12ms (View: 11 | 200 OK [http://www.example.com/test/feed]
|
1496
|
+
|
1497
|
+
|
1498
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 11:26:20) [GET]
|
1499
|
+
Rendering test/show
|
1500
|
+
Completed in 3ms (View: 2 | 200 OK [http://www.example.com/test/show]
|
1501
|
+
|
1502
|
+
|
1503
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 11:26:38) [GET]
|
1504
|
+
Rendering test/show
|
1505
|
+
Completed in 7ms (View: 6 | 200 OK [http://www.example.com/test/show]
|
1506
|
+
|
1507
|
+
|
1508
|
+
Processing TestController#feed (for 127.0.0.1 at 2011-03-31 11:26:38) [GET]
|
1509
|
+
Rendering test/feed
|
1510
|
+
Completed in 12ms (View: 11 | 200 OK [http://www.example.com/test/feed]
|
1511
|
+
|
1512
|
+
|
1513
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 11:26:38) [GET]
|
1514
|
+
Rendering test/show
|
1515
|
+
Completed in 3ms (View: 2 | 200 OK [http://www.example.com/test/show]
|
1516
|
+
|
1517
|
+
|
1518
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 11:27:18) [GET]
|
1519
|
+
Rendering test/show
|
1520
|
+
Completed in 7ms (View: 6 | 200 OK [http://www.example.com/test/show]
|
1521
|
+
|
1522
|
+
|
1523
|
+
Processing TestController#feed (for 127.0.0.1 at 2011-03-31 11:27:18) [GET]
|
1524
|
+
Rendering test/feed
|
1525
|
+
Completed in 12ms (View: 11 | 200 OK [http://www.example.com/test/feed]
|
1526
|
+
|
1527
|
+
|
1528
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 11:27:18) [GET]
|
1529
|
+
Rendering test/show
|
1530
|
+
Completed in 3ms (View: 2 | 200 OK [http://www.example.com/test/show]
|
1531
|
+
|
1532
|
+
|
1533
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 11:28:47) [GET]
|
1534
|
+
Rendering test/show
|
1535
|
+
Completed in 7ms (View: 6 | 200 OK [http://www.example.com/test/show]
|
1536
|
+
|
1537
|
+
|
1538
|
+
Processing TestController#feed (for 127.0.0.1 at 2011-03-31 11:28:47) [GET]
|
1539
|
+
Rendering test/feed
|
1540
|
+
Completed in 12ms (View: 11 | 200 OK [http://www.example.com/test/feed]
|
1541
|
+
|
1542
|
+
|
1543
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 11:28:47) [GET]
|
1544
|
+
Rendering test/show
|
1545
|
+
Completed in 3ms (View: 2 | 200 OK [http://www.example.com/test/show]
|
1546
|
+
|
1547
|
+
|
1548
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 11:29:05) [GET]
|
1549
|
+
Rendering test/show
|
1550
|
+
Completed in 7ms (View: 6 | 200 OK [http://www.example.com/test/show]
|
1551
|
+
|
1552
|
+
|
1553
|
+
Processing TestController#feed (for 127.0.0.1 at 2011-03-31 11:29:05) [GET]
|
1554
|
+
Rendering test/feed
|
1555
|
+
Completed in 12ms (View: 11 | 200 OK [http://www.example.com/test/feed]
|
1556
|
+
|
1557
|
+
|
1558
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 11:29:05) [GET]
|
1559
|
+
Rendering test/show
|
1560
|
+
Completed in 3ms (View: 2 | 200 OK [http://www.example.com/test/show]
|
1561
|
+
|
1562
|
+
|
1563
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 11:29:22) [GET]
|
1564
|
+
Rendering test/show
|
1565
|
+
Completed in 7ms (View: 6 | 200 OK [http://www.example.com/test/show]
|
1566
|
+
|
1567
|
+
|
1568
|
+
Processing TestController#feed (for 127.0.0.1 at 2011-03-31 11:29:22) [GET]
|
1569
|
+
Rendering test/feed
|
1570
|
+
Completed in 12ms (View: 11 | 200 OK [http://www.example.com/test/feed]
|
1571
|
+
|
1572
|
+
|
1573
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 11:29:22) [GET]
|
1574
|
+
Rendering test/show
|
1575
|
+
Completed in 3ms (View: 2 | 200 OK [http://www.example.com/test/show]
|
1576
|
+
|
1577
|
+
|
1578
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 11:29:49) [GET]
|
1579
|
+
Rendering test/show
|
1580
|
+
Completed in 8ms (View: 6 | 200 OK [http://www.example.com/test/show]
|
1581
|
+
|
1582
|
+
|
1583
|
+
Processing TestController#feed (for 127.0.0.1 at 2011-03-31 11:29:49) [GET]
|
1584
|
+
Rendering test/feed
|
1585
|
+
Completed in 12ms (View: 11 | 200 OK [http://www.example.com/test/feed]
|
1586
|
+
|
1587
|
+
|
1588
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 11:29:49) [GET]
|
1589
|
+
Rendering test/show
|
1590
|
+
Completed in 3ms (View: 2 | 200 OK [http://www.example.com/test/show]
|
1591
|
+
|
1592
|
+
|
1593
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 11:42:32) [GET]
|
1594
|
+
Rendering test/show
|
1595
|
+
Completed in 7ms (View: 6 | 200 OK [http://www.example.com/test/show]
|
1596
|
+
|
1597
|
+
|
1598
|
+
Processing TestController#feed (for 127.0.0.1 at 2011-03-31 11:42:32) [GET]
|
1599
|
+
Rendering test/feed
|
1600
|
+
Completed in 12ms (View: 11 | 200 OK [http://www.example.com/test/feed]
|
1601
|
+
|
1602
|
+
|
1603
|
+
Processing TestController#show (for 127.0.0.1 at 2011-03-31 11:42:33) [GET]
|
1604
|
+
Rendering test/show
|
1605
|
+
Completed in 3ms (View: 2 | 200 OK [http://www.example.com/test/show]
|
@@ -17,6 +17,11 @@ class Tokamak::Builder::BaseTest < Test::Unit::TestCase
|
|
17
17
|
def test_should_support_media_type_registering
|
18
18
|
assert_equal ["valid/media_type"] , SomeBuilder.media_types
|
19
19
|
assert_equal ["valid/media_type","another_valid/media_type"], AnotherBuilder.media_types
|
20
|
+
|
21
|
+
AnotherBuilder.add_media_type "awesome/media_type"
|
22
|
+
|
23
|
+
assert_equal ["valid/media_type","another_valid/media_type","awesome/media_type"], AnotherBuilder.media_types
|
24
|
+
assert_equal AnotherBuilder , Tokamak.builder_lookup("awesome/media_type")
|
20
25
|
end
|
21
26
|
|
22
27
|
def test_builder_lookup
|
@@ -24,5 +29,5 @@ class Tokamak::Builder::BaseTest < Test::Unit::TestCase
|
|
24
29
|
assert_equal AnotherBuilder , Tokamak.builder_lookup("another_valid/media_type")
|
25
30
|
assert_equal YetAnotherBuilder, Tokamak.builder_lookup("yet_another_valid/media_type")
|
26
31
|
end
|
27
|
-
|
32
|
+
|
28
33
|
end
|
@@ -27,6 +27,29 @@ class Tokamak::Builder::JsonTest < Test::Unit::TestCase
|
|
27
27
|
assert hash.members.kind_of?(Array)
|
28
28
|
end
|
29
29
|
|
30
|
+
def test_empty_value_as_nil
|
31
|
+
obj = [{ :foo => "bar" }]
|
32
|
+
json = Tokamak::Builder::Json.build(obj) do |collection|
|
33
|
+
collection.values do |values|
|
34
|
+
values.id "an_id"
|
35
|
+
values.empty_value
|
36
|
+
end
|
37
|
+
|
38
|
+
collection.members do |member, some_foos|
|
39
|
+
member.values do |values|
|
40
|
+
values.id some_foos[:foo]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
hash = JSON.parse(json).extend(Methodize)
|
46
|
+
|
47
|
+
assert_equal nil , hash.empty_value
|
48
|
+
assert_equal "an_id", hash.id
|
49
|
+
assert_equal "bar" , hash.members.first.id
|
50
|
+
assert hash.members.kind_of?(Array)
|
51
|
+
end
|
52
|
+
|
30
53
|
def test_root_set_on_builder
|
31
54
|
obj = [{ :foo => "bar" }, { :foo => "zue" }]
|
32
55
|
json = Tokamak::Builder::Json.build(obj, :root => "foos") do |collection|
|
@@ -74,7 +74,7 @@ class Tokamak::Builder::XmlTest < Test::Unit::TestCase
|
|
74
74
|
obj = 42
|
75
75
|
|
76
76
|
assert_raise Tokamak::BuilderError do
|
77
|
-
json = Tokamak::Builder::
|
77
|
+
json = Tokamak::Builder::Xml.build(obj) do |collection, number|
|
78
78
|
collection.values do |values|
|
79
79
|
values.id number
|
80
80
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tokamak
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 1.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 1.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Luis Cipriani
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-05-11 00:00:00 -03:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|