rabl 0.6.13 → 0.6.14
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/.travis.yml +4 -2
- data/CHANGELOG.md +8 -1
- data/Gemfile +5 -1
- data/Gemfile.ci +12 -0
- data/README.md +4 -4
- data/fixtures/ashared/views_rails_3/posts/show.rabl +7 -1
- data/fixtures/rails2/app/helpers/application_helper.rb +2 -0
- data/fixtures/rails2/app/helpers/posts_helper.rb +2 -0
- data/fixtures/rails2/app/helpers/users_helper.rb +2 -0
- data/fixtures/rails3_2/Gemfile +2 -1
- data/fixtures/rails3_2/app/helpers/application_helper.rb +3 -0
- data/fixtures/rails3_2/test/functional/posts_controller_test.rb +4 -0
- data/lib/rabl/builder.rb +1 -1
- data/lib/rabl/template.rb +1 -6
- data/lib/rabl/version.rb +1 -1
- data/test/builder_test.rb +6 -0
- data/test/helpers_test.rb +1 -0
- data/test/integration/rails3_2/posts_controller_test.rb +4 -0
- data/test/partials_test.rb +1 -0
- data/test/renderer_test.rb +2 -0
- metadata +6 -2
data/.travis.yml
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
# http://about.travis-ci.org/docs/user/build-configuration/
|
2
|
-
before_script: "git submodule update --init"
|
3
2
|
rvm:
|
4
3
|
- 1.8.7
|
5
4
|
- 1.9.2
|
6
5
|
- 1.9.3
|
7
6
|
- rbx
|
7
|
+
gemfile: Gemfile.ci
|
8
8
|
notifications:
|
9
9
|
recipients:
|
10
|
-
- nesquena@gmail.com
|
10
|
+
- nesquena@gmail.com
|
11
|
+
- databyte@gmail.com
|
12
|
+
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,15 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 0.6.15 (unreleased)
|
4
|
+
|
5
|
+
## 0.6.14
|
6
|
+
|
7
|
+
* Fix RSpec under Rails 3, use render_views to test output (Thanks @agibralter)
|
8
|
+
* Fix extends allows passing in local object when root object is specified
|
9
|
+
|
3
10
|
## 0.6.13
|
4
11
|
|
5
|
-
* Small tweak to is_collection detection (look for each and map)
|
12
|
+
* Small tweak to is_collection detection (look for each and map)
|
6
13
|
* Adds `include_child_root` configuration option (Thanks @yoon)
|
7
14
|
|
8
15
|
## 0.6.12
|
data/Gemfile
CHANGED
data/Gemfile.ci
ADDED
data/README.md
CHANGED
@@ -100,7 +100,7 @@ RABL is intended to require little to no configuration to get working. This is t
|
|
100
100
|
Rabl.configure do |config|
|
101
101
|
# Commented as these are defaults
|
102
102
|
# config.cache_all_output = false
|
103
|
-
# config.cache_sources = false
|
103
|
+
# config.cache_sources = Rails.env != 'development' # Defaults to false
|
104
104
|
# config.escape_all_output = false
|
105
105
|
# config.json_engine = nil # Any multi\_json engines
|
106
106
|
# config.msgpack_engine = nil # Defaults to ::MessagePack
|
@@ -110,7 +110,7 @@ Rabl.configure do |config|
|
|
110
110
|
# config.include_msgpack_root = true
|
111
111
|
# config.include_bson_root = true
|
112
112
|
# config.include_plist_root = true
|
113
|
-
# config.include_xml_root = false
|
113
|
+
# config.include_xml_root = false
|
114
114
|
# config.include_child_root = true
|
115
115
|
# config.enable_json_callbacks = false
|
116
116
|
# config.xml_options = { :dasherize => true, :skip_types => false }
|
@@ -120,9 +120,9 @@ end
|
|
120
120
|
|
121
121
|
Each option specifies behavior related to RABL's output. If `include_json_root` is disabled that removes the
|
122
122
|
root node for each root object in the output, and `enable_json_callbacks` enables support for 'jsonp' style callback
|
123
|
-
output if the incoming request has a 'callback' parameter.
|
123
|
+
output if the incoming request has a 'callback' parameter.
|
124
124
|
|
125
|
-
If `include_child_root` is set to false then child objects in the response will not include
|
125
|
+
If `include_child_root` is set to false then child objects in the response will not include
|
126
126
|
a root node by default. This allows you to further fine-tune your desired response structure.
|
127
127
|
|
128
128
|
If `cache_sources` is set to `true`, template lookups will be cached for improved performance.
|
data/fixtures/rails3_2/Gemfile
CHANGED
@@ -132,6 +132,10 @@ context "PostsController" do
|
|
132
132
|
asserts("contains date partial with hour") { topic['hour'] }.equals { @post1.created_at.hour }
|
133
133
|
asserts("contains date partial with full") { topic['full'] }.equals { @post1.created_at.iso8601 }
|
134
134
|
end # date node
|
135
|
+
|
136
|
+
asserts("contains helper action") { topic["foo"] }.equals { "BAR!" }
|
137
|
+
|
138
|
+
asserts("contains post attributes via node") { topic["post"] }.equals { [@post1.title, @post1.body] }
|
135
139
|
end # show action, json
|
136
140
|
|
137
141
|
context "for index action rendering JSON within HTML" do
|
data/lib/rabl/builder.rb
CHANGED
@@ -108,7 +108,7 @@ module Rabl
|
|
108
108
|
# Extends an existing rabl template with additional attributes in the block
|
109
109
|
# extends("users/show") { attribute :full_name }
|
110
110
|
def extends(file, options={}, &block)
|
111
|
-
options = @options.slice(:child_root).merge(
|
111
|
+
options = @options.slice(:child_root).merge(:object => @_object).merge(options)
|
112
112
|
result = self.partial(file, options, &block)
|
113
113
|
@_result.merge!(result) if result
|
114
114
|
end
|
data/lib/rabl/template.rb
CHANGED
@@ -45,16 +45,11 @@ if defined?(ActionView) && defined?(Rails) && Rails.version =~ /^3/
|
|
45
45
|
module ActionView
|
46
46
|
module Template::Handlers
|
47
47
|
class Rabl
|
48
|
-
|
49
48
|
class_attribute :default_format
|
50
49
|
self.default_format = Mime::JSON
|
51
50
|
|
52
51
|
def self.call(template)
|
53
|
-
source =
|
54
|
-
File.read(template.identifier)
|
55
|
-
else # use source
|
56
|
-
template.source
|
57
|
-
end
|
52
|
+
source = template.source
|
58
53
|
|
59
54
|
%{ ::Rabl::Engine.new(#{source.inspect}).
|
60
55
|
render(self, assigns.merge(local_assigns)) }
|
data/lib/rabl/version.rb
CHANGED
data/test/builder_test.rb
CHANGED
@@ -140,5 +140,11 @@ context "Rabl::Builder" do
|
|
140
140
|
mock(b).partial('users/show', { :object => @user }).returns({:user => 'xyz'}).subject
|
141
141
|
b.build(@user)
|
142
142
|
end.equivalent_to({:user => 'xyz'})
|
143
|
+
|
144
|
+
asserts "that it generates if local data is present but object is false" do
|
145
|
+
b = builder :extends => [{ :file => 'users/show', :options => { :object => @user }, :block => lambda { |u| attribute :name }}]
|
146
|
+
mock(b).partial('users/show', { :object => @user }).returns({:user => 'xyz'}).subject
|
147
|
+
b.build(false)
|
148
|
+
end.equivalent_to({:user => 'xyz'})
|
143
149
|
end
|
144
150
|
end
|
data/test/helpers_test.rb
CHANGED
@@ -132,6 +132,10 @@ context "PostsController" do
|
|
132
132
|
asserts("contains date partial with hour") { topic['hour'] }.equals { @post1.created_at.hour }
|
133
133
|
asserts("contains date partial with full") { topic['full'] }.equals { @post1.created_at.iso8601 }
|
134
134
|
end # date node
|
135
|
+
|
136
|
+
asserts("contains helper action") { topic["foo"] }.equals { "BAR!" }
|
137
|
+
|
138
|
+
asserts("contains post attributes via node") { topic["post"] }.equals { [@post1.title, @post1.body] }
|
135
139
|
end # show action, json
|
136
140
|
|
137
141
|
context "for index action rendering JSON within HTML" do
|
data/test/partials_test.rb
CHANGED
data/test/renderer_test.rb
CHANGED
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.6.
|
4
|
+
version: 0.6.14
|
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: 2012-06-
|
12
|
+
date: 2012-06-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -182,6 +182,7 @@ files:
|
|
182
182
|
- .travis.yml
|
183
183
|
- CHANGELOG.md
|
184
184
|
- Gemfile
|
185
|
+
- Gemfile.ci
|
185
186
|
- MIT-LICENSE
|
186
187
|
- README.md
|
187
188
|
- Rakefile
|
@@ -240,6 +241,9 @@ files:
|
|
240
241
|
- fixtures/rails2/app/controllers/application_controller.rb
|
241
242
|
- fixtures/rails2/app/controllers/posts_controller.rb
|
242
243
|
- fixtures/rails2/app/controllers/users_controller.rb
|
244
|
+
- fixtures/rails2/app/helpers/application_helper.rb
|
245
|
+
- fixtures/rails2/app/helpers/posts_helper.rb
|
246
|
+
- fixtures/rails2/app/helpers/users_helper.rb
|
243
247
|
- fixtures/rails2/config/boot.rb
|
244
248
|
- fixtures/rails2/config/database.yml
|
245
249
|
- fixtures/rails2/config/environment.rb
|