sqids 0.2.1 → 0.2.2

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: 8738a24714961747ba8fb004ffba899f34889de1e65ba3932a59a50b85558aef
4
- data.tar.gz: 6b26a781bd07bc2b805af36d29bd0cc838351569a3a44988e171b6083e75a3e4
3
+ metadata.gz: 59ddd592b26f4e6e11fa12ce1a9b20438f4aabf58f1a4ea8e14bb7180afe54e8
4
+ data.tar.gz: ce4692b53fdb5dd5f849e7c236511877a15e9cfc1658faa66e4f67664b0f2e9c
5
5
  SHA512:
6
- metadata.gz: 4dbacb914b13fc4a8125f3b313359db82afe1251d5f9ef7d5eaa724fb8b474521e102ec00ef938d621259c52541bf9f6b63647ef1d24243e3bd72a1ab07f6926
7
- data.tar.gz: 33660c785f18c7a2692e3e184c275c104c73dd72ac5aa6bca940f1da7dda1a5b3f66c30f55c4010d488bec694bafd0329979bcce3f3e0db20bfb87bdf01a6f4b
6
+ metadata.gz: 621bfad75a7b8c12ae514ff88a8c282ee795f1ccfc03b62aff497570c96a6d4912f0b1d8eab17f6d3039180def2950b20f6d402a017971abba96280e38f36864
7
+ data.tar.gz: b5f6856e38408ea64d78cdccec7f26b86abd3907819da248d2ece727850c2c1d652807fd5eb2530f5fcc3058134d4fd7ccd1199e7152becc4affb04342bcfd97
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # CHANGELOG
2
2
 
3
+ **v0.2.2:**
4
+ - Improvement: Encoding floats creates large encoded string: [[PR #8](https://github.com/sqids/sqids-ruby/pull/8)] (thanks to [@akeenl-sp](https://github.com/akeenl-sp))
5
+
3
6
  **v0.2.1:**
4
7
  - Improvement: speeding up Sqids.new: [[PR #7](https://github.com/sqids/sqids-ruby/pull/7)] (thanks to [@lawrencegripper](https://github.com/lawrencegripper))
5
8
 
data/README.md CHANGED
@@ -87,9 +87,9 @@ numbers = sqids.decode(id) # [1, 2, 3]
87
87
  ```
88
88
 
89
89
  > [!WARNING]
90
- > If you provide a large custom blocklist and/or custom alphabet, calls to `Sqid.new` can take
91
- > ~1ms. You should create a singleton instance of `Sqid` at service start and reusing that rather than
92
- > repeatedly calling `Squid.new`
90
+ > If you provide a large custom blocklist and/or custom alphabet, calls to `Sqids.new` can take
91
+ > ~1ms. You should create a singleton instance of `Sqids` at service start and reusing that rather than
92
+ > repeatedly calling `Sqids.new`
93
93
 
94
94
  ## 📝 License
95
95
 
data/lib/sqids.rb CHANGED
@@ -51,7 +51,7 @@ class Sqids
51
51
  def encode(numbers)
52
52
  return '' if numbers.empty?
53
53
 
54
- in_range_numbers = numbers.select { |n| n >= 0 && n <= Sqids.max_value }
54
+ in_range_numbers = numbers.map(&:to_i).select { |n| n >= 0 && n <= Sqids.max_value }
55
55
  unless in_range_numbers.length == numbers.length
56
56
  raise ArgumentError,
57
57
  "Encoding supports numbers between 0 and #{Sqids.max_value}"
@@ -100,6 +100,14 @@ describe 'Sqids' do
100
100
  expect(sqids.encode([])).to eq('')
101
101
  end
102
102
 
103
+ it 'encoding with float' do
104
+ sqids = Sqids.new
105
+ float = 3.14159265
106
+ encoded_float = sqids.encode([float])
107
+ encoded_int = sqids.encode([float.to_i])
108
+ expect(encoded_float).to eq(encoded_int)
109
+ end
110
+
103
111
  it 'decoding empty string' do
104
112
  sqids = Sqids.new
105
113
  expect(sqids.decode('')).to eq([])
data/sqids.gemspec CHANGED
@@ -7,7 +7,7 @@ require 'sqids'
7
7
 
8
8
  Gem::Specification.new do |gem|
9
9
  gem.name = 'sqids'
10
- gem.version = '0.2.1'
10
+ gem.version = '0.2.2'
11
11
  gem.authors = ['Sqids Maintainers']
12
12
  gem.summary = 'Generate YouTube-like ids from numbers.'
13
13
  gem.homepage = 'https://sqids.org/ruby'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqids
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sqids Maintainers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-25 00:00:00.000000000 Z
11
+ date: 2025-04-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: