hessian2 2.0.3 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b9a89d291633b69257f589b65f232b5dcc38466
4
- data.tar.gz: 69d82afa46069344e29a162c978ec3c095b9a0de
3
+ metadata.gz: c29b58ed9dcdc79f7e81a7dc8e204f9846fbd8ce
4
+ data.tar.gz: 868e420d3e2193979cac16c54fe1e8a72f0c3da8
5
5
  SHA512:
6
- metadata.gz: 336224add2f6534f56e6c1357567f6e165550c9a24f9e466b4530966c6d9a821844d1c7c8190aa69de8bffb979704e0fa791a95d61c7e9ad70cd9478f26a092e
7
- data.tar.gz: 26a9830f996c2a9bd0a4b3e2ea342bbd9ff532c2dc2b6fee33abf9fbdca6d0c0b1151b7e114e14ef9ad545e0db3b83b75de8aef563a61e8cb029bc7e2240ce34
6
+ metadata.gz: b34738c7d43f403b072ba23ee182bfefe680da6f6534b036a18329ecbd8f916c62cec834d2c4322bc169f4d4598dc32f753821d48cc3f3d3c6a776e42766da9c
7
+ data.tar.gz: ac41f701ff5b2cedd999be07986f8a4e58740a1fe9a3cd64e28f37d955d09943b328e2faf884797d85610a2600beea011be58cb8f6502899f4a836bdb5ca7e7e
data/README.md CHANGED
@@ -4,6 +4,8 @@ like json, additionally, 麻绳2 parse your object as a struct.
4
4
 
