canoser 0.1.2 → 0.1.3

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
  SHA256:
3
- metadata.gz: dd5d2302b41f369cd2aa3f7bbb4602735fd2be0e3523347ed438da306e224cac
4
- data.tar.gz: 5dc3bc174725cc60ec2a03841841a583701ead4358547750b44a865e1d2570ef
3
+ metadata.gz: b745e1e19b7edc1370a40fbe838de85573cabb4c5bd15c80e334411a2b12d883
4
+ data.tar.gz: 0b6ec30cd496ea7161980bd765ef183e79a839639360b9b54456d813dc2043b0
5
5
  SHA512:
6
- metadata.gz: 1ac39e842339805ae312a43731673aa22e1540466966ca1d47b85382df34c6019a4d7db291bcd3fa92cdc23ff3601fe2829ae029b7bd26e862c646db92961c72
7
- data.tar.gz: 26dae443e65e75f56fa582dbb5ea917cd16f46ed1ec7a5bba339d77db237e1546f973946abd60ed0a207899ea369a1a528f5581374c108d3d8034aa9fc360ee4
6
+ metadata.gz: fd05217db468838857f2bf3713d2557f7b9d31fe5a2d1bd69a8ae0c29547b15c669e0d80501bb7a782c6bf7235022d5047f272fe14e863f253b752845d9e0c18
7
+ data.tar.gz: 178b83a2e40b543a54c78d4834b1d5a435f11ea3893fce18e4e0541fc9e75a87e9157828fdabc3b5232ec4121ca7c12d86529f06c2b67240ac88de8167b2d53b
data/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ # Changelog
2
+
3
+ ## v0.1.3 (released at 2019-09-04)
4
+
5
+ * support signed int type
6
+ * change the project url from https://github.com/yuanxinyu/canoser-ruby.git to https://github.com/yuan-xy/canoser-ruby.git
7
+
8
+ ## v0.1.2 (released at 2019-09-01)
9
+
10
+ * change the field access method from obj["name"] to obj.name
11
+
12
+ ## v0.1.1
13
+
14
+ * Initial release from [canoser-ruby](https://github.com/yuan-xy/canoser-ruby.git).
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- canoser (0.1.0)
4
+ canoser (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -21,4 +21,4 @@ DEPENDENCIES
21
21
  rake (~> 10.0)
22
22
 
23
23
  BUNDLED WITH
24
- 2.0.1
24
+ 2.0.2
data/README-CN.md CHANGED
@@ -76,6 +76,10 @@ impl CanonicalSerialize for AccountResource {
76
76
  | Canoser::Uint16 | | 无符号16位整数 |
77
77
  | Canoser::Uint32 | | 无符号32位整数 |
78
78
  | Canoser::Uint64 | | 无符号64位整数 |
79
+ | Canoser::Int8 | | 有符号8位整数 |
80
+ | Canoser::Int16 | | 有符号16位整数 |
81
+ | Canoser::Int32 | | 有符号32位整数 |
82
+ | Canoser::Int64 | | 有符号64位整数 |
79
83
  | Canoser::Bool | | 布尔类型 |
80
84
  | Canoser::Str | | 字符串 |
81
85
  | [] | 支持 | 数组类型 |
data/README.md CHANGED
@@ -82,6 +82,10 @@ In Canoser, after defining the data structure, you don't need to write code to i
82
82
  | Canoser::Uint16 | | Unsigned 16-bit integer|
83
83
  | Canoser::Uint32 | | Unsigned 32-bit integer |
84
84
  | Canoser::Uint64 | | Unsigned 64-bit integer |
85
+ | Canoser::Int8 | | Signed 8-bit integer |
86
+ | Canoser::Int16 | | Signed 16-bit integer|
87
+ | Canoser::Int32 | | Signed 32-bit integer |
88
+ | Canoser::Int64 | | Signed 64-bit integer |
85
89
  | Canoser::Bool | | Boolean |
86
90
  | Canoser::Str | | String |
87
91
  | [] | supported | Array Type |
data/bin/console CHANGED
@@ -11,4 +11,5 @@ require "canoser"
11
11
  # Pry.start
12
12
 
13
13
  require "irb"
14
+ require 'irb/completion'
14
15
  IRB.start(__FILE__)
data/canoser.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
 
12
12
  spec.summary = %q{A ruby implementation of the canonical serialization for the Libra network.}
13
13
  spec.description = %q{A ruby implementation of the canonical serialization for the Libra network. Canonical serialization guarantees byte consistency when serializing an in-memory data structure. It is useful for situations where two parties want to efficiently compare data structures they independently maintain. It happens in consensus where independent validators need to agree on the state they independently compute. A cryptographic hash of the serialized data structure is what ultimately gets compared. In order for this to work, the serialization of the same data structures must be identical when computed by independent validators potentially running different implementations of the same spec in different languages.}
14
- spec.homepage = "https://github.com/yuanxinyu/canoser-ruby.git"
14
+ spec.homepage = "https://github.com/yuan-xy/canoser-ruby.git"
15
15
  spec.license = "MIT"
16
16
 
17
17
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
@@ -20,8 +20,8 @@ Gem::Specification.new do |spec|
20
20
  spec.metadata["allowed_push_host"] = "https://rubygems.org"
21
21
 
22
22
  spec.metadata["homepage_uri"] = spec.homepage
23
- spec.metadata["source_code_uri"] = "https://github.com/yuanxinyu/canoser-ruby.git"
24
- spec.metadata["changelog_uri"] = "https://github.com/yuanxinyu/canoser-ruby.git"
23
+ spec.metadata["source_code_uri"] = "https://github.com/yuan-xy/canoser-ruby.git"
24
+ spec.metadata["changelog_uri"] = "https://github.com/yuan-xy/canoser-ruby/blob/master/CHANGELOG.md"
25
25
  else
26
26
  raise "RubyGems 2.0 or newer is required to protect against " \
27
27
  "public gem pushes."
data/lib/canoser/field.rb CHANGED
@@ -3,12 +3,17 @@ module Canoser
3
3
  class IntField
4
4
  @@pack_map = {8 => "C", 16 => "S", 32 => "L", 64 => "Q"}
5
5
 
6
- def initialize(int_bits)
6
+ def initialize(int_bits, signed=false)
7
7
  @int_bits = int_bits
8
+ @signed = signed
8
9
  end
9
10
 
10
11
  def inspect
11
- "Uint#{@int_bits}"
12
+ if @signed
13
+ "Int#{@int_bits}"
14
+ else
15
+ "Uint#{@int_bits}"
16
+ end
12
17
  end
13
18
 
14
19
  def to_s
@@ -16,7 +21,9 @@ module Canoser
16
21
  end
17
22
 
18
23
  def pack_str
19
- @@pack_map[@int_bits]
24
+ str = @@pack_map[@int_bits]
25
+ str = str.downcase if @signed
26
+ str
20
27
  end
21
28
 
22
29
  def encode(value)
@@ -33,7 +40,11 @@ module Canoser
33
40
  end
34
41
 
35
42
  def max_value
36
- 2**@int_bits - 1
43
+ if @signed
44
+ 2**(@int_bits-1) - 1
45
+ else
46
+ 2**@int_bits - 1
47
+ end
37
48
  end
38
49
  end
39
50
 
@@ -42,6 +53,11 @@ module Canoser
42
53
  Uint32 = IntField.new(32)
43
54
  Uint64 = IntField.new(64)
44
55
 
56
+ Int8 = IntField.new(8, true)
57
+ Int16 = IntField.new(16, true)
58
+ Int32 = IntField.new(32, true)
59
+ Int64 = IntField.new(64, true)
60
+
45
61
  class Bool
46
62
  def self.encode(value)
47
63
  if value
@@ -1,3 +1,3 @@
1
1
  module Canoser
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canoser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - yuan xinyu
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-02 00:00:00.000000000 Z
11
+ date: 2019-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -83,6 +83,7 @@ extra_rdoc_files: []
83
83
  files:
84
84
  - ".gitignore"
85
85
  - ".travis.yml"
86
+ - CHANGELOG.md
86
87
  - Gemfile
87
88
  - Gemfile.lock
88
89
  - LICENSE.txt
@@ -98,14 +99,14 @@ files:
98
99
  - lib/canoser/field.rb
99
100
  - lib/canoser/struct.rb
100
101
  - lib/canoser/version.rb
101
- homepage: https://github.com/yuanxinyu/canoser-ruby.git
102
+ homepage: https://github.com/yuan-xy/canoser-ruby.git
102
103
  licenses:
103
104
  - MIT
104
105
  metadata:
105
106
  allowed_push_host: https://rubygems.org
106
- homepage_uri: https://github.com/yuanxinyu/canoser-ruby.git
107
- source_code_uri: https://github.com/yuanxinyu/canoser-ruby.git
108
- changelog_uri: https://github.com/yuanxinyu/canoser-ruby.git
107
+ homepage_uri: https://github.com/yuan-xy/canoser-ruby.git
108
+ source_code_uri: https://github.com/yuan-xy/canoser-ruby.git
109
+ changelog_uri: https://github.com/yuan-xy/canoser-ruby/blob/master/CHANGELOG.md
109
110
  post_install_message:
110
111
  rdoc_options: []
111
112
  require_paths: