base32-url 0.3 → 0.4

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
- SHA1:
3
- metadata.gz: a101ccc7f345bba071066ee065dd335e434fb680
4
- data.tar.gz: f0a1e95eeec9110ab4604246a3c2f6dca42ce6af
2
+ SHA256:
3
+ metadata.gz: 1905c3d866b4e3ce2f810b3a5c918c8ac20bdb2ae6e91a8ae8b6c2e366540274
4
+ data.tar.gz: effb748c3d55a28017ab77ff8b8f01803621fb617d247505d6c5c824b892921a
5
5
  SHA512:
6
- metadata.gz: 3d156713e87fa7ff31e62a74b066da157deae6199f857f83bf0bcbab15df14204f1fa4b02590d7f7b5801493b04ce54dc9c1e13e041f0272b50ae89861e31874
7
- data.tar.gz: 4f8e4d21ea3b6c6aa63b750fc11e6ce17dd5b9c226df5c96466519eea1ee230c131243a4dcfcf3e86dc5625446a36b9d8556f2512db1efa02479a5f7455b2b48
6
+ metadata.gz: 10c13658735a6d31812e4e9c60b33f125dbf466fc8d37367e6aa3469b1da22bcffbecddfbec325b379131a7337fb79c924b19788365ae109050f254dd2dd0e9e
7
+ data.tar.gz: 5333b4899d6ed9a0bdcf0ac008973daf36955ef5a6fa9877f86395504d86d05e4e392da42c887d6671d6905cb44f857cf5b5f0e5e184ff80a38c7541c792d399
data/README.md CHANGED
@@ -29,8 +29,8 @@ $ gem install base32-url
29
29
 
30
30
  require 'base32/url'
31
31
 
32
- Base32::Url.encode(1234) # => "16J"
33
- Base32::Url.encode(100**10, :split=>5, :length=>15) # => "02PQH-TY5NH-H0000"
34
- Base32::Url.decode("2pqh-ty5nh-hoooo") # => 10**100
35
- Base32::Url.encode(1234, checksum: true) # => "16JD"
36
- Base32::Url.decode("16JD", checksum: true) # => 1234
32
+ Base32::URL.encode(1234) # => "16j"
33
+ Base32::URL.encode(100**10, :split=>5, :length=>15) # => "02pqh-ty5nh-h0000"
34
+ Base32::URL.decode("2pqh-ty5nh-hoooo") # => 10**100
35
+ Base32::URL.encode(1234, checksum: true) # => "16jd"
36
+ Base32::URL.decode("16jd", checksum: true) # => 1234
@@ -48,15 +48,15 @@ class Base32::URL
48
48
  h[c] = i; h
49
49
  end.merge({'i' => 1, 'l' => 1, 'o' => 0})
50
50
 
51
- CHECKSUM_CHARS = %w(* ~ _ ^ u)
51
+ CHECKSUM_CHARS = %w(i l o u)
52
52
 
53
- CHECKSUM_MAP = { "*" => 32, "~" => 33, "_" => 34, "^" => 35, "u" => 36 }
53
+ CHECKSUM_MAP = { "i" => 32, "l" => 33, "o" => 34, "u" => 35 }
54
54
 
55
55
  # encodes an integer into a string
56
56
  #
57
57
  # when +checksum+ is given, a checksum is added at the end of the the string,
58
- # calculated as modulo 37 of +number+. Five additional checksum symbols are
59
- # used for symbol values 32-36
58
+ # calculated as modulo 36 of +number+. Four additional checksum symbols are
59
+ # used for symbol values 32-35
60
60
  #
61
61
  # when +split+ is given a hyphen is inserted every <n> characters to improve
62
62
  # readability
@@ -75,7 +75,7 @@ class Base32::URL
75
75
  ENCODE_CHARS[bits.reverse.to_i(2)]
76
76
  end.reverse.join
77
77
 
78
- str += (ENCODE_CHARS + CHECKSUM_CHARS)[number % 37] if opts[:checksum]
78
+ str += (ENCODE_CHARS + CHECKSUM_CHARS)[number % 36] if opts[:checksum]
79
79
 
80
80
  str = str.rjust(opts[:length], '0') if opts[:length]
81
81
 
@@ -113,7 +113,7 @@ class Base32::URL
113
113
  DECODE_MAP[char] or return nil
114
114
  }.inject(0) { |result,val| (result << 5) + val }
115
115
 
116
- return nil if opts[:checksum] && (number % 37 != checksum_number)
116
+ return nil if opts[:checksum] && (number % 36 != checksum_number)
117
117
 
118
118
  number
119
119
  end
@@ -1,5 +1,5 @@
1
1
  module Base32
2
2
  module Url
3
- VERSION = "0.3"
3
+ VERSION = "0.4"
4
4
  end
5
5
  end
@@ -73,21 +73,21 @@ class TestBase32Url < Test::Unit::TestCase
73
73
  end
74
74
 
75
75
  def test_encoding_checksum
76
- assert_equal "16jd",
76
+ assert_equal "16ja",
77
77
  Base32::URL.encode(1234, :checksum => true)
78
- assert_equal "016jd",
78
+ assert_equal "016ja",
79
79
  Base32::URL.encode(1234, :length => 5, :checksum => true)
80
- assert_equal "0-16-jd",
80
+ assert_equal "0-16-ja",
81
81
  Base32::URL.encode(1234, :length => 5, :split => 2, :checksum => true)
82
82
  end
83
83
 
84
84
  def test_decoding_checksum
85
85
  assert_equal 1234,
86
- Base32::URL.decode("16jd", :checksum => true)
86
+ Base32::URL.decode("16ja", :checksum => true)
87
87
  assert_equal 1234,
88
- Base32::URL.decode("016jd", :length => 5, :checksum => true)
88
+ Base32::URL.decode("016ja", :length => 5, :checksum => true)
89
89
  assert_equal 1234,
90
- Base32::URL.decode("0-16-jd", :length => 5, :split => 2, :checksum => true)
90
+ Base32::URL.decode("0-16-ja", :length => 5, :split => 2, :checksum => true)
91
91
  end
92
92
 
93
93
  def test_decoding_invalid_checksum
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: base32-url
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: '0.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Fenner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-19 00:00:00.000000000 Z
11
+ date: 2018-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -91,9 +91,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  version: '0'
92
92
  requirements: []
93
93
  rubyforge_project:
94
- rubygems_version: 2.6.12
94
+ rubygems_version: 2.7.4
95
95
  signing_key:
96
96
  specification_version: 4
97
97
  summary: Ruby client library for conversion of DOI Metadata
98
- test_files:
99
- - test/test_base32_url.rb
98
+ test_files: []