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 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
@@ -16,4 +16,8 @@ group :test do
16
16
  gem 'activerecord', :require => "active_record"
17
17
  gem 'sqlite3'
18
18
  gem 'sinatra', '>= 1.2.0'
19
- end
19
+ end
20
+
21
+ group :development, :test do
22
+ gem 'debugger'
23
+ end
data/Gemfile.ci ADDED
@@ -0,0 +1,12 @@
1
+ source :rubygems
2
+
3
+ # Specify your gem's dependencies in rabl.gemspec
4
+ gemspec
5
+
6
+ gem "rake"
7
+ gem "i18n", '~> 0.6'
8
+
9
+ platforms :mri_18 do
10
+ gem 'SystemTimer'
11
+ end
12
+
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.
@@ -14,4 +14,10 @@ end
14
14
 
15
15
  code(:created_date) do |p|
16
16
  partial("posts/date", :object => p.created_at)
17
- end
17
+ end
18
+
19
+ node(:foo) { helper_foo }
20
+
21
+ node(:post) do |post|
22
+ [post.title, post.body]
23
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module PostsHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module UsersHelper
2
+ end
@@ -37,4 +37,5 @@ gem 'jquery-rails'
37
37
  # gem 'capistrano'
38
38
 
39
39
  # To use debugger
40
- # gem 'ruby-debug19', :require => 'ruby-debug'
40
+ gem 'debugger'
41
+
@@ -1,2 +1,5 @@
1
1
  module ApplicationHelper
2
+ def helper_foo
3
+ "BAR!"
4
+ end
2
5
  end
@@ -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(options).merge(:object => @_object)
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 = if template.source.empty?
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
@@ -1,3 +1,3 @@
1
1
  module Rabl
2
- VERSION = "0.6.13"
2
+ VERSION = "0.6.14"
3
3
  end
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
@@ -1,5 +1,6 @@
1
1
  require 'tmpdir'
2
2
  require 'pathname'
3
+ require File.expand_path('../teststrap', __FILE__)
3
4
  require File.expand_path('../../lib/rabl', __FILE__)
4
5
 
5
6
  class TestHelperMethods
@@ -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
@@ -1,5 +1,6 @@
1
1
  require 'tmpdir'
2
2
  require 'pathname'
3
+ require File.expand_path('../teststrap', __FILE__)
3
4
  require File.expand_path('../../lib/rabl', __FILE__)
4
5
 
5
6
  class TestPartial
@@ -1,5 +1,7 @@
1
1
  require 'tmpdir'
2
2
  require 'pathname'
3
+ require File.expand_path('../teststrap', __FILE__)
4
+ require File.expand_path('../../lib/rabl', __FILE__)
3
5
 
4
6
  context "Rabl::Renderer" do
5
7
  helper(:tmp_path) { @tmp_path ||= Pathname.new(Dir.mktmpdir) }
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.13
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-04 00:00:00.000000000 Z
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