rubyfox-sfsobject 0.7.0-java → 0.8.0-java

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
  SHA256:
3
- metadata.gz: 951a3ae2c4685874984d864d8180e718aaafd244bb86568ad4559e98462e88f3
4
- data.tar.gz: 440f5a23113e6b4e97293b6f918021fe8c5de6d48be8bb69e38cc18fed66e652
3
+ metadata.gz: 9cbc395e880b6c8a4b07636b49e7266169200db71ce46d8b27f83324c03af15d
4
+ data.tar.gz: 17d13b29741f0448e2e2a261a48d68cfd9fe84b7db69f3a68d211dbfcc554194
5
5
  SHA512:
6
- metadata.gz: 80c53e96107964aa455c2524fe3f1f943481d8c593feaaa387a09f039cca807e13613d8f254c4084ac970290468c80b9c05897be7c65162478173c0ddf566884
7
- data.tar.gz: 9270e00d175de0b25dfcba579b724d5fe823429113438ae5d424ac9fef2e2c86be5a2c2e3e77e5ee77ebe1fb98411355fdf9ca5374b37bb7811c8068043b4334
6
+ metadata.gz: 366d114a0955eb824bc1aaf9531689db1652b5f1e4810a8fa09d1c2be29bb9bfb317731e3dfcf575506254d7cd1ca478482213a94a8fd880314a65fb1192b1e3
7
+ data.tar.gz: 53252d8adcf99713d9bb2d17ee8259df89dcaf2de339f6accfe40350edf5ab05a0b3cb4629cb3849747246759cd8884d10c1dfc1cb8cb473f9b1d57db337ada7
@@ -2,7 +2,8 @@ language: ruby
2
2
  sudo: false
3
3
  cache: bundler
4
4
  rvm:
5
- - jruby-9.1.13.0
5
+ - jruby-9.2.0.0
6
+ - jruby-9.1.17.0
6
7
  - jruby-1.7.27
7
8
  env:
8
9
  global:
data/README.md CHANGED
@@ -20,7 +20,7 @@ Converts between SmartFox's SFSObjects and Ruby Hashes.
20
20
 
21
21
  Add this line to your application's Gemfile:
22
22
 
23
- gem 'rubyfox-sfsobject', '~> 0.7.0'
23
+ gem 'rubyfox-sfsobject', '~> 0.8.0'
24
24
 
25
25
  And then execute:
26
26
 
@@ -28,7 +28,7 @@ And then execute:
28
28
 
29
29
  Or install it yourself as:
30
30
 
31
- $ gem install rubyfox-sfsobject -v 0.7.0
31
+ $ gem install rubyfox-sfsobject -v 0.8.0
32
32
 
33
33
  ## Usage
34
34
 
@@ -1,4 +1,4 @@
1
- require 'rubyfox/sfsobject/java'
1
+ require "rubyfox/sfsobject/java"
2
2
 
3
3
  module Rubyfox
4
4
  module SFSObject
@@ -6,24 +6,24 @@ module Rubyfox
6
6
  extend self
7
7
 
8
8
  TO_SFS = {
9
- NilClass => proc { |o, k, _| o.putNull(k) },
10
- String => :putUtfString,
11
- TrueClass => :putBool,
12
- FalseClass => :putBool,
13
- Fixnum => :putInt,
14
- Float => :putDouble,
15
- Hash => proc { |o, k, v| o.putSFSObject(k, to_sfs(v)) },
9
+ NilClass => proc { |o, k, _| o.putNull(k) },
10
+ String => :putUtfString,
11
+ TrueClass => :putBool,
12
+ FalseClass => :putBool,
13
+ Integer => :putInt,
14
+ Float => :putDouble,
15
+ Hash => proc { |o, k, v| o.putSFSObject(k, to_sfs(v)) },
16
16
  Java::SFSObject => :putSFSObject,
17
- [String] => :putUtfStringArray,
18
- [TrueClass] => :putBoolArray,
19
- [FalseClass] => :putBoolArray,
20
- [Fixnum] => proc do |o, k, v|
17
+ [String] => :putUtfStringArray,
18
+ [TrueClass] => :putBoolArray,
19
+ [FalseClass] => :putBoolArray,
20
+ [Integer] => proc do |o, k, v|
21
21
  collection = Java::ArrayList.new
22
22
  v.each { |e| collection.add(e.to_java(:int)) }
23
23
  o.putIntArray(k, collection)
24
24
  end,
25
- [Float] => :putDoubleArray,
26
- [Hash] => proc do |o, k, v|
25
+ [Float] => :putDoubleArray,
26
+ [Hash] => proc do |o, k, v|
27
27
  ary = Java::SFSArray.new
28
28
  v.each { |e| ary.addSFSObject(to_sfs(e)) }
29
29
  o.putSFSArray(k, ary)
@@ -32,29 +32,29 @@ module Rubyfox
32
32
  ary = Java::SFSArray.new
33
33
  v.each { |e| ary.addSFSObject(e) }
34
34
  o.putSFSArray(k, ary)
35
- end
35
+ end,
36
36
  }
