tokamak 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/tokamak/builder.rb +4 -4
- data/lib/tokamak/builder/json.rb +6 -2
- data/lib/tokamak/builder/xml.rb +6 -2
- data/lib/tokamak/version.rb +1 -1
- data/test/rails2_skel/log/development.log +45 -0
- metadata +3 -3
data/lib/tokamak/builder.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
module Tokamak
|
2
2
|
module Builder
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
require "tokamak/builder/base"
|
4
|
+
require "tokamak/builder/values"
|
5
|
+
require "tokamak/builder/json"
|
6
|
+
require "tokamak/builder/xml"
|
7
7
|
|
8
8
|
def self.helper_module_for(const)
|
9
9
|
mod = Module.new
|
data/lib/tokamak/builder/json.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require "json/pure"
|
2
|
-
|
3
1
|
module Tokamak
|
4
2
|
module Builder
|
5
3
|
class Json < Tokamak::Builder::Base
|
@@ -9,11 +7,17 @@ module Tokamak
|
|
9
7
|
attr_reader :raw
|
10
8
|
|
11
9
|
def initialize(obj, options = {})
|
10
|
+
initialize_library
|
12
11
|
@raw = options[:root] ? { options[:root] => {} } : {}
|
13
12
|
@current = options[:root] ? @raw[options[:root]] : @raw
|
14
13
|
@obj = obj
|
15
14
|
end
|
16
15
|
|
16
|
+
def initialize_library
|
17
|
+
return if defined?(::JSON)
|
18
|
+
require "json/pure"
|
19
|
+
end
|
20
|
+
|
17
21
|
def members(options = {}, &block)
|
18
22
|
collection = options[:collection] || @obj
|
19
23
|
raise Tokamak::BuilderError.new("Members method require a collection to execute") unless collection.respond_to?(:each)
|
data/lib/tokamak/builder/xml.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require "nokogiri"
|
2
|
-
|
3
1
|
module Tokamak
|
4
2
|
module Builder
|
5
3
|
class Xml < Tokamak::Builder::Base
|
@@ -9,12 +7,18 @@ module Tokamak
|
|
9
7
|
attr_reader :raw
|
10
8
|
|
11
9
|
def initialize(obj, options = {})
|
10
|
+
initialize_library
|
12
11
|
@raw = Nokogiri::XML::Document.new
|
13
12
|
@obj = obj
|
14
13
|
@parent = @raw.create_element(options[:root] || "root")
|
15
14
|
@parent.parent = @raw
|
16
15
|
end
|
17
16
|
|
17
|
+
def initialize_library
|
18
|
+
return if defined?(::Nokogiri)
|
19
|
+
require "nokogiri"
|
20
|
+
end
|
21
|
+
|
18
22
|
def members(options = {}, &block)
|
19
23
|
collection = options[:collection] || @obj
|
20
24
|
raise Tokamak::BuilderError.new("Members method require a collection to execute") unless collection.respond_to?(:each)
|
data/lib/tokamak/version.rb
CHANGED
@@ -1138,3 +1138,48 @@ Completed in 11ms (View: 9 | 200 OK [http://www.example.com/test/feed]
|
|
1138
1138
|
Processing TestController#show (for 127.0.0.1 at 2011-01-06 09:57:09) [GET]
|
1139
1139
|
Rendering test/show
|
1140
1140
|
Completed in 4ms (View: 3 | 200 OK [http://www.example.com/test/show]
|
1141
|
+
|
1142
|
+
|
1143
|
+
Processing TestController#show (for 127.0.0.1 at 2011-01-06 16:45:51) [GET]
|
1144
|
+
Rendering test/show
|
1145
|
+
Completed in 23ms (View: 22 | 200 OK [http://www.example.com/test/show]
|
1146
|
+
|
1147
|
+
|
1148
|
+
Processing TestController#feed (for 127.0.0.1 at 2011-01-06 16:45:51) [GET]
|
1149
|
+
Rendering test/feed
|
1150
|
+
Completed in 12ms (View: 11 | 200 OK [http://www.example.com/test/feed]
|
1151
|
+
|
1152
|
+
|
1153
|
+
Processing TestController#show (for 127.0.0.1 at 2011-01-06 16:45:51) [GET]
|
1154
|
+
Rendering test/show
|
1155
|
+
Completed in 5ms (View: 3 | 200 OK [http://www.example.com/test/show]
|
1156
|
+
|
1157
|
+
|
1158
|
+
Processing TestController#show (for 127.0.0.1 at 2011-01-06 16:55:22) [GET]
|
1159
|
+
Rendering test/show
|
1160
|
+
Completed in 156ms (View: 154 | 200 OK [http://www.example.com/test/show]
|
1161
|
+
|
1162
|
+
|
1163
|
+
Processing TestController#feed (for 127.0.0.1 at 2011-01-06 16:55:22) [GET]
|
1164
|
+
Rendering test/feed
|
1165
|
+
Completed in 10ms (View: 9 | 200 OK [http://www.example.com/test/feed]
|
1166
|
+
|
1167
|
+
|
1168
|
+
Processing TestController#show (for 127.0.0.1 at 2011-01-06 16:55:22) [GET]
|
1169
|
+
Rendering test/show
|
1170
|
+
Completed in 4ms (View: 2 | 200 OK [http://www.example.com/test/show]
|
1171
|
+
|
1172
|
+
|
1173
|
+
Processing TestController#show (for 127.0.0.1 at 2011-01-06 16:58:12) [GET]
|
1174
|
+
Rendering test/show
|
1175
|
+
Completed in 8ms (View: 6 | 200 OK [http://www.example.com/test/show]
|
1176
|
+
|
1177
|
+
|
1178
|
+
Processing TestController#feed (for 127.0.0.1 at 2011-01-06 16:58:12) [GET]
|
1179
|
+
Rendering test/feed
|
1180
|
+
Completed in 10ms (View: 9 | 200 OK [http://www.example.com/test/feed]
|
1181
|
+
|
1182
|
+
|
1183
|
+
Processing TestController#show (for 127.0.0.1 at 2011-01-06 16:58:12) [GET]
|
1184
|
+
Rendering test/show
|
1185
|
+
Completed in 4ms (View: 2 | 200 OK [http://www.example.com/test/show]
|
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: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 2
|
10
|
+
version: 1.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Luis Cipriani
|