jbuilder 2.0.0.beta → 2.0.0.beta2
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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/jbuilder.gemspec +1 -1
- data/lib/generators/rails/jbuilder_generator.rb +4 -0
- data/lib/jbuilder.rb +10 -9
- data/lib/jbuilder/jbuilder_template.rb +1 -1
- data/test/jbuilder_generator_test.rb +2 -2
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b0b628cdf50af7a4e659568d35ff32f8012c95f
|
4
|
+
data.tar.gz: b11afc7dbd0b7dde47149238490f8599dc0e1d80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1809fd60109a55c20893f0349837c809e83892d3b0e116a280b1cac9bf493c0902ad43ede7b5530b12daae854349ba03194056b0d3e3ae0b9803604ac6be461
|
7
|
+
data.tar.gz: aa8981b12fdf1783a9d9607d4320191c873b0cdd4de0038c90163bd88977ab82cbdbc32fb224187a5a3cd699762431fd422b23e34854420f6a8e84c97ec9a4a2
|
data/README.md
CHANGED
@@ -204,4 +204,4 @@ Libraries similar to this in some form or another include:
|
|
204
204
|
* JsonBuilder: https://github.com/nov/jsonbuilder
|
205
205
|
* JSON Builder: https://github.com/dewski/json_builder
|
206
206
|
* Jsonify: https://github.com/bsiggelkow/jsonify
|
207
|
-
*
|
207
|
+
* Representative View: https://github.com/mdub/representative_view
|
data/jbuilder.gemspec
CHANGED
data/lib/jbuilder.rb
CHANGED
@@ -273,6 +273,16 @@ class Jbuilder < JbuilderProxy
|
|
273
273
|
@attributes
|
274
274
|
end
|
275
275
|
|
276
|
+
# Merges hash or array into current builder.
|
277
|
+
def merge!(hash_or_array)
|
278
|
+
if ::Array === hash_or_array
|
279
|
+
@attributes = [] unless ::Array === @attributes
|
280
|
+
@attributes.concat hash_or_array
|
281
|
+
else
|
282
|
+
@attributes.update hash_or_array
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
276
286
|
# Encodes the current builder as JSON.
|
277
287
|
def target!
|
278
288
|
::MultiJson.dump(@attributes)
|
@@ -312,15 +322,6 @@ class Jbuilder < JbuilderProxy
|
|
312
322
|
@attributes, @key_formatter = parent_attributes, parent_formatter
|
313
323
|
end
|
314
324
|
|
315
|
-
def _merge(hash_or_array)
|
316
|
-
if ::Array === hash_or_array
|
317
|
-
@attributes = [] unless ::Array === @attributes
|
318
|
-
@attributes.concat hash_or_array
|
319
|
-
else
|
320
|
-
@attributes.update hash_or_array
|
321
|
-
end
|
322
|
-
end
|
323
|
-
|
324
325
|
def _mapable_arguments?(value, *args)
|
325
326
|
value.respond_to?(:map)
|
326
327
|
end
|
@@ -20,12 +20,12 @@ class JbuilderGeneratorTest < Rails::Generators::TestCase
|
|
20
20
|
|
21
21
|
assert_file 'app/views/posts/index.json.jbuilder' do |content|
|
22
22
|
assert_match /json\.array!\(@posts\) do \|post\|/, content
|
23
|
-
assert_match /json\.extract! post, :title, :body/, content
|
23
|
+
assert_match /json\.extract! post, :id, :title, :body/, content
|
24
24
|
assert_match /json\.url post_url\(post, format: :json\)/, content
|
25
25
|
end
|
26
26
|
|
27
27
|
assert_file 'app/views/posts/show.json.jbuilder' do |content|
|
28
|
-
assert_match /json\.extract! @post, :title, :body, :created_at, :updated_at/, content
|
28
|
+
assert_match /json\.extract! @post, :id, :title, :body, :created_at, :updated_at/, content
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jbuilder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -86,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
86
|
version: 1.3.1
|
87
87
|
requirements: []
|
88
88
|
rubyforge_project:
|
89
|
-
rubygems_version: 2.
|
89
|
+
rubygems_version: 2.0.14
|
90
90
|
signing_key:
|
91
91
|
specification_version: 4
|
92
92
|
summary: Create JSON structures via a Builder-style DSL
|
@@ -96,4 +96,3 @@ test_files:
|
|
96
96
|
- test/jbuilder_template_test.rb
|
97
97
|
- test/jbuilder_test.rb
|
98
98
|
- test/scaffold_controller_generator_test.rb
|
99
|
-
has_rdoc:
|