scout 5.7.3.pre.2 → 5.7.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. data/CHANGELOG.markdown +4 -0
  2. data/lib/scout/version.rb +1 -1
  3. data/vendor/json_pure/.gitignore +12 -0
  4. data/vendor/json_pure/.travis.yml +20 -0
  5. data/vendor/json_pure/CHANGES +282 -0
  6. data/vendor/json_pure/COPYING +58 -0
  7. data/vendor/json_pure/COPYING-json-jruby +57 -0
  8. data/vendor/json_pure/GPL +340 -0
  9. data/vendor/json_pure/Gemfile +11 -0
  10. data/vendor/json_pure/README-json-jruby.markdown +33 -0
  11. data/vendor/json_pure/README.rdoc +358 -0
  12. data/vendor/json_pure/Rakefile +412 -0
  13. data/vendor/json_pure/TODO +1 -0
  14. data/vendor/json_pure/VERSION +1 -0
  15. data/vendor/json_pure/data/example.json +1 -0
  16. data/vendor/json_pure/data/index.html +38 -0
  17. data/vendor/json_pure/data/prototype.js +4184 -0
  18. data/vendor/json_pure/diagrams/.keep +0 -0
  19. data/vendor/json_pure/ext/json/ext/fbuffer/fbuffer.h +181 -0
  20. data/vendor/json_pure/ext/json/ext/generator/depend +1 -0
  21. data/vendor/json_pure/ext/json/ext/generator/extconf.rb +14 -0
  22. data/vendor/json_pure/ext/json/ext/generator/generator.c +1435 -0
  23. data/vendor/json_pure/ext/json/ext/generator/generator.h +148 -0
  24. data/vendor/json_pure/ext/json/ext/parser/depend +1 -0
  25. data/vendor/json_pure/ext/json/ext/parser/extconf.rb +13 -0
  26. data/vendor/json_pure/ext/json/ext/parser/parser.c +2204 -0
  27. data/vendor/json_pure/ext/json/ext/parser/parser.h +77 -0
  28. data/vendor/json_pure/ext/json/ext/parser/parser.rl +927 -0
  29. data/vendor/json_pure/install.rb +23 -0
  30. data/vendor/json_pure/java/src/json/ext/ByteListTranscoder.java +167 -0
  31. data/vendor/json_pure/java/src/json/ext/Generator.java +444 -0
  32. data/vendor/json_pure/java/src/json/ext/GeneratorMethods.java +232 -0
  33. data/vendor/json_pure/java/src/json/ext/GeneratorService.java +43 -0
  34. data/vendor/json_pure/java/src/json/ext/GeneratorState.java +543 -0
  35. data/vendor/json_pure/java/src/json/ext/OptionsReader.java +114 -0
  36. data/vendor/json_pure/java/src/json/ext/Parser.java +2644 -0
  37. data/vendor/json_pure/java/src/json/ext/Parser.rl +968 -0
  38. data/vendor/json_pure/java/src/json/ext/ParserService.java +35 -0
  39. data/vendor/json_pure/java/src/json/ext/RuntimeInfo.java +121 -0
  40. data/vendor/json_pure/java/src/json/ext/StringDecoder.java +167 -0
  41. data/vendor/json_pure/java/src/json/ext/StringEncoder.java +106 -0
  42. data/vendor/json_pure/java/src/json/ext/Utils.java +89 -0
  43. data/vendor/json_pure/json-java.gemspec +23 -0
  44. data/vendor/json_pure/json.gemspec +37 -0
  45. data/vendor/json_pure/json_pure.gemspec +39 -0
  46. data/vendor/json_pure/lib/json.rb +62 -0
  47. data/vendor/json_pure/lib/json/add/bigdecimal.rb +28 -0
  48. data/vendor/json_pure/lib/json/add/complex.rb +22 -0
  49. data/vendor/json_pure/lib/json/add/core.rb +11 -0
  50. data/vendor/json_pure/lib/json/add/date.rb +34 -0
  51. data/vendor/json_pure/lib/json/add/date_time.rb +50 -0
  52. data/vendor/json_pure/lib/json/add/exception.rb +31 -0
  53. data/vendor/json_pure/lib/json/add/ostruct.rb +31 -0
  54. data/vendor/json_pure/lib/json/add/range.rb +29 -0
  55. data/vendor/json_pure/lib/json/add/rational.rb +22 -0
  56. data/vendor/json_pure/lib/json/add/regexp.rb +30 -0
  57. data/vendor/json_pure/lib/json/add/struct.rb +30 -0
  58. data/vendor/json_pure/lib/json/add/symbol.rb +25 -0
  59. data/vendor/json_pure/lib/json/add/time.rb +38 -0
  60. data/vendor/json_pure/lib/json/common.rb +487 -0
  61. data/vendor/json_pure/lib/json/ext.rb +21 -0
  62. data/vendor/json_pure/lib/json/ext/.keep +0 -0
  63. data/vendor/json_pure/lib/json/generic_object.rb +70 -0
  64. data/vendor/json_pure/lib/json/pure.rb +21 -0
  65. data/vendor/json_pure/lib/json/pure/generator.rb +522 -0
  66. data/vendor/json_pure/lib/json/pure/parser.rb +359 -0
  67. data/vendor/json_pure/lib/json/version.rb +8 -0
  68. data/vendor/json_pure/tests/fixtures/fail1.json +1 -0
  69. data/vendor/json_pure/tests/fixtures/fail10.json +1 -0
  70. data/vendor/json_pure/tests/fixtures/fail11.json +1 -0
  71. data/vendor/json_pure/tests/fixtures/fail12.json +1 -0
  72. data/vendor/json_pure/tests/fixtures/fail13.json +1 -0
  73. data/vendor/json_pure/tests/fixtures/fail14.json +1 -0
  74. data/vendor/json_pure/tests/fixtures/fail18.json +1 -0
  75. data/vendor/json_pure/tests/fixtures/fail19.json +1 -0
  76. data/vendor/json_pure/tests/fixtures/fail2.json +1 -0
  77. data/vendor/json_pure/tests/fixtures/fail20.json +1 -0
  78. data/vendor/json_pure/tests/fixtures/fail21.json +1 -0
  79. data/vendor/json_pure/tests/fixtures/fail22.json +1 -0
  80. data/vendor/json_pure/tests/fixtures/fail23.json +1 -0
  81. data/vendor/json_pure/tests/fixtures/fail24.json +1 -0
  82. data/vendor/json_pure/tests/fixtures/fail25.json +1 -0
  83. data/vendor/json_pure/tests/fixtures/fail27.json +2 -0
  84. data/vendor/json_pure/tests/fixtures/fail28.json +2 -0
  85. data/vendor/json_pure/tests/fixtures/fail3.json +1 -0
  86. data/vendor/json_pure/tests/fixtures/fail4.json +1 -0
  87. data/vendor/json_pure/tests/fixtures/fail5.json +1 -0
  88. data/vendor/json_pure/tests/fixtures/fail6.json +1 -0
  89. data/vendor/json_pure/tests/fixtures/fail7.json +1 -0
  90. data/vendor/json_pure/tests/fixtures/fail8.json +1 -0
  91. data/vendor/json_pure/tests/fixtures/fail9.json +1 -0
  92. data/vendor/json_pure/tests/fixtures/pass1.json +56 -0
  93. data/vendor/json_pure/tests/fixtures/pass15.json +1 -0
  94. data/vendor/json_pure/tests/fixtures/pass16.json +1 -0
  95. data/vendor/json_pure/tests/fixtures/pass17.json +1 -0
  96. data/vendor/json_pure/tests/fixtures/pass2.json +1 -0
  97. data/vendor/json_pure/tests/fixtures/pass26.json +1 -0
  98. data/vendor/json_pure/tests/fixtures/pass3.json +6 -0
  99. data/vendor/json_pure/tests/setup_variant.rb +11 -0
  100. data/vendor/json_pure/tests/test_json.rb +545 -0
  101. data/vendor/json_pure/tests/test_json_addition.rb +196 -0
  102. data/vendor/json_pure/tests/test_json_encoding.rb +65 -0
  103. data/vendor/json_pure/tests/test_json_fixtures.rb +35 -0
  104. data/vendor/json_pure/tests/test_json_generate.rb +322 -0
  105. data/vendor/json_pure/tests/test_json_generic_object.rb +75 -0
  106. data/vendor/json_pure/tests/test_json_string_matching.rb +39 -0
  107. data/vendor/json_pure/tests/test_json_unicode.rb +72 -0
  108. data/vendor/json_pure/tools/fuzz.rb +139 -0
  109. data/vendor/json_pure/tools/server.rb +62 -0
  110. metadata +111 -4
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env jruby
2
+ require "rubygems"
3
+
4
+ spec = Gem::Specification.new do |s|
5
+ s.name = "json"
6
+ s.version = File.read("VERSION").chomp
7
+ s.summary = "JSON implementation for JRuby"
8
+ s.description = "A JSON implementation as a JRuby extension."
9
+ s.author = "Daniel Luz"
10
+ s.email = "dev+ruby@mernen.com"
11
+ s.homepage = "http://json-jruby.rubyforge.org/"
12
+ s.platform = 'java'
13
+ s.rubyforge_project = "json-jruby"
14
+ s.license = "Ruby"
15
+
16
+ s.files = Dir["{docs,lib,tests}/**/*"]
17
+ end
18
+
19
+ if $0 == __FILE__
20
+ Gem::Builder.new(spec).build
21
+ else
22
+ spec
23
+ end
@@ -0,0 +1,37 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "json"
5
+ s.version = "1.8.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Florian Frank"]
9
+ s.date = "2013-05-13"
10
+ s.description = "This is a JSON implementation as a Ruby extension in C."
11
+ s.email = "flori@ping.de"
12
+ s.extensions = ["ext/json/ext/generator/extconf.rb", "ext/json/ext/parser/extconf.rb"]
13
+ s.extra_rdoc_files = ["README.rdoc"]
14
+ s.files = [".gitignore", ".travis.yml", "CHANGES", "COPYING", "COPYING-json-jruby", "GPL", "Gemfile", "README-json-jruby.markdown", "README.rdoc", "Rakefile", "TODO", "VERSION", "data/example.json", "data/index.html", "data/prototype.js", "diagrams/.keep", "ext/json/ext/fbuffer/fbuffer.h", "ext/json/ext/generator/depend", "ext/json/ext/generator/extconf.rb", "ext/json/ext/generator/generator.c", "ext/json/ext/generator/generator.h", "ext/json/ext/parser/depend", "ext/json/ext/parser/extconf.rb", "ext/json/ext/parser/parser.c", "ext/json/ext/parser/parser.h", "ext/json/ext/parser/parser.rl", "install.rb", "java/src/json/ext/ByteListTranscoder.java", "java/src/json/ext/Generator.java", "java/src/json/ext/GeneratorMethods.java", "java/src/json/ext/GeneratorService.java", "java/src/json/ext/GeneratorState.java", "java/src/json/ext/OptionsReader.java", "java/src/json/ext/Parser.java", "java/src/json/ext/Parser.rl", "java/src/json/ext/ParserService.java", "java/src/json/ext/RuntimeInfo.java", "java/src/json/ext/StringDecoder.java", "java/src/json/ext/StringEncoder.java", "java/src/json/ext/Utils.java", "json-java.gemspec", "json.gemspec", "json_pure.gemspec", "lib/json.rb", "lib/json/add/bigdecimal.rb", "lib/json/add/complex.rb", "lib/json/add/core.rb", "lib/json/add/date.rb", "lib/json/add/date_time.rb", "lib/json/add/exception.rb", "lib/json/add/ostruct.rb", "lib/json/add/range.rb", "lib/json/add/rational.rb", "lib/json/add/regexp.rb", "lib/json/add/struct.rb", "lib/json/add/symbol.rb", "lib/json/add/time.rb", "lib/json/common.rb", "lib/json/ext.rb", "lib/json/ext/.keep", "lib/json/generic_object.rb", "lib/json/pure.rb", "lib/json/pure/generator.rb", "lib/json/pure/parser.rb", "lib/json/version.rb", "tests/fixtures/fail1.json", "tests/fixtures/fail10.json", "tests/fixtures/fail11.json", "tests/fixtures/fail12.json", "tests/fixtures/fail13.json", "tests/fixtures/fail14.json", "tests/fixtures/fail18.json", "tests/fixtures/fail19.json", "tests/fixtures/fail2.json", "tests/fixtures/fail20.json", "tests/fixtures/fail21.json", "tests/fixtures/fail22.json", "tests/fixtures/fail23.json", "tests/fixtures/fail24.json", "tests/fixtures/fail25.json", "tests/fixtures/fail27.json", "tests/fixtures/fail28.json", "tests/fixtures/fail3.json", "tests/fixtures/fail4.json", "tests/fixtures/fail5.json", "tests/fixtures/fail6.json", "tests/fixtures/fail7.json", "tests/fixtures/fail8.json", "tests/fixtures/fail9.json", "tests/fixtures/pass1.json", "tests/fixtures/pass15.json", "tests/fixtures/pass16.json", "tests/fixtures/pass17.json", "tests/fixtures/pass2.json", "tests/fixtures/pass26.json", "tests/fixtures/pass3.json", "tests/setup_variant.rb", "tests/test_json.rb", "tests/test_json_addition.rb", "tests/test_json_encoding.rb", "tests/test_json_fixtures.rb", "tests/test_json_generate.rb", "tests/test_json_generic_object.rb", "tests/test_json_string_matching.rb", "tests/test_json_unicode.rb", "tools/fuzz.rb", "tools/server.rb", "./tests/test_json.rb", "./tests/test_json_addition.rb", "./tests/test_json_encoding.rb", "./tests/test_json_fixtures.rb", "./tests/test_json_generate.rb", "./tests/test_json_generic_object.rb", "./tests/test_json_string_matching.rb", "./tests/test_json_unicode.rb"]
15
+ s.homepage = "http://flori.github.com/json"
16
+ s.licenses = ["Ruby"]
17
+ s.rdoc_options = ["--title", "JSON implemention for Ruby", "--main", "README.rdoc"]
18
+ s.require_paths = ["lib"]
19
+ s.rubygems_version = "2.0.3"
20
+ s.summary = "JSON Implementation for Ruby"
21
+ s.test_files = ["./tests/test_json.rb", "./tests/test_json_addition.rb", "./tests/test_json_encoding.rb", "./tests/test_json_fixtures.rb", "./tests/test_json_generate.rb", "./tests/test_json_generic_object.rb", "./tests/test_json_string_matching.rb", "./tests/test_json_unicode.rb"]
22
+
23
+ if s.respond_to? :specification_version then
24
+ s.specification_version = 4
25
+
26
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
27
+ s.add_development_dependency(%q<permutation>, [">= 0"])
28
+ s.add_development_dependency(%q<sdoc>, ["~> 0.3.16"]) if RUBY_VERSION > "1.8.6"
29
+ else
30
+ s.add_dependency(%q<permutation>, [">= 0"])
31
+ s.add_dependency(%q<sdoc>, ["~> 0.3.16"]) if RUBY_VERSION > "1.8.6"
32
+ end
33
+ else
34
+ s.add_dependency(%q<permutation>, [">= 0"])
35
+ s.add_dependency(%q<sdoc>, ["~> 0.3.16"]) if RUBY_VERSION > "1.8.6"
36
+ end
37
+ end
@@ -0,0 +1,39 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "json_pure"
5
+ s.version = "1.8.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Florian Frank"]
9
+ s.date = "2013-05-13"
10
+ s.description = "This is a JSON implementation in pure Ruby."
11
+ s.email = "flori@ping.de"
12
+ s.extra_rdoc_files = ["README.rdoc"]
13
+ s.files = [".gitignore", ".travis.yml", "CHANGES", "COPYING", "COPYING-json-jruby", "GPL", "Gemfile", "README-json-jruby.markdown", "README.rdoc", "Rakefile", "TODO", "VERSION", "data/example.json", "data/index.html", "data/prototype.js", "diagrams/.keep", "ext/json/ext/fbuffer/fbuffer.h", "ext/json/ext/generator/depend", "ext/json/ext/generator/extconf.rb", "ext/json/ext/generator/generator.c", "ext/json/ext/generator/generator.h", "ext/json/ext/parser/depend", "ext/json/ext/parser/extconf.rb", "ext/json/ext/parser/parser.c", "ext/json/ext/parser/parser.h", "ext/json/ext/parser/parser.rl", "install.rb", "java/src/json/ext/ByteListTranscoder.java", "java/src/json/ext/Generator.java", "java/src/json/ext/GeneratorMethods.java", "java/src/json/ext/GeneratorService.java", "java/src/json/ext/GeneratorState.java", "java/src/json/ext/OptionsReader.java", "java/src/json/ext/Parser.java", "java/src/json/ext/Parser.rl", "java/src/json/ext/ParserService.java", "java/src/json/ext/RuntimeInfo.java", "java/src/json/ext/StringDecoder.java", "java/src/json/ext/StringEncoder.java", "java/src/json/ext/Utils.java", "json-java.gemspec", "json.gemspec", "json_pure.gemspec", "lib/json.rb", "lib/json/add/bigdecimal.rb", "lib/json/add/complex.rb", "lib/json/add/core.rb", "lib/json/add/date.rb", "lib/json/add/date_time.rb", "lib/json/add/exception.rb", "lib/json/add/ostruct.rb", "lib/json/add/range.rb", "lib/json/add/rational.rb", "lib/json/add/regexp.rb", "lib/json/add/struct.rb", "lib/json/add/symbol.rb", "lib/json/add/time.rb", "lib/json/common.rb", "lib/json/ext.rb", "lib/json/ext/.keep", "lib/json/generic_object.rb", "lib/json/pure.rb", "lib/json/pure/generator.rb", "lib/json/pure/parser.rb", "lib/json/version.rb", "tests/fixtures/fail1.json", "tests/fixtures/fail10.json", "tests/fixtures/fail11.json", "tests/fixtures/fail12.json", "tests/fixtures/fail13.json", "tests/fixtures/fail14.json", "tests/fixtures/fail18.json", "tests/fixtures/fail19.json", "tests/fixtures/fail2.json", "tests/fixtures/fail20.json", "tests/fixtures/fail21.json", "tests/fixtures/fail22.json", "tests/fixtures/fail23.json", "tests/fixtures/fail24.json", "tests/fixtures/fail25.json", "tests/fixtures/fail27.json", "tests/fixtures/fail28.json", "tests/fixtures/fail3.json", "tests/fixtures/fail4.json", "tests/fixtures/fail5.json", "tests/fixtures/fail6.json", "tests/fixtures/fail7.json", "tests/fixtures/fail8.json", "tests/fixtures/fail9.json", "tests/fixtures/pass1.json", "tests/fixtures/pass15.json", "tests/fixtures/pass16.json", "tests/fixtures/pass17.json", "tests/fixtures/pass2.json", "tests/fixtures/pass26.json", "tests/fixtures/pass3.json", "tests/setup_variant.rb", "tests/test_json.rb", "tests/test_json_addition.rb", "tests/test_json_encoding.rb", "tests/test_json_fixtures.rb", "tests/test_json_generate.rb", "tests/test_json_generic_object.rb", "tests/test_json_string_matching.rb", "tests/test_json_unicode.rb", "tools/fuzz.rb", "tools/server.rb", "./tests/test_json.rb", "./tests/test_json_addition.rb", "./tests/test_json_encoding.rb", "./tests/test_json_fixtures.rb", "./tests/test_json_generate.rb", "./tests/test_json_generic_object.rb", "./tests/test_json_string_matching.rb", "./tests/test_json_unicode.rb"]
14
+ s.homepage = "http://flori.github.com/json"
15
+ s.licenses = ["Ruby"]
16
+ s.rdoc_options = ["--title", "JSON implemention for ruby", "--main", "README.rdoc"]
17
+ s.require_paths = ["lib"]
18
+ s.rubygems_version = "2.0.3"
19
+ s.summary = "JSON Implementation for Ruby"
20
+ s.test_files = ["./tests/test_json.rb", "./tests/test_json_addition.rb", "./tests/test_json_encoding.rb", "./tests/test_json_fixtures.rb", "./tests/test_json_generate.rb", "./tests/test_json_generic_object.rb", "./tests/test_json_string_matching.rb", "./tests/test_json_unicode.rb"]
21
+
22
+ if s.respond_to? :specification_version then
23
+ s.specification_version = 4
24
+
25
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
+ s.add_development_dependency(%q<permutation>, [">= 0"])
27
+ s.add_development_dependency(%q<sdoc>, ["~> 0.3.16"]) if RUBY_VERSION > "1.8.6"
28
+ s.add_development_dependency(%q<rake>, ["~> 0.9.2"])
29
+ else
30
+ s.add_dependency(%q<permutation>, [">= 0"])
31
+ s.add_dependency(%q<sdoc>, ["~> 0.3.16"]) if RUBY_VERSION > "1.8.6"
32
+ s.add_dependency(%q<rake>, ["~> 0.9.2"])
33
+ end
34
+ else
35
+ s.add_dependency(%q<permutation>, [">= 0"])
36
+ s.add_dependency(%q<sdoc>, ["~> 0.3.16"]) if RUBY_VERSION > "1.8.6"
37
+ s.add_dependency(%q<rake>, ["~> 0.9.2"])
38
+ end
39
+ end
@@ -0,0 +1,62 @@
1
+ require 'json/common'
2
+
3
+ ##
4
+ # = JavaScript Object Notation (JSON)
5
+ #
6
+ # JSON is a lightweight data-interchange format. It is easy for us
7
+ # humans to read and write. Plus, equally simple for machines to generate or parse.
8
+ # JSON is completely language agnostic, making it the ideal interchange format.
9
+ #
10
+ # Built on two universally available structures:
11
+ # 1. A collection of name/value pairs. Often referred to as an _object_, hash table, record, struct, keyed list, or associative array.
12
+ # 2. An ordered list of values. More commonly called an _array_, vector, sequence or list.
13
+ #
14
+ # To read more about JSON visit: http://json.org
15
+ #
16
+ # == Parsing JSON
17
+ #
18
+ # To parse a JSON string received by another application or generated within
19
+ # your existing application:
20
+ #
21
+ # require 'json'
22
+ #
23
+ # my_hash = JSON.parse('{"hello": "goodbye"}')
24
+ # puts my_hash["hello"] => "goodbye"
25
+ #
26
+ # Notice the extra quotes <tt>''</tt> around the hash notation. Ruby expects
27
+ # the argument to be a string and can't convert objects like a hash or array.
28
+ #
29
+ # Ruby converts your string into a hash
30
+ #
31
+ # == Generating JSON
32
+ #
33
+ # Creating a JSON string for communication or serialization is
34
+ # just as simple.
35
+ #
36
+ # require 'json'
37
+ #
38
+ # my_hash = {:hello => "goodbye"}
39
+ # puts JSON.generate(my_hash) => "{\"hello\":\"goodbye\"}"
40
+ #
41
+ # Or an alternative way:
42
+ #
43
+ # require 'json'
44
+ # puts {:hello => "goodbye"}.to_json => "{\"hello\":\"goodbye\"}"
45
+ #
46
+ # <tt>JSON.generate</tt> only allows objects or arrays to be converted
47
+ # to JSON syntax. <tt>to_json</tt>, however, accepts many Ruby classes
48
+ # even though it acts only as a method for serialization:
49
+ #
50
+ # require 'json'
51
+ #
52
+ # 1.to_json => "1"
53
+ #
54
+ module JSON
55
+ require 'json/version'
56
+
57
+ begin
58
+ require 'json/ext'
59
+ rescue LoadError
60
+ require 'json/pure'
61
+ end
62
+ end
@@ -0,0 +1,28 @@
1
+ unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
2
+ require 'json'
3
+ end
4
+ defined?(::BigDecimal) or require 'bigdecimal'
5
+
6
+ class BigDecimal
7
+ # Import a JSON Marshalled object.
8
+ #
9
+ # method used for JSON marshalling support.
10
+ def self.json_create(object)
11
+ BigDecimal._load object['b']
12
+ end
13
+
14
+ # Marshal the object to JSON.
15
+ #
16
+ # method used for JSON marshalling support.
17
+ def as_json(*)
18
+ {
19
+ JSON.create_id => self.class.name,
20
+ 'b' => _dump,
21
+ }
22
+ end
23
+
24
+ # return the JSON value
25
+ def to_json(*)
26
+ as_json.to_json
27
+ end
28
+ end
@@ -0,0 +1,22 @@
1
+ unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
2
+ require 'json'
3
+ end
4
+ defined?(::Complex) or require 'complex'
5
+
6
+ class Complex
7
+ def self.json_create(object)
8
+ Complex(object['r'], object['i'])
9
+ end
10
+
11
+ def as_json(*)
12
+ {
13
+ JSON.create_id => self.class.name,
14
+ 'r' => real,
15
+ 'i' => imag,
16
+ }
17
+ end
18
+
19
+ def to_json(*)
20
+ as_json.to_json
21
+ end
22
+ end
@@ -0,0 +1,11 @@
1
+ # This file requires the implementations of ruby core's custom objects for
2
+ # serialisation/deserialisation.
3
+
4
+ require 'json/add/date'
5
+ require 'json/add/date_time'
6
+ require 'json/add/exception'
7
+ require 'json/add/range'
8
+ require 'json/add/regexp'
9
+ require 'json/add/struct'
10
+ require 'json/add/symbol'
11
+ require 'json/add/time'
@@ -0,0 +1,34 @@
1
+ unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
2
+ require 'json'
3
+ end
4
+ require 'date'
5
+
6
+ # Date serialization/deserialization
7
+ class Date
8
+
9
+ # Deserializes JSON string by converting Julian year <tt>y</tt>, month
10
+ # <tt>m</tt>, day <tt>d</tt> and Day of Calendar Reform <tt>sg</tt> to Date.
11
+ def self.json_create(object)
12
+ civil(*object.values_at('y', 'm', 'd', 'sg'))
13
+ end
14
+
15
+ alias start sg unless method_defined?(:start)
16
+
17
+ # Returns a hash, that will be turned into a JSON object and represent this
18
+ # object.
19
+ def as_json(*)
20
+ {
21
+ JSON.create_id => self.class.name,
22
+ 'y' => year,
23
+ 'm' => month,
24
+ 'd' => day,
25
+ 'sg' => start,
26
+ }
27
+ end
28
+
29
+ # Stores class name (Date) with Julian year <tt>y</tt>, month <tt>m</tt>, day
30
+ # <tt>d</tt> and Day of Calendar Reform <tt>sg</tt> as JSON string
31
+ def to_json(*args)
32
+ as_json.to_json(*args)
33
+ end
34
+ end
@@ -0,0 +1,50 @@
1
+ unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
2
+ require 'json'
3
+ end
4
+ require 'date'
5
+
6
+ # DateTime serialization/deserialization
7
+ class DateTime
8
+
9
+ # Deserializes JSON string by converting year <tt>y</tt>, month <tt>m</tt>,
10
+ # day <tt>d</tt>, hour <tt>H</tt>, minute <tt>M</tt>, second <tt>S</tt>,
11
+ # offset <tt>of</tt> and Day of Calendar Reform <tt>sg</tt> to DateTime.
12
+ def self.json_create(object)
13
+ args = object.values_at('y', 'm', 'd', 'H', 'M', 'S')
14
+ of_a, of_b = object['of'].split('/')
15
+ if of_b and of_b != '0'
16
+ args << Rational(of_a.to_i, of_b.to_i)
17
+ else
18
+ args << of_a
19
+ end
20
+ args << object['sg']
21
+ civil(*args)
22
+ end
23
+
24
+ alias start sg unless method_defined?(:start)
25
+
26
+ # Returns a hash, that will be turned into a JSON object and represent this
27
+ # object.
28
+ def as_json(*)
29
+ {
30
+ JSON.create_id => self.class.name,
31
+ 'y' => year,
32
+ 'm' => month,
33
+ 'd' => day,
34
+ 'H' => hour,
35
+ 'M' => min,
36
+ 'S' => sec,
37
+ 'of' => offset.to_s,
38
+ 'sg' => start,
39
+ }
40
+ end
41
+
42
+ # Stores class name (DateTime) with Julian year <tt>y</tt>, month <tt>m</tt>,
43
+ # day <tt>d</tt>, hour <tt>H</tt>, minute <tt>M</tt>, second <tt>S</tt>,
44
+ # offset <tt>of</tt> and Day of Calendar Reform <tt>sg</tt> as JSON string
45
+ def to_json(*args)
46
+ as_json.to_json(*args)
47
+ end
48
+ end
49
+
50
+
@@ -0,0 +1,31 @@
1
+ unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
2
+ require 'json'
3
+ end
4
+
5
+ # Exception serialization/deserialization
6
+ class Exception
7
+
8
+ # Deserializes JSON string by constructing new Exception object with message
9
+ # <tt>m</tt> and backtrace <tt>b</tt> serialized with <tt>to_json</tt>
10
+ def self.json_create(object)
11
+ result = new(object['m'])
12
+ result.set_backtrace object['b']
13
+ result
14
+ end
15
+
16
+ # Returns a hash, that will be turned into a JSON object and represent this
17
+ # object.
18
+ def as_json(*)
19
+ {
20
+ JSON.create_id => self.class.name,
21
+ 'm' => message,
22
+ 'b' => backtrace,
23
+ }
24
+ end
25
+
26
+ # Stores class name (Exception) with message <tt>m</tt> and backtrace array
27
+ # <tt>b</tt> as JSON string
28
+ def to_json(*args)
29
+ as_json.to_json(*args)
30
+ end
31
+ end
@@ -0,0 +1,31 @@
1
+ unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
2
+ require 'json'
3
+ end
4
+ require 'ostruct'
5
+
6
+ # OpenStruct serialization/deserialization
7
+ class OpenStruct
8
+
9
+ # Deserializes JSON string by constructing new Struct object with values
10
+ # <tt>v</tt> serialized by <tt>to_json</tt>.
11
+ def self.json_create(object)
12
+ new(object['t'] || object[:t])
13
+ end
14
+
15
+ # Returns a hash, that will be turned into a JSON object and represent this
16
+ # object.
17
+ def as_json(*)
18
+ klass = self.class.name
19
+ klass.to_s.empty? and raise JSON::JSONError, "Only named structs are supported!"
20
+ {
21
+ JSON.create_id => klass,
22
+ 't' => table,
23
+ }
24
+ end
25
+
26
+ # Stores class name (OpenStruct) with this struct's values <tt>v</tt> as a
27
+ # JSON string.
28
+ def to_json(*args)
29
+ as_json.to_json(*args)
30
+ end
31
+ end
@@ -0,0 +1,29 @@
1
+ unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
2
+ require 'json'
3
+ end
4
+
5
+ # Range serialization/deserialization
6
+ class Range
7
+
8
+ # Deserializes JSON string by constructing new Range object with arguments
9
+ # <tt>a</tt> serialized by <tt>to_json</tt>.
10
+ def self.json_create(object)
11
+ new(*object['a'])
12
+ end
13
+
14
+ # Returns a hash, that will be turned into a JSON object and represent this
15
+ # object.
16
+ def as_json(*)
17
+ {
18
+ JSON.create_id => self.class.name,
19
+ 'a' => [ first, last, exclude_end? ]
20
+ }
21
+ end
22
+
23
+ # Stores class name (Range) with JSON array of arguments <tt>a</tt> which
24
+ # include <tt>first</tt> (integer), <tt>last</tt> (integer), and
25
+ # <tt>exclude_end?</tt> (boolean) as JSON string.
26
+ def to_json(*args)
27
+ as_json.to_json(*args)
28
+ end
29
+ end
@@ -0,0 +1,22 @@
1
+ unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
2
+ require 'json'
3
+ end
4
+ defined?(::Rational) or require 'rational'
5
+
6
+ class Rational
7
+ def self.json_create(object)
8
+ Rational(object['n'], object['d'])
9
+ end
10
+
11
+ def as_json(*)
12
+ {
13
+ JSON.create_id => self.class.name,
14
+ 'n' => numerator,
15
+ 'd' => denominator,
16
+ }
17
+ end
18
+
19
+ def to_json(*)
20
+ as_json.to_json
21
+ end
22
+ end
@@ -0,0 +1,30 @@
1
+ unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
2
+ require 'json'
3
+ end
4
+
5
+ # Regexp serialization/deserialization
6
+ class Regexp
7
+
8
+ # Deserializes JSON string by constructing new Regexp object with source
9
+ # <tt>s</tt> (Regexp or String) and options <tt>o</tt> serialized by
10
+ # <tt>to_json</tt>
11
+ def self.json_create(object)
12
+ new(object['s'], object['o'])
13
+ end
14
+
15
+ # Returns a hash, that will be turned into a JSON object and represent this
16
+ # object.
17
+ def as_json(*)
18
+ {
19
+ JSON.create_id => self.class.name,
20
+ 'o' => options,
21
+ 's' => source,
22
+ }
23
+ end
24
+
25
+ # Stores class name (Regexp) with options <tt>o</tt> and source <tt>s</tt>
26
+ # (Regexp or String) as JSON string
27
+ def to_json(*)
28
+ as_json.to_json
29
+ end
30
+ end