Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

1.8.7 fixes

  • Loading branch information...
commit 5f4c8e729322d212415f93322d3912f93fa2f034 1 parent ebf10aa
@joshbuddy authored
View
4 lib/data_bindings.rb
@@ -28,6 +28,10 @@ def method_missing(m, *args, &blk)
DefaultGeneratorInstance.send(m, *args, &blk)
end
+ def type(name, &blk)
+ DefaultGeneratorInstance.type(name, &blk)
+ end
+
def true_boolean?(el)
el == true or el == 'true' or el == 1 or el == '1' or el == 'yes'
end
View
2  lib/data_bindings/adapters/tnetstring.rb
@@ -22,7 +22,7 @@ module Convert
# @param [Array, Hash] obj The object to be represented in JSON
# @return [String] The Tnetstring representation of this object
def force_convert_to_tnetstring
- ::TNetstring.dump(self)
+ ::TNetstring.dump(self.to_hash)
end
gentle_require_gem :force_convert_to_tnetstring, 'tnetstring'
standard_converter :convert_to_tnetstring
View
2  lib/data_bindings/adapters/yaml.rb
@@ -17,7 +17,7 @@ module Convert
include ConverterHelper
def force_convert_to_yaml
- ::YAML::dump(self.to_hash)
+ ::YAML::dump(self.to_nonindifferent_hash)
end
standard_converter :convert_to_yaml
end
View
8 lib/data_bindings/bound.rb
@@ -178,6 +178,14 @@ def to_hash
}
end
+ def to_nonindifferent_hash
+ keys.inject({}) { |h, k|
+ val = self[k]
+ h[k.to_s] = dump_val(val)
+ h
+ }
+ end
+
def to_native
valid!
data = inject(IndifferentHash.new) { |h, (k, v)|
View
2  test/tnetstring_test.rb
@@ -3,7 +3,7 @@
describe "Data Bindings tnetstring" do
describe "tnetstring parsing" do
it "should parse tnetstring" do
- a = DataBindings.from_tnetstring(TNetstring.dump(:author => 'siggy', :title => 'bible')).bind { property :author; property :title }
+ a = DataBindings.from_tnetstring(TNetstring.dump('author' => 'siggy', 'title' => 'bible')).bind { property :author; property :title }
assert a.valid?
assert_equal "siggy", a[:author]
end
View
3  test/xml_test.rb
@@ -13,7 +13,8 @@
it "should generate yaml" do
a = DataBindings.from_ruby('author' => 'siggy',"title" => 'koran').bind { property :author; property :title }
assert a.valid?
- assert_equal "<?xml version=\"1.0\" encoding=\"UTF-8\"?><doc><author>siggy</author><title>koran</title></doc>", a.convert_to_xml
+ assert ["<?xml version=\"1.0\" encoding=\"UTF-8\"?><doc><author>siggy</author><title>koran</title></doc>",
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><doc><title>koran</title><author>siggy</author></doc>"].include?(a.convert_to_xml)
end
end
end
View
2  test/yaml_test.rb
@@ -13,7 +13,7 @@
it "should generate yaml" do
a = DataBindings.from_ruby('author' => 'siggy',"title" => 'koran').bind { property :author; property :title }
assert a.valid?
- assert_match /--- ?\nauthor: siggy\ntitle: koran\n/, a.convert_to_yaml
+ assert_match /--- ?\nauthor: siggy\ntitle: koran\n|--- ?\ntitle: koran\nauthor: siggy\n/, a.convert_to_yaml
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.