encoded_id-rails 1.0.0.rc1 → 1.0.0.rc6

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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +77 -18
  3. data/LICENSE.txt +1 -1
  4. data/README.md +76 -479
  5. data/context/encoded_id-rails.md +433 -0
  6. data/context/encoded_id.md +283 -0
  7. data/lib/encoded_id/rails/active_record_finders.rb +52 -0
  8. data/lib/encoded_id/rails/annotated_id.rb +8 -0
  9. data/lib/encoded_id/rails/annotated_id_parser.rb +8 -1
  10. data/lib/encoded_id/rails/coder.rb +20 -2
  11. data/lib/encoded_id/rails/configuration.rb +44 -4
  12. data/lib/encoded_id/rails/encoder_methods.rb +9 -1
  13. data/lib/encoded_id/rails/finder_methods.rb +10 -0
  14. data/lib/encoded_id/rails/model.rb +25 -2
  15. data/lib/encoded_id/rails/path_param.rb +7 -0
  16. data/lib/encoded_id/rails/persists.rb +52 -8
  17. data/lib/encoded_id/rails/query_methods.rb +20 -4
  18. data/lib/encoded_id/rails/railtie.rb +13 -0
  19. data/lib/encoded_id/rails/salt.rb +7 -0
  20. data/lib/encoded_id/rails/slugged_id.rb +8 -0
  21. data/lib/encoded_id/rails/slugged_id_parser.rb +8 -1
  22. data/lib/encoded_id/rails/slugged_path_param.rb +7 -0
  23. data/lib/encoded_id/rails.rb +9 -6
  24. data/lib/generators/encoded_id/rails/templates/encoded_id.rb +22 -2
  25. metadata +13 -23
  26. data/.devcontainer/Dockerfile +0 -17
  27. data/.devcontainer/compose.yml +0 -10
  28. data/.devcontainer/devcontainer.json +0 -12
  29. data/.standard.yml +0 -3
  30. data/Appraisals +0 -9
  31. data/Gemfile +0 -24
  32. data/Rakefile +0 -20
  33. data/Steepfile +0 -4
  34. data/gemfiles/.bundle/config +0 -2
  35. data/gemfiles/rails_7.2.gemfile +0 -19
  36. data/gemfiles/rails_8.0.gemfile +0 -19
  37. data/lib/encoded_id/rails/version.rb +0 -7
  38. data/rbs_collection.yaml +0 -24
  39. data/sig/encoded_id/rails.rbs +0 -141
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67437c2f5ede5d3d8a7ff14079ce9518b1e63a48812fd37a88d61772fa1d0ea3
4
- data.tar.gz: 59f73a3eb40b421bdf50115f806cbf5cd41b09213ebe87ce4d1842b098530f47
3
+ metadata.gz: 45d2f2c1637f43c14a714d4051ec7a1692a8267234ea90c302da97872b2da7b0
4
+ data.tar.gz: 26030ffcef1dc8798d0919a68faf4ec5bb6d17c3a28730eee0d2bb1e9ecb8e3e
5
5
  SHA512:
6
- metadata.gz: c8f03e548c344e45343ad831b568eedf705c02db9da876445a67d8814d9d4efd37d0ae639bf7eb6a1fd33685d68bc01077a523addffa319c9022cfd534771de7
7
- data.tar.gz: 0037b79f44ce1ddeb97bc142e11c35b045c446db1b87e7122eeceb06bb606499a60764c3ab85593d352f0be39b074cf72805078d511bce80c53cd3ba745372b5
6
+ metadata.gz: 05ca59de2b281917cb214cfaeb9a94c7453aba4a64d8e89ac484a583030839a192d5242a774bc511e78d6667c47d11bca27bb3a0b096aefa6c2aad3e3c39ad84
7
+ data.tar.gz: e3cc3563234d3c13d10f34c55cc77b14f3a7c55e3b391d679d5c2239f39b272cd3e4a02c614f0638a20db815d1c425fd58c334a3b842d0cdb8c88a2c26e6e655
data/CHANGELOG.md CHANGED
@@ -1,31 +1,90 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [1.0.0] - (in beta)
3
+ ## [2.0.0.alpha1] - unreleased
4
4
 
