ciri-rlp 0.2.1 → 0.2.2

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: 800e7157f6b31a8893ed4ab6edb398db105a14e4c207b6149e743bbbdc7dc484
4
- data.tar.gz: cd9725a068e53b4f33e9d2f7b8138384351622e30f2e38b419ab98d4820951a4
3
+ metadata.gz: a9c3349059c761090b9c9fd81eea54c8247d5ea7fa5b33d879822c12b3f0a1f0
4
+ data.tar.gz: 3646c2b7ddcac8185eb4875c71c9a4ed802198f616155144c2f45466f1816399
5
5
  SHA512:
6
- metadata.gz: bb46db492841b225783ac4f95ac114638419afee9e7054837d824ff76baead89978c7f165b93bec23489d76e5daef62fdb8c78fd8e9643a22a4fdfcd59100b8f
7
- data.tar.gz: 391bbd770b0ff99a2d0a4c555f2a1f55976cbec04eb23a9bfb0180512fd6b0ffdba419a5ae9e12b627f946c435765aecf81697f80fc5d0f08d420bee15a2dc3c
6
+ metadata.gz: e7e175ab3452d4eda0487008a5cd1f6f3f6b14f922413d37672aa0f622cb76e0468feee44e558b00d4744c14499ffa6d7582b3fef005e603dadb3e01987e3c1e
7
+ data.tar.gz: 35739e554737cc4314878f3e92c603a30dd984cbd6f788839071891de75bcdcb4052526154a3e1025466fa4bcd3d4b233471b152f5d6d8067535057ac55ec2eb
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ tags
data/.travis.yml CHANGED
@@ -2,4 +2,9 @@ sudo: false
2
2
  language: ruby
3
3
  rvm:
4
4
  - 2.5.0
5
- before_install: gem install bundler -v 1.16.1
5
+ before_install:
6
+ - gem install bundler -v 1.16.1
7
+ - bundle
8
+ script:
9
+ - bundle exec rake spec
10
+
data/Gemfile.lock ADDED
@@ -0,0 +1,39 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ciri-rlp (0.2.2)
5
+ ciri-utils (~> 0.2.1)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ciri-utils (0.2.1)
11
+ digest-sha3 (~> 1.1.0)
12
+ diff-lcs (1.3)
13
+ digest-sha3 (1.1.0)
14
+ rake (12.3.1)
15
+ rspec (3.7.0)
16
+ rspec-core (~> 3.7.0)
17
+ rspec-expectations (~> 3.7.0)
18
+ rspec-mocks (~> 3.7.0)
19
+ rspec-core (3.7.1)
20
+ rspec-support (~> 3.7.0)
21
+ rspec-expectations (3.7.0)
22
+ diff-lcs (>= 1.2.0, < 2.0)
23
+ rspec-support (~> 3.7.0)
24
+ rspec-mocks (3.7.0)
25
+ diff-lcs (>= 1.2.0, < 2.0)
26
+ rspec-support (~> 3.7.0)
27
+ rspec-support (3.7.1)
28
+
29
+ PLATFORMS
30
+ ruby
31
+
32
+ DEPENDENCIES
33
+ bundler (~> 1.16)
34
+ ciri-rlp!
35
+ rake (~> 12.0)
36
+ rspec (~> 3.0)
37
+
38
+ BUNDLED WITH
39
+ 1.16.3
data/README.md CHANGED
@@ -87,7 +87,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
87
87
 
88
88
  ## Contributing
89
89
 
90
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ciri-rlp. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
90
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ciri-ethereum/ciri-rlp. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
91
91
 
92
92
  ## License
93
93
 
