rabl 0.3.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.travis.yml +10 -0
- data/CHANGELOG.md +34 -0
- data/Gemfile +14 -1
- data/README.md +53 -4
- data/Rakefile +26 -1
- data/fixtures/ashared/NOTES +35 -0
- data/fixtures/ashared/README +35 -0
- data/fixtures/ashared/migrate/20111002092016_create_users.rb +15 -0
- data/fixtures/ashared/migrate/20111002092019_create_posts.rb +14 -0
- data/fixtures/ashared/migrate/20111002092024_create_phone_numbers.rb +16 -0
- data/fixtures/ashared/models/phone_number.rb +7 -0
- data/fixtures/ashared/models/post.rb +3 -0
- data/fixtures/ashared/models/user.rb +3 -0
- data/fixtures/ashared/views/layouts/application.html.erb +6 -0
- data/fixtures/ashared/views/posts/date.json.rabl +3 -0
- data/fixtures/ashared/views/posts/index.json.rabl +11 -0
- data/fixtures/ashared/views/posts/show.json.rabl +16 -0
- data/fixtures/ashared/views/users/index.rabl +3 -0
- data/fixtures/ashared/views/users/phone_number.rabl +6 -0
- data/fixtures/ashared/views/users/show.rabl +16 -0
- data/fixtures/padrino_test/.components +7 -0
- data/fixtures/padrino_test/.gitignore +7 -0
- data/fixtures/padrino_test/Gemfile +17 -0
- data/fixtures/padrino_test/Rakefile +3 -0
- data/fixtures/padrino_test/app/app.rb +59 -0
- data/fixtures/padrino_test/app/controllers/posts.rb +11 -0
- data/fixtures/padrino_test/app/controllers/users.rb +11 -0
- data/fixtures/padrino_test/app/helpers/posts_helper.rb +7 -0
- data/fixtures/padrino_test/app/helpers/users_helper.rb +7 -0
- data/fixtures/padrino_test/config.ru +9 -0
- data/fixtures/padrino_test/config/apps.rb +34 -0
- data/fixtures/padrino_test/config/boot.rb +29 -0
- data/fixtures/padrino_test/config/database.rb +43 -0
- data/fixtures/padrino_test/db/schema.rb +42 -0
- data/fixtures/padrino_test/public/favicon.ico +0 -0
- data/fixtures/padrino_test/test/app/controllers/posts_controller_test.rb +108 -0
- data/fixtures/padrino_test/test/app/controllers/users_controller_test.rb +87 -0
- data/fixtures/padrino_test/test/test.rake +18 -0
- data/fixtures/padrino_test/test/test_config.rb +18 -0
- data/fixtures/rails2/.gitignore +1 -0
- data/fixtures/rails2/Gemfile +8 -0
- data/fixtures/rails2/Rakefile +14 -0
- data/fixtures/rails2/app/controllers/application_controller.rb +10 -0
- data/fixtures/rails2/app/controllers/posts_controller.rb +15 -0
- data/fixtures/rails2/app/controllers/users_controller.rb +15 -0
- data/fixtures/rails2/config/boot.rb +129 -0
- data/fixtures/rails2/config/database.yml +16 -0
- data/fixtures/rails2/config/environment.rb +42 -0
- data/fixtures/rails2/config/environments/development.rb +17 -0
- data/fixtures/rails2/config/environments/production.rb +28 -0
- data/fixtures/rails2/config/environments/test.rb +28 -0
- data/fixtures/rails2/config/initializers/backtrace_silencers.rb +7 -0
- data/fixtures/rails2/config/initializers/cookie_verification_secret.rb +7 -0
- data/fixtures/rails2/config/initializers/inflections.rb +10 -0
- data/fixtures/rails2/config/initializers/mime_types.rb +5 -0
- data/fixtures/rails2/config/initializers/new_rails_defaults.rb +21 -0
- data/fixtures/rails2/config/initializers/session_store.rb +15 -0
- data/fixtures/rails2/config/locales/en.yml +5 -0
- data/fixtures/rails2/config/preinitializer.rb +20 -0
- data/fixtures/rails2/config/routes.rb +45 -0
- data/fixtures/rails2/db/schema.rb +40 -0
- data/fixtures/rails2/db/seeds.rb +7 -0
- data/fixtures/rails2/public/404.html +30 -0
- data/fixtures/rails2/public/422.html +30 -0
- data/fixtures/rails2/public/500.html +30 -0
- data/fixtures/rails2/public/favicon.ico +0 -0
- data/fixtures/rails2/public/images/rails.png +0 -0
- data/fixtures/rails2/public/index.html +275 -0
- data/fixtures/rails2/public/robots.txt +5 -0
- data/fixtures/rails2/script/about +4 -0
- data/fixtures/rails2/script/console +3 -0
- data/fixtures/rails2/script/dbconsole +3 -0
- data/fixtures/rails2/script/destroy +3 -0
- data/fixtures/rails2/script/generate +3 -0
- data/fixtures/rails2/script/performance/benchmarker +3 -0
- data/fixtures/rails2/script/performance/profiler +3 -0
- data/fixtures/rails2/script/plugin +3 -0
- data/fixtures/rails2/script/runner +3 -0
- data/fixtures/rails2/script/server +3 -0
- data/fixtures/rails2/test/functionals/posts_controller_test.rb +108 -0
- data/fixtures/rails2/test/functionals/users_controller_test.rb +87 -0
- data/fixtures/rails2/test/test_helper.rb +33 -0
- data/fixtures/rails3/.gitignore +4 -0
- data/fixtures/rails3/Gemfile +37 -0
- data/fixtures/rails3/Rakefile +12 -0
- data/fixtures/rails3/app/controllers/application_controller.rb +14 -0
- data/fixtures/rails3/app/controllers/posts_controller.rb +11 -0
- data/fixtures/rails3/app/controllers/users_controller.rb +11 -0
- data/fixtures/rails3/config.ru +4 -0
- data/fixtures/rails3/config/application.rb +42 -0
- data/fixtures/rails3/config/boot.rb +6 -0
- data/fixtures/rails3/config/database.yml +22 -0
- data/fixtures/rails3/config/environment.rb +5 -0
- data/fixtures/rails3/config/environments/development.rb +26 -0
- data/fixtures/rails3/config/environments/production.rb +49 -0
- data/fixtures/rails3/config/environments/test.rb +35 -0
- data/fixtures/rails3/config/initializers/backtrace_silencers.rb +7 -0
- data/fixtures/rails3/config/initializers/inflections.rb +10 -0
- data/fixtures/rails3/config/initializers/mime_types.rb +5 -0
- data/fixtures/rails3/config/initializers/secret_token.rb +7 -0
- data/fixtures/rails3/config/initializers/session_store.rb +8 -0
- data/fixtures/rails3/config/locales/en.yml +5 -0
- data/fixtures/rails3/config/routes.rb +61 -0
- data/fixtures/rails3/db/seeds.rb +7 -0
- data/fixtures/rails3/lib/tasks/.gitkeep +0 -0
- data/fixtures/rails3/public/404.html +26 -0
- data/fixtures/rails3/public/422.html +26 -0
- data/fixtures/rails3/public/500.html +26 -0
- data/fixtures/rails3/public/favicon.ico +0 -0
- data/fixtures/rails3/public/images/rails.png +0 -0
- data/fixtures/rails3/public/index.html +239 -0
- data/fixtures/rails3/public/robots.txt +5 -0
- data/fixtures/rails3/public/stylesheets/.gitkeep +0 -0
- data/fixtures/rails3/script/rails +6 -0
- data/fixtures/rails3/test/functional/posts_controller_test.rb +108 -0
- data/fixtures/rails3/test/functional/users_controller_test.rb +87 -0
- data/fixtures/rails3/test/test_helper.rb +26 -0
- data/fixtures/sinatra_test/Gemfile +13 -0
- data/fixtures/sinatra_test/Rakefile +6 -0
- data/fixtures/sinatra_test/app.rb +44 -0
- data/fixtures/sinatra_test/config.ru +7 -0
- data/fixtures/sinatra_test/test/functional/posts_controller_test.rb +108 -0
- data/fixtures/sinatra_test/test/functional/users_controller_test.rb +87 -0
- data/fixtures/sinatra_test/test/test_helper.rb +19 -0
- data/lib/rabl.rb +13 -1
- data/lib/rabl/builder.rb +14 -7
- data/lib/rabl/configuration.rb +41 -1
- data/lib/rabl/engine.rb +29 -19
- data/lib/rabl/helpers.rb +45 -18
- data/lib/rabl/template.rb +1 -1
- data/lib/rabl/version.rb +1 -1
- data/rabl.gemspec +6 -5
- data/test/builder_test.rb +4 -4
- data/test/configuration_test.rb +7 -22
- data/test/engine_test.rb +63 -44
- data/test/helpers_test.rb +68 -0
- data/test/integration/posts_controller_test.rb +108 -0
- data/test/integration/test_init.rb +35 -0
- data/test/integration/users_controller_test.rb +87 -0
- data/test/models/ormless.rb +2 -0
- data/test/models/user.rb +17 -6
- data/test/msgpack_engine_test.rb +332 -0
- data/test/silence.rb +21 -0
- data/test/teststrap.rb +22 -6
- metadata +160 -14
data/test/models/user.rb
CHANGED
@@ -1,9 +1,20 @@
|
|
1
|
-
require 'mongoid'
|
2
|
-
|
3
1
|
class User
|
4
|
-
|
2
|
+
attr_accessor :age, :city, :name
|
3
|
+
|
4
|
+
DEFAULT_AGE = 24
|
5
|
+
DEFAULT_CITY = 'irvine'
|
6
|
+
DEFAULT_NAME = 'rabl'
|
7
|
+
|
8
|
+
def initialize(attributes={})
|
9
|
+
self.age = attributes[:age] || DEFAULT_AGE
|
10
|
+
self.city = attributes[:city] || DEFAULT_CITY
|
11
|
+
self.name = attributes[:name] || DEFAULT_NAME
|
12
|
+
end
|
13
|
+
end
|
5
14
|
|
6
|
-
|
7
|
-
|
8
|
-
|
15
|
+
module NestedScope
|
16
|
+
class User
|
17
|
+
def controller; self; end
|
18
|
+
def controller_name; self.class.name.downcase; end
|
19
|
+
end
|
9
20
|
end
|
@@ -0,0 +1,332 @@
|
|
1
|
+
require File.expand_path('../teststrap', __FILE__)
|
2
|
+
require File.expand_path('../../lib/rabl', __FILE__)
|
3
|
+
require File.expand_path('../../lib/rabl/template', __FILE__)
|
4
|
+
require File.expand_path('../models/user', __FILE__)
|
5
|
+
|
6
|
+
context "Rabl::Engine" do
|
7
|
+
|
8
|
+
helper(:rabl) { |t| RablTemplate.new("code", :format => 'msgpack') { t } }
|
9
|
+
|
10
|
+
context "with msgpack defaults" do
|
11
|
+
setup do
|
12
|
+
Rabl.configure do |config|
|
13
|
+
# Comment this line out because include_msgpack_root is default.
|
14
|
+
#config.include_msgpack_root = true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "#object" do
|
19
|
+
|
20
|
+
asserts "that it sets data source" do
|
21
|
+
template = rabl %q{
|
22
|
+
object @user
|
23
|
+
}
|
24
|
+
scope = Object.new
|
25
|
+
scope.instance_variable_set :@user, User.new
|
26
|
+
template.render(scope)
|
27
|
+
end.matches "\x81\xA4user\x80"
|
28
|
+
|
29
|
+
asserts "that it can set root node" do
|
30
|
+
template = rabl %q{
|
31
|
+
object @user => :person
|
32
|
+
}
|
33
|
+
scope = Object.new
|
34
|
+
scope.instance_variable_set :@user, User.new
|
35
|
+
template.render(scope).split("").sort
|
36
|
+
end.equals "\x81\xA6person\x80".split("").sort
|
37
|
+
end
|
38
|
+
|
39
|
+
context "#collection" do
|
40
|
+
|
41
|
+
asserts "that it sets object to be casted as a simple array" do
|
42
|
+
template = rabl %{
|
43
|
+
collection @users
|
44
|
+
}
|
45
|
+
scope = Object.new
|
46
|
+
scope.instance_variable_set :@users, [User.new, User.new]
|
47
|
+
template.render(scope).split("").sort
|
48
|
+
end.equals "\x92\x81\xA4user\x80\x81\xA4user\x80".split("").sort
|
49
|
+
|
50
|
+
asserts "that it sets root node for objects" do
|
51
|
+
template = rabl %{
|
52
|
+
collection @users => :person
|
53
|
+
}
|
54
|
+
scope = Object.new
|
55
|
+
scope.instance_variable_set :@users, [User.new, User.new]
|
56
|
+
template.render(scope).split("").sort
|
57
|
+
end.equals "\x81\xA6person\x92\x81\xA6person\x80\x81\xA6person\x80".split("").sort
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
context "#attribute" do
|
62
|
+
|
63
|
+
asserts "that it adds an attribute or method to be included in output" do
|
64
|
+
template = rabl %{
|
65
|
+
object @user
|
66
|
+
attribute :name
|
67
|
+
}
|
68
|
+
scope = Object.new
|
69
|
+
scope.instance_variable_set :@user, User.new(:name => 'irvine')
|
70
|
+
template.render(scope).split("").sort
|
71
|
+
end.equals "\x81\xA4user\x81\xA4name\xA6irvine".split("").sort
|
72
|
+
|
73
|
+
asserts "that it can add attribute under a different key name through :as" do
|
74
|
+
template = rabl %{
|
75
|
+
object @user
|
76
|
+
attribute :name, :as => 'city'
|
77
|
+
}
|
78
|
+
scope = Object.new
|
79
|
+
scope.instance_variable_set :@user, User.new(:name => 'irvine')
|
80
|
+
template.render(scope).split("").sort
|
81
|
+
end.equals "\x81\xA4user\x81\xA4city\xA6irvine".split("").sort
|
82
|
+
|
83
|
+
asserts "that it can add attribute under a different key name through hash" do
|
84
|
+
template = rabl %{
|
85
|
+
object @user
|
86
|
+
attribute :name => :city
|
87
|
+
}
|
88
|
+
scope = Object.new
|
89
|
+
scope.instance_variable_set :@user, User.new(:name => 'irvine')
|
90
|
+
template.render(scope).split("").sort
|
91
|
+
end.equals "\x81\xA4user\x81\xA4city\xA6irvine".split("").sort
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
context "#code" do
|
96
|
+
|
97
|
+
asserts "that it can create an arbitraty code node" do
|
98
|
+
template = rabl %{
|
99
|
+
code(:foo) { 'bar' }
|
100
|
+
}
|
101
|
+
template.render(Object.new).split("").sort
|
102
|
+
end.equals "\x81\xA3foo\xA3bar".split("").sort
|
103
|
+
|
104
|
+
asserts "that it can be passed conditionals" do
|
105
|
+
template = rabl %{
|
106
|
+
code(:foo, :if => lambda { |i| false }) { 'bar' }
|
107
|
+
}
|
108
|
+
template.render(Object.new).split("").sort
|
109
|
+
end.equals "\x80".split("").sort
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
context "#child" do
|
114
|
+
|
115
|
+
asserts "that it can create a child node" do
|
116
|
+
template = rabl %{
|
117
|
+
object @user
|
118
|
+
attribute :name
|
119
|
+
child(@user) { attribute :city }
|
120
|
+
}
|
121
|
+
scope = Object.new
|
122
|
+
scope.instance_variable_set :@user, User.new(:name => 'leo', :city => 'LA')
|
123
|
+
template.render(scope).split("").sort
|
124
|
+
end.equals "\x81\xA4user\x82\xA4name\xA3leo\xA4user\x81\xA4city\xA2LA".split("").sort
|
125
|
+
|
126
|
+
asserts "that it can create a child node with different key" do
|
127
|
+
template = rabl %{
|
128
|
+
object @user
|
129
|
+
attribute :name
|
130
|
+
child(@user => :person) { attribute :city }
|
131
|
+
}
|
132
|
+
scope = Object.new
|
133
|
+
scope.instance_variable_set :@user, User.new(:name => 'leo', :city => 'LA')
|
134
|
+
template.render(scope).split("").sort
|
135
|
+
|
136
|
+
end.equals "\x81\xA4user\x82\xA4name\xA3leo\xA6person\x81\xA4city\xA2LA".split("").sort
|
137
|
+
end
|
138
|
+
|
139
|
+
context "#glue" do
|
140
|
+
|
141
|
+
asserts "that it glues data from a child node" do
|
142
|
+
template = rabl %{
|
143
|
+
object @user
|
144
|
+
attribute :name
|
145
|
+
glue(@user) { attribute :city }
|
146
|
+
glue(@user) { attribute :age }
|
147
|
+
}
|
148
|
+
scope = Object.new
|
149
|
+
scope.instance_variable_set :@user, User.new(:name => 'leo', :city => 'LA', :age => 12)
|
150
|
+
template.render(scope).split("").sort
|
151
|
+
end.equals "\x81\xA4user\x83\xA4name\xA3leo\xA4city\xA2LA\xA3age\f".split("").sort
|
152
|
+
end
|
153
|
+
|
154
|
+
teardown do
|
155
|
+
Rabl.reset_configuration!
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
context "with msgpack_engine" do
|
160
|
+
setup do
|
161
|
+
class CustomEncodeEngine
|
162
|
+
def self.pack string
|
163
|
+
42
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
Rabl.configure do |config|
|
168
|
+
config.msgpack_engine = CustomEncodeEngine
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
asserts 'that it returns process by custom to_json' do
|
173
|
+
template = rabl %q{
|
174
|
+
object @user
|
175
|
+
}
|
176
|
+
scope = Object.new
|
177
|
+
scope.instance_variable_set :@user, User.new
|
178
|
+
template.render(scope)
|
179
|
+
end.equals 42
|
180
|
+
|
181
|
+
teardown do
|
182
|
+
Rabl.reset_configuration!
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
context "without msgpack root" do
|
187
|
+
setup do
|
188
|
+
Rabl.configure do |config|
|
189
|
+
config.include_msgpack_root = false
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
context "#object" do
|
194
|
+
|
195
|
+
asserts "that it sets data source" do
|
196
|
+
template = rabl %q{
|
197
|
+
object @user
|
198
|
+
}
|
199
|
+
scope = Object.new
|
200
|
+
scope.instance_variable_set :@user, User.new
|
201
|
+
template.render(scope)
|
202
|
+
end.matches "\x80"
|
203
|
+
|
204
|
+
asserts "that it can set root node" do
|
205
|
+
template = rabl %q{
|
206
|
+
object @user => :person
|
207
|
+
}
|
208
|
+
scope = Object.new
|
209
|
+
scope.instance_variable_set :@user, User.new
|
210
|
+
template.render(scope)
|
211
|
+
end.equals "\x80"
|
212
|
+
end
|
213
|
+
|
214
|
+
context "#collection" do
|
215
|
+
|
216
|
+
asserts "that it sets object to be casted as a simple array" do
|
217
|
+
template = rabl %{
|
218
|
+
collection @users
|
219
|
+
}
|
220
|
+
scope = Object.new
|
221
|
+
scope.instance_variable_set :@users, [User.new, User.new]
|
222
|
+
template.render(scope).split("").sort
|
223
|
+
end.equals "\x92\x80\x80".split("").sort
|
224
|
+
|
225
|
+
asserts "that it sets root node for objects" do
|
226
|
+
template = rabl %{
|
227
|
+
collection @users => :person
|
228
|
+
}
|
229
|
+
scope = Object.new
|
230
|
+
scope.instance_variable_set :@users, [User.new, User.new]
|
231
|
+
template.render(scope).split("").sort
|
232
|
+
end.equals "\x81\xA6person\x92\x80\x80".split("").sort
|
233
|
+
|
234
|
+
end
|
235
|
+
|
236
|
+
context "#attribute" do
|
237
|
+
|
238
|
+
asserts "that it adds an attribute or method to be included in output" do
|
239
|
+
template = rabl %{
|
240
|
+
object @user
|
241
|
+
attribute :name
|
242
|
+
}
|
243
|
+
scope = Object.new
|
244
|
+
scope.instance_variable_set :@user, User.new(:name => 'irvine')
|
245
|
+
template.render(scope).split("").sort
|
246
|
+
end.equals "\x81\xA4name\xA6irvine".split("").sort
|
247
|
+
|
248
|
+
asserts "that it can add attribute under a different key name through :as" do
|
249
|
+
template = rabl %{
|
250
|
+
object @user
|
251
|
+
attribute :name, :as => 'city'
|
252
|
+
}
|
253
|
+
scope = Object.new
|
254
|
+
scope.instance_variable_set :@user, User.new(:name => 'irvine')
|
255
|
+
template.render(scope).split("").sort
|
256
|
+
end.equals "\x81\xA4city\xA6irvine".split("").sort
|
257
|
+
|
258
|
+
asserts "that it can add attribute under a different key name through hash" do
|
259
|
+
template = rabl %{
|
260
|
+
object @user
|
261
|
+
attribute :name => :city
|
262
|
+
}
|
263
|
+
scope = Object.new
|
264
|
+
scope.instance_variable_set :@user, User.new(:name => 'irvine')
|
265
|
+
template.render(scope).split("").sort
|
266
|
+
end.equals "\x81\xA4city\xA6irvine".split("").sort
|
267
|
+
|
268
|
+
end
|
269
|
+
|
270
|
+
context "#code" do
|
271
|
+
|
272
|
+
asserts "that it can create an arbitraty code node" do
|
273
|
+
template = rabl %{
|
274
|
+
code(:foo) { 'bar' }
|
275
|
+
}
|
276
|
+
template.render(Object.new).split("").sort
|
277
|
+
end.equals "\x81\xA3foo\xA3bar".split("").sort
|
278
|
+
|
279
|
+
asserts "that it can be passed conditionals" do
|
280
|
+
template = rabl %{
|
281
|
+
code(:foo, :if => lambda { |i| false }) { 'bar' }
|
282
|
+
}
|
283
|
+
template.render(Object.new).split("").sort
|
284
|
+
end.equals "\x80".split("").sort
|
285
|
+
|
286
|
+
end
|
287
|
+
|
288
|
+
context "#child" do
|
289
|
+
|
290
|
+
asserts "that it can create a child node" do
|
291
|
+
template = rabl %{
|
292
|
+
object @user
|
293
|
+
attribute :name
|
294
|
+
child(@user) { attribute :city }
|
295
|
+
}
|
296
|
+
scope = Object.new
|
297
|
+
scope.instance_variable_set :@user, User.new(:name => 'leo', :city => 'LA')
|
298
|
+
template.render(scope).split("").sort
|
299
|
+
end.equals "\x82\xA4name\xA3leo\xA4user\x81\xA4city\xA2LA".split("").sort
|
300
|
+
|
301
|
+
asserts "that it can create a child node with different key" do
|
302
|
+
template = rabl %{
|
303
|
+
object @user
|
304
|
+
attribute :name
|
305
|
+
child(@user => :person) { attribute :city }
|
306
|
+
}
|
307
|
+
scope = Object.new
|
308
|
+
scope.instance_variable_set :@user, User.new(:name => 'leo', :city => 'LA')
|
309
|
+
template.render(scope).split("").sort
|
310
|
+
end.equals "\x82\xA4name\xA3leo\xA6person\x81\xA4city\xA2LA".split("").sort
|
311
|
+
end
|
312
|
+
|
313
|
+
context "#glue" do
|
314
|
+
|
315
|
+
asserts "that it glues data from a child node" do
|
316
|
+
template = rabl %{
|
317
|
+
object @user
|
318
|
+
attribute :name
|
319
|
+
glue(@user) { attribute :city }
|
320
|
+
glue(@user) { attribute :age }
|
321
|
+
}
|
322
|
+
scope = Object.new
|
323
|
+
scope.instance_variable_set :@user, User.new(:name => 'leo', :city => 'LA', :age => 12)
|
324
|
+
template.render(scope).split("").sort
|
325
|
+
end.equals "\x83\xA4name\xA3leo\xA4city\xA2LA\xA3age\f".split("").sort
|
326
|
+
end
|
327
|
+
|
328
|
+
teardown do
|
329
|
+
Rabl.reset_configuration!
|
330
|
+
end
|
331
|
+
end
|
332
|
+
end
|
data/test/silence.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module Kernel
|
2
|
+
def silence_warnings
|
3
|
+
with_warnings(nil) { yield }
|
4
|
+
end
|
5
|
+
|
6
|
+
def silence_stream(stream)
|
7
|
+
old_stream = stream.dup
|
8
|
+
stream.reopen(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? 'NUL:' : '/dev/null')
|
9
|
+
stream.sync = true
|
10
|
+
yield
|
11
|
+
ensure
|
12
|
+
stream.reopen(old_stream)
|
13
|
+
end
|
14
|
+
|
15
|
+
def with_warnings(flag)
|
16
|
+
old_verbose, $VERBOSE = $VERBOSE, flag
|
17
|
+
yield
|
18
|
+
ensure
|
19
|
+
$VERBOSE = old_verbose
|
20
|
+
end
|
21
|
+
end unless Kernel.respond_to? :silence_warnings
|
data/test/teststrap.rb
CHANGED
@@ -1,14 +1,30 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
module Kernel
|
2
|
+
def silence_warnings
|
3
|
+
with_warnings(nil) { yield }
|
4
|
+
end
|
5
|
+
|
6
|
+
def with_warnings(flag)
|
7
|
+
old_verbose, $VERBOSE = $VERBOSE, flag
|
8
|
+
yield
|
9
|
+
ensure
|
10
|
+
$VERBOSE = old_verbose
|
11
|
+
end
|
12
|
+
end unless Kernel.respond_to? :silence_warnings
|
13
|
+
|
14
|
+
silence_warnings do
|
15
|
+
require 'riot'
|
16
|
+
require 'riot/rr'
|
17
|
+
require 'tilt'
|
18
|
+
require File.expand_path('../../lib/rabl',__FILE__)
|
19
|
+
end
|
7
20
|
|
8
21
|
Riot.pretty_dots
|
9
22
|
|
10
23
|
class Riot::Situation
|
24
|
+
# Custom situation code here
|
11
25
|
end
|
12
26
|
|
13
27
|
class Riot::Context
|
28
|
+
# Custom context code here
|
14
29
|
end
|
30
|
+
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rabl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.5.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Nathan Esquenazi
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-10-19 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: multi_json
|
@@ -24,40 +24,40 @@ dependencies:
|
|
24
24
|
type: :runtime
|
25
25
|
version_requirements: *id001
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
|
-
name:
|
27
|
+
name: activesupport
|
28
28
|
prerelease: false
|
29
29
|
requirement: &id002 !ruby/object:Gem::Requirement
|
30
30
|
none: false
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
35
|
-
type: :
|
34
|
+
version: 2.3.14
|
35
|
+
type: :runtime
|
36
36
|
version_requirements: *id002
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
|
-
name:
|
38
|
+
name: riot
|
39
39
|
prerelease: false
|
40
40
|
requirement: &id003 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
45
|
+
version: 0.12.3
|
46
46
|
type: :development
|
47
47
|
version_requirements: *id003
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
|
-
name:
|
49
|
+
name: rr
|
50
50
|
prerelease: false
|
51
51
|
requirement: &id004 !ruby/object:Gem::Requirement
|
52
52
|
none: false
|
53
53
|
requirements:
|
54
|
-
- -
|
54
|
+
- - ~>
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version:
|
56
|
+
version: 1.0.2
|
57
57
|
type: :development
|
58
58
|
version_requirements: *id004
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
|
-
name:
|
60
|
+
name: rake
|
61
61
|
prerelease: false
|
62
62
|
requirement: &id005 !ruby/object:Gem::Requirement
|
63
63
|
none: false
|
@@ -68,7 +68,7 @@ dependencies:
|
|
68
68
|
type: :development
|
69
69
|
version_requirements: *id005
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
|
-
name:
|
71
|
+
name: tilt
|
72
72
|
prerelease: false
|
73
73
|
requirement: &id006 !ruby/object:Gem::Requirement
|
74
74
|
none: false
|
@@ -89,6 +89,17 @@ dependencies:
|
|
89
89
|
version: "0"
|
90
90
|
type: :development
|
91
91
|
version_requirements: *id007
|
92
|
+
- !ruby/object:Gem::Dependency
|
93
|
+
name: msgpack
|
94
|
+
prerelease: false
|
95
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ~>
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: 0.4.5
|
101
|
+
type: :development
|
102
|
+
version_requirements: *id008
|
92
103
|
description: General ruby templating for json or xml
|
93
104
|
email:
|
94
105
|
- nesquena@gmail.com
|
@@ -100,6 +111,8 @@ extra_rdoc_files: []
|
|
100
111
|
|
101
112
|
files:
|
102
113
|
- .gitignore
|
114
|
+
- .travis.yml
|
115
|
+
- CHANGELOG.md
|
103
116
|
- Gemfile
|
104
117
|
- MIT-LICENSE
|
105
118
|
- README.md
|
@@ -108,6 +121,125 @@ files:
|
|
108
121
|
- examples/base.json.rabl
|
109
122
|
- examples/demo.json.rabl
|
110
123
|
- examples/inherited.json.rabl
|
124
|
+
- fixtures/ashared/NOTES
|
125
|
+
- fixtures/ashared/README
|
126
|
+
- fixtures/ashared/migrate/20111002092016_create_users.rb
|
127
|
+
- fixtures/ashared/migrate/20111002092019_create_posts.rb
|
128
|
+
- fixtures/ashared/migrate/20111002092024_create_phone_numbers.rb
|
129
|
+
- fixtures/ashared/models/phone_number.rb
|
130
|
+
- fixtures/ashared/models/post.rb
|
131
|
+
- fixtures/ashared/models/user.rb
|
132
|
+
- fixtures/ashared/views/layouts/application.html.erb
|
133
|
+
- fixtures/ashared/views/posts/date.json.rabl
|
134
|
+
- fixtures/ashared/views/posts/index.json.rabl
|
135
|
+
- fixtures/ashared/views/posts/show.json.rabl
|
136
|
+
- fixtures/ashared/views/users/index.rabl
|
137
|
+
- fixtures/ashared/views/users/phone_number.rabl
|
138
|
+
- fixtures/ashared/views/users/show.rabl
|
139
|
+
- fixtures/padrino_test/.components
|
140
|
+
- fixtures/padrino_test/.gitignore
|
141
|
+
- fixtures/padrino_test/Gemfile
|
142
|
+
- fixtures/padrino_test/Rakefile
|
143
|
+
- fixtures/padrino_test/app/app.rb
|
144
|
+
- fixtures/padrino_test/app/controllers/posts.rb
|
145
|
+
- fixtures/padrino_test/app/controllers/users.rb
|
146
|
+
- fixtures/padrino_test/app/helpers/posts_helper.rb
|
147
|
+
- fixtures/padrino_test/app/helpers/users_helper.rb
|
148
|
+
- fixtures/padrino_test/config.ru
|
149
|
+
- fixtures/padrino_test/config/apps.rb
|
150
|
+
- fixtures/padrino_test/config/boot.rb
|
151
|
+
- fixtures/padrino_test/config/database.rb
|
152
|
+
- fixtures/padrino_test/db/schema.rb
|
153
|
+
- fixtures/padrino_test/public/favicon.ico
|
154
|
+
- fixtures/padrino_test/test/app/controllers/posts_controller_test.rb
|
155
|
+
- fixtures/padrino_test/test/app/controllers/users_controller_test.rb
|
156
|
+
- fixtures/padrino_test/test/test.rake
|
157
|
+
- fixtures/padrino_test/test/test_config.rb
|
158
|
+
- fixtures/rails2/.gitignore
|
159
|
+
- fixtures/rails2/Gemfile
|
160
|
+
- fixtures/rails2/Rakefile
|
161
|
+
- fixtures/rails2/app/controllers/application_controller.rb
|
162
|
+
- fixtures/rails2/app/controllers/posts_controller.rb
|
163
|
+
- fixtures/rails2/app/controllers/users_controller.rb
|
164
|
+
- fixtures/rails2/config/boot.rb
|
165
|
+
- fixtures/rails2/config/database.yml
|
166
|
+
- fixtures/rails2/config/environment.rb
|
167
|
+
- fixtures/rails2/config/environments/development.rb
|
168
|
+
- fixtures/rails2/config/environments/production.rb
|
169
|
+
- fixtures/rails2/config/environments/test.rb
|
170
|
+
- fixtures/rails2/config/initializers/backtrace_silencers.rb
|
171
|
+
- fixtures/rails2/config/initializers/cookie_verification_secret.rb
|
172
|
+
- fixtures/rails2/config/initializers/inflections.rb
|
173
|
+
- fixtures/rails2/config/initializers/mime_types.rb
|
174
|
+
- fixtures/rails2/config/initializers/new_rails_defaults.rb
|
175
|
+
- fixtures/rails2/config/initializers/session_store.rb
|
176
|
+
- fixtures/rails2/config/locales/en.yml
|
177
|
+
- fixtures/rails2/config/preinitializer.rb
|
178
|
+
- fixtures/rails2/config/routes.rb
|
179
|
+
- fixtures/rails2/db/schema.rb
|
180
|
+
- fixtures/rails2/db/seeds.rb
|
181
|
+
- fixtures/rails2/public/404.html
|
182
|
+
- fixtures/rails2/public/422.html
|
183
|
+
- fixtures/rails2/public/500.html
|
184
|
+
- fixtures/rails2/public/favicon.ico
|
185
|
+
- fixtures/rails2/public/images/rails.png
|
186
|
+
- fixtures/rails2/public/index.html
|
187
|
+
- fixtures/rails2/public/robots.txt
|
188
|
+
- fixtures/rails2/script/about
|
189
|
+
- fixtures/rails2/script/console
|
190
|
+
- fixtures/rails2/script/dbconsole
|
191
|
+
- fixtures/rails2/script/destroy
|
192
|
+
- fixtures/rails2/script/generate
|
193
|
+
- fixtures/rails2/script/performance/benchmarker
|
194
|
+
- fixtures/rails2/script/performance/profiler
|
195
|
+
- fixtures/rails2/script/plugin
|
196
|
+
- fixtures/rails2/script/runner
|
197
|
+
- fixtures/rails2/script/server
|
198
|
+
- fixtures/rails2/test/functionals/posts_controller_test.rb
|
199
|
+
- fixtures/rails2/test/functionals/users_controller_test.rb
|
200
|
+
- fixtures/rails2/test/test_helper.rb
|
201
|
+
- fixtures/rails3/.gitignore
|
202
|
+
- fixtures/rails3/Gemfile
|
203
|
+
- fixtures/rails3/Rakefile
|
204
|
+
- fixtures/rails3/app/controllers/application_controller.rb
|
205
|
+
- fixtures/rails3/app/controllers/posts_controller.rb
|
206
|
+
- fixtures/rails3/app/controllers/users_controller.rb
|
207
|
+
- fixtures/rails3/config.ru
|
208
|
+
- fixtures/rails3/config/application.rb
|
209
|
+
- fixtures/rails3/config/boot.rb
|
210
|
+
- fixtures/rails3/config/database.yml
|
211
|
+
- fixtures/rails3/config/environment.rb
|
212
|
+
- fixtures/rails3/config/environments/development.rb
|
213
|
+
- fixtures/rails3/config/environments/production.rb
|
214
|
+
- fixtures/rails3/config/environments/test.rb
|
215
|
+
- fixtures/rails3/config/initializers/backtrace_silencers.rb
|
216
|
+
- fixtures/rails3/config/initializers/inflections.rb
|
217
|
+
- fixtures/rails3/config/initializers/mime_types.rb
|
218
|
+
- fixtures/rails3/config/initializers/secret_token.rb
|
219
|
+
- fixtures/rails3/config/initializers/session_store.rb
|
220
|
+
- fixtures/rails3/config/locales/en.yml
|
221
|
+
- fixtures/rails3/config/routes.rb
|
222
|
+
- fixtures/rails3/db/seeds.rb
|
223
|
+
- fixtures/rails3/lib/tasks/.gitkeep
|
224
|
+
- fixtures/rails3/public/404.html
|
225
|
+
- fixtures/rails3/public/422.html
|
226
|
+
- fixtures/rails3/public/500.html
|
227
|
+
- fixtures/rails3/public/favicon.ico
|
228
|
+
- fixtures/rails3/public/images/rails.png
|
229
|
+
- fixtures/rails3/public/index.html
|
230
|
+
- fixtures/rails3/public/robots.txt
|
231
|
+
- fixtures/rails3/public/stylesheets/.gitkeep
|
232
|
+
- fixtures/rails3/script/rails
|
233
|
+
- fixtures/rails3/test/functional/posts_controller_test.rb
|
234
|
+
- fixtures/rails3/test/functional/users_controller_test.rb
|
235
|
+
- fixtures/rails3/test/test_helper.rb
|
236
|
+
- fixtures/sinatra_test/Gemfile
|
237
|
+
- fixtures/sinatra_test/Rakefile
|
238
|
+
- fixtures/sinatra_test/app.rb
|
239
|
+
- fixtures/sinatra_test/config.ru
|
240
|
+
- fixtures/sinatra_test/test/functional/posts_controller_test.rb
|
241
|
+
- fixtures/sinatra_test/test/functional/users_controller_test.rb
|
242
|
+
- fixtures/sinatra_test/test/test_helper.rb
|
111
243
|
- lib/rabl.rb
|
112
244
|
- lib/rabl/builder.rb
|
113
245
|
- lib/rabl/configuration.rb
|
@@ -121,7 +253,14 @@ files:
|
|
121
253
|
- test/builder_test.rb
|
122
254
|
- test/configuration_test.rb
|
123
255
|
- test/engine_test.rb
|
256
|
+
- test/helpers_test.rb
|
257
|
+
- test/integration/posts_controller_test.rb
|
258
|
+
- test/integration/test_init.rb
|
259
|
+
- test/integration/users_controller_test.rb
|
260
|
+
- test/models/ormless.rb
|
124
261
|
- test/models/user.rb
|
262
|
+
- test/msgpack_engine_test.rb
|
263
|
+
- test/silence.rb
|
125
264
|
- test/template_test.rb
|
126
265
|
- test/teststrap.rb
|
127
266
|
homepage: https://github.com/nesquena/rabl
|
@@ -147,7 +286,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
286
|
requirements: []
|
148
287
|
|
149
288
|
rubyforge_project: rabl
|
150
|
-
rubygems_version: 1.
|
289
|
+
rubygems_version: 1.8.10
|
151
290
|
signing_key:
|
152
291
|
specification_version: 3
|
153
292
|
summary: General ruby templating for json or xml
|
@@ -155,6 +294,13 @@ test_files:
|
|
155
294
|
- test/builder_test.rb
|
156
295
|
- test/configuration_test.rb
|
157
296
|
- test/engine_test.rb
|
297
|
+
- test/helpers_test.rb
|
298
|
+
- test/integration/posts_controller_test.rb
|
299
|
+
- test/integration/test_init.rb
|
300
|
+
- test/integration/users_controller_test.rb
|
301
|
+
- test/models/ormless.rb
|
158
302
|
- test/models/user.rb
|
303
|
+
- test/msgpack_engine_test.rb
|
304
|
+
- test/silence.rb
|
159
305
|
- test/template_test.rb
|
160
306
|
- test/teststrap.rb
|