37
37
 
38
38
  TO_HASH = {
39
- "NULL" => proc { |k, v| nil },
40
- "UTF_STRING" => :getUtfString,
41
- "BOOL" => :getBool,
42
- "INT" => :getInt,
43
- "DOUBLE" => :getDouble,
44
- "FLOAT" => :getFloat,
45
- "UTF_STRING_ARRAY" => :getUtfStringArray,
46
- "BOOL_ARRAY" => :getBoolArray,
39
+ "NULL" => proc { |k, v| nil },
40
+ "UTF_STRING" => :getUtfString,
41
+ "BOOL" => :getBool,
42
+ "INT" => :getInt,
43
+ "DOUBLE" => :getDouble,
44
+ "FLOAT" => :getFloat,
45
+ "UTF_STRING_ARRAY" => :getUtfStringArray,
46
+ "BOOL_ARRAY" => :getBoolArray,
47
47
  #"INT_ARRAY" => :getIntArray,
48
- "INT_ARRAY" => proc { |k, v| v.object.to_a },
49
- "LONG_ARRAY" => :getLongArray,
50
- "DOUBLE_ARRAY" => :getDoubleArray,
51
- "FLOAT_ARRAY" => :getFloatArray,
52
- "SFS_OBJECT" => proc { |k, v| to_hash(v.object) },
53
- "SFS_ARRAY" => proc { |k, v| to_array(v.object) }
48
+ "INT_ARRAY" => proc { |k, v| v.object.to_a },
49
+ "LONG_ARRAY" => :getLongArray,
50
+ "DOUBLE_ARRAY" => :getDoubleArray,
51
+ "FLOAT_ARRAY" => :getFloatArray,
52
+ "SFS_OBJECT" => proc { |k, v| to_hash(v.object) },
53
+ "SFS_ARRAY" => proc { |k, v| to_array(v.object) },
54
54
  }
55
55
 
56
56
  # hash -> object
57
- def to_sfs(hash={})
57
+ def to_sfs(hash = {})
58
58
  object = Java::SFSObject.new
59
59
  hash.each do |key, value|
60
60
  wrap_value!(object, key, value)
@@ -78,7 +78,14 @@ module Rubyfox
78
78
  def _wrapper(value)
79
79
  case value
80
80
  when Array
81
- TO_SFS[[value.first.class]]
81
+ case value = value.first
82
+ when Integer # This is necessary to support ruby < 2.4.
83
+ TO_SFS[[Integer]]
84
+ else
85
+ TO_SFS[[value.class]]
86
+ end
87
+ when Integer # See above.
88
+ TO_SFS[Integer]
82
89
  else
83
90
  TO_SFS[value.class]
84
91
  end