5
5
  ### Breaking changes
6
6
 
7
- - Ruby 2.7.x support dropped. The minimum supported Ruby version is now 3.0.0.
8
- - `#encoded_id` now defaults to returning an 'annotated' ID, one in which a prefix is added to the encoded ID to indicate
9
- the 'type' of the record the ID represents. This can be disabled. IDs generated by older versions of this gem will
10
- decode correctly. But not that IDs generated by this version onwards will not decode correctly by older versions of this
11
- gem so make sure to disable annotation if you need to support older versions of this gem.
12
- - `#name_for_encoded_id_slug` no longer provides a default implementation, it is up to the user to define this method,
13
- or configure the gem to use a different method name.
14
- - `#slugged_encoded_id` no longer takes a `with:` parameter. To specify the name of the method to call to generate the
15
- slug, use the `slug_value_method_name` configuration option.
7
+ - `ReversibleId` now no longer downcases the encodedid input string by default on decode, ie the `decode` option `downcase` is now `false`. In a future release the `downcase` option will be removed.
8
+ - The default encoding engine is now `:sqids` to reflect the official "deprecated" status of `Hashid`s (see https://sqids.org/faq#why-hashids)
9
+ - Ruby < 3.2 support dropped. The minimum supported Ruby version is now 3.2.0
10
+
11
+ **Important!!: `:sqids` are not compatible with `:hashids`, DO NOT CHANGE FROM ONE TO THE OTHER AFTER GOING LIVE.**
12
+
13
+ ## [1.0.0.rc6] - 2025-11-17
14
+
15
+ ### Breaking changes
16
+
17
+ - Empty array inputs will now raise `InvalidInputError`
16
18
 
17
19
  ### Added
18
20
 
19
- - `#encoded_id_hash` has been added to return only the encoded ID without an annotation prefix. If annotation is disabled,
20
- this method is basically an alias to `#encoded_id`.
21
- - `.find_all_by_encoded_id` has been added to return all records matching the given encoded ID. This will return all
22
- matching records whose IDs are encoded in the encoded_id. Missing records are ignored.
23
- - `.find_all_by_encoded_id!` like `.find_all_by_encoded_id` but raises an `ActiveRecord::RecordNotFound` exception if
24
- *any* of the records are not found.
21
+ - Added support for [Sqids](https://sqids.org) as an alternative ID encoding engine. The default remains HashIds for backward compatibility.
22
+ - New encoder abstraction layer allows switching between HashIds and Sqids via the `encoder: :sqids` or `encoder: :hashids` parameter to `ReversibleId.new`.
23
+ - Support for blocklists in both HashIds and Sqids encoders to prevent generating IDs containing specific words. Use the `blocklist` parameter with a `Set` or `Array` of strings to `ReversibleId.new`. For Hashids encodings, an error will be raised if a generated ID contains a blocklisted word. For Sqids a new ID is generated that does not contain the block word.
24
+
25
+ ### Added (Rails integration)
26
+
27
+ - Merged `encoded_id-rails` gem into the monorepo
28
+ - Support for configuring the encoder and blocklist options in Rails through the configuration class
29
+ - `#encoded_id` now defaults to returning an 'annotated' ID, one in which a prefix is added to the encoded ID to indicate the 'type' of the record the ID represents. This can be disabled. IDs generated by older versions of this gem will decode correctly. But note that IDs generated by this version onwards will not decode correctly by older versions of this gem so make sure to disable annotation if you need to support older versions of this gem.
30
+ - New `EncodedId::Rails::Persists` module which adds hooks to the model to persist the encoded ID to the DB (see docs).
31
+ - `#encoded_id_hash` has been added to return only the encoded ID without an annotation prefix. If annotation is disabled, this method is basically an alias to `#encoded_id`.
32
+ - `.find_all_by_encoded_id` has been added to return all records matching the given encoded ID. This will return all matching records whose IDs are encoded in the encoded_id. Missing records are ignored.
33
+ - `.find_all_by_encoded_id!` like `.find_all_by_encoded_id` but raises an `ActiveRecord::RecordNotFound` exception if *any* of the records are not found.
34
+ - `Configuration#model_to_param_returns_encoded_id` to allow `EncodedId::Rails::Model` inclusion to also bring in `EncodedId::Rails::PathParam` automatically.
25
35
 
26
- ### Fixed
36
+ ### Changed (Rails integration)
37
+
38
+ - `#name_for_encoded_id_slug` no longer provides a default implementation, it is up to the user to define this method, or configure the gem to use a different method name.
39
+ - `#slugged_encoded_id` no longer takes a `with:` parameter. To specify the name of the method to call to generate the slug, use the `slug_value_method_name` configuration option.
40
+
41
+ ### Fixed (Rails integration)
27
42
 
28
43
  - `#decode_encoded_id` now raises if the encoded ID is not a string.
44
+ - Handle more cases where a record held onto a memoized `encoded_id` even though its `id` had changed
45
+
46
+ ## [1.0.0.rc5] - 2025-04-09
47
+
48
+ - `encoded_id` now uses its own implementation of `hashids` which is more efficient and has a smaller memory footprint. This massively reduces the GC churn in high-throughput applications. This is an implementation based on the original `hashids` gem but with many optimisations and improvements. Functionally it is identical to the original `hashids` gem.
49
+
50
+ ## [1.0.0.rc4] - 2024-04-29
51
+
52
+ - Add an optional `max_inputs_per_id` argument to `ReversibleId`, thanks to [@avcwisesa](https://github.com/avcwisesa)
53
+ - The option `split_with:` can also now be set to nil to disable splitting of the encoded ID string
54
+
55
+ ## [1.0.0.rc3] - 2023-10-23
56
+
57
+ - Add an optional `max_length` argument to `ReversibleId`, thanks to [@jugglebird](https://github.com/jugglebird)
58
+ - Alphabet validations to prevent whitespace and null chars
59
+ - Add `Alphabet#to_a`, `Alphabet#to_s`, `Alphabet#size` and a custom `Alphabet#inspect`
60
+ - Fixes to input validations
61
+ - hashids are case-sensitive, as are `Alphabet`s, however `ReversibleId` was always `downcase`ing the encodedid input string on decode. A new option has been added to `decode` and `decode_hex`, `downcase`, which defaults to `true`. Thus, the default behaviour is unchanged, but you can opt out to allow mixed case encodedid decode. *Note:* In V2 this will default to `false`.
62
+
63
+ ## [1.0.0.rc2] - 2023-08-07
64
+
65
+ - `Alphabet` now has `#include?` and `#unique_charaters` methods
66
+
67
+ ## [1.0.0.rc1] - 2023-08-06
68
+
69
+ - Improved RBS definitions
70
+ - Improved test coverage
71
+
72
+ ## [0.4.0] - 2022-12-04
73
+
74
+ - Support custom 'split' character which must not be in the alphabet
75
+ - Ability to provide a custom character equivalence mapping
76
+
77
+ ## [0.3.0] - 2022-10-12
78
+
79
+ - Fix splitting of encoded ID string
80
+ - Checks that integer values to be encoded are positive
81
+ - Experimental support for encoding hex strings
82
+
83
+ ## [0.1.0] - 2022-10-11
84
+
85
+ - Initial release
86
+
87
+ ## Rails Integration History
29
88
 
30
89
  ## [0.6.2] - 2023-02-09
31
90
 
@@ -64,4 +123,4 @@
64
123
 
65
124
  ## [0.1.0] - 2022-11-17
66
125
 
67
- - Initial release
126
+ - Initial release of Rails integration
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2022 Stephen Ierodiaconou
3
+ Copyright (c) 2022-2024 Stephen Ierodiaconou
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal