multicodecs 0.2.0 → 0.2.1

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: c00bbb236838d2e04b43906e147ba2c3572ccec437c4c50b58c74446a04a6c08
4
- data.tar.gz: f6a5ecbb16cdf71dba833efe72b9f1b53585f590f56d1ad5b09ab6ac03939189
3
+ metadata.gz: 3ae87450a3251c123d99fe7a050eaef36023d16a80c359030a366ae6b000e72d
4
+ data.tar.gz: 86afee1666905ea25f2e82b1b584a80a9baeb6e0faea9300eec60769090530ab
5
5
  SHA512:
6
- metadata.gz: 226df7a1dcb3ab951fe86c15f13cb532619602c735455b5a0ee9902b7574e28baea8df7cb312efc3db03fea272a0d32444e87d460dccaa1867b84a00f4c93dcd
7
- data.tar.gz: e61b4b1d0a58fe12145adc89787cc893e5508244f47ad8212c61b5c158fa0a9bdb543db150f2a046c191c0f4faed7f334844092d61ad4c309af0d4e14423d438
6
+ metadata.gz: 478732cd67ee4cb967239307a1497f56d02537798e28a0741341675278bb199e0b865d94c779cbb5544655b584a7326cacc9e7702a70f1b9086bbde84875f65e
7
+ data.tar.gz: 0f585a08ca3f75e07d2caf1a2fabdcc80af9582d6a0c09a4c3e51e89c5314beeb350e0b8297941304882fd766b4b473204651027b938d4dcec4a7ae8a7435b91
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
@@ -1,7 +1,7 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.6.3
7
- before_install: gem install bundler -v 2.0.1
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.3
7
+ before_install: gem install bundler -v 2.0.1
@@ -0,0 +1,22 @@
1
+ # Changelog
2
+
3
+ ## 0.2.1
4
+
5
+ - Fix deprecation warning in update rake task ([#3][pr-3])
6
+ - Update [multicodec table](https://github.com/SleeplessByte/ruby-multicodec/blob/master/lib/table.csv) ([#1][pr-1])
7
+ - Update dev dependency ([#2][pr-2])
8
+
9
+ [pr-1]: https://github.com/SleeplessByte/ruby-multicodec/pull/1
10
+ [pr-2]: https://github.com/SleeplessByte/ruby-multicodec/pull/2
11
+ [pr-3]: https://github.com/SleeplessByte/ruby-multicodec/pull/3
12
+
13
+ ## 0.2.0
14
+
15
+ - Add tests for registry
16
+ - Add `where(tag:)` to create a _live_ sub selection of the registry
17
+ - Add `tags` to return the tags that exist
18
+ - Add `each(tag: nil)` to iterate the registry, optionally on a tag
19
+
20
+ ## 0.1.0
21
+
22
+ :baby: initial release
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in multicodecs.gemspec
4
- gemspec
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in multicodecs.gemspec
4
+ gemspec
data/README.md CHANGED
@@ -1,145 +1,145 @@
1
- # Multicodecs
2
-
3
- [![Build Status](https://travis-ci.com/SleeplessByte/ruby-multicodec.svg?branch=master)][shield-link-travis]
4
- [![Gem Version](https://badge.fury.io/rb/multicodecs.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/e5b0e892f0c098edd78c/maintainability)][shield-link-codeclimate]
7
-
8
- [shield-link-travis]: https://travis-ci.com/SleeplessByte/ruby-multicodec
9
- [shield-link-gem]: https://badge.fury.io/rb/multicodecs
10
- [shield-link-license]: http://opensource.org/licenses/MIT
11
- [shield-link-codeclimate]: https://codeclimate.com/github/SleeplessByte/ruby-multicodec/maintainability
12
-
13
- > Canonical table of of codecs used by various multiformats
14
-
15
- `Multicodecs` is the ruby implementation of [multiformats/multicodec][spec].
16
-
17
- > 🙌🏽 This is called `multicodecs` instead of the singular form, to stay
18
- > consistent with the `multihashes` gem, which was _forced_ to take a different
19
- > name has `multihash` was already taken, which is also the case for `multibase`
20
- > and others. In the future, this might be renamed to `multiformats-codec`, with
21
- > a backwards-compatible interface.
22
-
23
- ## Installation
24
-
25
- Add this line to your application's Gemfile:
26
-
27
- ```Ruby
28
- gem 'multicodecs', require: false
29
- ```
30
-
31
- Or if you want to autoload the last known table:
32
-
33
- ```Ruby
34
- gem 'multicodecs'
35
- ```
36
-
37
- Or if you want the PORO _without_ any values:
38
-
39
- ```Ruby
40
- gem 'multicodecs', require: 'multicodecs/bare'
41
- ```
42
-
43
- And then execute:
44
-
45
- $ bundle
46
-
47
- Or install it yourself as:
48
-
49
- $ gem install multicodecs
50
-
51
- ## Usage
52
-
53
- This is just a codec, not a protocol. This means that this gem only provides
54
- a nice-to-use mapping from the [single source of truth][table] to a PORO. It
55
- also allows you to bring your own values.
56
-
57
- ```ruby
58
- require 'multicodecs'
59
-
60
- Multicodecs['identity']
61
- # => #<struct Multicodecs::Registration code=0, name="identity", tag="multihash">
62
-
63
- Multicodecs[0x12]
64
- # => #<struct Multicodecs::Registration code=18, name="sha2-256", tag="multihash">
65
-
66
- Multicodecs.find_by(name: 'protobuf')
67
- # => #<struct Multicodecs::Registration code=80, name="protobuf", tag="serialization">
68
- ```
69
-
70
- You can `register` your own values
71
-
72
- ```ruby
73
- Multicodecs.register(code: 0x12345, name: 'xxx', tag: 'vendor')
74
- # => #<struct Multicodecs::Registration code=74565, name="xxx", tag="vendor">
75
- ```
76
-
77
- Convenience methods exist:
78
-
79
- - `Multicodecs.names`: returns all the known names
80
- - `Multicodecs.codes`: returns all the known codes
81
- - `Multicodecs.find_by(code: nil, name: nil)`: same as `[]`
82
- - `Multicodecs.fetch_by!(code: nil, name: nil)`: same as `[]` but errors if not found
83
- - `Multicodecs.load_csv(csv, radix: 16)`: loads table.csv like data
84
-
85
- ## Related
86
-
87
- - [`multiformats/multicodec`][git-multicodec]: the spec repository
88
- - [`multiformats/ruby-multiaddr`][git-ruby-multiaddr]: the ruby implementation of [`multiformats/multiaddr`][git-multiaddr]
89
- - [`multiformats/ruby-multibase`][git-ruby-multibase]: the ruby implementation of [`multiformats/multibase`][git-multibase]
90
- - [`multiformats/ruby-multihash`][git-ruby-multihash]: the ruby implementation of [`multiformats/multihash`][git-multihash]
91
-
92
- ## Development
93
-
94
- After checking out the repo, run `bin/setup` to install dependencies. Then, run
95
- `rake test` to run the tests. You can also run `bin/console` for an interactive
96
- prompt that will allow you to experiment.
97
-
98
- To install this gem onto your local machine, run `bundle exec rake install`.
99
- To release a new version, update the version number in `version.rb`, and then
100
- run `bundle exec rake release`, which will create a git tag for the version,
101
- push git commits and tags, and push the `.gem` file to [rubygems.org][web-rubygems].
102
-
103
- ### Updating the table
104
-
105
- The `Rakefile` provides an easy way of updating the `table.csv`, using a `rake`
106
- command.
107
-
108
- ```ruby
109
- rake update
110
- # => updated lib/table.csv
111
- ```
112
-
113
- ## Contributing
114
-
115
- Bug reports and pull requests are welcome on GitHub at [SleeplessByte/ruby-multicodec][git-self].
116
- This project is intended to be a safe, welcoming space for collaboration, and
117
- contributors are expected to adhere to the [Contributor Covenant][web-coc] code
118
- of conduct.
119
-
120
- ## License
121
-
122
- The gem is available as open source under the terms of the [MIT License][web-mit].
123
-
124
- ## Code of Conduct
125
-
126
- Everyone interacting in this project’s codebases, issue trackers, chat rooms and
127
- mailing lists is expected to follow the [code of conduct][git-self-coc].
128
-
129
- [spec]: https://github.com/multiformats/multicodec
130
- [git-self-coc]: https://github.com/SleeplessByte/ruby-multibase/blob/master/CODE_OF_CONDUCT.md
131
- [git-self]: https://github.com/SleeplessByte/ruby-multibase
132
- [git-ruby-multiaddr]: https://github.com/SleeplessByte/ruby-multiaddr
133
- [git-multiaddr]: https://github.com/multiformats/multiaddr
134
- [git-ruby-multicodec]: https://github.com/SleeplessByte/ruby-multicodec
135
- [git-multicodec-table]: https://github.com/multiformats/multicodec/blob/master/multicodec.csv
136
- [git-multicodec]: https://github.com/multiformats/multicodec
137
- [git-ruby-multibase]: https://github.com/SleeplessByte/ruby-multibase
138
- [git-multibase]: https://github.com/multiformats/multibase
139
- [git-ruby-multihash]: https://github.com/multiformats/ruby-multihash
140
- [git-multihash]: https://github.com/multiformats/multihash
141
- [web-coc]: http://contributor-covenant.org
142
- [web-mit]: https://opensource.org/licenses/MIT
143
- [web-rubygems]: https://rubygems.org
144
-
145
-
1
+ # Multicodecs
2
+
3
+ [![Build Status](https://travis-ci.com/SleeplessByte/ruby-multicodec.svg?branch=master)][shield-link-travis]
4
+ [![Gem Version](https://badge.fury.io/rb/multicodecs.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/e5b0e892f0c098edd78c/maintainability)][shield-link-codeclimate]
7
+
8
+ [shield-link-travis]: https://travis-ci.com/SleeplessByte/ruby-multicodec
9
+ [shield-link-gem]: https://badge.fury.io/rb/multicodecs
10
+ [shield-link-license]: http://opensource.org/licenses/MIT
11
+ [shield-link-codeclimate]: https://codeclimate.com/github/SleeplessByte/ruby-multicodec/maintainability
12
+
13
+ > Canonical table of of codecs used by various multiformats
14
+
15
+ `Multicodecs` is the ruby implementation of [multiformats/multicodec][spec].
16
+
17
+ > 🙌🏽 This is called `multicodecs` instead of the singular form, to stay
18
+ > consistent with the `multihashes` gem, which was _forced_ to take a different
19
+ > name has `multihash` was already taken, which is also the case for `multibase`
20
+ > and others. In the future, this might be renamed to `multiformats-codec`, with
21
+ > a backwards-compatible interface.
22
+
23
+ ## Installation
24
+
25
+ Add this line to your application's Gemfile:
26
+
27
+ ```Ruby
28
+ gem 'multicodecs', require: false
29
+ ```
30
+
31
+ Or if you want to autoload the last known table:
32
+
33
+ ```Ruby
34
+ gem 'multicodecs'
35
+ ```
36
+
37
+ Or if you want the PORO _without_ any values:
38
+
39
+ ```Ruby
40
+ gem 'multicodecs', require: 'multicodecs/bare'
41
+ ```
42
+
43
+ And then execute:
44
+
45
+ $ bundle
46
+
47
+ Or install it yourself as:
48
+
49
+ $ gem install multicodecs
50
+
51
+ ## Usage
52
+
53
+ This is just a codec, not a protocol. This means that this gem only provides
54
+ a nice-to-use mapping from the [single source of truth][table] to a PORO. It
55
+ also allows you to bring your own values.
56
+
57
+ ```ruby
58
+ require 'multicodecs'
59
+
60
+ Multicodecs['identity']
61
+ # => #<struct Multicodecs::Registration code=0, name="identity", tag="multihash">
62
+
63
+ Multicodecs[0x12]
64
+ # => #<struct Multicodecs::Registration code=18, name="sha2-256", tag="multihash">
65
+
66
+ Multicodecs.find_by(name: 'protobuf')
67
+ # => #<struct Multicodecs::Registration code=80, name="protobuf", tag="serialization">
68
+ ```
69
+
70
+ You can `register` your own values
71
+
72
+ ```ruby
73
+ Multicodecs.register(code: 0x12345, name: 'xxx', tag: 'vendor')
74
+ # => #<struct Multicodecs::Registration code=74565, name="xxx", tag="vendor">
75
+ ```
76
+
77
+ Convenience methods exist:
78
+
79
+ - `Multicodecs.names`: returns all the known names
80
+ - `Multicodecs.codes`: returns all the known codes
81
+ - `Multicodecs.find_by(code: nil, name: nil)`: same as `[]`
82
+ - `Multicodecs.fetch_by!(code: nil, name: nil)`: same as `[]` but errors if not found
83
+ - `Multicodecs.load_csv(csv, radix: 16)`: loads table.csv like data
84
+
85
+ ## Related
86
+
87
+ - [`multiformats/multicodec`][git-multicodec]: the spec repository
88
+ - [`multiformats/ruby-multiaddr`][git-ruby-multiaddr]: the ruby implementation of [`multiformats/multiaddr`][git-multiaddr]
89
+ - [`multiformats/ruby-multibase`][git-ruby-multibase]: the ruby implementation of [`multiformats/multibase`][git-multibase]
90
+ - [`multiformats/ruby-multihash`][git-ruby-multihash]: the ruby implementation of [`multiformats/multihash`][git-multihash]
91
+
92
+ ## Development
93
+
94
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run
95
+ `rake test` to run the tests. You can also run `bin/console` for an interactive
96
+ prompt that will allow you to experiment.
97
+
98
+ To install this gem onto your local machine, run `bundle exec rake install`.
99
+ To release a new version, update the version number in `version.rb`, and then
100
+ run `bundle exec rake release`, which will create a git tag for the version,
101
+ push git commits and tags, and push the `.gem` file to [rubygems.org][web-rubygems].
102
+
103
+ ### Updating the table
104
+
105
+ The `Rakefile` provides an easy way of updating the `table.csv`, using a `rake`
106
+ command.
107
+
108
+ ```ruby
109
+ rake update
110
+ # => updated lib/table.csv
111
+ ```
112
+
113
+ ## Contributing
114
+
115
+ Bug reports and pull requests are welcome on GitHub at [SleeplessByte/ruby-multicodec][git-self].
116
+ This project is intended to be a safe, welcoming space for collaboration, and
117
+ contributors are expected to adhere to the [Contributor Covenant][web-coc] code
118
+ of conduct.
119
+
120
+ ## License
121
+
122
+ The gem is available as open source under the terms of the [MIT License][web-mit].
123
+
124
+ ## Code of Conduct
125
+
126
+ Everyone interacting in this project’s codebases, issue trackers, chat rooms and
127
+ mailing lists is expected to follow the [code of conduct][git-self-coc].
128
+
129
+ [spec]: https://github.com/multiformats/multicodec
130
+ [git-self-coc]: https://github.com/SleeplessByte/ruby-multibase/blob/master/CODE_OF_CONDUCT.md
131
+ [git-self]: https://github.com/SleeplessByte/ruby-multibase
132
+ [git-ruby-multiaddr]: https://github.com/SleeplessByte/ruby-multiaddr
133
+ [git-multiaddr]: https://github.com/multiformats/multiaddr
134
+ [git-ruby-multicodec]: https://github.com/SleeplessByte/ruby-multicodec
135
+ [git-multicodec-table]: https://github.com/multiformats/multicodec/blob/master/multicodec.csv
136
+ [git-multicodec]: https://github.com/multiformats/multicodec
137
+ [git-ruby-multibase]: https://github.com/SleeplessByte/ruby-multibase
138
+ [git-multibase]: https://github.com/multiformats/multibase
139
+ [git-ruby-multihash]: https://github.com/multiformats/ruby-multihash
140
+ [git-multihash]: https://github.com/multiformats/multihash
141
+ [web-coc]: http://contributor-covenant.org
142
+ [web-mit]: https://opensource.org/licenses/MIT
143
+ [web-rubygems]: https://rubygems.org
144
+
145
+
data/Rakefile CHANGED
@@ -1,22 +1,22 @@
1
- require 'bundler/gem_tasks'
2
- require 'rake/testtask'
3
-
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << 'test'
6
- t.libs << 'lib'
7
- t.test_files = FileList['test/**/*_test.rb']
8
- end
9
-
10
- Rake::Task.define_task(:update) do |t|
11
- require 'open-uri'
12
-
13
- SOURCE_FILE = 'https://raw.githubusercontent.com/multiformats/multicodec/master/table.csv'
14
-
15
- File.open(File.join(__dir__, 'lib', 'table.csv'), 'wb') do |saved_file|
16
- open(SOURCE_FILE, 'rb') do |read_file|
17
- saved_file.write(read_file.read)
18
- end
19
- end
20
- end
21
-
22
- task :default => :test
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'test'
6
+ t.libs << 'lib'
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ Rake::Task.define_task(:update) do |t|
11
+ require 'open-uri'
12
+
13
+ SOURCE_FILE = 'https://raw.githubusercontent.com/multiformats/multicodec/master/table.csv'
14
+
15
+ File.open(File.join(__dir__, 'lib', 'table.csv'), 'wb') do |saved_file|
16
+ URI.open(SOURCE_FILE, 'rb') do |read_file|
17
+ saved_file.write(read_file.read)
18
+ end
19
+ end
20
+ end
21
+
22
+ task :default => :test
@@ -1,15 +1,15 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require 'bundler/setup'
5
- require 'multicodecs'
6
-
7
- # You can add fixtures and/or initialization code here to make experimenting
8
- # with your gem easier. You can also use a different console, if you like.
9
-
10
- # (If you use this, don't forget to add pry to your Gemfile!)
11
- # require 'pry'
12
- # Pry.start
13
-
14
- require 'irb'
15
- IRB.start(__FILE__)
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'multicodecs'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require 'pry'
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
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