base32-url 0.4 → 0.6.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: 1905c3d866b4e3ce2f810b3a5c918c8ac20bdb2ae6e91a8ae8b6c2e366540274
4
- data.tar.gz: effb748c3d55a28017ab77ff8b8f01803621fb617d247505d6c5c824b892921a
3
+ metadata.gz: 6700c1c53464c4318f6361ebe22cf4276c925f24bf92cc6fc841e2075c502e6a
4
+ data.tar.gz: 5b58a804226b9714abde687042e207d8d00a10ed0859c716ccefa1c350a7fd69
5
5
  SHA512:
6
- metadata.gz: 10c13658735a6d31812e4e9c60b33f125dbf466fc8d37367e6aa3469b1da22bcffbecddfbec325b379131a7337fb79c924b19788365ae109050f254dd2dd0e9e
7
- data.tar.gz: 5333b4899d6ed9a0bdcf0ac008973daf36955ef5a6fa9877f86395504d86d05e4e392da42c887d6671d6905cb44f857cf5b5f0e5e184ff80a38c7541c792d399
6
+ metadata.gz: fa905b9b15aafdeb4ef156da982952e613d397b0f4dda8d5a1145eaeda61b461deeba2410f850564d20246ad5902c84d02d330602d1a30d7b9f9f0ede5b785c4
7
+ data.tar.gz: 1831d2538ff6892222341b9082db32ee93456e9385a0521db10a2549ef50eb7940e2cd57bcce3ae82c98518c010e6508c68994ce325699c6ab38293d45eb7780
@@ -0,0 +1,38 @@
1
+ name: Build
2
+ on:
3
+ push:
4
+ branches:
5
+ - master
6
+ pull_request:
7
+ types: [opened, synchronize, reopened]
8
+ jobs:
9
+ sonarcloud:
10
+ name: SonarCloud
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v3
14
+ with:
15
+ fetch-depth: 0
16
+ - name: Set up Ruby 3.1
17
+ uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: 3.1
20
+ - name: Build and test
21
+ run: |
22
+ gem install bundler
23
+ bundle install
24
+ bundle exec rake test
25
+ - name: fix code coverage paths
26
+ working-directory: ./coverage
27
+ run: |
28
+ sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' coverage.json
29
+ - name: Upload coverage report
30
+ uses: actions/upload-artifact@v3
31
+ with:
32
+ name: coverage-report
33
+ path: coverage/coverage.json
34
+ - name: SonarCloud Scan
35
+ uses: SonarSource/sonarcloud-github-action@master
36
+ env:
37
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38
+ SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  Gemfile.lock
2
2
  doc
3
3
  pkg
