gson 0.5.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. data/.gitignore +5 -0
  2. data/.rbenv-version +1 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE +201 -0
  5. data/README.md +104 -0
  6. data/Rakefile +22 -0
  7. data/benchmark/README.markdown +28 -0
  8. data/benchmark/benchmark.rb +97 -0
  9. data/benchmark/profile.rb +46 -0
  10. data/benchmark/subjects/item.json +1 -0
  11. data/benchmark/subjects/ohai.json +1216 -0
  12. data/benchmark/subjects/twitter_search.json +1 -0
  13. data/benchmark/subjects/twitter_stream.json +430 -0
  14. data/benchmark/subjects/unicode.json +1 -0
  15. data/ext/gson_ext/Decoder.java +222 -0
  16. data/ext/gson_ext/Encoder.java +181 -0
  17. data/ext/gson_ext/GsonExtService.java +50 -0
  18. data/gson.gemspec +38 -0
  19. data/lib/gson-2.2.2.jar +0 -0
  20. data/lib/gson.rb +33 -0
  21. data/lib/gson/version.rb +20 -0
  22. data/tasks/compile.rake +33 -0
  23. data/tasks/test.rake +25 -0
  24. data/tasks/util.rake +21 -0
  25. data/test/okjson/README.markdown +18 -0
  26. data/test/okjson/t/decode-bignum-e.json +1 -0
  27. data/test/okjson/t/decode-bignum-e.json.exp +1 -0
  28. data/test/okjson/t/decode-bignum.json +1 -0
  29. data/test/okjson/t/decode-bignum.json.exp +1 -0
  30. data/test/okjson/t/decode-invalid15.json +1 -0
  31. data/test/okjson/t/decode-invalid15.json.exp +1 -0
  32. data/test/okjson/t/decode-invalid16.json +1 -0
  33. data/test/okjson/t/decode-invalid16.json.exp +1 -0
  34. data/test/okjson/t/decode-invalid17.json +1 -0
  35. data/test/okjson/t/decode-invalid17.json.exp +1 -0
  36. data/test/okjson/t/decode-invalid25.json +1 -0
  37. data/test/okjson/t/decode-invalid25.json.exp +1 -0
  38. data/test/okjson/t/decode-invalid26.json +1 -0
  39. data/test/okjson/t/decode-invalid26.json.exp +1 -0
  40. data/test/okjson/t/decode-invalid27.json +2 -0
  41. data/test/okjson/t/decode-invalid27.json.exp +1 -0
  42. data/test/okjson/t/decode-invalid28.json +2 -0
  43. data/test/okjson/t/decode-invalid28.json.exp +1 -0
  44. data/test/okjson/t/encode-badutf8.rb +1 -0
  45. data/test/okjson/t/encode-badutf8.rb.exp +1 -0
  46. data/test/okjson/t/encode-bignum.json +1 -0
  47. data/test/okjson/t/encode-bignum.json.exp +1 -0
  48. data/test/okjson/t/encode-int.rb +1 -0
  49. data/test/okjson/t/encode-int.rb.exp +1 -0
  50. data/test/okjson/t/encode-obj.rb +1 -0
  51. data/test/okjson/t/encode-obj.rb.exp +1 -0
  52. data/test/okjson/t/encode-utf8.rb +1 -0
  53. data/test/okjson/t/encode-utf8.rb.exp +1 -0
  54. data/test/okjson/t/err-key.rb +1 -0
  55. data/test/okjson/t/err-naninf.rb +1 -0
  56. data/test/okjson/t/err-other.rb +1 -0
  57. data/test/okjson/t/err-root.rb +1 -0
  58. data/test/okjson/t/err-symbol.rb +1 -0
  59. data/test/okjson/t/invalid-key.json +1 -0
  60. data/test/okjson/t/invalid-uescape.json +1 -0
  61. data/test/okjson/t/invalid1.json +1 -0
  62. data/test/okjson/t/invalid10.json +1 -0
  63. data/test/okjson/t/invalid11.json +1 -0
  64. data/test/okjson/t/invalid12.json +1 -0
  65. data/test/okjson/t/invalid13.json +1 -0
  66. data/test/okjson/t/invalid14.json +1 -0
  67. data/test/okjson/t/invalid19.json +1 -0
  68. data/test/okjson/t/invalid2.json +1 -0
  69. data/test/okjson/t/invalid20.json +1 -0
  70. data/test/okjson/t/invalid21.json +1 -0
  71. data/test/okjson/t/invalid22.json +1 -0
  72. data/test/okjson/t/invalid23.json +1 -0
  73. data/test/okjson/t/invalid24.json +1 -0
  74. data/test/okjson/t/invalid3.json +1 -0
  75. data/test/okjson/t/invalid4.json +1 -0
  76. data/test/okjson/t/invalid5.json +1 -0
  77. data/test/okjson/t/invalid6.json +1 -0
  78. data/test/okjson/t/invalid7.json +1 -0
  79. data/test/okjson/t/invalid8.json +1 -0
  80. data/test/okjson/t/invalid9.json +1 -0
  81. data/test/okjson/t/valid-0.json +1 -0
  82. data/test/okjson/t/valid-0.json.exp +1 -0
  83. data/test/okjson/t/valid-1.json +1 -0
  84. data/test/okjson/t/valid-1.json.exp +1 -0
  85. data/test/okjson/t/valid-alnum.json +1 -0
  86. data/test/okjson/t/valid-alnum.json.exp +1 -0
  87. data/test/okjson/t/valid-array-deep.json +1 -0
  88. data/test/okjson/t/valid-array-deep.json.exp +1 -0
  89. data/test/okjson/t/valid-array-empty.json +1 -0
  90. data/test/okjson/t/valid-array-empty.json.exp +1 -0
  91. data/test/okjson/t/valid-array-single.json +1 -0
  92. data/test/okjson/t/valid-array-single.json.exp +1 -0
  93. data/test/okjson/t/valid-backslash.json +1 -0
  94. data/test/okjson/t/valid-backslash.json.exp +1 -0
  95. data/test/okjson/t/valid-comment.json +1 -0
  96. data/test/okjson/t/valid-comment.json.exp +1 -0
  97. data/test/okjson/t/valid-comment2.json +1 -0
  98. data/test/okjson/t/valid-comment2.json.exp +1 -0
  99. data/test/okjson/t/valid-compact.json +1 -0
  100. data/test/okjson/t/valid-compact.json.exp +1 -0
  101. data/test/okjson/t/valid-escape.json +1 -0
  102. data/test/okjson/t/valid-escape.json.exp +1 -0
  103. data/test/okjson/t/valid-false.json +1 -0
  104. data/test/okjson/t/valid-false.json.exp +1 -0
  105. data/test/okjson/t/valid-frac-E-minus.json +1 -0
  106. data/test/okjson/t/valid-frac-E-minus.json.exp +1 -0
  107. data/test/okjson/t/valid-frac-E-plus.json +1 -0
  108. data/test/okjson/t/valid-frac-E-plus.json.exp +1 -0
  109. data/test/okjson/t/valid-frac.json +1 -0
  110. data/test/okjson/t/valid-frac.json.exp +1 -0
  111. data/test/okjson/t/valid-hex.json +1 -0
  112. data/test/okjson/t/valid-hex.json.exp +1 -0
  113. data/test/okjson/t/valid-integer.json +1 -0
  114. data/test/okjson/t/valid-integer.json.exp +1 -0
  115. data/test/okjson/t/valid-json.json +1 -0
  116. data/test/okjson/t/valid-json.json.exp +1 -0
  117. data/test/okjson/t/valid-key.json +1 -0
  118. data/test/okjson/t/valid-key.json.exp +1 -0
  119. data/test/okjson/t/valid-null.json +1 -0
  120. data/test/okjson/t/valid-null.json.exp +1 -0
  121. data/test/okjson/t/valid-object-empty.json +1 -0
  122. data/test/okjson/t/valid-object-empty.json.exp +1 -0
  123. data/test/okjson/t/valid-object-single.json +1 -0
  124. data/test/okjson/t/valid-object-single.json.exp +1 -0
  125. data/test/okjson/t/valid-punc.json +1 -0
  126. data/test/okjson/t/valid-punc.json.exp +1 -0
  127. data/test/okjson/t/valid-quote.json +1 -0
  128. data/test/okjson/t/valid-quote.json.exp +1 -0
  129. data/test/okjson/t/valid-quotes.json +1 -0
  130. data/test/okjson/t/valid-quotes.json.exp +1 -0
  131. data/test/okjson/t/valid-slash.json +1 -0
  132. data/test/okjson/t/valid-slash.json.exp +1 -0
  133. data/test/okjson/t/valid-space.json +1 -0
  134. data/test/okjson/t/valid-space.json.exp +1 -0
  135. data/test/okjson/t/valid-spaced.json +5 -0
  136. data/test/okjson/t/valid-spaced.json.exp +1 -0
  137. data/test/okjson/t/valid-spaced2.json +13 -0
  138. data/test/okjson/t/valid-spaced2.json.exp +1 -0
  139. data/test/okjson/t/valid-true.json +1 -0
  140. data/test/okjson/t/valid-true.json.exp +1 -0
  141. data/test/okjson/t/valid-url.json +1 -0
  142. data/test/okjson/t/valid-url.json.exp +1 -0
  143. data/test/test_decoder.rb +88 -0
  144. data/test/test_encoder.rb +102 -0
  145. data/test/test_okjson.rb +57 -0
  146. metadata +329 -0
