sqids 0.1.0 → 0.1.1

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: d51e2c5981c5b59b42e1cd3ddcf953ca6f1f5dfa21998b066064081888523a07
4
- data.tar.gz: f3279de8aa60f40dbe20f338d18731f71018958784aaf5e95b65e22a57cd5664
3
+ metadata.gz: e6375d093506a2d4058cecce28ee9f4e00148e7bde606bb4d64e613cbfb698d8
4
+ data.tar.gz: c5eb151f25ba5156995c4f7ab9fdf064d931ae619524ddae73cbe420b9ec3c48
5
5
  SHA512:
6
- metadata.gz: 510e16706f4310fdaab202bfef003d2cd7ce622e79b606d2ea948bf8b04a5f5c0d000e06102447782a87ff25ee0395b7e02e3b24b242af7fe6038b1682e34bde
7
- data.tar.gz: 9232d0467cf326a4860d09fcb5e820893e426f6963e0296f821baef7e9873d1ccdd9bba98846f82d02f5ea55c9780c4bd8b136167c2bd8e858cb8b6653409947
6
+ metadata.gz: 3f92140fe71c4f38875cd66485188b303d46ba3114af2467386256bfa4e8e5bad8f6fff0a0d4f8b478a1ec7bfd2160689c63da46a4d7c9364300383ad43a1894
7
+ data.tar.gz: 50b51f34611e1d1465fc58cf1f97d406bf4768d7208a77cc2829e55b686806f3189834291dbc12b87774a3852dd41b55c0e994e51909d917fe5002a8adbcbd63
@@ -12,7 +12,7 @@ jobs:
12
12
  - name: Set up Ruby
13
13
  uses: ruby/setup-ruby@v1
14
14
  with:
15
- ruby-version: '3.1'
15
+ ruby-version: '3.0'
16
16
  bundler-cache: true
17
17
  - name: Install dependencies
18
18
  run: bundle install
data/.rubocop.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  AllCops:
2
2
  NewCops: enable
3
- TargetRubyVersion: 3.1
3
+ TargetRubyVersion: 3.0
data/CHANGELOG.md CHANGED
@@ -1,4 +1,7 @@
1
1
  # CHANGELOG
2
2
 
3
+ **v0.1.1:**
4
+ - Lowering Ruby version requirement to 3.0
5
+
3
6
  **v0.1.0:**
4
7
  - First implementation of [the spec](https://github.com/sqids/sqids-spec)
data/README.md CHANGED
@@ -1,10 +1,35 @@
1
1
  # [Sqids Ruby](https://sqids.org/ruby)
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/sqids.svg)](https://rubygems.org/gems/sqids)
3
4
  [![Github Actions](https://img.shields.io/github/actions/workflow/status/sqids/sqids-ruby/tests.yml)](https://github.com/sqids/sqids-ruby/actions)
5
+ [![Downloads](https://img.shields.io/gem/dt/sqids)](https://crates.io/crates/sqids)
4
6
 
5
- Sqids (pronounced "squids") is a small library that lets you generate YouTube-looking IDs from numbers. It's good for link shortening, fast & URL-safe ID generation and decoding back into numbers for quicker database lookups.
7
+ [Sqids](https://sqids.org/ruby) (*pronounced "squids"*) is a small library that lets you **generate unique IDs from numbers**. It's good for link shortening, fast & URL-safe ID generation and decoding back into numbers for quicker database lookups.
6
8
 
7
- ## Getting started
9
+ Features:
10
+
11
+ - **Encode multiple numbers** - generate short IDs from one or several non-negative numbers
12
+ - **Quick decoding** - easily decode IDs back into numbers
13
+ - **Unique IDs** - generate unique IDs by shuffling the alphabet once
14
+ - **ID padding** - provide minimum length to make IDs more uniform
15
+ - **URL safe** - auto-generated IDs do not contain common profanity
16
+ - **Randomized output** - Sequential input provides nonconsecutive IDs
17
+ - **Many implementations** - Support for [40+ programming languages](https://sqids.org/)
18
+
19
+ ## 🧰 Use-cases
20
+
21
+ Good for:
22
+
23
+ - Generating IDs for public URLs (eg: link shortening)
24
+ - Generating IDs for internal systems (eg: event tracking)
25
+ - Decoding for quicker database lookups (eg: by primary keys)
26
+
27
+ Not good for:
28
+
29
+ - Sensitive data (this is not an encryption library)
30
+ - User IDs (can be decoded revealing user count)
31
+
32
+ ## 🚀 Getting started
8
33
 
9
34
  Add this line to your application's Gemfile:
10
35
 
@@ -24,7 +49,7 @@ Or install it via:
24
49
  gem install sqids
25
50
  ```
26
51
 
27
- ## Examples
52
+ ## 👩‍💻 Examples
28
53
 
29
54
  Simple encode & decode:
30
55
 
@@ -34,6 +59,9 @@ id = sqids.encode([1, 2, 3]) # '8QRLaD'
34
59
  numbers = sqids.decode(id) # [1, 2, 3]
35
60
  ```
36
61
 
62
+ > **Note**
63
+ > 🚧 Because of the algorithm's design, **multiple IDs can decode back into the same sequence of numbers**. If it's important to your design that IDs are canonical, you have to manually re-encode decoded numbers and check that the generated ID matches.
64
+
37
65
  Randomize IDs by providing a custom alphabet:
38
66
 
39
67
  ```ruby
@@ -58,6 +86,6 @@ id = sqids.encode([1, 2, 3]) # '8QRLaD'
58
86
  numbers = sqids.decode(id) # [1, 2, 3]
59
87
  ```
60
88
 
61
- ## License
89
+ ## 📝 License
62
90
 
63
91
  [MIT](LICENSE)
@@ -49,7 +49,7 @@ describe Sqids do
49
49
  [1_000_000],
50
50
  [Sqids.max_value]
51
51
  ].each do |numbers|
52
- sqids = Sqids.new(min_length:)
52
+ sqids = Sqids.new(min_length: min_length)
53
53
 
54
54
  id = sqids.encode(numbers)
55
55
  expect(id.length).to be >= min_length
data/sqids.gemspec CHANGED
@@ -7,13 +7,13 @@ require 'sqids'
7
7
 
8
8
  Gem::Specification.new do |gem|
9
9
  gem.name = 'sqids'
10
- gem.version = '0.1.0'
10
+ gem.version = '0.1.1'
11
11
  gem.authors = ['Sqids Maintainers']
12
12
  gem.summary = 'Generate YouTube-like ids from numbers.'
13
13
  gem.homepage = 'https://sqids.org/ruby'
14
14
  gem.license = 'MIT'
15
15
 
16
- gem.required_ruby_version = '>= 3.1'
16
+ gem.required_ruby_version = '>= 3.0'
17
17
 
18
18
  gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
19
19
  gem.require_paths = ['lib']
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.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sqids Maintainers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-12 00:00:00.000000000 Z
11
+ date: 2023-08-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -42,7 +42,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
42
42
  requirements:
43
43
  - - ">="
44
44
  - !ruby/object:Gem::Version
45
- version: '3.1'
45
+ version: '3.0'
46
46
  required_rubygems_version: !ruby/object:Gem::Requirement
47
47
  requirements:
48
48
  - - ">="