hashids 1.0.4 → 1.0.6

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: bcf921c95958fac763731852a7bada447d74e30f
4
- data.tar.gz: 6f6c71145d00140152c127e0978c28966fc30fe1
2
+ SHA256:
3
+ metadata.gz: 9bd407187c5ce1192bccaa9c8a7ade234459074d81e6bd878814fa6d5bb2fe0d
4
+ data.tar.gz: 98c7b15fe5cea31af4764503c2f13948fe1c7034c5f0bd806cc5be35e04e186b
5
5
  SHA512:
6
- metadata.gz: 6170e1679f92a5590f4a64c9350dd64bbca1518725726ef0340bd375c6c5f71779bf80b7dfd043e78b3c70ee00075376fcab13e57645ef36e45ec48efb9da154
7
- data.tar.gz: b3baeb0247049a60da810b66206f44018923b248cf511451239053a0ec8f1c35d39e9ff0e71f5eb6c57ea0d6cd1ff1bccbab6e3806d0bbe9c9b2e2c2f720d602
6
+ metadata.gz: b1ec375ecfe8ab134d5f5fbafad43fdd00253fdbf9c4ad16f00363b93a303df71fe380abe3b0b0bc5ea81f5bb730a6c1d3ddcba13711413b5767ce3ec679cae1
7
+ data.tar.gz: 9e8985ae3da3ab8909892e609afe967d4f10eaf6d52bb6e444de499024ac131eb923f0a094af2da5202534af0dea14d07b05ded59587183a083679889d34c3e6
@@ -0,0 +1 @@
1
+ ko_fi: peterhellberg
@@ -0,0 +1,30 @@
1
+ name: Tests
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-latest
8
+ timeout-minutes: 10
9
+
10
+ env:
11
+ RUBYOPT: "--enable=frozen-string-literal"
12
+
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ os: [ubuntu]
17
+ ruby: [2.6, 2.7, 3.0, jruby, jruby-head, truffleruby, truffleruby-head]
18
+ continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
19
+
20
+ steps:
21
+ - uses: actions/checkout@v2
22
+
23
+ - name: Set up Ruby
24
+ uses: ruby/setup-ruby@v1
25
+ with:
26
+ ruby-version: ${{ matrix.ruby }}
27
+ bundler-cache: true # Runs also bundle install
28
+
29
+ - name: Run tests
30
+ run: bundle exec rake
data/README.md CHANGED
@@ -5,8 +5,7 @@ Use hashids when you do not want to expose your database ids to the user.
5
5
 
6
6
  [http://hashids.org/ruby/](http://hashids.org/ruby/)
7
7
 
8
- [![Build Status](https://travis-ci.org/peterhellberg/hashids.rb.svg?branch=master)](http://travis-ci.org/peterhellberg/hashids.rb)
9
- (2.4.0 2.3.1, 2.2.5, 2.1.9, 2.0.0, jruby-9.0.5.0, jruby-1.7.20)
8
+ [![Build Status (push)](https://github.com/peterhellberg/hashids.rb/actions/workflows/tests.yml/badge.svg?event=push)](https://github.com/peterhellberg/hashids.rb/actions/workflows/tests.yml)
10
9
 
11
10
  ## What is it?
12
11
 
@@ -208,6 +207,17 @@ hex_str = hashids.decode_hex("kRNrpKlJ")
208
207
 
209
208
  ## Changelog
210
209
 
210
+ **1.0.6**
211
+
212
+ - Fixed using lib with frozen strings
213
+ - Remove deprecated global use of `must_equal` and `must_raise`
214
+ - Use GitHub Actions instead of Travis-CI
215
+
216
+ **1.0.5**
217
+
218
+ - Improve shuffle performance
219
+ - Update rubies used by Travis-CI
220
+
211
221
  **1.0.4**
212
222
 
213
223
  - Improved encode/decode performance
data/hashids.gemspec CHANGED
@@ -11,6 +11,7 @@ Gem::Specification.new do |gem|
11
11
  gem.summary = %q{Generate YouTube-like hashes from one or many numbers.}
12
12
  gem.description = %q{Use hashids when you do not want to expose your database ids to the user.}
13
13
  gem.homepage = "https://github.com/peterhellberg/hashids.rb"
14
+ gem.license = "MIT"
14
15
 
15
16
  gem.required_ruby_version = '>= 1.9.3'
16
17
 
data/lib/hashids.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  class Hashids
4
- VERSION = "1.0.4"
4
+ VERSION = "1.0.6"
5
5
 
6
6
  MIN_ALPHABET_LENGTH = 16
7
7
  SEP_DIV = 3.5
@@ -142,18 +142,19 @@ class Hashids
142
142
 
143
143
  def consistent_shuffle(alphabet, salt)
144
144
  return alphabet if salt.nil? || salt.empty?
145
- v = 0
146
- p = 0
147
- chars = alphabet.chars.to_a
148
- slen = salt.length
145
+
146
+ chars = alphabet.each_char.to_a
147
+ salt_ords = salt.codepoints.to_a
148
+ salt_length = salt_ords.length
149
+ idx = ord_total = 0
150
+
149
151
  (alphabet.length-1).downto(1) do |i|
150
- v = v % slen
151
- p += n = salt[v].ord
152
- j = (n + v + p) % i
152
+ ord_total += n = salt_ords[idx]
153
+ j = (n + idx + ord_total) % i
153
154
 
154
155
  chars[i], chars[j] = chars[j], chars[i]
155
156
 
156
- v += 1
157
+ idx = (idx + 1) % salt_length
157
158
  end
158
159
 
159
160
  chars.join
@@ -191,7 +192,7 @@ class Hashids
191
192
  def setup_alphabet
192
193
  validate_attributes
193
194
 
194
- @alphabet = uniq_characters(alphabet)
195
+ @alphabet = String.new(uniq_characters(alphabet))
195
196
 
196
197
  validate_alphabet
197
198
 
@@ -200,7 +201,7 @@ class Hashids
200
201
  end
201
202
 
202
203
  def setup_seps
203
- @seps = DEFAULT_SEPS
204
+ @seps = String.new(DEFAULT_SEPS)
204
205
 
205
206
  seps.length.times do |i|
206
207
  # Seps should only contain characters present in alphabet,
data/spec/hashids_spec.rb CHANGED
@@ -26,302 +26,301 @@ describe Hashids do
26
26
 
27
27
  describe "setup" do
28
28
  it "has a default alphabet" do
29
- Hashids::DEFAULT_ALPHABET.must_equal default_alphabet
29
+ _(Hashids::DEFAULT_ALPHABET).must_equal default_alphabet
30
30
  end
31
31
 
32
32
  it "has default separators" do
33
- Hashids::DEFAULT_SEPS.must_equal default_seps
33
+ _(Hashids::DEFAULT_SEPS).must_equal default_seps
34
34
  end
35
35
 
36
36
  it "has a default salt" do
37
- Hashids.new.encode(1,2,3).must_equal "o2fXhV"
37
+ _(Hashids.new.encode(1,2,3)).must_equal "o2fXhV"
38
38
  end
39
39
 
40
40
  it "has the correct salt" do
41
- hashids.instance_variable_get(:@salt).must_equal salt
41
+ _(hashids.instance_variable_get(:@salt)).must_equal salt
42
42
  end
43
43
 
44
44
  it "defaults to a min_length of 0" do
45
- hashids.instance_variable_get(:@min_hash_length).must_equal 0
45
+ _(hashids.instance_variable_get(:@min_hash_length)).must_equal 0
46
46
  end
47
47
 
48
48
  it "generates the correct seps" do
49
- hashids.instance_variable_get(:@seps).must_equal seps
49
+ _(hashids.instance_variable_get(:@seps)).must_equal seps
50
50
  end
51
51
 
52
52
  it "generates the correct @guards" do
53
- hashids.instance_variable_get(:@guards).must_equal guards
53
+ _(hashids.instance_variable_get(:@guards)).must_equal guards
54
54
  end
55
55
 
56
56
  it "generates the correct alphabet" do
57
- hashids.instance_variable_get(:@alphabet).must_equal alphabet
57
+ _(hashids.instance_variable_get(:@alphabet)).must_equal alphabet
58
58
  end
59
59
 
60
60
  it "has a minimum alphabet length" do
61
- -> {
61
+ _(-> {
62
62
  Hashids.new("", 0, 'shortalphabet')
63
- }.must_raise Hashids::AlphabetError
63
+ }).must_raise Hashids::AlphabetError
64
64
  end
65
65
 
66
66
  it "has a final alphabet length that can be shorter than the minimum" do
67
- Hashids.new("this is my salt", 0, 'cfhistuCFHISTU01').
68
- alphabet.must_equal "10"
67
+ _(Hashids.new("this is my salt", 0, 'cfhistuCFHISTU01').
68
+ alphabet).must_equal "10"
69
69
  end
70
70
 
71
71
  it "checks the alphabet for spaces" do
72
- -> {
72
+ _(-> {
73
73
  Hashids.new("", 0, 'abc odefghijklmnopqrstuv')
74
- }.must_raise Hashids::AlphabetError
74
+ }).must_raise Hashids::AlphabetError
75
75
  end
76
76
  end
77
77
 
78
78
  describe "encode" do
79
79
  it "encodes a single number" do
80
- hashids.encode(12345).must_equal 'NkK9'
80
+ _(hashids.encode(12345)).must_equal 'NkK9'
81
81
 
82
82
  hashids.tap do |h|
83
- h.encode(-1).must_equal ''
84
- h.encode(1).must_equal 'NV'
85
- h.encode(22).must_equal 'K4'
86
- h.encode(333).must_equal 'OqM'
87
- h.encode(9999).must_equal 'kQVg'
88
- h.encode(123_000).must_equal '58LzD'
89
- h.encode(456_000_000).must_equal '5gn6mQP'
90
- h.encode(987_654_321).must_equal 'oyjYvry'
83
+ _(h.encode(-1)).must_equal ''
84
+ _(h.encode(1)).must_equal 'NV'
85
+ _(h.encode(22)).must_equal 'K4'
86
+ _(h.encode(333)).must_equal 'OqM'
87
+ _(h.encode(9999)).must_equal 'kQVg'
88
+ _(h.encode(123_000)).must_equal '58LzD'
89
+ _(h.encode(456_000_000)).must_equal '5gn6mQP'
90
+ _(h.encode(987_654_321)).must_equal 'oyjYvry'
91
91
  end
92
92
  end
93
93
 
94
94
  it "can encode a list of numbers" do
95
95
  hashids.tap do |h|
96
- h.encode(1,2,3).must_equal "laHquq"
97
- h.encode(2,4,6).must_equal "44uotN"
98
- h.encode(99,25).must_equal "97Jun"
96
+ _(h.encode(1,2,3)).must_equal "laHquq"
97
+ _(h.encode(2,4,6)).must_equal "44uotN"
98
+ _(h.encode(99,25)).must_equal "97Jun"
99
99
 
100
- h.encode(1337,42,314).
100
+ _(h.encode(1337,42,314)).
101
101
  must_equal "7xKhrUxm"
102
102
 
103
- h.encode(683, 94108, 123, 5).
103
+ _(h.encode(683, 94108, 123, 5)).
104
104
  must_equal "aBMswoO2UB3Sj"
105
105
 
106
- h.encode(547, 31, 241271, 311, 31397, 1129, 71129).
106
+ _(h.encode(547, 31, 241271, 311, 31397, 1129, 71129)).
107
107
  must_equal "3RoSDhelEyhxRsyWpCx5t1ZK"
108
108
 
109
- h.encode(21979508, 35563591, 57543099, 93106690, 150649789).
109
+ _(h.encode(21979508, 35563591, 57543099, 93106690, 150649789)).
110
110
  must_equal "p2xkL3CK33JjcrrZ8vsw4YRZueZX9k"
111
111
  end
112
112
  end
113
113
 
114
114
  it "can encode a list of numbers passed in as an array" do
115
- hashids.encode([1,2,3]).must_equal "laHquq"
115
+ _(hashids.encode([1,2,3])).must_equal "laHquq"
116
116
  end
117
117
 
118
118
  it "can encode string encoded number" do
119
- hashids.encode('1').must_equal "NV"
120
- hashids.encode('-1').must_equal ""
119
+ _(hashids.encode('1')).must_equal "NV"
120
+ _(hashids.encode('-1')).must_equal ""
121
121
  end
122
122
 
123
123
  it "raises exception if integer conversion fails" do
124
- -> { hashids.encode('-') }.must_raise ArgumentError
124
+ _(-> { hashids.encode('-') }).must_raise ArgumentError
125
125
  end
126
126
 
127
127
  it "returns an empty string if no numbers" do
128
- hashids.encode.must_equal ""
128
+ _(hashids.encode).must_equal ""
129
129
  end
130
130
 
131
131
  it "returns an empty string if any of the numbers are negative" do
132
- hashids.encode(-1).must_equal ""
133
- hashids.encode(10,-10).must_equal ""
132
+ _(hashids.encode(-1)).must_equal ""
133
+ _(hashids.encode(10,-10)).must_equal ""
134
134
  end
135
135
 
136
136
  it "can encode to a minumum length" do
137
137
  h = Hashids.new(salt, 18)
138
- h.encode(1).must_equal "aJEDngB0NV05ev1WwP"
138
+ _(h.encode(1)).must_equal "aJEDngB0NV05ev1WwP"
139
139
 
140
- h.encode(4140, 21147, 115975, 678570, 4213597, 27644437).
140
+ _(h.encode(4140, 21147, 115975, 678570, 4213597, 27644437)).
141
141
  must_equal "pLMlCWnJSXr1BSpKgqUwbJ7oimr7l6"
142
142
  end
143
143
 
144
144
  it "can encode with a custom alphabet" do
145
145
  h = Hashids.new(salt, 0, "ABCDEFGhijklmn34567890-:")
146
- h.encode(1,2,3,4,5).must_equal "6nhmFDikA0"
146
+ _(h.encode(1,2,3,4,5)).must_equal "6nhmFDikA0"
147
147
  end
148
148
 
149
149
  it "does not produce repeating patterns for identical numbers" do
150
- hashids.encode(5,5,5,5).must_equal "1Wc8cwcE"
150
+ _(hashids.encode(5,5,5,5)).must_equal "1Wc8cwcE"
151
151
  end
152
152
 
153
153
  it "does not produce repeating patterns for incremented numbers" do
154
- hashids.encode(*(1..10).to_a).must_equal "kRHnurhptKcjIDTWC3sx"
154
+ _(hashids.encode(*(1..10).to_a)).must_equal "kRHnurhptKcjIDTWC3sx"
155
155
  end
156
156
 
157
157
  it "does not produce similarities between incrementing number hashes" do
158
- hashids.encode(1).must_equal 'NV'
159
- hashids.encode(2).must_equal '6m'
160
- hashids.encode(3).must_equal 'yD'
161
- hashids.encode(4).must_equal '2l'
162
- hashids.encode(5).must_equal 'rD'
158
+ _(hashids.encode(1)).must_equal 'NV'
159
+ _(hashids.encode(2)).must_equal '6m'
160
+ _(hashids.encode(3)).must_equal 'yD'
161
+ _(hashids.encode(4)).must_equal '2l'
162
+ _(hashids.encode(5)).must_equal 'rD'
163
163
  end
164
164
  end
165
165
 
166
166
  describe "encode_hex" do
167
167
  it "encodes hex string" do
168
168
  hashids.tap { |h|
169
- h.encode_hex("FA").must_equal "lzY"
170
- h.encode_hex("26dd").must_equal "MemE"
171
- h.encode_hex("FF1A").must_equal "eBMrb"
172
- h.encode_hex("12abC").must_equal "D9NPE"
173
- h.encode_hex("185b0").must_equal "9OyNW"
174
- h.encode_hex("17b8d").must_equal "MRWNE"
175
-
176
- h.encode_hex("1d7f21dd38").must_equal "4o6Z7KqxE"
177
- h.encode_hex("20015111d").must_equal "ooweQVNB"
169
+ _(h.encode_hex("FA")).must_equal "lzY"
170
+ _(h.encode_hex("26dd")).must_equal "MemE"
171
+ _(h.encode_hex("FF1A")).must_equal "eBMrb"
172
+ _(h.encode_hex("12abC")).must_equal "D9NPE"
173
+ _(h.encode_hex("185b0")).must_equal "9OyNW"
174
+ _(h.encode_hex("17b8d")).must_equal "MRWNE"
175
+
176
+ _(h.encode_hex("1d7f21dd38")).must_equal "4o6Z7KqxE"
177
+ _(h.encode_hex("20015111d")).must_equal "ooweQVNB"
178
178
  }
179
179
  end
180
180
 
181
181
  it "returns an empty string if passed non-hex string" do
182
- hashids.encode_hex("XYZ123").must_equal ""
182
+ _(hashids.encode_hex("XYZ123")).must_equal ""
183
183
  end
184
184
  end
185
185
 
186
186
  describe "decode" do
187
187
  it "decodes an encoded number" do
188
- hashids.decode("NkK9").must_equal [12345]
189
- hashids.decode("5O8yp5P").must_equal [666555444]
190
- hashids.decode("KVO9yy1oO5j").must_equal [666555444333222]
188
+ _(hashids.decode("NkK9")).must_equal [12345]
189
+ _(hashids.decode("5O8yp5P")).must_equal [666555444]
190
+ _(hashids.decode("KVO9yy1oO5j")).must_equal [666555444333222]
191
191
 
192
192
  hashids.tap { |h|
193
- h.decode("Wzo").must_equal [1337]
194
- h.decode("DbE").must_equal [808]
195
- h.decode("yj8").must_equal [303]
193
+ _(h.decode("Wzo")).must_equal [1337]
194
+ _(h.decode("DbE")).must_equal [808]
195
+ _(h.decode("yj8")).must_equal [303]
196
196
  }
197
197
  end
198
198
 
199
199
  it "decodes a list of encoded numbers" do
200
- hashids.decode("1gRYUwKxBgiVuX").must_equal [66655,5444333,2,22]
201
- hashids.decode('aBMswoO2UB3Sj').must_equal [683, 94108, 123, 5]
200
+ _(hashids.decode("1gRYUwKxBgiVuX")).must_equal [66655,5444333,2,22]
201
+ _(hashids.decode('aBMswoO2UB3Sj')).must_equal [683, 94108, 123, 5]
202
202
 
203
203
  hashids.tap { |h|
204
- h.decode('jYhp').must_equal [3, 4]
205
- h.decode('k9Ib').must_equal [6, 5]
204
+ _(h.decode('jYhp')).must_equal [3, 4]
205
+ _(h.decode('k9Ib')).must_equal [6, 5]
206
206
 
207
- h.decode('EMhN').must_equal [31, 41]
208
- h.decode('glSgV').must_equal [13, 89]
207
+ _(h.decode('EMhN')).must_equal [31, 41]
208
+ _(h.decode('glSgV')).must_equal [13, 89]
209
209
  }
210
210
  end
211
211
 
212
212
  it "does not decode with a different salt" do
213
213
  peppers = Hashids.new('this is my pepper')
214
214
 
215
- hashids.decode('NkK9').must_equal [12345]
216
- peppers.decode('NkK9').must_equal []
215
+ _(hashids.decode('NkK9')).must_equal [12345]
216
+ _(peppers.decode('NkK9')).must_equal []
217
217
  end
218
218
 
219
219
  it "can decode from a hash with a minimum length" do
220
220
  h = Hashids.new(salt, 8)
221
- h.decode("gB0NV05e").must_equal [1]
221
+ _(h.decode("gB0NV05e")).must_equal [1]
222
222
 
223
- h.decode("mxi8XH87").must_equal [25, 100, 950]
224
- h.decode("KQcmkIW8hX").must_equal [5,200,195, 1]
223
+ _(h.decode("mxi8XH87")).must_equal [25, 100, 950]
224
+ _(h.decode("KQcmkIW8hX")).must_equal [5,200,195, 1]
225
225
  end
226
226
 
227
227
  it "handles invalid input by raising InputError" do
228
- -> { hashids.decode('asdf-') }.must_raise Hashids::InputError
228
+ _(-> { hashids.decode('asdf-') }).must_raise Hashids::InputError
229
229
  end
230
230
  end
231
231
 
232
232
  describe "decode_hex" do
233
233
  it "decodes hex string" do
234
- hashids.decode_hex("lzY").must_equal "FA"
235
- hashids.decode_hex("eBMrb").must_equal "FF1A"
236
- hashids.decode_hex("D9NPE").must_equal "12ABC"
234
+ _(hashids.decode_hex("lzY")).must_equal "FA"
235
+ _(hashids.decode_hex("eBMrb")).must_equal "FF1A"
236
+ _(hashids.decode_hex("D9NPE")).must_equal "12ABC"
237
237
  end
238
238
  end
239
239
 
240
240
  describe "setup" do
241
241
  it "raises an exception if the alphabet has less than 16 unique chars" do
242
- -> { Hashids.new('salt', 0, 'abc') }.
242
+ _(-> { Hashids.new('salt', 0, 'abc') }).
243
243
  must_raise Hashids::AlphabetError
244
244
  end
245
245
  end
246
246
 
247
247
  describe "validation of attributes" do
248
248
  it "raises an ArgumentError unless the salt is a String" do
249
- -> { Hashids.new(:not_a_string) }.
249
+ _(-> { Hashids.new(:not_a_string) }).
250
250
  must_raise Hashids::SaltError
251
251
  end
252
252
 
253
253
  it "raises an ArgumentError unless the min_length is an Integer" do
254
- -> { Hashids.new('salt', :not_an_integer)}.
254
+ _(-> { Hashids.new('salt', :not_an_integer)}).
255
255
  must_raise Hashids::MinLengthError
256
256
  end
257
257
 
258
258
  it "raises an ArgumentError unless the alphabet is a String" do
259
- -> { Hashids.new('salt', 2, :not_a_string) }.
259
+ _(-> { Hashids.new('salt', 2, :not_a_string) }).
260
260
  must_raise Hashids::AlphabetError
261
261
  end
262
262
  end
263
263
 
264
264
  describe "protected methods" do
265
-
266
265
  describe "unhash" do
267
266
  it "unhashes" do
268
- hashids.send(:unhash, 'bb', 'abc').must_equal 4
269
- hashids.send(:unhash, 'aaa', 'abc').must_equal 0
270
- hashids.send(:unhash, 'cba', 'abc').must_equal 21
271
- hashids.send(:unhash, 'cbaabc', 'abc').must_equal 572
272
- hashids.send(:unhash, 'aX11b', 'abcXYZ123').must_equal 2728
267
+ _(hashids.send(:unhash, 'bb', 'abc')).must_equal 4
268
+ _(hashids.send(:unhash, 'aaa', 'abc')).must_equal 0
269
+ _(hashids.send(:unhash, 'cba', 'abc')).must_equal 21
270
+ _(hashids.send(:unhash, 'cbaabc', 'abc')).must_equal 572
271
+ _(hashids.send(:unhash, 'aX11b', 'abcXYZ123')).must_equal 2728
273
272
  end
274
273
  end
275
274
 
276
275
  describe "internal_decode" do
277
276
  it "decodes" do
278
- hashids.send(:internal_decode, 'NV', alphabet).must_equal [1]
277
+ _(hashids.send(:internal_decode, 'NV', alphabet)).must_equal [1]
279
278
  end
280
279
  end
281
280
 
282
281
  describe "consistent_shuffle" do
283
282
  it "returns the alphabet if empty salt" do
284
- hashids.send(:consistent_shuffle, default_alphabet, '').
283
+ _(hashids.send(:consistent_shuffle, default_alphabet, '')).
285
284
  must_equal default_alphabet
286
285
  end
287
286
 
288
287
  it "shuffles consistently" do
289
- hashids.send(:consistent_shuffle, 'ab', salt).must_equal 'ba'
290
- hashids.send(:consistent_shuffle, 'abc', salt).must_equal 'bca'
291
- hashids.send(:consistent_shuffle, 'abcd', salt).must_equal 'cadb'
292
- hashids.send(:consistent_shuffle, 'abcde', salt).must_equal 'dceba'
288
+ _(hashids.send(:consistent_shuffle, 'ab', salt)).must_equal 'ba'
289
+ _(hashids.send(:consistent_shuffle, 'abc', salt)).must_equal 'bca'
290
+ _(hashids.send(:consistent_shuffle, 'abcd', salt)).must_equal 'cadb'
291
+ _(hashids.send(:consistent_shuffle, 'abcde', salt)).must_equal 'dceba'
293
292
 
294
- hashids.send(:consistent_shuffle, default_alphabet, 'salt').
293
+ _(hashids.send(:consistent_shuffle, default_alphabet, 'salt')).
295
294
  must_equal "f17a8zvCwo0iuqYDXlJ4RmAS2end5gh" +
296
295
  "TcpjbOWLK9GFyE6xUI3ZBMQtPsNHrkV"
297
296
 
298
- hashids.send(:consistent_shuffle, 'abcdefghijklmnopqrstuvwxyz', salt).
297
+ _(hashids.send(:consistent_shuffle, 'abcdefghijklmnopqrstuvwxyz', salt)).
299
298
  must_equal 'fcaodykrgqvblxjwmtupzeisnh'
300
299
  end
301
300
  end
302
301
 
303
302
  describe "hash" do
304
303
  it "hashes" do
305
- hashids.send(:hash, 12, 'abcdefg').must_equal "bf"
306
- hashids.send(:hash, 42, 'abcdefg').must_equal "ga"
307
- hashids.send(:hash, 123, 'abcdefg').must_equal "cde"
308
- hashids.send(:hash, 1024, 'abcdefg').must_equal "cggc"
309
- hashids.send(:hash, 950000, 'abcdefg').must_equal "bbadeefc"
310
- hashids.send(:hash, 950000, 'åäö-ÅÄÖ').must_equal "ääå-ÅÅÄö"
311
- hashids.send(:hash, 3500000, 'abcdefg').must_equal "ebfbfaea"
312
- hashids.send(:hash, 3500000, 'Xyz01-å').must_equal "1y-y-X1X"
304
+ _(hashids.send(:hash, 12, 'abcdefg')).must_equal "bf"
305
+ _(hashids.send(:hash, 42, 'abcdefg')).must_equal "ga"
306
+ _(hashids.send(:hash, 123, 'abcdefg')).must_equal "cde"
307
+ _(hashids.send(:hash, 1024, 'abcdefg')).must_equal "cggc"
308
+ _(hashids.send(:hash, 950000, 'abcdefg')).must_equal "bbadeefc"
309
+ _(hashids.send(:hash, 950000, 'åäö-ÅÄÖ')).must_equal "ääå-ÅÅÄö"
310
+ _(hashids.send(:hash, 3500000, 'abcdefg')).must_equal "ebfbfaea"
311
+ _(hashids.send(:hash, 3500000, 'Xyz01-å')).must_equal "1y-y-X1X"
313
312
  end
314
313
  end
315
314
 
316
315
  describe "unhash" do
317
316
  it "unhashes" do
318
- hashids.send(:unhash, 'abbd', 'abcdefg').must_equal 59
319
- hashids.send(:unhash, 'abcd', 'abcdefg').must_equal 66
320
- hashids.send(:unhash, 'acac', 'abcdefg').must_equal 100
321
- hashids.send(:unhash, 'acfg', 'abcdefg').must_equal 139
322
- hashids.send(:unhash, 'x21y', 'xyz1234').must_equal 218
323
- hashids.send(:unhash, 'yy44', 'xyz1234').must_equal 440
324
- hashids.send(:unhash, '1xzz', 'xyz1234').must_equal 1045
317
+ _(hashids.send(:unhash, 'abbd', 'abcdefg')).must_equal 59
318
+ _(hashids.send(:unhash, 'abcd', 'abcdefg')).must_equal 66
319
+ _(hashids.send(:unhash, 'acac', 'abcdefg')).must_equal 100
320
+ _(hashids.send(:unhash, 'acfg', 'abcdefg')).must_equal 139
321
+ _(hashids.send(:unhash, 'x21y', 'xyz1234')).must_equal 218
322
+ _(hashids.send(:unhash, 'yy44', 'xyz1234')).must_equal 440
323
+ _(hashids.send(:unhash, '1xzz', 'xyz1234')).must_equal 1045
325
324
  end
326
325
  end
327
326
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hashids
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Hellberg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-16 00:00:00.000000000 Z
11
+ date: 2021-11-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Use hashids when you do not want to expose your database ids to the user.
14
14
  email:
@@ -17,8 +17,9 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
+ - ".github/FUNDING.yml"
21
+ - ".github/workflows/tests.yml"
20
22
  - ".gitignore"
21
- - ".travis.yml"
22
23
  - Gemfile
23
24
  - LICENSE.txt
24
25
  - README.md
@@ -27,7 +28,8 @@ files:
27
28
  - lib/hashids.rb
28
29
  - spec/hashids_spec.rb
29
30
  homepage: https://github.com/peterhellberg/hashids.rb
30
- licenses: []
31
+ licenses:
32
+ - MIT
31
33
  metadata: {}
32
34
  post_install_message:
33
35
  rdoc_options: []
@@ -44,8 +46,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
44
46
  - !ruby/object:Gem::Version
45
47
  version: '0'
46
48
  requirements: []
47
- rubyforge_project:
48
- rubygems_version: 2.6.8
49
+ rubygems_version: 3.2.3
49
50
  signing_key:
50
51
  specification_version: 4
51
52
  summary: Generate YouTube-like hashes from one or many numbers.
data/.travis.yml DELETED
@@ -1,14 +0,0 @@
1
- language: ruby
2
-
3
- bundler_args: --without documentation
4
-
5
- rvm:
6
- - 2.4.0
7
- - 2.3.3
8
- - 2.2.6
9
- - 2.1.10
10
- - 2.0.0
11
- - jruby-9.1.6.0
12
- - jruby-1.7.26
13
-
14
- sudo: false