transit-ruby 0.8.539 → 0.8.567

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4c90ad9b7561aaa1ad18f56cc7ed90af38d7d70d
4
- data.tar.gz: fbeacd5a32fbe9ce5030a5d0f341c0e895269d1c
3
+ metadata.gz: fe3de1c0cb0b40c993517350d09d3cbeafd65671
4
+ data.tar.gz: 4c7d0f451d76ff25a5d5b34eae1ec4a910132db0
5
5
  SHA512:
6
- metadata.gz: c959bd7c9532b09cdae9edf20bb657ef0232b3b7220e5cc97af2ff2027f60bcce14e049e026fd23936620a5d3a150c13b482fbf52ab49f8b6959e6ed5d94f5af
7
- data.tar.gz: 12609c53e17740223bc6a485a8de42d5f45faa67a145e741606a7bd79b24414d3597f71e9edbd2a40016860db0556c197310194a05fe31ae9fc22947346f8bf6
6
+ metadata.gz: 355faa7d96d7bc98a696950ffef72930f626f5d104ff692aef5a751d604dff7725da864e5629929a2e3fe597989c34dae3c9332a48376b344f558cfb39736a9b
7
+ data.tar.gz: 9a3544ffe4f173d17cefbedd5f4391a60fc165a0095f51536bae003b0866ca66b11d7a4251c9529c2966738ebeb6e8bf01fc2002ec3a5005cd9f55713b7fb409
data/.yardopts CHANGED
@@ -2,4 +2,5 @@
2
2
  --markup-provider redcarpet
3
3
  --plugin redcarpet-ext
4
4
  -
5
+ CHANGELOG.md
5
6
  LICENSE
data/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ ### 0.8.560 (java platform only) / 2014-09-12
2
+
3
+ * Bump dependency on transit-java to 0.8.269
4
+ ** fixes bug which turned an empty set into an array
5
+
6
+ ### 0.8.552 (java platform only) / 2014-09-12
7
+
8
+ * Support JRuby!
9
+
10
+ ### 0.8.539 / 2014-09-05
11
+
12
+ * Support special numbers (NaN, INF, -INF)
13
+
14
+ ### 0.8.467 / 2014-07-22
15
+
16
+ * Initial release
data/README.md CHANGED
@@ -18,7 +18,7 @@ between applications, it should not yet be used for storing data
18
18
  durably over time. This recommendation will change when the
19
19
  specification is complete._
20
20
 
21
- ### Contributing
21
+ ## Contributing
22
22
 