5
5
  hessian2 implements hessian 2.0 protocol. look [web services protocol](http://hessian.caucho.com/doc/hessian-ws.html) and [serialization protocol](http://hessian.caucho.com/doc/hessian-serialization.html).
6
6
 
7
+ Sequel::Mysql2::Dataset and ActiveRecord::Relation are also okey.
8
+
7
9
  ## comparing
8
10
 
9
11
  yajl-ruby: json, fast.
data/hessian2.gemspec CHANGED
@@ -20,6 +20,5 @@ Gem::Specification.new do |s|
20
20
  s.require_paths = ['lib']
21
21
 
22
22
  s.add_development_dependency 'rspec'
23
- s.add_runtime_dependency 'activerecord'
24
23
  s.add_runtime_dependency 'bigdecimal'
25
24
  end
@@ -15,6 +15,8 @@ module Hessian2
15
15
  else
16
16
  fields = if sample.is_a?(Hash)
17
17
  sample.keys.map{|k| k.to_sym }
18
+ elsif sample.instance_variable_get(:@values).is_a?(Hash)
19
+ sample.values.keys.map{|k| k }
18
20
  elsif sample.instance_variable_get(:@attributes).is_a?(Hash)
19
21
  sample.attributes.keys.map{|k| k.to_sym }
20
22
  elsif sample.is_a?(ClassWrapper)
@@ -32,6 +34,8 @@ module Hessian2
32
34
  nil
33
35
  elsif obj.is_a?(Hash)
34
36
  fields.map{|f| obj[f] || obj[f.to_s] }
37
+ elsif obj.instance_variable_get(:@values).is_a?(Hash)
38
+ fields.map{|f| obj.values[f] }
35
39
  elsif obj.instance_variable_get(:@attributes).is_a?(Hash)
36
40
  fields.map{|f| obj.attributes[f.to_s] }
37
41
  elsif obj.is_a?(ClassWrapper)
@@ -53,6 +57,11 @@ module Hessian2
53
57
  fields << k.to_sym
54
58
  values << v
55
59
  end
60
+ elsif object.instance_variable_get(:@values).is_a?(Hash)
61
+ object.values.each do |k, v|
62
+ fields << k
63
+ values << v
64
+ end
56
65
  elsif object.instance_variable_get(:@attributes).is_a?(Hash)
57
66
  object.attributes.each do |k, v|
58
67
  fields << k.to_sym
@@ -41,6 +41,9 @@ module Hessian2
41
41
  values = []
42
42
  if object.is_a?(Hash)
43
43
  members.each{|f| values << (object[f] || object[f.to_s]) }
44
+ elsif object.instance_variable_get(:@values).is_a?(Hash)
45
+ attrs = object.values
46
+ members.each{|f| values << attrs[f] }
44
47
  elsif object.instance_variable_get(:@attributes).is_a?(Hash)
45
48
  attrs = object.attributes
46
49
  members.each{|f| values << attrs[f.to_s] }
@@ -1,3 +1,3 @@
1
1
  module Hessian2
2
- VERSION = "2.0.3"
2
+ VERSION = "2.0.5"
3
3
  end
@@ -1,6 +1,5 @@
1
1
  require 'hessian2/constants'
2
2
  require 'bigdecimal'
3
- require 'active_record'
4
3
 
5
4
  module Hessian2
6
5
  module Writer
@@ -53,7 +52,7 @@ module Hessian2
53
52
  write_float(val)
54
53
  when Fixnum
55
54
  write_int(val)
56
- when Array, ActiveRecord::Relation
55
+ when Array
57
56
  write_array(val, refs, crefs, trefs)
58
57
  when Bignum
59
58
  if val >= -0x80_000_000 && val <= 0x7f_fff_fff # four octet longs
@@ -102,7 +101,7 @@ module Hessian2
102
101
  return write_ref(idx) if idx
103
102
 
104
103
  refs[arr.object_id] = refs.size
105
- len = arr.size
104
+ len = arr.count
106
105
  if len <= LIST_DIRECT_MAX # [x78-7f] value*
107
106
  str = [ BC_LIST_DIRECT_UNTYPED + len ].pack('C')
108
107
  else # x58 int value*
@@ -287,6 +286,8 @@ module Hessian2
287
286
  def write_object(object, refs = {}, crefs = {}, trefs = {})
288
287
  return write_nil unless object
289
288
 
289
+ return write_array(object, refs, crefs, trefs) if object.respond_to?(:count) && (object.respond_to?(:sql) || object.respond_to?(:to_sql))
290
+
290
291
  idx = refs[object.object_id]
291
292
  return write_ref(idx) if idx
292
293
 
@@ -469,8 +470,10 @@ module Hessian2
469
470
  def get_fields(object)
470
471
  fields = if object.is_a?(Hash)
471
472
  object.keys.map{|k| k.to_sym }
473
+ elsif object.instance_variable_get(:@values).is_a?(Hash)
474
+ object.values.keys
472
475
  elsif object.instance_variable_get(:@attributes).is_a?(Hash)
473
- object.attributes.keys.map{|k| k.to_sym }
476
+ object.attributes.keys
474
477
  else
475
478
  object.instance_variables.map{|k| k[1..-1].to_sym }
476
479
  end
@@ -486,8 +489,10 @@ module Hessian2
486
489
 
487
490
  vstr = if object.is_a?(Hash)
488
491
  fields.map{|f| write(object[f] || object[f.to_s], refs, crefs, trefs) }.join
492
+ elsif object.instance_variable_get(:@values).is_a?(Hash)
493
+ fields.map{|f| write(object.values[f], refs, crefs, trefs) }.join
489
494
  elsif object.instance_variable_get(:@attributes).is_a?(Hash)
490
- fields.map{|f| write(object.attributes[f.to_s], refs, crefs, trefs) }.join
495
+ fields.map{|f| write(object.attributes[f], refs, crefs, trefs) }.join
491
496
  else
492
497
  fields.map{|f| write(object.instance_variable_get(f.to_s.prepend('@')), refs, crefs, trefs) }.join
493
498
  end
metadata CHANGED
@@ -1,55 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hessian2
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - takafan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-20 00:00:00.000000000 Z
11
+ date: 2014-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: activerecord
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - '>='
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - '>='
24
+ - - ">="
39
25
  - !ruby/object:Gem::Version
40
26
  version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: bigdecimal
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
- - - '>='
31
+ - - ">="
46
32
  - !ruby/object:Gem::Version
47
33
  version: '0'
48
34
  type: :runtime
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
- - - '>='
38
+ - - ">="
53
39
  - !ruby/object:Gem::Version
54
40
  version: '0'
55
41
  description: like json, additionally, 麻绳2 parse your object as a struct.
@@ -59,7 +45,7 @@ executables: []
59
45
  extensions: []
60
46
  extra_rdoc_files: []
61
47
  files:
62
- - .gitignore
48
+ - ".gitignore"
63
49
  - Gemfile
64
50
  - LICENSE.txt
65
51
  - README.md
@@ -129,17 +115,17 @@ require_paths:
129
115
  - lib
130
116
  required_ruby_version: !ruby/object:Gem::Requirement
131
117
  requirements:
132
- - - '>='
118
+ - - ">="
133
119
  - !ruby/object:Gem::Version
134
120
  version: '0'
135
121
  required_rubygems_version: !ruby/object:Gem::Requirement
136
122
  requirements:
137
- - - '>='
123
+ - - ">="
138
124
  - !ruby/object:Gem::Version
139
125
  version: '0'
140
126
  requirements: []
141
127
  rubyforge_project: hessian2
142
- rubygems_version: 2.1.11
128
+ rubygems_version: 2.2.2
143
129
  signing_key:
144
130
  specification_version: 4
145
131
  summary: Hessian2