leon 1.0.2 → 1.0.3
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.
- data/lib/constants.rb +1 -0
- data/lib/io.rb +51 -3
- metadata +10 -8
- checksums.yaml +0 -7
data/lib/constants.rb
CHANGED
data/lib/io.rb
CHANGED
@@ -231,6 +231,8 @@ module LEON
|
|
231
231
|
return Constants::DOUBLE
|
232
232
|
end
|
233
233
|
return Constants::FLOAT
|
234
|
+
elsif v.kind_of? Object
|
235
|
+
return Constants::NATIVE_OBJECT
|
234
236
|
end
|
235
237
|
end
|
236
238
|
|
@@ -292,7 +294,11 @@ module LEON
|
|
292
294
|
implicit = false
|
293
295
|
end
|
294
296
|
typeByte = StringBuffer.new
|
295
|
-
|
297
|
+
if type === Constants::NATIVE_OBJECT
|
298
|
+
typeByte.writeUInt8(Constants::OBJECT, 0)
|
299
|
+
else
|
300
|
+
typeByte.writeUInt8(type, 0)
|
301
|
+
end
|
296
302
|
if type === Constants::UNDEFINED or type === Constants::BOOLEAN or type === Constants::BOOLEAN + 1 or type === Constants::NULL or type === Constants::NAN or type === Constants::MINUS_INFINITY or type === Constants::INFINITY
|
297
303
|
append(typeByte)
|
298
304
|
return 1
|
@@ -360,7 +366,9 @@ module LEON
|
|
360
366
|
return
|
361
367
|
elsif type === Constants::OBJECT
|
362
368
|
index = LEON::match_layout(val, @stringIndex, @OLI)
|
363
|
-
|
369
|
+
if !implicit
|
370
|
+
writeValue(index, @OLItype, true)
|
371
|
+
end
|
364
372
|
for i in 0..(@OLI[index].length - 1)
|
365
373
|
key = @stringIndex[@OLI[index][i]]
|
366
374
|
if not val.has_key? key
|
@@ -370,6 +378,17 @@ module LEON
|
|
370
378
|
writeValue(tmp, LEON::type_check(tmp))
|
371
379
|
end
|
372
380
|
return
|
381
|
+
elsif type === Constants::NATIVE_OBJECT
|
382
|
+
index = LEON::match_layout(val, @stringIndex, @OLI)
|
383
|
+
if !implicit
|
384
|
+
writeValue(index, @OLItype, true)
|
385
|
+
end
|
386
|
+
for i in 0..(@OLI[index].length - 1)
|
387
|
+
key = @stringIndex[@OLI[index][i]]
|
388
|
+
tmp = val.send key
|
389
|
+
writeValue(tmp, LEON::type_check(tmp))
|
390
|
+
end
|
391
|
+
return
|
373
392
|
elsif type === Constants::BUFFER
|
374
393
|
len = val.buffer.length
|
375
394
|
writeValue(len, LEON::type_check(len))
|
@@ -434,7 +453,13 @@ module LEON
|
|
434
453
|
end
|
435
454
|
end
|
436
455
|
def self.match_layout(val, stringIndex, oli)
|
437
|
-
|
456
|
+
if val.kind_of? Hash
|
457
|
+
keys = val.keys
|
458
|
+
elsif val.kind_of? Object
|
459
|
+
keys = val.instance_variables.map { |v|
|
460
|
+
v.to_s.sub("@", "")
|
461
|
+
}
|
462
|
+
end
|
438
463
|
layout = Array.new
|
439
464
|
for i in 0..(keys.length - 1)
|
440
465
|
if keys[i].kind_of? Symbol
|
@@ -481,6 +506,18 @@ module LEON
|
|
481
506
|
branch.each { |k, v|
|
482
507
|
LEON::gather_layouts(val, stringIndex, ret, v)
|
483
508
|
}
|
509
|
+
elsif branch.kind_of? Object
|
510
|
+
ret.push Array.new
|
511
|
+
vars = branch.instance_variables
|
512
|
+
vars.map! { |v|
|
513
|
+
v.to_s.sub("@", "")
|
514
|
+
}
|
515
|
+
vars.each { |v|
|
516
|
+
ret[ret.length - 1].push stringIndex.index(v)
|
517
|
+
}
|
518
|
+
vars.each { |v|
|
519
|
+
LEON::gather_layouts(val, stringIndex, ret, branch.send(v))
|
520
|
+
}
|
484
521
|
end
|
485
522
|
return ret
|
486
523
|
end
|
@@ -514,6 +551,17 @@ module LEON
|
|
514
551
|
set_push(ret, branch)
|
515
552
|
elsif branch.kind_of? Symbol
|
516
553
|
set_push(ret, branch.to_s)
|
554
|
+
elsif branch.kind_of? Object
|
555
|
+
vars = branch.instance_variables
|
556
|
+
vars.map! { |v|
|
557
|
+
v.to_s.sub("@", "")
|
558
|
+
}
|
559
|
+
vars.each { |v|
|
560
|
+
set_push(ret, v)
|
561
|
+
}
|
562
|
+
vars.each { |v|
|
563
|
+
LEON::gather_strings(val, ret, branch.send(v))
|
564
|
+
}
|
517
565
|
end
|
518
566
|
return ret
|
519
567
|
end
|
metadata
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Raymond Pulver IV
|
@@ -18,33 +19,34 @@ extensions: []
|
|
18
19
|
extra_rdoc_files: []
|
19
20
|
files:
|
20
21
|
- lib/buffer-iterator.rb
|
21
|
-
- lib/constants.rb
|
22
22
|
- lib/io.rb
|
23
|
-
- lib/leon.rb
|
24
23
|
- lib/string-buffer.rb
|
24
|
+
- lib/constants.rb
|
25
|
+
- lib/leon.rb
|
25
26
|
- lib/types.rb
|
26
27
|
homepage: http://github.com/raypulver/ruby-leon
|
27
28
|
licenses:
|
28
29
|
- MIT
|
29
|
-
metadata: {}
|
30
30
|
post_install_message:
|
31
31
|
rdoc_options: []
|
32
32
|
require_paths:
|
33
33
|
- lib
|
34
34
|
required_ruby_version: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
35
36
|
requirements:
|
36
|
-
- -
|
37
|
+
- - ! '>='
|
37
38
|
- !ruby/object:Gem::Version
|
38
39
|
version: '0'
|
39
40
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
40
42
|
requirements:
|
41
|
-
- -
|
43
|
+
- - ! '>='
|
42
44
|
- !ruby/object:Gem::Version
|
43
45
|
version: '0'
|
44
46
|
requirements: []
|
45
47
|
rubyforge_project:
|
46
|
-
rubygems_version:
|
48
|
+
rubygems_version: 1.8.23
|
47
49
|
signing_key:
|
48
|
-
specification_version:
|
50
|
+
specification_version: 3
|
49
51
|
summary: LEON serialization for Ruby.
|
50
52
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 09190913d79621df63948f902d65aca5f8d13e3f
|
4
|
-
data.tar.gz: c3a17075d68bd15dca1c55c5205df75db1f977f5
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 59ab7f117bee96787579fc9cd432142ded094f3bae7bdf037f68f59ba8826065e8c07dfabedb57bfab8a3d494264d89f4819baa69cf3c1d29ee4082bb558982a
|
7
|
-
data.tar.gz: 06c47c6c116e853180662b6b8fec1dcb41f58a2744cac6887c06b67f614c872dd0a6b3ddf4495d5865c65374a13613c9212b9f5dc36c2970d52760a0fa7f80a7
|