rabl 0.14.4 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/CONTRIBUTING.md +1 -1
- data/README.md +4 -3
- data/lib/rabl/builder.rb +1 -0
- data/lib/rabl/digestor/rails3.rb +2 -0
- data/lib/rabl/digestor/rails41.rb +2 -0
- data/lib/rabl/digestor/rails5.rb +2 -0
- data/lib/rabl/digestor.rb +2 -0
- data/lib/rabl/engine.rb +12 -4
- data/lib/rabl/railtie.rb +1 -1
- data/lib/rabl/template.rb +2 -2
- data/lib/rabl/version.rb +1 -1
- data/lib/rabl.rb +3 -3
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91c470d38efde97412e3291ae2445165daecbd06410818ad0043c8398acff5c6
|
4
|
+
data.tar.gz: 6dd9d32a042987020e50a05d4e164ab6d616345e0696e2d411fc74acf0b65781
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ecb3137c900dcf729baec44e89e9d626d108f7ac3d6ae476c64586e26aaee6b27f0a3a08a0a7232f87fe243292802c0f3c96fc9d51fb8c1faa0df5608ff2627
|
7
|
+
data.tar.gz: 51f138ada14f33aa10ddddf10f488a8042d9fe43a5cf3e2ab472f1c8b7487e28034ebac9953c6c33de81586464e6610b430f3cdb90d92772c3b05152300e7dbd
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 0.16.0 (August 21, 2022)
|
4
|
+
|
5
|
+
* Add "except" option to `extends` (Thanks @perryqh)
|
6
|
+
* Fix `ArgumentError` when block given with keyword arguments (Thanks @kyoshidajp)
|
7
|
+
* Add Ruby 3.1 to the CI matrix (Thanks @petergoldstein)
|
8
|
+
* Document Rabl setting `oj`'s mode (Thanks @ghiculescu)
|
9
|
+
|
10
|
+
## 0.15.0 (December 30, 2021)
|
11
|
+
|
12
|
+
* Support for Rails 7 (@tagliala)
|
13
|
+
* Improvements to unit testing
|
14
|
+
* Miscellanious other bug fixes
|
15
|
+
|
16
|
+
## 0.14.5 (May 29th, 2021)
|
17
|
+
|
18
|
+
* Restrict and validate the `to_***` methods available within engine (Brian McFadden)
|
19
|
+
|
3
20
|
## 0.14.4 (April 1st, 2021)
|
4
21
|
|
5
22
|
* Test against latest Ruby versions
|
data/CONTRIBUTING.md
CHANGED
@@ -34,4 +34,4 @@ Syntax:
|
|
34
34
|
|
35
35
|
And in case we didn't emphasize it enough: we love tests!
|
36
36
|
|
37
|
-
NOTE: Adapted from https://raw.
|
37
|
+
NOTE: Adapted from https://raw.githubusercontent.com/thoughtbot/factory_bot_rails/main/CONTRIBUTING.md
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# RABL #
|
2
2
|
|
3
|
-
[![Continuous Integration status](https://
|
3
|
+
[![Continuous Integration status](https://github.com/nesquena/rabl/actions/workflows/ci.yml/badge.svg)](https://github.com/nesquena/rabl/actions)
|
4
4
|
[![Code Climate](https://codeclimate.com/github/nesquena/rabl.svg)](https://codeclimate.com/github/nesquena/rabl)
|
5
5
|
|
6
6
|
RABL (Ruby API Builder Language) is a Rails and [Padrino](http://padrinorb.com) ruby templating system for generating JSON, XML, MessagePack, PList and BSON.
|
@@ -51,6 +51,7 @@ or add to your Gemfile:
|
|
51
51
|
# Gemfile
|
52
52
|
gem 'rabl'
|
53
53
|
# Also add either `oj` or `yajl-ruby` as the JSON parser
|
54
|
+
# If using `oj`, Rabl will set the mode to :compat
|
54
55
|
gem 'oj'
|
55
56
|
```
|
56
57
|
|
@@ -184,9 +185,9 @@ If `replace_nil_values_with_empty_strings` is set to `true`, all values that are
|
|
184
185
|
|
185
186
|
If `exclude_nil_values` is set to `true`, all values that are `nil` and would normally be displayed as `null` in the response are not included in the response.
|
186
187
|
|
187
|
-
if `exclude_empty_values_in_collections` is set to `true`, all
|
188
|
+
if `exclude_empty_values_in_collections` is set to `true`, all values in a collection that are `{}` and would normally be displayed as `{}` in the response are not included in the response.
|
188
189
|
|
189
|
-
If `camelize_keys` is set to `true`, all object keys will be converted to camel case. By default the first character will be lower case. The value can be set to `:upper` to set the first
|
190
|
+
If `camelize_keys` is set to `true`, all object keys will be converted to camel case. By default the first character will be lower case. The value can be set to `:upper` to set the first character to upper case.
|
190
191
|
|
191
192
|
If you wish to use [oj](https://github.com/ohler55/oj) as
|
192
193
|
the primary JSON encoding engine simply add that to your Gemfile:
|
data/lib/rabl/builder.rb
CHANGED
@@ -153,6 +153,7 @@ module Rabl
|
|
153
153
|
# node(:foo, :if => lambda { |m| m.foo.present? }) { "bar" }
|
154
154
|
def node(name, options = {}, &block)
|
155
155
|
return unless resolve_condition(options)
|
156
|
+
return if @options.has_key?(:except) && [@options[:except]].flatten.include?(name)
|
156
157
|
|
157
158
|
result = block.call(@_object)
|
158
159
|
if name.present?
|
data/lib/rabl/digestor/rails3.rb
CHANGED
data/lib/rabl/digestor/rails5.rb
CHANGED
data/lib/rabl/digestor.rb
CHANGED
data/lib/rabl/engine.rb
CHANGED
@@ -6,6 +6,7 @@ module Rabl
|
|
6
6
|
|
7
7
|
# List of supported rendering formats
|
8
8
|
FORMATS = [:json, :xml, :plist, :bson, :msgpack]
|
9
|
+
SAFE_FORMATS = FORMATS + [:mpac, :dumpable, :hash]
|
9
10
|
|
10
11
|
# Constructs a new ejs engine based on given vars, handler and declarations
|
11
12
|
# Rabl::Engine.new("...source...", { :format => "xml", :root => true, :view_path => "/path/to/views" })
|
@@ -61,7 +62,7 @@ module Rabl
|
|
61
62
|
template = @_options[:template] || @virtual_path
|
62
63
|
|
63
64
|
digest =
|
64
|
-
if Rails.version.to_s =~ /^[
|
65
|
+
if Rails.version.to_s =~ /^[67]/
|
65
66
|
Digestor.digest(name: template, finder: lookup_context, format: :rabl)
|
66
67
|
elsif Gem::Version.new(Rails.version) >= Gem::Version.new('4.1')
|
67
68
|
Digestor.digest(:name => template, :finder => lookup_context)
|
@@ -355,8 +356,8 @@ module Rabl
|
|
355
356
|
end
|
356
357
|
|
357
358
|
# Supports calling helpers defined for the template context_scope using method_missing hook
|
358
|
-
def method_missing(name, *args, &block)
|
359
|
-
context_scope.respond_to?(name, true) ? context_scope.__send__(name, *args, &block) : super
|
359
|
+
def method_missing(name, *args, **kwargs, &block)
|
360
|
+
context_scope.respond_to?(name, true) ? context_scope.__send__(name, *args, **kwargs, &block) : super
|
360
361
|
end
|
361
362
|
|
362
363
|
def copy_instance_variables_from(object, exclude = []) #:nodoc:
|
@@ -392,7 +393,11 @@ module Rabl
|
|
392
393
|
end
|
393
394
|
|
394
395
|
def digestor_available?
|
395
|
-
defined?(Rails) && Rails.version =~ /^[
|
396
|
+
defined?(Rails) && Rails.version =~ /^[4567]/
|
397
|
+
end
|
398
|
+
|
399
|
+
def valid_format?(format)
|
400
|
+
SAFE_FORMATS.include?(format.to_sym) && respond_to?("to_#{format}")
|
396
401
|
end
|
397
402
|
|
398
403
|
def set_instance_variables!(context_scope, locals)
|
@@ -403,6 +408,9 @@ module Rabl
|
|
403
408
|
|
404
409
|
@_options[:format] ||= request_format
|
405
410
|
|
411
|
+
# Prevent calls to inherited methods `to_yaml`, `to_enum`, etc.
|
412
|
+
@_options[:format] = 'json' unless valid_format?(@_options[:format])
|
413
|
+
|
406
414
|
set_locals(@_locals)
|
407
415
|
end
|
408
416
|
|
data/lib/rabl/railtie.rb
CHANGED
@@ -22,7 +22,7 @@ module Rabl
|
|
22
22
|
Rabl.register!
|
23
23
|
|
24
24
|
# Inject dependency tracker for :rabl
|
25
|
-
if Rails.version =~ /^[
|
25
|
+
if Rails.version =~ /^[4567]/
|
26
26
|
require 'action_view/dependency_tracker'
|
27
27
|
ActionView::DependencyTracker.register_tracker :rabl, Rabl::Tracker
|
28
28
|
end
|
data/lib/rabl/template.rb
CHANGED
@@ -62,8 +62,8 @@ if defined?(ActionView) && defined?(Rails) && Rails.respond_to?(:version) && Rai
|
|
62
62
|
ActionView::Template.register_template_handler :rabl, ActionView::Template::Handlers::Rabl
|
63
63
|
end
|
64
64
|
|
65
|
-
# Rails 6.X Template
|
66
|
-
if defined?(ActionView) && defined?(Rails) && Rails.respond_to?(:version) && Rails.version.to_s =~ /^[
|
65
|
+
# Rails 6.X / 7.X Template
|
66
|
+
if defined?(ActionView) && defined?(Rails) && Rails.respond_to?(:version) && Rails.version.to_s =~ /^[67]/
|
67
67
|
module ActionView
|
68
68
|
module Template::Handlers
|
69
69
|
class Rabl
|
data/lib/rabl/version.rb
CHANGED
data/lib/rabl.rb
CHANGED
@@ -17,9 +17,9 @@ require 'rabl/renderer'
|
|
17
17
|
require 'rabl/cache_engine'
|
18
18
|
|
19
19
|
if defined?(Rails) && Rails.respond_to?(:version)
|
20
|
-
require 'rabl/tracker' if Rails.version =~ /^[
|
21
|
-
require 'rabl/digestor' if Rails.version =~ /^[
|
22
|
-
require 'rabl/railtie' if Rails.version =~ /^[
|
20
|
+
require 'rabl/tracker' if Rails.version =~ /^[4567]/
|
21
|
+
require 'rabl/digestor' if Rails.version =~ /^[4567]/
|
22
|
+
require 'rabl/railtie' if Rails.version =~ /^[34567]/
|
23
23
|
end
|
24
24
|
|
25
25
|
# Rabl.register!
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rabl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Esquenazi
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: rr
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -169,7 +169,7 @@ homepage: https://github.com/nesquena/rabl
|
|
169
169
|
licenses:
|
170
170
|
- MIT
|
171
171
|
metadata: {}
|
172
|
-
post_install_message:
|
172
|
+
post_install_message:
|
173
173
|
rdoc_options: []
|
174
174
|
require_paths:
|
175
175
|
- lib
|
@@ -185,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
185
|
version: '0'
|
186
186
|
requirements: []
|
187
187
|
rubygems_version: 3.0.6
|
188
|
-
signing_key:
|
188
|
+
signing_key:
|
189
189
|
specification_version: 4
|
190
190
|
summary: General ruby templating with json, bson, xml and msgpack support
|
191
191
|
test_files: []
|