Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Don't call inspect on the extensions, return own string

  • Loading branch information...
commit 1cb778b0ef25ae179ea5c92685bc4bafc8771d3d 1 parent 7ed94c9
@dewski dewski authored
View
1  .rbenv-version
@@ -0,0 +1 @@
+1.8.7-p358
View
2  lib/json_builder.rb
@@ -5,4 +5,4 @@
module JSONBuilder
class InvalidArgument < StandardError; end
class MissingKeyError < StandardError; end
-end
+end
View
16 lib/json_builder/extensions.rb
@@ -2,19 +2,19 @@
class FalseClass
def to_builder
- inspect
+ 'false'
end
end
class TrueClass
def to_builder
- inspect
+ 'true'
end
end
class String
def to_builder
- inspect
+ "\"#{self}\""
end
end
@@ -33,33 +33,33 @@ def to_builder
module ActiveSupport
class TimeWithZone
def to_builder
- iso8601.inspect
+ "\"#{iso8601}\""
end
end
end
class Time
def to_builder
- iso8601.inspect
+ "\"#{iso8601}\""
end
end
class Date
def to_builder
- to_time.iso8601.inspect
+ "\"#{to_time.iso8601}\""
end
end
class DateTime
def to_builder
- to_time.iso8601.inspect
+ "\"#{to_time.iso8601}\""
end
end
module BSON
class ObjectId
def to_builder
- to_s.inspect
+ "\"#{self}\""
end
end
end
View
2  test/compiler_test.rb
@@ -91,7 +91,7 @@ def test_adding_hash_objects
def test_adding_unicoded_key
assert_builder_json('{"é": "json"}') do
- é "json"
+ key "é", "json"
end
end
end
View
2  test/elements_test.rb
@@ -18,4 +18,4 @@ def test_raises_invalid_argument
JSONBuilder::Elements.new(nil, false).to_s
}
end
-end
+end
View
4 test/member_test.rb
@@ -16,7 +16,7 @@ def test_key_as_symbol
end
def test_key_as_unicoded_symbol
- assert_equal '"hellyé": true', member(:hellyé, true).to_s
+ assert_equal '"hellyé": true', member('hellyé', true).to_s
end
def test_key_as_string
@@ -28,7 +28,7 @@ def test_value_as_array
end
def test_value_as_block
- assert_equal '"hello": "hi"', member('hello') { "hi" }.to_s
+ assert_equal '"hello": "hi"', member('hello') { 'hi' }.to_s
end
def test_value_as_block_with_hash
View
4 test/value_test.rb
@@ -7,10 +7,6 @@ def value(value)
JSONBuilder::Value.new(nil, value).to_s
end
- def test_is_a_builder_value
- assert_equal JSONBuilder::Value, JSONBuilder::Value.new(nil, true).class
- end
-
def test_positive_value
assert_equal '1', value(1)
end
Please sign in to comment.
Something went wrong with that request. Please try again.