23
23
  This library is open source, developed internally by Cognitect. We welcome discussions of potential problems and enhancement suggestions on the [transit-format mailing list](https://groups.google.com/forum/#!forum/transit-format). Issues can be filed using GitHub [issues](https://github.com/cognitect/transit-ruby/issues) for this project. Because transit is incorporated into products and client projects, we prefer to do development internally and are not accepting pull requests or patches.
24
24
 
@@ -153,6 +153,7 @@ for more info.
153
153
  ## Supported Rubies
154
154
 
155
155
  * MRI 1.9.3, 2.0.0, 2.1.0, 2.1.1, 2.1.2
156
+ * JRuby 1.7.13..16
156
157
 
157
158
  ## Copyright and License
158
159
 
@@ -46,18 +46,16 @@ module Transit
46
46
  if cache.has_key?(node)
47
47
  cache.read(node)
48
48
  else
49
- parsed = begin
50
- if !node.start_with?(ESC)
51
- node
52
- elsif node.start_with?(TAG)
53
- Tag.new(node[2..-1])
54
- elsif handler = @handlers[node[1]]
55
- handler.from_rep(node[2..-1])
56
- elsif node.start_with?(ESC_ESC, ESC_SUB, ESC_RES)
57
- node[1..-1]
58
- else
59
- @default_handler.from_rep(node[1], node[2..-1])
60
- end
49
+ parsed = if !node.start_with?(ESC)
50
+ node
51
+ elsif node.start_with?(TAG)
52
+ Tag.new(node[2..-1])
53
+ elsif handler = @handlers[node[1]]
54
+ handler.from_rep(node[2..-1])
55
+ elsif node.start_with?(ESC_ESC, ESC_SUB, ESC_RES)
56
+ node[1..-1]
57
+ else
58
+ @default_handler.from_rep(node[1], node[2..-1])
61
59
  end
62
60
  if cache.cacheable?(node, as_map_key)
63
61
  cache.write(parsed)
@@ -134,27 +134,30 @@ module Transit
134
134
  end
135
135
 
136
136
  def marshal(obj, as_map_key, cache)
137
- handler = find_handler(obj)
138
- tag = handler.tag(obj)
139
- case tag
140
- when "_"
141
- emit_nil(as_map_key, cache)
142
- when "?"
143
- emit_boolean(handler, obj, as_map_key, cache)
144
- when "s"
145
- emit_string(nil, nil, escape(handler.rep(obj)), as_map_key, cache)
146
- when "i"
147
- emit_int(tag, handler.rep(obj), as_map_key, cache)
148
- when "d"
149
- emit_double(handler.rep(obj), as_map_key, cache)
150
- when "'"
151
- emit_tagged_value(tag, handler.rep(obj), cache)
152
- when "array"
153
- emit_array(handler.rep(obj), cache)
154
- when "map"
155
- emit_map(handler.rep(obj), cache)
137
+ if handler = find_handler(obj)
138
+ tag = handler.tag(obj)
139
+ case tag
140
+ when "_"
141
+ emit_nil(as_map_key, cache)
142
+ when "?"
143
+ emit_boolean(handler, obj, as_map_key, cache)
144
+ when "s"
145
+ emit_string(nil, nil, escape(handler.rep(obj)), as_map_key, cache)
146
+ when "i"
147
+ emit_int(tag, handler.rep(obj), as_map_key, cache)
148
+ when "d"
149
+ emit_double(handler.rep(obj), as_map_key, cache)
150
+ when "'"
151
+ emit_tagged_value(tag, handler.rep(obj), cache)
152
+ when "array"
153
+ emit_array(handler.rep(obj), cache)
154
+ when "map"
155
+ emit_map(handler.rep(obj), cache)
156
+ else
157
+ emit_encoded(handler, tag, obj, as_map_key, cache)
158
+ end
156
159
  else
157
- emit_encoded(handler, tag, obj, as_map_key, cache)
160
+ raise "Can not find a Write Handler for #{obj.inspect}."
158
161
  end
159
162
  end
160
163
 
@@ -26,7 +26,7 @@ module Transit
26
26
  end
27
27
 
28
28
  def initialize(io, opts)
29
- @oj = Oj::StreamWriter.new(io)
29
+ @oj = Oj::StreamWriter.new(io,opts.delete(:oj_opts) || {})
30
30
  parse_options(default_opts.merge(opts))
31
31
  @state = []
32
32
  end
data/spec/spec_helper.rb CHANGED
@@ -37,25 +37,11 @@ require 'wrong/adapters/rspec'
37
37
  require 'transit'
38
38
  require 'spec_helper-local' if File.exist?(File.expand_path('../spec_helper-local.rb', __FILE__))
39
39
 
40
- if Transit::jruby?
41
- require 'transit/unmarshaler/jruby/messagepack'
42
- end
43
-
44
40
  RSpec.configure do |c|
45
41
  c.alias_example_to :fit, :focus => true
46
42
  c.filter_run_including :focus => true, :focused => true
47
- c.filter_run_excluding :jruby => true
48
43
  c.run_all_when_everything_filtered = true
49
44
  c.mock_with :nothing
50
-
51
- c.before(:suite) do
52
- # TODO: make it work later
53
- #if Transit::jruby?
54
- # require 'rake'
55
- # load File.expand_path("Rakefile")
56
- # Rake::Task['compile'].invoke
57
- #end
58
- end
59
45
  end
60
46
 
61
47
  ALPHA_NUM = 'abcdefghijklmnopqrstuvwxyzABCDESFHIJKLMNOPQRSTUVWXYZ_0123456789'
@@ -16,19 +16,47 @@ require 'spec_helper'
16
16
 
17
17
  module Transit
18
18
  describe Reader do
19
- def read(value, &block)
20
- reader = Reader.new(:json, StringIO.new(value.to_json, 'r+'))
21
- reader.read &block
19
+ shared_examples "read without a block" do |type|
20
+ it "reads a single top-level #{type} element" do
21
+ input = {:this => [1,2,3,{:that => "the other"}]}
22
+
23
+ io = StringIO.new('', 'w+')
24
+ writer = Transit::Writer.new(type, io)
25
+ writer.write(input)
26
+
27
+ reader = Transit::Reader.new(type, StringIO.new(io.string))
28
+ assert { reader.read == input }
29
+ end
22
30
  end
23
31
 
24
- it 'reads without a block' do
25
- assert { read([1,2,3]) == [1,2,3] }
32
+ describe "reading without a block" do
33
+ include_examples "read without a block", :json
34
+ include_examples "read without a block", :json_verbose
35
+ include_examples "read without a block", :msgpack
36
+ end
37
+
38
+ shared_examples "read with a block" do |type|
39
+ it "reads multiple top-level #{type} elements from a single IO" do
40
+ inputs = ["abc",
41
+ 123456789012345678901234567890,
42
+ [:this, :that],
43
+ {:this => [1,2,3,{:that => "the other"}]}]
44
+ outputs = []
45
+
46
+ io = StringIO.new('', 'w+')
47
+ writer = Transit::Writer.new(type, io)
48
+ inputs.each {|i| writer.write(i)}
49
+ reader = Transit::Reader.new(type, StringIO.new(io.string))
50
+ reader.read {|val| outputs << val}
51
+
52
+ assert { outputs == inputs }
53
+ end
26
54
  end
27
55
 
28
- it 'reads with a block' do
29
- result = nil
30
- read([1,2,3]) {|v| result = v}
31
- assert { result == [1,2,3] }
56
+ describe "reading with a block" do
57
+ include_examples "read with a block", :json
58
+ include_examples "read with a block", :json_verbose
59
+ include_examples "read with a block", :msgpack
32
60
  end
33
61
 
34
62
  describe 'handler registration' do
@@ -76,10 +76,8 @@ module Transit
76
76
  def tag(_) nil end
77
77
  end
78
78
  writer = Writer.new(:json_verbose, io, :handlers => {Date => handler.new})
79
- # transit-java returns the error message "Not supported:
80
- # 2014-08-20". JRuby tests the error will be raised
81
79
  if Transit::jruby?
82
- assert { rescuing { writer.write(Date.today) }.is_a?(RuntimeError) }
80
+ assert { rescuing { writer.write(Date.today) }.message =~ /Not supported/ }
83
81
  else
84
82
  assert { rescuing { writer.write(Date.today) }.message =~ /must provide a non-nil tag/ }
85
83
  end
@@ -218,22 +216,22 @@ module Transit
218
216
  end
219
217
  end
220
218
 
221
- describe "MESSAGE_PACK" do
219
+ # JRuby skips these 3 examples since they use raw massage pack
220
+ # api. Also, JRuby doesn't hava good counterpart.
221
+ describe "MESSAGE_PACK", :unless => Transit::jruby? do
222
222
  let(:writer) { Writer.new(:msgpack, io) }
223
223
 
224
- # JRuby skips these 3 examples since they use raw massage pack
225
- # api. Also, JRuby doesn't hava good counterpart.
226
- it "writes a single-char tagged-value as a 2-element array", :jruby => Transit::jruby? do
224
+ it "writes a single-char tagged-value as a 2-element array" do
227
225
  writer.write(TaggedValue.new("a","bc"))
228
226
  assert { MessagePack::Unpacker.new(StringIO.new(io.string)).read == ["~#'", "~abc"] }
229
227
  end
230
228
 
231
- it "writes a multi-char tagged-value as a 2-element array", :jruby => Transit::jruby? do
229
+ it "writes a multi-char tagged-value as a 2-element array" do
232
230
  writer.write(TaggedValue.new("abc","def"))
233
231
  assert { MessagePack::Unpacker.new(StringIO.new(io.string)).read == ["~#abc", "def"] }
234
232
  end
235
233
 
236
- it "writes a top-level scalar as a quote-tagged value", :jruby => Transit::jruby? do
234
+ it "writes a top-level scalar as a quote-tagged value" do
237
235
  writer.write("this")
238
236
  assert { MessagePack::Unpacker.new(StringIO.new(io.string)).read == ["~#'", "this"] }
239
237
  end
@@ -285,16 +283,19 @@ module Transit
285
283
  assert { JSON.parse(io.string).first == "~`~hello" }
286
284
  end
287
285
 
286
+ it 'raises when there is no handler for the type at the top level' do
287
+ if Transit::jruby?
288
+ assert { rescuing { writer.write(Class.new.new) }.message =~ /Not supported/ }
289
+ else
290
+ assert { rescuing { writer.write(Class.new.new) }.message =~ /Can not find a Write Handler/ }
291
+ end
292
+ end
293
+
288
294
  it 'raises when there is no handler for the type' do
289
- type = Class.new
290
- obj = type.new
291
- # transit-java returns the error message "Not supported:
292
- # #<#<Class:0x12d40609>:0x76437e9b>". JRuby tests error will
293
- # be raised.
294
295
  if Transit::jruby?
295
- assert { rescuing { writer.write(obj) }.is_a?(RuntimeError) }
296
+ assert { rescuing { writer.write([Class.new.new]) }.message =~ /Not supported/ }
296
297
  else
297
- assert { rescuing { writer.write(obj) }.message =~ /Can not find a Write Handler/ }
298
+ assert { rescuing { writer.write([Class.new.new]) }.message =~ /Can not find a Write Handler/ }
298
299
  end
299
300
  end
300
301
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transit-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.539
4
+ version: 0.8.567
5
5
  platform: ruby
6
6
  authors:
7
7
  - Russ Olsen
@@ -9,31 +9,8 @@ authors:
9
9
  - Yoko Harada
10
10
  autorequire:
11
11
  bindir: bin
12
- cert_chain:
13
- - |
14
- -----BEGIN CERTIFICATE-----
15
- MIIDkjCCAnqgAwIBAgIBATANBgkqhkiG9w0BAQUFADBHMRUwEwYDVQQDDAx0cmFu
16
- c2l0LXJ1YnkxGTAXBgoJkiaJk/IsZAEZFgljb2duaXRlY3QxEzARBgoJkiaJk/Is
17
- ZAEZFgNjb20wHhcNMTQwNzE4MjA0ODAzWhcNMTUwNzE4Mj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vWcT2dmub6YZ7uYGfNsYcuGKXLIs5Ew95ebzWGJ16M
34
- PSs4XGS0
35
- -----END CERTIFICATE-----
36
- date: 2014-09-05 00:00:00.000000000 Z
12
+ cert_chain: []
13
+ date: 2014-10-23 00:00:00.000000000 Z
37
14
  dependencies:
38
15
  - !ruby/object:Gem::Dependency
39
16
  name: oj
@@ -172,6 +149,7 @@ extra_rdoc_files: []
172
149
  files:
173
150
  - ".yard_redcarpet_ext"
174
151
  - ".yardopts"
152
+ - CHANGELOG.md
175
153
  - LICENSE
176
154
  - README.md
177
155
  - lib/transit.rb
checksums.yaml.gz.sig DELETED
@@ -1 +0,0 @@
1
- �� B��骐�A3Y�o�bS�1���A�X(�\���iX�i�ʖ�`"X:�(� =�Ͼ�Ɓ=�_ ��ٝY*��,��#��"��8� �nlj��[@��PҔ� Ű�`�S��4�M�Т�������𤡬���w�N�*h��Pa�ӷdt��#��J�jw�����%���t� �5�5�*�0�؁,������I�_j"}�7����(XXmTF����l1��(�g�É�pX �6,�Ӟf%z��`NR��
data.tar.gz.sig DELETED
Binary file
metadata.gz.sig DELETED
@@ -1,3 +0,0 @@
1
- �Rą#U�2�V�=c.�w
2
- �[5O3�,��MqK��Q}���׊�NiТU)I����HW�&|5����<�����n�91g>K�H��Z��Q�4H�,\ ��a�ʹz(h���tR�`'��P�m�V�]����m�RU/��n ����x7�p��U��1�qS�v LW��I����
3
- �h&?y~}����M6���c�����)