rabl 0.8.4 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -12,4 +12,5 @@ notifications:
12
12
  - databyte@gmail.com
13
13
  matrix:
14
14
  allow_failures:
15
+ - rvm: 1.8.7
15
16
  - rvm: 2.0.0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.8.5
4
+
5
+ * FIX #386 Support disabling root on child calls (Thanks @digger69)
6
+
3
7
  ## 0.8.4
4
8
 
5
9
  * NEW #411 Add "replace nil values with empty strings" option (Thanks @manuelmeurer)
data/Gemfile CHANGED
@@ -8,6 +8,7 @@ gem 'i18n', '~> 0.6'
8
8
 
9
9
  platforms :mri_18 do
10
10
  gem 'SystemTimer'
11
+ gem 'json'
11
12
  end
12
13
 
13
14
  group :test do
data/Gemfile.ci CHANGED
@@ -1,4 +1,4 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in rabl.gemspec
4
4
  gemspec
@@ -8,6 +8,7 @@ gem "i18n", '~> 0.6'
8
8
 
9
9
  platforms :mri_18 do
10
10
  gem 'SystemTimer'
11
+ gem 'json'
11
12
  end
12
13
 
13
14
  gem 'activesupport', :require => 'active_support'
data/lib/rabl/builder.rb CHANGED
@@ -100,7 +100,7 @@ module Rabl
100
100
  def child(data, options={}, &block)
101
101
  return false unless data.present? && resolve_condition(options)
102
102
  name, object = data_name(data), data_object(data)
103
- include_root = is_collection?(object) && @options[:child_root] # child @users
103
+ include_root = is_collection?(object) && options.fetch(:object_root, @options[:child_root]) # child @users
104
104
  engine_options = @options.slice(:child_root).merge(:root => include_root)
105
105
  object = { object => name } if data.respond_to?(:each_pair) && object # child :users => :people
106
106
  @_result[name] = self.object_to_hash(object, engine_options, &block)
data/lib/rabl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rabl
2
- VERSION = "0.8.4"
2
+ VERSION = "0.8.5"
3
3
  end
data/test/engine_test.rb CHANGED
@@ -280,6 +280,31 @@ context "Rabl::Engine" do
280
280
  scope.instance_variable_set :@user, User.new(:name => 'leo')
281
281
  template.render(scope)
282
282
  end.equals "{\"user\":{\"person\":{\"name\":\"leo\"}}}"
283
+
284
+ asserts "it sets root node for child collection" do
285
+ template = rabl %{
286
+ object @user
287
+ attribute :name
288
+ child(@users) { attribute :city }
289
+ }
290
+ scope = Object.new
291
+ scope.instance_variable_set :@user, User.new(:name => 'leo', :city => 'LA')
292
+ scope.instance_variable_set :@users, [User.new(:name => 'one', :city => 'UNO'), User.new(:name => 'two', :city => 'DOS')]
293
+ template.render(scope)
294
+ end.equals "{\"user\":{\"name\":\"leo\",\"users\":[{\"user\":{\"city\":\"UNO\"}},{\"user\":{\"city\":\"DOS\"}}]}}"
295
+
296
+ asserts "it allows suppression of root node for child collection" do
297
+ template = rabl %{
298
+ object @user
299
+ attribute :name
300
+ child(@users, :object_root => false) { attribute :city }
301
+ }
302
+ scope = Object.new
303
+ scope.instance_variable_set :@user, User.new(:name => 'leo', :city => 'LA')
304
+ scope.instance_variable_set :@users, [User.new(:name => 'one', :city => 'UNO'), User.new(:name => 'two', :city => 'DOS')]
305
+ template.render(scope)
306
+ end.equals "{\"user\":{\"name\":\"leo\",\"users\":[{\"city\":\"UNO\"},{\"city\":\"DOS\"}]}}"
307
+
283
308
  end
284
309
 
285
310
  context "#glue" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rabl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4
4
+ version: 0.8.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-23 00:00:00.000000000 Z
12
+ date: 2013-05-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -421,7 +421,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
421
421
  version: '0'
422
422
  segments:
423
423
  - 0
424
- hash: 501966820991429896
424
+ hash: -2073633213331132502
425
425
  required_rubygems_version: !ruby/object:Gem::Requirement
426
426
  none: false
427
427
  requirements:
@@ -430,7 +430,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
430
430
  version: '0'
431
431
  segments:
432
432
  - 0
433
- hash: 501966820991429896
433
+ hash: -2073633213331132502
434
434
  requirements: []
435
435
  rubyforge_project: rabl
436
436
  rubygems_version: 1.8.25