data/bin/bundle ADDED
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'bundle' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "rubygems"
12
+
13
+ m = Module.new do
14
+ module_function
15
+
16
+ def invoked_as_script?
17
+ File.expand_path($0) == File.expand_path(__FILE__)
18
+ end
19
+
20
+ def env_var_version
21
+ ENV["BUNDLER_VERSION"]
22
+ end
23
+
24
+ def cli_arg_version
25
+ return unless invoked_as_script? # don't want to hijack other binstubs
26
+ return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27
+ bundler_version = nil
28
+ update_index = nil
29
+ ARGV.each_with_index do |a, i|
30
+ if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
31
+ bundler_version = a
32
+ end
33
+ next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
34
+ bundler_version = $1 || ">= 0.a"
35
+ update_index = i
36
+ end
37
+ bundler_version
38
+ end
39
+
40
+ def gemfile
41
+ gemfile = ENV["BUNDLE_GEMFILE"]
42
+ return gemfile if gemfile && !gemfile.empty?
43
+
44
+ File.expand_path("../../Gemfile", __FILE__)
45
+ end
46
+
47
+ def lockfile
48
+ lockfile =
49
+ case File.basename(gemfile)
50
+ when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
51
+ else "#{gemfile}.lock"
52
+ end
53
+ File.expand_path(lockfile)
54
+ end
55
+
56
+ def lockfile_version
57
+ return unless File.file?(lockfile)
58
+ lockfile_contents = File.read(lockfile)
59
+ return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
60
+ Regexp.last_match(1)
61
+ end
62
+
63
+ def bundler_version
64
+ @bundler_version ||= begin
65
+ env_var_version || cli_arg_version ||
66
+ lockfile_version || "#{Gem::Requirement.default}.a"
67
+ end
68
+ end
69
+
70
+ def load_bundler!
71
+ ENV["BUNDLE_GEMFILE"] ||= gemfile
72
+
73
+ # must dup string for RG < 1.8 compatibility
74
+ activate_bundler(bundler_version.dup)
75
+ end
76
+
77
+ def activate_bundler(bundler_version)
78
+ if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0")
79
+ bundler_version = "< 2"
80
+ end
81
+ gem_error = activation_error_handling do
82
+ gem "bundler", bundler_version
83
+ end
84
+ return if gem_error.nil?
85
+ require_error = activation_error_handling do
86
+ require "bundler/version"
87
+ end
88
+ return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION))
89
+ warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`"
90
+ exit 42
91
+ end
92
+
93
+ def activation_error_handling
94
+ yield
95
+ nil
96
+ rescue StandardError, LoadError => e
97
+ e
98
+ end
99
+ end
100
+
101
+ m.load_bundler!
102
+
103
+ if m.invoked_as_script?
104
+ load Gem.bin_path("bundler", "bundle")
105
+ end
data/bin/htmldiff ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'htmldiff' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("diff-lcs", "htmldiff")
data/bin/ldiff ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'ldiff' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("diff-lcs", "ldiff")
data/bin/rake ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rake' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rake", "rake")
data/bin/rspec ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rspec-core", "rspec")
@@ -44,7 +44,7 @@ module Ciri
44
44
  if type == Integer
45
45
  item = s.read(1)
46
46
  if item.nil?
47
- raise InvalidError.new "invalid bool value nil"
47
+ raise InvalidError.new "invalid Integer value nil"
48
48
  elsif item == "\x80".b || item.empty?
49
49
  0
50
50
  elsif item.ord < 0x80
@@ -97,6 +97,8 @@ module Ciri
97
97
  s = StringIO.new(s) if s.is_a?(String)
98
98
  c = first_char || s.read(1)
99
99
  list = []
100
+ # list is empty
101
+ # return list if c.nil?
100
102
  sub_s = case c.ord
101
103
  when 0xc0..0xf7
102
104
  length = c.ord - 0xc0
@@ -151,4 +153,4 @@ module Ciri
151
153
 
152
154
  end
153
155
  end
154
- end
156
+ end
@@ -30,12 +30,16 @@ module Ciri
30
30
  class Raw
31
31
  end
32
32
 
33
- class RawString
33
+ class Bytes
34
34
  end
35
35
 
36
- class RawList
36
+ RawString = Bytes
37
+
38
+ class List
37
39
  end
38
40
 
41
+ RawList = List
42
+
39
43
  # Serializable module allow ruby objects serialize/deserialize to or from RLP encoding.
40
44
  # See Ciri::RLP::Serializable::TYPES for supported type.
41
45
  #
@@ -75,7 +79,7 @@ module Ciri
75
79
  #
76
80
  module Serializable
77
81
  # nil represent RLP raw value(string or array of string)
78
- TYPES = [Raw, RawString, RawList, Integer, Bool].map {|key| [key, true]}.to_h.freeze
82
+ TYPES = [Raw, Bytes, List, Integer, Bool].map {|key| [key, true]}.to_h.freeze
79
83
 
80
84
  # Schema specific columns types of classes, normally you should not use Serializable::Schema directly
81
85
  #
@@ -104,7 +108,7 @@ module Ciri
104
108
  options = {}
105
109
  type = Raw
106
110
  end
107
- raise InvalidSchemaError.new("missing type #{type} for key #{key}") unless check_key_type(type)
111
+ raise InvalidSchemaError.new("incorrect type on key #{key}, #{type} is not a valid RLP class") unless check_key_type(type)
108
112
  keys << key
109
113
  @_schema[key] = KeySchema.new(type: type, options: options)
110
114
  end
@@ -1,5 +1,5 @@
1
1
  module Ciri
2
2
  module RLP
3
- VERSION = "0.2.1"
3
+ VERSION = "0.2.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ciri-rlp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jiang Jinyang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-07 00:00:00.000000000 Z
11
+ date: 2018-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ciri-utils
@@ -78,10 +78,16 @@ files:
78
78
  - ".travis.yml"
79
79
  - CODE_OF_CONDUCT.md
80
80
  - Gemfile
81
+ - Gemfile.lock
81
82
  - LICENSE.txt
82
83
  - README.md
83
84
  - Rakefile
85
+ - bin/bundle
84
86
  - bin/console
87
+ - bin/htmldiff
88
+ - bin/ldiff
89
+ - bin/rake
90
+ - bin/rspec
85
91
  - bin/setup
86
92
  - ciri-rlp.gemspec
87
93
  - lib/ciri/rlp.rb