tinycode 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.yardopts +2 -0
- data/Gemfile.lock +1 -1
- data/README.md +3 -3
- data/Rakefile +1 -1
- data/lib/tinycode/module.rb +4 -4
- data/lib/tinycode/version.rb +1 -1
- data/tinycode.gemspec +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3438fb3aab3c2d58592ed6c9bc1f63f37e98effbecb60a67f110d4306a3822aa
|
4
|
+
data.tar.gz: 65b47a8b537de5b3e40b6c0dfd7efd5789135e2ae71d463df1e372cc697eb436
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2214f092bbbc76b3daa8f694a2ddf04556ae80a5627cb80e0060ad25b842ad431c948a828e1d0f0dcb29ab1a3dc8171e3f8ca81a4c9f1f66b3495074dfd126fd
|
7
|
+
data.tar.gz: b9824631c29c06ec9fd66b1e127f9a3c35c5956ee4514758c07b3290317a253609a36d73201795686ea419fb0a86444ed043e353d3397d2ecf279435a40c4d3a
|
data/.rubocop.yml
CHANGED
data/.yardopts
ADDED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Tinycode
|
2
2
|
|
3
|
-
This gem provides an encoder and decoder for tinycode, which is a
|
3
|
+
This gem provides an encoder and decoder for tinycode, which is a [Bencode] like
|
4
4
|
encoding that supports more data-types and slightly smaller encoded sizes.
|
5
5
|
|
6
6
|
The encoder supports arrays, hashes, strings, symbols, and integers, as well as
|
@@ -9,13 +9,13 @@ specialized fixed-width integers: `Tinycode::U8`, `Tinycode::U16`,
|
|
9
9
|
Like [YAML] but unlike [JSON], this encoder maintains a distinction between
|
10
10
|
strings and symbols.
|
11
11
|
|
12
|
-
The encoding is inspired by
|
12
|
+
The encoding is inspired by Bencode's tag-length-value construction for strings, which eliminates the need for escaping in Strings.
|
13
13
|
This makes this encoding particularly appropriate for serializing binary strings
|
14
14
|
directly.
|
15
15
|
|
16
16
|
[YAML]: https://ruby-doc.org/stdlib-3.0.2/libdoc/yaml/rdoc/YAML.html
|
17
17
|
[JSON]: https://ruby-doc.org/stdlib-3.0.2/libdoc/json/rdoc/JSON.html
|
18
|
-
[
|
18
|
+
[Bencode]: https://en.wikipedia.org/wiki/Bencode
|
19
19
|
|
20
20
|
## Demo
|
21
21
|
|
data/Rakefile
CHANGED
data/lib/tinycode/module.rb
CHANGED
@@ -28,7 +28,7 @@ module Tinycode
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def load(tinycode)
|
31
|
-
raise ArgumentError, "Cannot convert #{
|
31
|
+
raise ArgumentError, "Cannot convert #{tinycode.class} to String" if !tinycode.respond_to?(:to_str)
|
32
32
|
|
33
33
|
tinycode = tinycode.to_str.b
|
34
34
|
struct, length = load_with_length(tinycode)
|
@@ -102,7 +102,7 @@ module Tinycode
|
|
102
102
|
|
103
103
|
def load_id(tinycode)
|
104
104
|
length = tinycode.index(/[':]/)
|
105
|
-
value = tinycode[...length]
|
105
|
+
value = tinycode[0...length]
|
106
106
|
value = if tinycode[length] == ':'
|
107
107
|
value.to_sym
|
108
108
|
else
|
@@ -117,7 +117,7 @@ module Tinycode
|
|
117
117
|
end
|
118
118
|
|
119
119
|
def dump_symbol(sym)
|
120
|
-
dump_string(sym.
|
120
|
+
dump_string(sym.to_s, code: ':')
|
121
121
|
end
|
122
122
|
|
123
123
|
def load_symbol(sym)
|
@@ -150,7 +150,7 @@ module Tinycode
|
|
150
150
|
|
151
151
|
def load_varint(tinycode)
|
152
152
|
length = tinycode.each_byte.lazy.take_while {|b| b > 0x7F }.count + 1
|
153
|
-
[tinycode[...length].unpack1('w'), length]
|
153
|
+
[tinycode[0...length].unpack1('w'), length]
|
154
154
|
end
|
155
155
|
|
156
156
|
def load_boolean(tinycode)
|
data/lib/tinycode/version.rb
CHANGED
data/tinycode.gemspec
CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.executables = spec.files.grep(%r{\Aexe/}) {|f| File.basename(f) }
|
30
30
|
spec.require_paths = ['lib']
|
31
31
|
|
32
|
-
spec.required_ruby_version = '>=
|
32
|
+
spec.required_ruby_version = '>= 2.6.0'
|
33
33
|
|
34
34
|
spec.add_development_dependency 'rake', '~> 13.0'
|
35
35
|
spec.add_development_dependency 'rerun', '~> 0.13'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tinycode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Gittemeier
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -132,6 +132,7 @@ extra_rdoc_files: []
|
|
132
132
|
files:
|
133
133
|
- ".rspec"
|
134
134
|
- ".rubocop.yml"
|
135
|
+
- ".yardopts"
|
135
136
|
- Gemfile
|
136
137
|
- Gemfile.lock
|
137
138
|
- LICENSE
|
@@ -159,7 +160,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
159
160
|
requirements:
|
160
161
|
- - ">="
|
161
162
|
- !ruby/object:Gem::Version
|
162
|
-
version:
|
163
|
+
version: 2.6.0
|
163
164
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
164
165
|
requirements:
|
165
166
|
- - ">="
|