jsonbuilder 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -82,6 +82,7 @@ module Builder
82
82
 
83
83
  def _explore_key_and_args(key, *args)
84
84
  key = (args.first.is_a?(Symbol) ? "#{key}:#{args.shift}" : key.to_s).gsub(/[-:]/, "_").to_sym
85
+ args.reject! { |arg| arg.nil? }
85
86
  if args.size > 1 && !args[0].is_a?(Hash)
86
87
  args[0] = StackableHash.new.replace(@default_content_key => args[0])
87
88
  end
@@ -2,7 +2,7 @@ module JsonBuilder
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- REVISION = 0
5
+ REVISION = 1
6
6
  class << self
7
7
  def to_version
8
8
  "#{MAJOR}.#{MINOR}.#{REVISION}"
@@ -23,6 +23,24 @@ describe Builder::HashStructure do
23
23
  builder.target!.should == {:atom_name => "atom:name", :thr_in_reply_to => "thr:in-reply-to", :dc_creator => "dc:creator"}
24
24
  end
25
25
 
26
+ it "should support root attributes" do
27
+ builder = Builder::HashStructure.new
28
+ # XML :: <root><tag>value</tag></root>
29
+ builder.root(:id => 1) do
30
+ builder.tag "value"
31
+ end
32
+ builder.target!.should == {:id => 1, :tag => "value"}
33
+ end
34
+
35
+ it "should ignore nil attributes" do
36
+ builder = Builder::HashStructure.new
37
+ # XML :: <root><tag>value</tag></root>
38
+ builder.root(nil) do
39
+ builder.tag "value"
40
+ end
41
+ builder.target!.should == {:tag => "value"}
42
+ end
43
+
26
44
  it "should remove the root tag" do
27
45
  builder = Builder::HashStructure.new
28
46
  # XML :: <root><tag>value</tag></root>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonbuilder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - nov