@@ -0,0 +1,181 @@
1
+ /*
2
+ * Copyright 2012 Couchbase, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package gson_ext;
18
+
19
+ import com.google.gson.stream.JsonWriter;
20
+ import java.io.StringWriter;
21
+ import java.io.Writer;
22
+ import java.io.IOException;
23
+ import org.jruby.Ruby;
24
+ import org.jruby.RubyArray;
25
+ import org.jruby.RubyBoolean;
26
+ import org.jruby.RubyClass;
27
+ import org.jruby.RubyException;
28
+ import org.jruby.RubyHash;
29
+ import org.jruby.RubyNumeric;
30
+ import org.jruby.RubyFloat;
31
+ import org.jruby.RubyInteger;
32
+ import org.jruby.RubyObject;
33
+ import org.jruby.RubyString;
34
+ import org.jruby.RubySymbol;
35
+ import org.jruby.anno.JRubyClass;
36
+ import org.jruby.anno.JRubyMethod;
37
+ import org.jruby.exceptions.RaiseException;
38
+ import org.jruby.runtime.ThreadContext;
39
+ import org.jruby.runtime.builtin.IRubyObject;
40
+
41
+ @JRubyClass(name = "Gson::Encoder")
42
+ public class Encoder extends RubyObject {
43
+
44
+ static final long serialVersionUID = 5035506147333315973L;
45
+ private boolean htmlSafe = false;
46
+ private boolean lenient = true;
47
+ private boolean serializeNulls = true;
48
+ private String indent = "";
49
+ private IRubyObject options;
50
+
51
+ public Encoder(final Ruby ruby, RubyClass rubyClass) {
52
+ super(ruby, rubyClass);
53
+ }
54
+
55
+ @JRubyMethod(name = "lenient?")
56
+ public IRubyObject isLenient(ThreadContext context) {
57
+ return RubyBoolean.newBoolean(context.getRuntime(), this.lenient);
58
+ }
59
+
60
+ @JRubyMethod(name = "html_safe?")
61
+ public IRubyObject isHtmlSafe(ThreadContext context) {
62
+ return RubyBoolean.newBoolean(context.getRuntime(), this.htmlSafe);
63
+ }
64
+
65
+ @JRubyMethod(name = "serialize_nils?")
66
+ public IRubyObject isSerializeNulls(ThreadContext context) {
67
+ return RubyBoolean.newBoolean(context.getRuntime(), this.serializeNulls);
68
+ }
69
+
70
+ @JRubyMethod(name = "indent")
71
+ public IRubyObject getIndent(ThreadContext context) {
72
+ return RubyString.newString(context.getRuntime(), this.indent);
73
+ }
74
+
75
+ @JRubyMethod(optional = 1)
76
+ public IRubyObject initialize(ThreadContext context, IRubyObject[] args) {
77
+ Ruby ruby = context.getRuntime();
78
+ this.options = context.nil;
79
+ if (args.length < 1) {
80
+ return context.nil;
81
+ }
82
+ if (!(args[0] instanceof RubyHash)) {
83
+ throw ruby.newArgumentError("expected Hash for options argument");
84
+ }
85
+ this.options = args[0];
86
+ RubyHash options = (RubyHash)this.options;
87
+ RubySymbol name = ruby.newSymbol("lenient");
88
+ if (options.containsKey(name)) {
89
+ this.lenient = options.op_aref(context, name).isTrue();
90
+ }
91
+ name = ruby.newSymbol("serialize_nils");
92
+ if (options.containsKey(name)) {
93
+ this.serializeNulls = options.op_aref(context, name).isTrue();
94
+ }
95
+ name = ruby.newSymbol("html_safe");
96
+ if (options.containsKey(name)) {
97
+ this.htmlSafe = options.op_aref(context, name).isTrue();
98
+ }
99
+ name = ruby.newSymbol("indent");
100
+ if (options.containsKey(name)) {
101
+ IRubyObject val = options.op_aref(context, name);
102
+ if (val.isNil()) {
103
+ this.indent = "";
104
+ } else {
105
+ this.indent = val.checkStringType().asJavaString();
106
+ }
107
+ }
108
+ return context.nil;
109
+ }
110
+
111
+ @JRubyClass(name="Gson::EncodeError", parent="StandardError")
112
+ public static class EncodeError {
113
+
114
+ public static RaiseException newEncodeError(Ruby ruby, String message) {
115
+ RubyClass errorClass = ruby.getModule("Gson").getClass("EncodeError");
116
+ return new RaiseException(RubyException.newException(ruby, errorClass, message), true);
117
+ }
118
+
119
+ }
120
+
121
+
122
+ @JRubyMethod
123
+ public IRubyObject encode(ThreadContext context, IRubyObject arg) {
124
+ Ruby ruby = context.getRuntime();
125
+
126
+ StringWriter out = new StringWriter();
127
+ JsonWriter writer = new JsonWriter(out);
128
+ writer.setLenient(this.lenient);
129
+ writer.setHtmlSafe(this.htmlSafe);
130
+ writer.setIndent(this.indent);
131
+ writer.setSerializeNulls(this.serializeNulls);
132
+ try {
133
+ encodeValue(writer, context, arg);
134
+ } catch (Exception ex) {
135
+ throw EncodeError.newEncodeError(ruby, ex.getMessage());
136
+ }
137
+ return ruby.newString(out.toString());
138
+ }
139
+
140
+ private void encodeValue(JsonWriter writer, ThreadContext context, IRubyObject val)
141
+ throws IOException {
142
+ Ruby ruby = context.getRuntime();
143
+
144
+ if (val.isNil()) {
145
+ writer.nullValue();
146
+ } else if (val instanceof RubyHash) {
147
+ writer.beginObject();
148
+ for (Object obj : ((RubyHash)val).directEntrySet()) {
149
+ RubyHash.RubyHashEntry item = (RubyHash.RubyHashEntry)obj;
150
+ writer.name(item.getKey().toString());
151
+ encodeValue(writer, context, (IRubyObject)item.getValue());
152
+ }
153
+ writer.endObject();
154
+ } else if (val instanceof RubyArray) {
155
+ writer.beginArray();
156
+ for (IRubyObject item : ((RubyArray)val).toJavaArray()) {
157
+ encodeValue(writer, context, item);
158
+ }
159
+ writer.endArray();
160
+ } else if (val instanceof RubyString || val instanceof RubySymbol) {
161
+ writer.value(val.toString());
162
+ } else if (val instanceof RubyInteger) {
163
+ try {
164
+ writer.value(((RubyInteger)val).getLongValue());
165
+ } catch (RaiseException ex) {
166
+ if ("RangeError".equals(ex.getException().getType().getName())) {
167
+ writer.value(((RubyInteger)val).getBigIntegerValue());
168
+ } else {
169
+ throw ex;
170
+ }
171
+ }
172
+ } else if (val instanceof RubyFloat) {
173
+ writer.value((Double)((RubyFloat)val).getDoubleValue());
174
+ } else if (val instanceof RubyBoolean) {
175
+ writer.value(val.isTrue());
176
+ } else if (val.respondsTo("to_json")) {
177
+ encodeValue(writer, context, val.callMethod(context, "to_json", this.options));
178
+ }
179
+ }
180
+
181
+ }
@@ -0,0 +1,50 @@
1
+ /*
2
+ * Copyright 2012 Couchbase, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import gson_ext.Decoder;
18
+ import gson_ext.Encoder;
19
+ import java.io.IOException;
20
+ import org.jruby.Ruby;
21
+ import org.jruby.RubyClass;
22
+ import org.jruby.RubyModule;
23
+ import org.jruby.runtime.ObjectAllocator;
24
+ import org.jruby.runtime.builtin.IRubyObject;
25
+ import org.jruby.runtime.load.BasicLibraryService;
26
+
27
+ public class GsonExtService implements BasicLibraryService {
28
+
29
+ public boolean basicLoad(final Ruby ruby) throws IOException {
30
+ RubyModule gson = ruby.defineModule("Gson");
31
+
32
+ gson.defineClassUnder("Encoder", ruby.getObject(), new ObjectAllocator() {
33
+ public IRubyObject allocate(Ruby ruby, RubyClass rubyClass) {
34
+ return new Encoder(ruby, rubyClass);
35
+ }
36
+ }).defineAnnotatedMethods(Encoder.class);
37
+
38
+ gson.defineClassUnder("Decoder", ruby.getObject(), new ObjectAllocator() {
39
+ public IRubyObject allocate(Ruby ruby, RubyClass rubyClass) {
40
+ return new Decoder(ruby, rubyClass);
41
+ }
42
+ }).defineAnnotatedMethods(Decoder.class);
43
+
44
+ RubyClass standardError = ruby.getStandardError();
45
+ gson.defineClassUnder("DecodeError", standardError, standardError.getAllocator());
46
+ gson.defineClassUnder("EncodeError", standardError, standardError.getAllocator());
47
+
48
+ return true;
49
+ }
50
+ }
@@ -0,0 +1,38 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # Author:: Couchbase <info@couchbase.com>
3
+ # Copyright:: 2012 Couchbase, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ lib = File.expand_path('../lib', __FILE__)
20
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
21
+ require 'gson/version'
22
+
23
+ Gem::Specification.new do |gem|
24
+ gem.name = "gson"
25
+ gem.version = Gson::VERSION
26
+ gem.author = "Sergey Avseyev"
27
+ gem.email = "sergey.avseyev@gmail.com"
28
+ gem.description = %q{Ruby wrapper for GSON. https://code.google.com/p/google-gson/}
29
+ gem.summary = %q{Ruby wrapper for GSON}
30
+ gem.homepage = "https://github.com/avsej/gson.rb"
31
+
32
+ gem.files = `git ls-files`.split($/)
33
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
34
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
35
+ gem.require_paths = ["lib"]
36
+
37
+ gem.add_development_dependency 'rake-compiler', '>= 0.7.5'
38
+ end
Binary file
@@ -0,0 +1,33 @@
1
+ # Author:: Couchbase <info@couchbase.com>
2
+ # Copyright:: 2012 Couchbase, Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'java'
19
+ require "gson/version"
20
+ require "gson-2.2.2.jar"
21
+ require "gson_ext.jar"
22
+
23
+ module Gson
24
+
25
+ def self.load(object, options = {})
26
+ Decoder.new(options).decode(string)
27
+ end
28
+
29
+ def self.dump(string, options = {})
30
+ Encoder.new(options).encode(object)
31
+ end
32
+
33
+ end
@@ -0,0 +1,20 @@
1
+ # Author:: Couchbase <info@couchbase.com>
2
+ # Copyright:: 2012 Couchbase, Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ module Gson
19
+ VERSION = "0.5.0"
20
+ end
@@ -0,0 +1,33 @@
1
+ # Author:: Couchbase <info@couchbase.com>
2
+ # Copyright:: 2012 Couchbase, Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ gem 'rake-compiler', '>= 0.7.5'
19
+ require "rake/javaextensiontask"
20
+
21
+ def gemspec
22
+ @clean_gemspec ||= eval(File.read(File.expand_path('../../gson.gemspec', __FILE__)))
23
+ end
24
+
25
+ Rake::JavaExtensionTask.new('gson_ext', gemspec) do |ext|
26
+ ext.classpath = File.expand_path("../../lib/gson-2.2.2.jar", __FILE__)
27
+ end
28
+
29
+ require 'rubygems/package_task'
30
+ Gem::PackageTask.new(gemspec) do |pkg|
31
+ pkg.need_tar = true
32
+ end
33
+
@@ -0,0 +1,25 @@
1
+ # Author:: Couchbase <info@couchbase.com>
2
+ # Copyright:: 2012 Couchbase, Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'rake/testtask'
19
+ Rake::TestTask.new do |test|
20
+ test.libs << "test" << "."
21
+ test.pattern = 'test/test_*.rb'
22
+ test.options = '--verbose'
23
+ end
24
+
25
+ Rake::Task['test'].prerequisites.unshift(:compile)
@@ -0,0 +1,21 @@
1
+ # Author:: Couchbase <info@couchbase.com>
2
+ # Copyright:: 2012 Couchbase, Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ desc 'Start an irb session and load the library.'
19
+ task :console => :compile do
20
+ exec "irb -I. -Ilib -rgson"
21
+ end
@@ -0,0 +1,18 @@
1
+ These tests originated at https://github.com/kr/okjson
2
+
3
+ Except following changes:
4
+
5
+ * GSON generates floats with uppercase 'E'
6
+ * It doesn't renders Bignum's as numbers, it renders Infinity. See
7
+ `*bignum*.json` tests
8
+ * GSON understands escaping illegal characters like single quote and
9
+ silently skip the backslash. Therefore these tests were renamed:
10
+ * `invalid15.json` to `decode-invalid15.json{,.exp}`
11
+ * `invalid16.json` to `decode-invalid16.json{,.exp}`
12
+ * `invalid17.json` to `decode-invalid17.json{,.exp}`
13
+ * GSON understands verbatim tabs and line breaks in the JSON string.
14
+ Therefore these tests were renamed:
15
+ * `invalid25.json` to `decode-invalid25.json{,.exp}`
16
+ * `invalid26.json` to `decode-invalid26.json{,.exp}`
17
+ * `invalid27.json` to `decode-invalid27.json{,.exp}`
18
+ * `invalid28.json` to `decode-invalid28.json{,.exp}`
@@ -0,0 +1 @@
1
+ [23456789012E666]
@@ -0,0 +1 @@
1
+ [Infinity]
@@ -0,0 +1 @@
1
+ [23456789012000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]
@@ -0,0 +1 @@
1
+ [23456789012000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]
@@ -0,0 +1 @@
1
+ ["Illegal backslash escape: \x15"]