multibases 0.1.0 → 0.2.0

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: 57c641bb941bf22ba1e15624ec2f798ccfdbda9c349f8abaa18bc6ef39275008
4
- data.tar.gz: 5dd0cbd27ac8ee91362505fa0ab64b021856109ce61ca8d1815242d21a2f347e
3
+ metadata.gz: e2b0dd76dacf9936bc730a2568740868ffd7da45d0d341bfbde1e7884ccfd162
4
+ data.tar.gz: b494e77003851e5cc216a163d2b75ef443a05609789de4f4070ed3fa2cc3d3cb
5
5
  SHA512:
6
- metadata.gz: 4ebd6b9d19633242cf696170912d7897c2ebc40321b92a3f717d918d1adad0d65ab2cbd9c50dca09497917221236c6110ffcf65f2be93fa690b6df9c658018d6
7
- data.tar.gz: 59e4ddce0a22b82771c695e7f50e9da0653af855cd09e6be53329539a0115ac85329606ce15ff03ca28c0eb1cf07fbda45c4005975cbaf633c84d4763d729b74
6
+ metadata.gz: 2c15a0d0e856d94c6edf60c2e2a83d722c2c67527cd1c07b28bb917cb5e73572e834d3662352c3b0afe895e0109fb11d3848194a66477ca28565dabaa99ef925
7
+ data.tar.gz: 61b9616e4627224d15d76f04c75e621f16059de0128cd2a4f4a7b49cf62513200ef5c418495526b2cb65eebb1fc271cdb27620156c0ce388fa4a550972be4d38
data/.gitignore CHANGED
@@ -1,9 +1,9 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
- Gemfile.lock
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ Gemfile.lock
data/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0
4
+
5
+ - Add convenience methods to registry, like `multicodecs`
6
+ - Change tests to use fixture files and add `rake` task to update these
7
+
8
+ ## 0.1.0
9
+
10
+ :baby: intial release
data/README.md CHANGED
@@ -1,9 +1,14 @@
1
1
  # Multibases
2
2
 