4
+ coverage
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 DataCite
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,11 +1,13 @@
1
+ [![Build](https://github.com/front-matter/base32-url/actions/workflows/build.yml/badge.svg)](https://github.com/front-matter/base32-url/actions/workflows/build.yml)
2
+ [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=front-matter_base32-url&metric=coverage)](https://sonarcloud.io/summary/new_code?id=front-matter_base32-url)
3
+ [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=front-matter_base32-url&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=front-matter_base32-url)
1
4
  [![Gem Version](https://badge.fury.io/rb/base32-url.svg)](https://badge.fury.io/rb/base32-url)
2
- [![Build Status](https://travis-ci.org/datacite/base32-url.svg?branch=master)](https://travis-ci.org/datacite/base32-url)
3
5
 
4
6
  An implementation of Douglas Crockfords Base32-Encoding in Ruby, with two modifications to make
5
7
  the resulting strings more URL friendly:
6
8
 
7
9
  * use lower case characters
8
- * only use characters that don't need URL encoding for checksum
10
+ * use two digits (mod 97-10, ISO 7064) for the checksum
9
11
 
10
12
  see <http://www.crockford.com/wrmg/base32.html>
11
13
 
@@ -18,6 +20,8 @@ $ gem install base32-url
18
20
  ## Changes
19
21
 
20
22
  ```
23
+ 0.6.0 - support Ruby versions beyond 2.x
24
+ 0.5.0 - use mod 97-10 (ISO 7064) to calculate checksum
21
25
  0.3.0 - encode into lower case characters, use * ~ _ ^ u for checksum
22
26
  0.2.0 - added optional checksum
23
27
  ```
@@ -32,5 +36,27 @@ require 'base32/url'
32
36
  Base32::URL.encode(1234) # => "16j"
33
37
  Base32::URL.encode(100**10, :split=>5, :length=>15) # => "02pqh-ty5nh-h0000"
34
38
  Base32::URL.decode("2pqh-ty5nh-hoooo") # => 10**100
35
- Base32::URL.encode(1234, checksum: true) # => "16jd"
36
- Base32::URL.decode("16jd", checksum: true) # => 1234
39
+ Base32::URL.encode(1234, checksum: true) # => "16j82"
40
+ Base32::URL.decode("16j82", checksum: true) # => 1234
41
+ ```
42
+
43
+ ## Development
44
+
45
+ We use test-unit for unit testing:
46
+
47
+ ```
48
+ bundle exec rake
49
+ ```
50
+
51
+ Follow along via [Github Issues](https://github.com/datacite/base32-url/issues).
52
+
53
+ ### Note on Patches/Pull Requests
54
+
55
+ * Fork the project
56
+ * Write tests for your new feature or a test that reproduces a bug
57
+ * Implement your feature or make a bug fix
58
+ * Do not mess with Rakefile, version or history
59
+ * Commit, push and make a pull request. Bonus points for topical branches.
60
+
61
+ ## License
62
+ **base32-url** is released under the [MIT License](https://github.com/datacite/base32-url/blob/master/LICENSE.md).
data/Rakefile CHANGED
@@ -6,5 +6,4 @@ Bundler::GemHelper.install_tasks
6
6
  require 'rake/testtask'
7
7
  Rake::TestTask.new(:test)
8
8
 
9
- task :default => :test
10
-
9
+ task default: :test
data/base32-url.gemspec CHANGED
@@ -1,26 +1,29 @@
1
- require "date"
2
- require File.expand_path("../lib/base32/version", __FILE__)
1
+ require 'date'
2
+ require File.expand_path('lib/base32/version', __dir__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
- s.authors = "Martin Fenner"
6
- s.email = "mfenner@datacite.org"
7
- s.name = "base32-url"
8
- s.homepage = "https://github.com/datacite/base32-url"
9
- s.summary = "Ruby client library for conversion of DOI Metadata"
5
+ s.authors = 'Martin Fenner'
6
+ s.email = 'martin@front-matter.io'
7
+ s.name = 'base32-url'
8
+ s.homepage = 'https://github.com/front-matter/base32-url'
9
+ s.summary = '32-symbol notation for expressing numbers in a form that can be conveniently and accurately transmitted between humans'
10
10
  s.date = Date.today
11
- s.description = "32-symbol notation for expressing numbers in a form that can be conveniently and accurately transmitted between humans. URL-friendly version of the base32-crockford gem."
12
- s.require_paths = ["lib"]
11
+ s.description = '32-symbol notation for expressing numbers in a form that can be conveniently and accurately transmitted between humans. URL-friendly version of the base32-crockford gem.'
12
+ s.require_paths = ['lib']
13
13
  s.version = Base32::Url::VERSION
14
- s.extra_rdoc_files = ["README.md"]
15
- s.license = 'MIT'
16
- s.required_ruby_version = '~> 2.2'
14
+ s.extra_rdoc_files = ['README.md']
15
+ s.license = 'MIT'
16
+ s.required_ruby_version = '>= 2.6.0'
17
17
 
18
18
  # Declary dependencies here, rather than in the Gemfile
19
- s.add_development_dependency 'bundler', '~> 1.0'
20
- s.add_development_dependency 'rake'
21
- s.add_development_dependency 'test-unit', '~> 3.2.3'
19
+ s.add_development_dependency 'bundler', '>= 1.11', "< 3"
20
+ s.add_development_dependency 'rake', '>= 11.3', "< 14"
21
+ s.add_development_dependency 'rubocop', '~> 1.36'
22
+ s.add_development_dependency 'rubocop-rake', '~> 0.6.0'
23
+ s.add_development_dependency 'simplecov', '0.22.0'
24
+ s.add_development_dependency 'simplecov_json_formatter', '~> 0.1.4'
25
+ s.add_development_dependency 'test-unit', '~> 3.2', '>= 3.2.3'
22
26
 
23
- s.require_paths = ["lib"]
24
- s.files = `git ls-files`.split($/)
25
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
27
+ s.files = `git ls-files`.split($/)
28
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
26
29
  end
data/lib/base32/url.rb CHANGED
@@ -1,34 +1,29 @@
1
- # encoding: UTF-8
1
+ # frozen_string_literal: true
2
+
2
3
  #
3
4
  # (c) 2008, Levin Alexander <http://levinalex.net>
4
5
  #
5
6
  # This file is released under the same license as ruby.
6
7
 
7
- require 'enumerator'
8
-
9
8
  module Base32
10
9
  end
11
10
 
12
- # encode a value with the encoding defined by _Douglas_ _Crockford_ in
13
- # <http://www.crockford.com/wrmg/base32.html>
14
- #
15
11
  # this is *not* the same as the Base32 encoding defined in RFC 4648
16
12
  #
17
- #
18
13
  # The Base32 symbol set is a superset of the Base16 symbol set.
19
14
  #
20
15
  # We chose a symbol set of 10 digits and 22 letters. We exclude 4 of the 26
21
- # letters: I L O U.
16
+ # letters: i l o u.
22
17
  #
23
18
  # Excluded Letters
24
19
  #
25
- # I:: Can be confused with 1
26
- # L:: Can be confused with 1
27
- # O:: Can be confused with 0
28
- # U:: Accidental obscenity
20
+ # i:: Can be confused with 1
21
+ # l:: Can be confused with 1
22
+ # o:: Can be confused with 0
23
+ # u:: Accidental obscenity
29
24
  #
30
25
  # When decoding, upper and lower case letters are accepted, and i and l will
31
- # be treated as 1 and o will be treated as 0. When encoding, lower upper case
26
+ # be treated as 1 and o will be treated as 0. When encoding, lower case
32
27
  # letters are used.
33
28
  #
34
29
  # If the bit-length of the number to be encoded is not a multiple of 5 bits,
@@ -42,21 +37,16 @@ end
42
37
  #
43
38
  class Base32::URL
44
39
  ENCODE_CHARS =
45
- %w(0 1 2 3 4 5 6 7 8 9 a b c d e f g h j k m n p q r s t v w x y z ?)
40
+ %w[0 1 2 3 4 5 6 7 8 9 a b c d e f g h j k m n p q r s t v w x y z ?].freeze
46
41
 
47
- DECODE_MAP = ENCODE_CHARS.to_enum(:each_with_index).inject({}) do |h,(c,i)|
48
- h[c] = i; h
49
- end.merge({'i' => 1, 'l' => 1, 'o' => 0})
50
-
51
- CHECKSUM_CHARS = %w(i l o u)
52
-
53
- CHECKSUM_MAP = { "i" => 32, "l" => 33, "o" => 34, "u" => 35 }
42
+ DECODE_MAP = ENCODE_CHARS.to_enum(:each_with_index).each_with_object({}) do |(c, i), hsh|
43
+ hsh[c] = i
44
+ end.merge({ 'i' => 1, 'l' => 1, 'o' => 0 })
54
45
 
55
46
  # encodes an integer into a string
56
47
  #
57
48
  # when +checksum+ is given, a checksum is added at the end of the the string,
58
- # calculated as modulo 36 of +number+. Four additional checksum symbols are
59
- # used for symbol values 32-35
49
+ # calculated as modulo 97-10 (ISO 7064)
60
50
  #
61
51
  # when +split+ is given a hyphen is inserted every <n> characters to improve
62
52
  # readability
@@ -69,20 +59,23 @@ class Base32::URL
69
59
  #
70
60
  def self.encode(number, opts = {})
71
61
  # verify options
72
- raise ArgumentError unless (opts.keys - [:length, :split, :checksum] == [])
62
+ raise ArgumentError unless opts.keys - %i[length split checksum] == []
73
63
 
74
64
  str = number.to_s(2).reverse.scan(/.{1,5}/).map do |bits|
75
65
  ENCODE_CHARS[bits.reverse.to_i(2)]
76
66
  end.reverse.join
77
67
 
78
- str += (ENCODE_CHARS + CHECKSUM_CHARS)[number % 36] if opts[:checksum]
68
+ if opts[:checksum]
69
+ remainder = 98 - ((number * 100) % 97)
70
+ str += format('%02d', remainder)
71
+ end
79
72
 
80
73
  str = str.rjust(opts[:length], '0') if opts[:length]
81
74
 
82
75
  if opts[:split]
83
76
  str = str.reverse
84
- str = str.scan(/.{1,#{opts[:split]}}/).map { |x| x.reverse }
85
- str = str.reverse.join("-")
77
+ str = str.scan(/.{1,#{opts[:split]}}/).map(&:reverse)
78
+ str = str.reverse.join('-')
86
79
  end
87
80
 
88
81
  str
@@ -96,31 +89,33 @@ class Base32::URL
96
89
  # I,i,l,L decodes to 1
97
90
  # O,o decodes to 0
98
91
  #
99
- # Base32::Crockford.decode("16J") # => 1234
100
- # Base32::Crockford.decode("OI") # => 1
101
- # Base32::Crockford.decode("3G923-0VQVS") # => 123456789012345
92
+ # Base32::URL.decode("16J") # => 1234
93
+ # Base32::URL.decode("OI") # => 1
94
+ # Base32::URL.decode("3G923-0VQVS") # => 123456789012345
102
95
  #
103
96
  # returns +nil+ if the string contains invalid characters and can't be
104
97
  # decoded, or if checksum option is used and checksum is incorrect
105
- #
98
+
106
99
  def self.decode(string, opts = {})
107
100
  if opts[:checksum]
108
- checksum_char = string.slice!(-1)
109
- checksum_number = DECODE_MAP.merge(CHECKSUM_MAP)[checksum_char]
101
+ checksum = string[-2..].to_i
102
+ string = string[0..-3]
110
103
  end
111
104
 
112
- number = clean(string).split(//).map { |char|
105
+ number = clean(string).split(//).map do |char|
113
106
  DECODE_MAP[char] or return nil
114
- }.inject(0) { |result,val| (result << 5) + val }
107
+ end.inject(0) { |result, val| (result << 5) + val }
115
108
 
116
- return nil if opts[:checksum] && (number % 36 != checksum_number)
109
+ if opts[:checksum]
110
+ remainder = 98 - ((number * 100) % 97)
111
+ return nil if remainder != checksum
112
+ end
117
113
 
118
114
  number
119
115
  end
120
116
 
121
117
  # same as decode, but raises ArgumentError when the string can't be decoded
122
- #
123
- def self.decode!(string, opts = {})
118
+ def self.decode!(string, _opts = {})
124
119
  decode(string) or raise ArgumentError
125
120
  end
126
121
 
@@ -130,13 +125,16 @@ class Base32::URL
130
125
  # replaces invalid characters with a question mark ('?')
131
126
  #
132
127
  def self.normalize(string, opts = {})
133
- checksum_char = string.slice!(-1) if opts[:checksum]
128
+ if opts[:checksum]
129
+ checksum = string.split(//).last(2).join
130
+ string = string[0..-2]
131
+ end
134
132
 
135
133
  string = clean(string).split(//).map do |char|
136
134
  ENCODE_CHARS[DECODE_MAP[char] || 32]
137
135
  end.join
138
136
 
139
- string += checksum_char if opts[:checksum]
137
+ string += checksum if opts[:checksum]
140
138
 
141
139
  string
142
140
  end
@@ -145,12 +143,12 @@ class Base32::URL
145
143
  # decoded
146
144
  #
147
145
  def self.valid?(string, opts = {})
148
- !(normalize(string, opts) =~ /\?/)
146
+ (normalize(string, opts) !~ /\?/)
149
147
  end
150
148
 
151
149
  class << self
152
150
  def clean(string)
153
- string.gsub(/-/,'').downcase
151
+ string.gsub(/-/, '').downcase
154
152
  end
155
153
  private :clean
156
154
  end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Base32
2
4
  module Url
3
- VERSION = "0.4"
5
+ VERSION = '0.6.0'
4
6
  end
5
7
  end
data/lib/base32-url.rb CHANGED
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'base32/url'
@@ -0,0 +1,11 @@
1
+ sonar.organization=front-matter
2
+ sonar.projectKey=front-matter_base32-url
3
+
4
+ # This is the name and version displayed in the SonarCloud UI.
5
+ sonar.projectName=base32-url
6
+ #sonar.projectVersion=1.0
7
+
8
+ # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
9
+ sonar.sources=.
10
+
11
+ sonar.ruby.coverage.reportPaths=coverage/coverage.json
@@ -1,13 +1,17 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
+
3
+ require 'simplecov'
4
+ require 'simplecov_json_formatter'
5
+ SimpleCov.formatter = SimpleCov::Formatter::JSONFormatter
6
+ SimpleCov.start
2
7
 
3
8
  require 'test/unit'
4
9
  require 'base32/url'
5
10
 
6
11
  class TestBase32Url < Test::Unit::TestCase
7
-
8
12
  def test_encoding_and_decoding_single_chars
9
13
  from = (0..31).to_a
10
- to = %w(0 1 2 3 4 5 6 7 8 9 a b c d e f g h j k m n p q r s t v w x y z)
14
+ to = %w[0 1 2 3 4 5 6 7 8 9 a b c d e f g h j k m n p q r s t v w x y z]
11
15
 
12
16
  from.zip(to) do |symbol_value, encode_symbol|
13
17
  assert_equal encode_symbol, Base32::URL.encode(symbol_value)
@@ -16,22 +20,22 @@ class TestBase32Url < Test::Unit::TestCase
16
20
  end
17
21
 
18
22
  def test_encoding_larger_numbers
19
- assert_equal("10", Base32::URL.encode(32))
20
- assert_equal("16j", Base32::URL.encode(1234))
23
+ assert_equal('10', Base32::URL.encode(32))
24
+ assert_equal('16j', Base32::URL.encode(1234))
21
25
  end
22
26
 
23
27
  def test_decoding_strings
24
- assert_equal(1234, Base32::URL.decode("16J"))
28
+ assert_equal(1234, Base32::URL.decode('16j'))
25
29
  end
26
30
 
27
31
  def test_decoding_normalizes_symbols
28
32
  assert_equal Base32::URL.decode('11100110'),
29
- Base32::URL.decode('IL1O0ilo')
33
+ Base32::URL.decode('IL1O0ilo')
30
34
  end
31
35
 
32
36
  def test_decoding_lowercase
33
- assert_equal Base32::URL.decode("abcdefghijklmnopqrstvwxyz"),
34
- Base32::URL.decode("ABCDEFGHIJKLMNOPQRSTVWXYZ")
37
+ assert_equal Base32::URL.decode('abcdefghijklmnopqrstvwxyz'),
38
+ Base32::URL.decode('ABCDEFGHIJKLMNOPQRSTVWXYZ')
35
39
  end
36
40
 
37
41
  def test_decoding_invalid_strings
@@ -40,58 +44,58 @@ class TestBase32Url < Test::Unit::TestCase
40
44
  end
41
45
 
42
46
  def test_decode_should_ignore_hyphens
43
- assert_equal 1234, Base32::URL.decode("1-6-j")
47
+ assert_equal 1234, Base32::URL.decode('1-6-j')
44
48
  end
45
49
 
46
50
  def test_normalize
47
- assert_equal "he110w0r1d", Base32::URL.normalize("hello-world")
48
- assert_equal "he110w0r1d", Base32::URL.normalize("HELLO-WORLD")
49
- assert_equal "b?123", Base32::URL.normalize("BU-123")
51
+ assert_equal 'he110w0r1d', Base32::URL.normalize('hello-world')
52
+ assert_equal 'he110w0r1d', Base32::URL.normalize('HELLO-WORLD')
53
+ assert_equal 'b?123', Base32::URL.normalize('BU-123')
50
54
  end
51
55
 
52
56
  def test_normalize_with_checksum
53
- assert_equal "b?123", Base32::URL.normalize("BU-123", :checksum => true)
54
- assert_equal "b123u", Base32::URL.normalize("B123u", :checksum => true)
57
+ assert_equal 'b?1223', Base32::URL.normalize('BU-123', checksum: true)
58
+ assert_equal 'b1223', Base32::URL.normalize('B123', checksum: true)
55
59
  end
56
60
 
57
61
  def test_valid
58
- assert_equal true, Base32::URL.valid?("hello-world")
59
- assert_equal false, Base32::URL.valid?("BU-123")
62
+ assert_equal true, Base32::URL.valid?('hello-world')
63
+ assert_equal false, Base32::URL.valid?('BU-123')
60
64
  end
61
65
 
62
66
  def test_valid_with_checksum
63
- assert_equal true, Base32::URL.valid?("b123u", :checksum => true)
64
- assert_equal false, Base32::URL.valid?("bu-123", :checksum => true)
67
+ assert_equal true, Base32::URL.valid?('b123u', checksum: true)
68
+ assert_equal false, Base32::URL.valid?('bu-123', checksum: true)
65
69
  end
66
70
 
67
71
  def test_length_and_hyphenization
68
- assert_equal "0016j", Base32::URL.encode(1234, :length => 5)
69
- assert_equal "0-01-6j",
70
- Base32::URL.encode(1234, :length => 5, :split => 2)
71
- assert_equal "00-010",
72
- Base32::URL.encode(32, :length => 5, :split => 3)
72
+ assert_equal '0016j', Base32::URL.encode(1234, length: 5)
73
+ assert_equal '0-01-6j',
74
+ Base32::URL.encode(1234, length: 5, split: 2)
75
+ assert_equal '00-010',
76
+ Base32::URL.encode(32, length: 5, split: 3)
73
77
  end
74
78
 
75
79
  def test_encoding_checksum
76
- assert_equal "16ja",
77
- Base32::URL.encode(1234, :checksum => true)
78
- assert_equal "016ja",
79
- Base32::URL.encode(1234, :length => 5, :checksum => true)
80
- assert_equal "0-16-ja",
81
- Base32::URL.encode(1234, :length => 5, :split => 2, :checksum => true)
80
+ assert_equal '16j82',
81
+ Base32::URL.encode(1234, checksum: true)
82
+ assert_equal '016j82',
83
+ Base32::URL.encode(1234, length: 6, checksum: true)
84
+ assert_equal '01-6j-82',
85
+ Base32::URL.encode(1234, length: 6, split: 2, checksum: true)
82
86
  end
83
87
 
84
88
  def test_decoding_checksum
85
89
  assert_equal 1234,
86
- Base32::URL.decode("16ja", :checksum => true)
90
+ Base32::URL.decode('16j82', checksum: true)
87
91
  assert_equal 1234,
88
- Base32::URL.decode("016ja", :length => 5, :checksum => true)
92
+ Base32::URL.decode('016j82', length: 6, checksum: true)
89
93
  assert_equal 1234,
90
- Base32::URL.decode("0-16-ja", :length => 5, :split => 2, :checksum => true)
94
+ Base32::URL.decode('01-6j-82', length: 6, split: 2, checksum: true)
91
95
  end
92
96
 
93
97
  def test_decoding_invalid_checksum
94
98
  assert_equal nil,
95
- Base32::URL.decode("16jc", :checksum => true)
99
+ Base32::URL.decode('16j44', checksum: true)
96
100
  end
97
101
  end
metadata CHANGED
@@ -1,48 +1,119 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: base32-url
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.4'
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Fenner
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-31 00:00:00.000000000 Z
11
+ date: 2023-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: '1.11'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '3'
20
23
  type: :development
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '1.11'
30
+ - - "<"
25
31
  - !ruby/object:Gem::Version
26
- version: '1.0'
32
+ version: '3'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: rake
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - ">="
32
38
  - !ruby/object:Gem::Version
33
- version: '0'
39
+ version: '11.3'
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '14'
34
43
  type: :development
35
44
  prerelease: false
36
45
  version_requirements: !ruby/object:Gem::Requirement
37
46
  requirements:
38
47
  - - ">="
39
48
  - !ruby/object:Gem::Version
40
- version: '0'
49
+ version: '11.3'
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '14'
53
+ - !ruby/object:Gem::Dependency
54
+ name: rubocop
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '1.36'
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '1.36'
67
+ - !ruby/object:Gem::Dependency
68
+ name: rubocop-rake
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: 0.6.0
74
+ type: :development
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - "~>"
79
+ - !ruby/object:Gem::Version
80
+ version: 0.6.0
81
+ - !ruby/object:Gem::Dependency
82
+ name: simplecov
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - '='
86
+ - !ruby/object:Gem::Version
87
+ version: 0.22.0
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - '='
93
+ - !ruby/object:Gem::Version
94
+ version: 0.22.0
95
+ - !ruby/object:Gem::Dependency
96
+ name: simplecov_json_formatter
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: 0.1.4
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - "~>"
107
+ - !ruby/object:Gem::Version
108
+ version: 0.1.4
41
109
  - !ruby/object:Gem::Dependency
42
110
  name: test-unit
43
111
  requirement: !ruby/object:Gem::Requirement
44
112
  requirements:
45
113
  - - "~>"
114
+ - !ruby/object:Gem::Version
115
+ version: '3.2'
116
+ - - ">="
46
117
  - !ruby/object:Gem::Version
47
118
  version: 3.2.3
48
119
  type: :development
@@ -50,49 +121,56 @@ dependencies:
50
121
  version_requirements: !ruby/object:Gem::Requirement
51
122
  requirements:
52
123
  - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: '3.2'
126
+ - - ">="
53
127
  - !ruby/object:Gem::Version
54
128
  version: 3.2.3
55
129
  description: 32-symbol notation for expressing numbers in a form that can be conveniently
56
130
  and accurately transmitted between humans. URL-friendly version of the base32-crockford
57
131
  gem.
58
- email: mfenner@datacite.org
132
+ email: martin@front-matter.io
59
133
  executables: []
60
134
  extensions: []
61
135
  extra_rdoc_files:
62
136
  - README.md
63
137
  files:
138
+ - ".github/workflows/build.yml"
64
139
  - ".gitignore"
65
140
  - ".travis.yml"
66
141
  - Gemfile
142
+ - LICENSE.md
67
143
  - README.md
68
144
  - Rakefile
69
145
  - base32-url.gemspec
70
146
  - lib/base32-url.rb
71
147
  - lib/base32/url.rb
72
148
  - lib/base32/version.rb
149
+ - sonar-project.properties
73
150
  - test/test_base32_url.rb
74
- homepage: https://github.com/datacite/base32-url
151
+ homepage: https://github.com/front-matter/base32-url
75
152
  licenses:
76
153
  - MIT
77
154
  metadata: {}
78
- post_install_message:
155
+ post_install_message:
79
156
  rdoc_options: []
80
157
  require_paths:
81
158
  - lib
82
159
  required_ruby_version: !ruby/object:Gem::Requirement
83
160
  requirements:
84
- - - "~>"
161
+ - - ">="
85
162
  - !ruby/object:Gem::Version
86
- version: '2.2'
163
+ version: 2.6.0
87
164
  required_rubygems_version: !ruby/object:Gem::Requirement
88
165
  requirements:
89
166
  - - ">="
90
167
  - !ruby/object:Gem::Version
91
168
  version: '0'
92
169
  requirements: []
93
- rubyforge_project:
94
- rubygems_version: 2.7.4
95
- signing_key:
170
+ rubygems_version: 3.4.8
171
+ signing_key:
96
172
  specification_version: 4
97
- summary: Ruby client library for conversion of DOI Metadata
98
- test_files: []
173
+ summary: 32-symbol notation for expressing numbers in a form that can be conveniently
174
+ and accurately transmitted between humans
175
+ test_files:
176
+ - test/test_base32_url.rb