encoded_id-rails 1.0.0 → 1.1.0
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 +6 -0
- data/README.md +1 -1
- data/lib/encoded_id/rails/coder.rb +14 -2
- data/lib/encoded_id/rails/configuration.rb +9 -0
- data/lib/encoded_id/rails/encoder_methods.rb +3 -0
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4da003d36ccb45772078a30f7a28b6c65f1810ba057e538bc6e79c0156b4d5e5
|
|
4
|
+
data.tar.gz: f2944b9ef646adaebdba1379ae60ff84f2ac1250c8e09ce63964d78c04c723f6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f87ba716543874cad1edcf0c1fbd6259b0b4fde72134a200df9320533a37d36e3e776c9e78b76b4a694481d0987def973423ff48035301f5b3ebae1f61d50065
|
|
7
|
+
data.tar.gz: affff6f578bea25443d4aafd4b2ac64291f58ad25188c85251ff498fffa89ba250874dbd7fa03fb3afe8efe05df4a46bfaf3c379d9e45f69193a52d559f282e1
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -111,7 +111,7 @@ Read more about the security implications: [Hashids expose salt value](https://w
|
|
|
111
111
|
- [with_uid](https://github.com/SPBTV/with_uid)
|
|
112
112
|
- [bullet_train-obfuscates_id](https://github.com/bullet-train-co/bullet_train-core/blob/main/bullet_train-obfuscates_id/app/models/concerns/obfuscates_id.rb)
|
|
113
113
|
|
|
114
|
-
For a detailed comparison, see the [Compared to Other Gems](https://encoded-id.onrender.com/docs/
|
|
114
|
+
For a detailed comparison, see the [Compared to Other Gems](https://encoded-id.onrender.com/docs/similar-gems/) documentation page.
|
|
115
115
|
|
|
116
116
|
## Documentation
|
|
117
117
|
|
|
@@ -8,6 +8,9 @@ module EncodedId
|
|
|
8
8
|
class Coder
|
|
9
9
|
# @rbs @salt: String?
|
|
10
10
|
# @rbs @id_length: Integer
|
|
11
|
+
# @rbs @max_length: Integer?
|
|
12
|
+
# @rbs @max_inputs_per_id: Integer
|
|
13
|
+
# @rbs @hex_digit_encoding_group_size: Integer
|
|
11
14
|
# @rbs @character_group_size: Integer
|
|
12
15
|
# @rbs @separator: String
|
|
13
16
|
# @rbs @alphabet: ::EncodedId::Alphabet
|
|
@@ -17,14 +20,17 @@ module EncodedId
|
|
|
17
20
|
# @rbs @blocklist_max_length: Integer
|
|
18
21
|
# @rbs @downcase_on_decode: bool
|
|
19
22
|
|
|
20
|
-
# @rbs (salt: String?, id_length: Integer, character_group_size: Integer, separator: String, alphabet: ::EncodedId::Alphabet, ?encoder: Symbol?, ?blocklist: ::EncodedId::Blocklist?, ?blocklist_mode: Symbol?, ?blocklist_max_length: Integer?, ?downcase_on_decode: bool?) -> void
|
|
21
|
-
def initialize(salt:, id_length:, character_group_size:, separator:, alphabet:, encoder: nil, blocklist: nil, blocklist_mode: nil, blocklist_max_length: nil, downcase_on_decode: nil)
|
|
23
|
+
# @rbs (salt: String?, id_length: Integer, character_group_size: Integer, separator: String, alphabet: ::EncodedId::Alphabet, ?max_length: Integer?, ?max_inputs_per_id: Integer?, ?hex_digit_encoding_group_size: Integer?, ?encoder: Symbol?, ?blocklist: ::EncodedId::Blocklist?, ?blocklist_mode: Symbol?, ?blocklist_max_length: Integer?, ?downcase_on_decode: bool?) -> void
|
|
24
|
+
def initialize(salt:, id_length:, character_group_size:, separator:, alphabet:, max_length: nil, max_inputs_per_id: nil, hex_digit_encoding_group_size: nil, encoder: nil, blocklist: nil, blocklist_mode: nil, blocklist_max_length: nil, downcase_on_decode: nil)
|
|
22
25
|
@salt = salt
|
|
23
26
|
@id_length = id_length
|
|
24
27
|
@character_group_size = character_group_size
|
|
25
28
|
@separator = separator
|
|
26
29
|
@alphabet = alphabet
|
|
27
30
|
config = EncodedId::Rails.configuration
|
|
31
|
+
@max_length = max_length.nil? ? config.max_length : max_length
|
|
32
|
+
@max_inputs_per_id = max_inputs_per_id || config.max_inputs_per_id
|
|
33
|
+
@hex_digit_encoding_group_size = hex_digit_encoding_group_size || config.hex_digit_encoding_group_size
|
|
28
34
|
@encoder = encoder || config.encoder
|
|
29
35
|
@blocklist = blocklist || config.blocklist
|
|
30
36
|
@blocklist_mode = blocklist_mode || config.blocklist_mode
|
|
@@ -54,6 +60,9 @@ module EncodedId
|
|
|
54
60
|
::EncodedId::Encoders::HashidConfiguration.new(
|
|
55
61
|
salt: @salt || raise(ArgumentError, "Salt is required for hashids encoder"),
|
|
56
62
|
min_length: @id_length,
|
|
63
|
+
max_length: @max_length,
|
|
64
|
+
max_inputs_per_id: @max_inputs_per_id,
|
|
65
|
+
hex_digit_encoding_group_size: @hex_digit_encoding_group_size,
|
|
57
66
|
split_at: @character_group_size,
|
|
58
67
|
split_with: @separator,
|
|
59
68
|
alphabet: @alphabet,
|
|
@@ -64,6 +73,9 @@ module EncodedId
|
|
|
64
73
|
when :sqids
|
|
65
74
|
::EncodedId::Encoders::SqidsConfiguration.new(
|
|
66
75
|
min_length: @id_length,
|
|
76
|
+
max_length: @max_length,
|
|
77
|
+
max_inputs_per_id: @max_inputs_per_id,
|
|
78
|
+
hex_digit_encoding_group_size: @hex_digit_encoding_group_size,
|
|
67
79
|
split_at: @character_group_size,
|
|
68
80
|
split_with: @separator,
|
|
69
81
|
alphabet: @alphabet,
|
|
@@ -13,6 +13,9 @@ module EncodedId
|
|
|
13
13
|
# @rbs @character_group_size: Integer
|
|
14
14
|
# @rbs @alphabet: ::EncodedId::Alphabet
|
|
15
15
|
# @rbs @id_length: Integer
|
|
16
|
+
# @rbs @max_length: Integer?
|
|
17
|
+
# @rbs @max_inputs_per_id: Integer
|
|
18
|
+
# @rbs @hex_digit_encoding_group_size: Integer
|
|
16
19
|
# @rbs @slug_value_method_name: Symbol
|
|
17
20
|
# @rbs @annotation_method_name: Symbol
|
|
18
21
|
# @rbs @model_to_param_returns_encoded_id: bool
|
|
@@ -29,6 +32,9 @@ module EncodedId
|
|
|
29
32
|
attr_accessor :character_group_size #: Integer
|
|
30
33
|
attr_accessor :alphabet #: ::EncodedId::Alphabet
|
|
31
34
|
attr_accessor :id_length #: Integer
|
|
35
|
+
attr_accessor :max_length #: Integer?
|
|
36
|
+
attr_accessor :max_inputs_per_id #: Integer
|
|
37
|
+
attr_accessor :hex_digit_encoding_group_size #: Integer
|
|
32
38
|
attr_accessor :slug_value_method_name #: Symbol
|
|
33
39
|
attr_accessor :annotation_method_name #: Symbol
|
|
34
40
|
attr_accessor :model_to_param_returns_encoded_id #: bool
|
|
@@ -47,6 +53,9 @@ module EncodedId
|
|
|
47
53
|
@group_separator = "-"
|
|
48
54
|
@alphabet = ::EncodedId::Alphabet.modified_crockford
|
|
49
55
|
@id_length = 8
|
|
56
|
+
@max_length = 128
|
|
57
|
+
@max_inputs_per_id = 32
|
|
58
|
+
@hex_digit_encoding_group_size = 4
|
|
50
59
|
@slug_value_method_name = :name_for_encoded_id_slug
|
|
51
60
|
@slugged_id_separator = "--"
|
|
52
61
|
@annotation_method_name = :annotation_for_encoded_id
|
|
@@ -46,6 +46,9 @@ module EncodedId
|
|
|
46
46
|
EncodedId::Rails::Coder.new(
|
|
47
47
|
salt: merged_options[:salt] || encoded_id_salt,
|
|
48
48
|
id_length: merged_options[:id_length] || config.id_length,
|
|
49
|
+
max_length: merged_options.key?(:max_length) ? merged_options[:max_length] : config.max_length,
|
|
50
|
+
max_inputs_per_id: merged_options[:max_inputs_per_id] || config.max_inputs_per_id,
|
|
51
|
+
hex_digit_encoding_group_size: merged_options[:hex_digit_encoding_group_size] || config.hex_digit_encoding_group_size,
|
|
49
52
|
character_group_size: merged_options.key?(:character_group_size) ? merged_options[:character_group_size] : config.character_group_size,
|
|
50
53
|
alphabet: merged_options[:alphabet] || config.alphabet,
|
|
51
54
|
separator: merged_options.key?(:separator) ? merged_options[:separator] : config.group_separator,
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: encoded_id-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stephen Ierodiaconou
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: activesupport
|
|
@@ -55,14 +55,14 @@ dependencies:
|
|
|
55
55
|
requirements:
|
|
56
56
|
- - '='
|
|
57
57
|
- !ruby/object:Gem::Version
|
|
58
|
-
version: 1.
|
|
58
|
+
version: 1.1.0
|
|
59
59
|
type: :runtime
|
|
60
60
|
prerelease: false
|
|
61
61
|
version_requirements: !ruby/object:Gem::Requirement
|
|
62
62
|
requirements:
|
|
63
63
|
- - '='
|
|
64
64
|
- !ruby/object:Gem::Version
|
|
65
|
-
version: 1.
|
|
65
|
+
version: 1.1.0
|
|
66
66
|
description: ActiveRecord concern to use EncodedID to turn IDs into reversible and
|
|
67
67
|
human friendly obfuscated strings.
|
|
68
68
|
email:
|
|
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
121
121
|
- !ruby/object:Gem::Version
|
|
122
122
|
version: '0'
|
|
123
123
|
requirements: []
|
|
124
|
-
rubygems_version: 3.6.
|
|
124
|
+
rubygems_version: 3.6.7
|
|
125
125
|
specification_version: 4
|
|
126
126
|
summary: Use `encoded_id` with ActiveRecord models
|
|
127
127
|
test_files: []
|