3
- [![Build Status: master](https://travis-ci.com/SleeplessByte/ruby-multibase.svg?branch=master)](https://travis-ci.com/SleeplessByte/ruby-multibase)
4
- [![Gem Version](https://badge.fury.io/rb/ruby-multibase.svg)](https://badge.fury.io/rb/ruby-multibase)
5
- [![MIT license](https://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)
6
- [![Maintainability](https://api.codeclimate.com/v1/badges/1e5600a4be90eec063e0/maintainability)](https://codeclimate.com/repos/5d094b036bd112014f005f98/maintainability)
3
+ [![Build Status](https://travis-ci.com/SleeplessByte/ruby-multibase.svg?branch=master)][shield-link-travis]
4
+ [![Gem Version](https://badge.fury.io/rb/multibases.svg)][shield-link-gem]
5
+ [![MIT license](https://img.shields.io/badge/license-MIT-brightgreen.svg)][shield-link-license]
6
+ [![Maintainability](https://api.codeclimate.com/v1/badges/1253cc22b664d27d4052/maintainability)][shield-link-codeclimate]
7
+
8
+ [shield-link-travis]: https://travis-ci.com/SleeplessByte/ruby-multibase
9
+ [shield-link-gem]: https://badge.fury.io/rb/multibases
10
+ [shield-link-license]: http://opensource.org/licenses/MIT
11
+ [shield-link-codeclimate]: https://codeclimate.com/github/SleeplessByte/ruby-multibase/maintainability
7
12
 
8
13
  > Multibase is a protocol for disambiguating the encoding of base-encoded
9
14
  > (e.g., base32, base64, base58, etc.) binary appearing in text.
@@ -283,6 +288,7 @@ expected == Multibases::Base16.encode(Multibases::ByteArray.new("abc".bytes))
283
288
  ## Related
284
289
 
285
290
  - [`multiformats/multibase`][git-multibase]: the spec repository
291
+ - [`multiformats/ruby-multicodec`][git-ruby-multicodec]: the ruby implementation of [`multiformats/multicodec`][git-multicodec]
286
292
  - [`multiformats/ruby-multihash`][git-ruby-multihash]: the ruby implementation of [`multiformats/multihash`][git-multihash]
287
293
 
288
294
  ## Development
@@ -298,7 +304,7 @@ push git commits and tags, and push the `.gem` file to [rubygems.org][web-rubyge
298
304
 
299
305
  ## Contributing
300
306
 
301
- Bug reports and pull requests are welcome on GitHub at [SleeplessByte/commmand][git-self].
307
+ Bug reports and pull requests are welcome on GitHub at [SleeplessByte/ruby-multibase][git-self].
302
308
  This project is intended to be a safe, welcoming space for collaboration, and
303
309
  contributors are expected to adhere to the [Contributor Covenant][web-coc] code
304
310
  of conduct.
@@ -316,6 +322,8 @@ issue trackers, chat rooms and mailing lists is expected to follow the
316
322
  [spec]: https://github.com/multiformats/multibase
317
323
  [git-self-coc]: https://github.com/SleeplessByte/ruby-multibase/blob/master/CODE_OF_CONDUCT.md
318
324
  [git-self]: https://github.com/SleeplessByte/ruby-multibase
325
+ [git-ruby-multicodec]: https://github.com/SleeplessByte/ruby-multicodec
326
+ [git-multicodec]: https://github.com/multiformats/multicodec
319
327
  [git-multibase]: https://github.com/multiformats/multibase
320
328
  [git-multibase-table]: https://github.com/multiformats/multibase/blob/master/multibase.csv
321
329
  [git-ruby-multihash]: https://github.com/multiformats/ruby-multihash
data/Rakefile CHANGED
@@ -9,4 +9,25 @@ Rake::TestTask.new(:test) do |t|
9
9
  t.test_files = FileList["test/**/*_test.rb"]
10
10
  end
11
11
 
12
+ Rake::Task.define_task(:update) do |t|
13
+ require 'open-uri'
14
+
15
+ SOURCE_FILE = 'https://raw.githubusercontent.com/multiformats/multibase/master/multibase.csv'
16
+ SPEC_FILE_FORMAT = 'https://raw.githubusercontent.com/multiformats/multibase/master/tests/test%<index>d.csv'
17
+
18
+ File.open(File.join(__dir__, 'lib', 'table.csv'), "wb") do |saved_file|
19
+ open(SOURCE_FILE, "rb") do |read_file|
20
+ saved_file.write(read_file.read)
21
+ end
22
+ end
23
+
24
+ (1..6).each do |index|
25
+ File.open(File.join(__dir__, 'test', 'fixtures', format('test%<index>s.csv', index: index)), "wb") do |saved_file|
26
+ open(format(SPEC_FILE_FORMAT, index: index), "rb") do |read_file|
27
+ saved_file.write(read_file.read)
28
+ end
29
+ end
30
+ end
31
+ end
32
+
12
33
  task :default => :test
data/bin/setup CHANGED
@@ -1,8 +1,8 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -23,6 +23,10 @@ module Multibases
23
23
 
24
24
  module_function
25
25
 
26
+ def [](entry)
27
+ find_by(code: entry, encoding: entry)
28
+ end
29
+
26
30
  def implement(encoding, code, implementation = nil, alphabet = nil)
27
31
  Multibases::IMPLEMENTATIONS[encoding] = Registration.new(
28
32
  code,
@@ -45,6 +49,14 @@ module Multibases
45
49
  end
46
50
  end
47
51
 
52
+ def codes
53
+ Multicodecs::REGISTRATIONS.values.map(&:code)
54
+ end
55
+
56
+ def names
57
+ Multicodecs::REGISTRATIONS.keys
58
+ end
59
+
48
60
  def multibase_version(multibase_semver = nil)
49
61
  return @multibase_version if multibase_semver.nil?
50
62
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Multibases
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
data/lib/multibases.rb CHANGED
@@ -11,8 +11,6 @@ require 'multibases/base32'
11
11
  require 'multibases/base64'
12
12
 
13
13
  module Multibases
14
- class Error < StandardError; end
15
-
16
14
  # https://github.com/multiformats/multibase#multibase-table-v100-rc-semver
17
15
  multibase_version '1.0.0'
18
16
 
data/lib/table.csv ADDED
@@ -0,0 +1,23 @@
1
+ encoding, code, description
2
+ identity, 0x00, 8-bit binary (encoder and decoder keeps data unmodified)
3
+ base1, 1, unary (11111)
4
+ base2, 0, binary (01010101)
5
+ base8, 7, octal
6
+ base10, 9, decimal
7
+ base16, f, hexadecimal
8
+ base16upper, F, hexadecimal
9
+ base32hex, v, rfc4648 no padding - highest char
10
+ base32hexupper, V, rfc4648 no padding - highest char
11
+ base32hexpad, t, rfc4648 with padding
12
+ base32hexpadupper, T, rfc4648 with padding
13
+ base32, b, rfc4648 no padding
14
+ base32upper, B, rfc4648 no padding
15
+ base32pad, c, rfc4648 with padding
16
+ base32padupper, C, rfc4648 with padding
17
+ base32z, h, z-base-32 (used by Tahoe-LAFS)
18
+ base58flickr, Z, base58 flicker
19
+ base58btc, z, base58 bitcoin
20
+ base64, m, rfc4648 no padding
21
+ base64pad, M, rfc4648 with padding - MIME encoding
22
+ base64url, u, rfc4648 no padding
23
+ base64urlpad, U, rfc4648 with padding
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multibases
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derk-Jan Karrenbeld
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-19 00:00:00.000000000 Z
11
+ date: 2019-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -67,6 +67,7 @@ files:
67
67
  - ".gitignore"
68
68
  - ".rubocop.yml"
69
69
  - ".travis.yml"
70
+ - CHANGELOG.md
70
71
  - Gemfile
71
72
  - README.md
72
73
  - Rakefile
@@ -83,6 +84,7 @@ files:
83
84
  - lib/multibases/ord_table.rb
84
85
  - lib/multibases/registry.rb
85
86
  - lib/multibases/version.rb
87
+ - lib/table.csv
86
88
  - multibases.gemspec
87
89
  homepage: https://github.com/SleeplessByte/ruby-multibase
88
90
  licenses: []
@@ -105,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
107
  - !ruby/object:Gem::Version
106
108
  version: '0'
107
109
  requirements: []
108
- rubygems_version: 3.0.2
110
+ rubygems_version: 3.0.3
109
111
  signing_key:
110
112
  specification_version: 4
111
113
  summary: Ruby implementation of the multibase specification