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 +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +3 -3
- data/lib/sqids.rb +1 -1
- data/spec/encoding_spec.rb +8 -0
- data/sqids.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59ddd592b26f4e6e11fa12ce1a9b20438f4aabf58f1a4ea8e14bb7180afe54e8
|
4
|
+
data.tar.gz: ce4692b53fdb5dd5f849e7c236511877a15e9cfc1658faa66e4f67664b0f2e9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 `
|
91
|
-
> ~1ms. You should create a singleton instance of `
|
92
|
-
> repeatedly calling `
|
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}"
|
data/spec/encoding_spec.rb
CHANGED
@@ -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
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.
|
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:
|
11
|
+
date: 2025-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|