@@ -17,12 +17,12 @@ module Rubyfox
17
17
  TO_SFS = {
18
18
  String => proc { |o, s, k, v| o.put_utf_string(k, v) },
19
19
  Boolean => proc { |o, s, k, v| o.put_bool(k, v) },
20
- Fixnum => proc { |o, s, k, v| o.put_int(k, v) },
20
+ Integer => proc { |o, s, k, v| o.put_int(k, v) },
21
21
  Float => proc { |o, s, k, v| o.put_double(k, v) },
22
22
  Hash => proc { |o, s, k, v| o.put_sfs_object(k, to_sfs(s, v)) },
23
23
  [String] => proc { |o, s, k, v| o.put_utf_string_array(k, v) },
24
24
  [Boolean] => proc { |o, s, k, v| o.put_bool_array(k, v) },
25
- [Fixnum] => proc do |o, s, k, v|
25
+ [Integer] => proc do |o, s, k, v|
26
26
  collection = Java::ArrayList.new(v.size)
27
27
  v.each { |e| collection.add(e.to_java(:int)) }
28
28
  o.put_int_array(k, collection)
@@ -39,12 +39,12 @@ module Rubyfox
39
39
  TO_HASH = {
40
40
  String => proc { |o, s, k| o.get_utf_string(k) },
41
41
  Boolean => proc { |o, s, k| o.get_bool(k) },
42
- Fixnum => proc { |o, s, k| o.get_int(k) },
42
+ Integer => proc { |o, s, k| o.get_int(k) },
43
43
  Float => proc { |o, s, k| o.get_double(k) },
44
44
  Hash => proc { |o, s, k| to_hash(s, o.get_sfs_object(k)) },
45
45
  [String] => proc { |o, s, k| o.get_utf_string_array(k).to_a },
46
46
  [Boolean] => proc { |o, s, k| o.get_bool_array(k).to_a },
47
- [Fixnum] => proc { |o, s, k| o.get_int_array(k).to_a },
47
+ [Integer] => proc { |o, s, k| o.get_int_array(k).to_a },
48
48
  [Float] => proc { |o, s, k| o.get_double_array(k).to_a },
49
49
  [Hash] => proc { |o, s, k|
50
50
  sfs_ary = o.get_sfs_array(k)
@@ -1,5 +1,5 @@
1
1
  module Rubyfox
2
2
  module SFSObject
3
- VERSION = "0.7.0"
3
+ VERSION = "0.8.0"
4
4
  end
5
5
  end
@@ -18,9 +18,9 @@ class RubyfoxSFSObjectAccessorTest < RubyfoxCase
18
18
 
19
19
  context "SFSObject[]" do
20
20
  test "sets hash" do
21
- object = Rubyfox::SFSObject[:string => "value", :sub => { :fixnum => 23 }]
21
+ object = Rubyfox::SFSObject[:string => "value", :sub => { :integer => 23 }]
22
22
  assert_equal "value", object[:string]
23
- assert_equal 23, object[:sub][:fixnum]
23
+ assert_equal 23, object[:sub][:integer]
24
24
  end
25
25
  end
26
26
 
@@ -51,21 +51,21 @@ class RubyfoxSFSObjectAccessorTest < RubyfoxCase
51
51
  assert_accessor :true => true, :false => false
52
52
  end
53
53
 
54
- test "fixnum" do
55
- assert_accessor :fixnum => 1
56
- assert_accessor :fixnum => (2 ** 31 - 1)
57
- assert_accessor :fixnum => -(2 ** 31)
54
+ test "integer" do
55
+ assert_accessor :integer => 1
56
+ assert_accessor :integer => (2 ** 31 - 1)
57
+ assert_accessor :integer => -(2 ** 31)
58
58
  end
59
59
 
60
- test "fixnum too big for int" do
60
+ test "integer too big for int" do
61
61
  assert_raises RangeError, :message => /too big for int/ do
62
- assert_accessor :fixnum => (2 ** 31)
62
+ assert_accessor :integer => (2 ** 31)
63
63
  end
64
64
  end
65
65
 
66
66
  test "cannot handle bignum" do
67
- assert_raises ArgumentError, :message => /Bignum/ do
68
- assert_accessor :fixnum => (2 ** 63)
67
+ assert_raises RangeError, :message => /bignum too big/ do
68
+ assert_accessor :integer => (2 ** 63)
69
69
  end
70
70
  end
71
71
 
@@ -92,8 +92,8 @@ class RubyfoxSFSObjectAccessorTest < RubyfoxCase
92
92
  assert_accessor :bool => [ true, false ]
93
93
  end
94
94
 
95
- test "fixnum" do
96
- assert_accessor :fixnum => [ 1, 2, 3 ]
95
+ test "integer" do
96
+ assert_accessor :integer => [ 1, 2, 3 ]
97
97
  end
98
98
 
99
99
  test "float" do
@@ -1,7 +1,7 @@
1
- # encoding: utf-8
1
+ # encoding: utf-8
2
2
 
3
- require 'helper'
4
- require 'rubyfox/sfsobject/bulk'
3
+ require "helper"
4
+ require "rubyfox/sfsobject/bulk"
5
5
 
6
6
  class RubyfoxSFSObjectBulkTest < RubyfoxCase
7
7
  test "empty" do
@@ -9,7 +9,7 @@ class RubyfoxSFSObjectBulkTest < RubyfoxCase
9
9
  end
10
10
 
11
11
  test "converts keys to symbols" do
12
- assert_conversion({ "key" => nil }, { :key => nil })
12
+ assert_conversion({"key" => nil}, {:key => nil})
13
13
  end
14
14
 
15
15
  test "raise ArgumentError for nil values" do
@@ -33,21 +33,21 @@ class RubyfoxSFSObjectBulkTest < RubyfoxCase
33
33
  assert_conversion :true => true, :false => false
34
34
  end
35
35
 
36
- test "fixnum" do
37
- assert_conversion :fixnum => 1
38
- assert_conversion :fixnum => (2 ** 31 - 1)
39
- assert_conversion :fixnum => -(2 ** 31)
36
+ test "integer" do
37
+ assert_conversion :integer => 1
38
+ assert_conversion :integer => (2 ** 31 - 1)
39
+ assert_conversion :integer => -(2 ** 31)
40
40
  end
41
41
 
42
- test "fixnum too big for int" do
42
+ test "integer too big for int" do
43
43
  assert_raises RangeError, :message => /too big for int/ do
44
- assert_conversion :fixnum => (2 ** 31)
44
+ assert_conversion :integer => (2 ** 31)
45
45
  end
46
46
  end
47
47
 
48
48
  test "cannot handle bignum" do
49
- assert_raises ArgumentError, :message => /Bignum/ do
50
- assert_conversion :fixnum => (2 ** 63)
49
+ assert_raises RangeError, :message => /bignum too big/ do
50
+ assert_conversion :integer => (2 ** 63)
51
51
  end
52
52
  end
53
53
 
@@ -73,12 +73,12 @@ class RubyfoxSFSObjectBulkTest < RubyfoxCase
73
73
  end
74
74
 
75
75
  test "sub hashes" do
76
- assert_conversion :sub => { :key => "value" }
77
- assert_conversion :sub => { :deep => { :key => "value" } }
76
+ assert_conversion :sub => {:key => "value"}
77
+ assert_conversion :sub => {:deep => {:key => "value"}}
78
78
  end
79
79
 
80
80
  test "sfsobject" do
81
- assert_conversion({ :sfsobject => Rubyfox::SFSObject.new }, { :sfsobject => {} })
81
+ assert_conversion({:sfsobject => Rubyfox::SFSObject.new}, {:sfsobject => {}})
82
82
  end
83
83
  end
84
84
 
@@ -91,15 +91,15 @@ class RubyfoxSFSObjectBulkTest < RubyfoxCase
91
91
  end
92
92
 
93
93
  test "boolean" do
94
- assert_conversion :bool => [ true, false ]
94
+ assert_conversion :bool => [true, false]
95
95
  end
96
96
 
97
- test "fixnum" do
98
- assert_conversion :fixnum => [ 1, 2, 3 ]
97
+ test "integer" do
98
+ assert_conversion :integer => [1, 2, 3]
99
99
  end
100
100
 
101
101
  test "float" do
102
- assert_conversion :float => [ 1.0, 1.0 / 3 ]
102
+ assert_conversion :float => [1.0, 1.0 / 3]
103
103
  end
104
104
 
105
105
  test "converts Java's double array to Ruby's Float array" do
@@ -119,12 +119,12 @@ class RubyfoxSFSObjectBulkTest < RubyfoxCase
119
119
  end
120
120
 
121
121
  test "sub hashes" do
122
- assert_conversion :sub => [{ :key => "value" }]
123
- assert_conversion :sub => [{ :deep => [{ :key => "value" }] }]
122
+ assert_conversion :sub => [{:key => "value"}]
123
+ assert_conversion :sub => [{:deep => [{:key => "value"}]}]
124
124
  end
125
125
 
126
126
  test "sfsobject" do
127
- assert_conversion({ :sfsobject => [Rubyfox::SFSObject.new]}, { :sfsobject => [{}] })
127
+ assert_conversion({:sfsobject => [Rubyfox::SFSObject.new]}, {:sfsobject => [{}]})
128
128
  end
129
129
 
130
130
  test "loads mixed arrays" do
@@ -137,7 +137,7 @@ class RubyfoxSFSObjectBulkTest < RubyfoxCase
137
137
  }
138
138
  ]}')
139
139
  expected = {
140
- :mixed => ["foo", true, 1.0, {:deep => ["Föhn", "BÄR"]}]
140
+ :mixed => ["foo", true, 1.0, {:deep => ["Föhn", "BÄR"]}],
141
141
  }
142
142
  assert_equal expected, Rubyfox::SFSObject::Bulk.to_hash(object)
143
143
  end
@@ -145,7 +145,7 @@ class RubyfoxSFSObjectBulkTest < RubyfoxCase
145
145
 
146
146
  private
147
147
 
148
- def assert_conversion(input, output=input)
148
+ def assert_conversion(input, output = input)
149
149
  object = Rubyfox::SFSObject::Bulk.to_sfs(input)
150
150
  assert_equal output, Rubyfox::SFSObject::Bulk.to_hash(object)
151
151
  end
@@ -26,15 +26,15 @@ class RubyfoxSFSObjectSchemaTest < RubyfoxCase
26
26
  assert_schema({ :bool => Boolean }, { :bool => false })
27
27
  end
28
28
 
29
- test "fixnum" do
30
- assert_schema({ :fixnum => Fixnum }, { :fixnum => 1 })
31
- assert_schema({ :fixnum => Fixnum }, { :fixnum => (2 ** 31 - 1) })
32
- assert_schema({ :fixnum => Fixnum }, { :fixnum => -(2 ** 31) })
29
+ test "integer" do
30
+ assert_schema({ :integer => Integer }, { :integer => 1 })
31
+ assert_schema({ :integer => Integer }, { :integer => (2 ** 31 - 1) })
32
+ assert_schema({ :integer => Integer }, { :integer => -(2 ** 31) })
33
33
  end
34
34
 
35
- test "fixnum too big for int" do
35
+ test "integer too big for int" do
36
36
  assert_raises RangeError, :message => /too big for int/ do
37
- assert_schema({ :fixnum => Fixnum }, { :fixnum => (2 ** 31) })
37
+ assert_schema({ :integer => Integer }, { :integer => (2 ** 31) })
38
38
  end
39
39
  end
40
40
 
@@ -69,9 +69,9 @@ class RubyfoxSFSObjectSchemaTest < RubyfoxCase
69
69
  assert_schema({ :bool => [Boolean] }, { :bool => [true, 23] }) # strange?
70
70
  end
71
71
 
72
- test "fixnum" do
73
- assert_schema({ :fixnum => [Fixnum] }, { :fixnum => [1, 2] })
74
- assert_schema({ :fixnum => [Fixnum] }, { :fixnum => [(2 ** 31 - 1), -(2 ** 31)] })
72
+ test "integer" do
73
+ assert_schema({ :integer => [Integer] }, { :integer => [1, 2] })
74
+ assert_schema({ :integer => [Integer] }, { :integer => [(2 ** 31 - 1), -(2 ** 31)] })
75
75
  end
76
76
 
77
77
  test "float" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyfox-sfsobject
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: java
6
6
  authors:
7
7
  - Peter Suschlik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-26 00:00:00.000000000 Z
11
+ date: 2018-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  version: '0'
102
102
  requirements: []
103
103
  rubyforge_project:
104
- rubygems_version: 2.6.11
104
+ rubygems_version: 2.7.6
105
105
  signing_key:
106
106
  specification_version: 4
107
107
  summary: ''