make_taggable 0.7.5 → 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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +98 -0
  3. data/CONTRIBUTING.md +71 -22
  4. data/LICENSE.md +18 -17
  5. data/README.md +73 -444
  6. data/UPGRADING.md +32 -2
  7. data/db/migrate/6_add_unowned_taggings_unique_index.rb +18 -0
  8. data/docs/caching.md +93 -0
  9. data/docs/configuration.md +108 -0
  10. data/docs/contexts.md +147 -0
  11. data/docs/database.md +123 -0
  12. data/docs/getting-started.md +114 -0
  13. data/docs/migrating-from-aato.md +67 -0
  14. data/docs/ownership.md +111 -0
  15. data/docs/parsers.md +109 -0
  16. data/docs/querying.md +163 -0
  17. data/docs/tag-clouds.md +74 -0
  18. data/lib/make_taggable/default_parser.rb +45 -32
  19. data/lib/make_taggable/engine.rb +6 -0
  20. data/lib/make_taggable/generic_parser.rb +30 -4
  21. data/lib/make_taggable/tag.rb +121 -19
  22. data/lib/make_taggable/tag_list.rb +77 -24
  23. data/lib/make_taggable/taggable/cache.rb +61 -11
  24. data/lib/make_taggable/taggable/collection.rb +102 -30
  25. data/lib/make_taggable/taggable/core.rb +154 -34
  26. data/lib/make_taggable/taggable/ownership.rb +82 -4
  27. data/lib/make_taggable/taggable/related.rb +66 -3
  28. data/lib/make_taggable/taggable/tag_list_type.rb +8 -0
  29. data/lib/make_taggable/taggable/tagged_with_query/all_tags_query.rb +10 -0
  30. data/lib/make_taggable/taggable/tagged_with_query/any_tags_query.rb +10 -0
  31. data/lib/make_taggable/taggable/tagged_with_query/exclude_tags_query.rb +10 -0
  32. data/lib/make_taggable/taggable/tagged_with_query/query_base.rb +15 -0
  33. data/lib/make_taggable/taggable/tagged_with_query.rb +17 -0
  34. data/lib/make_taggable/taggable.rb +34 -33
  35. data/lib/make_taggable/tagger.rb +73 -12
  36. data/lib/make_taggable/tagging.rb +30 -3
  37. data/lib/make_taggable/tags_helper.rb +22 -1
  38. data/lib/make_taggable/utils.rb +40 -5
  39. data/lib/make_taggable/version.rb +8 -1
  40. data/lib/make_taggable.rb +153 -8
  41. data/make_taggable.gemspec +13 -20
  42. metadata +55 -165
  43. data/.dummyrc +0 -17
  44. data/.github/workflows/ci.yml +0 -140
  45. data/.github/workflows/standard-ci.yml +0 -27
  46. data/.gitignore +0 -17
  47. data/.rspec +0 -3
  48. data/Appraisals +0 -15
  49. data/Gemfile +0 -16
  50. data/Rakefile +0 -13
  51. data/gemfiles/rails_5.gemfile +0 -9
  52. data/gemfiles/rails_6.gemfile +0 -9
  53. data/gemfiles/rails_6_1.gemfile +0 -9
  54. data/gemfiles/rails_master.gemfile +0 -9
  55. data/lib/tasks/setup_test_db.rake +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 418910d2f9e9a651f3101d4e9d1688d970e1fa5aa4bd4036ba7bcf8e0efff02b
4
- data.tar.gz: 6aeadae682477523982efee1f9a4903613c5a23e3512580d32f7c8e319516a16
3
+ metadata.gz: 9313e4b6fc5d1b81f44b56665f2dbf6c6a8c8a8213f492b00e17e1e20c0a27bb
4
+ data.tar.gz: ef32dbb42368817bea0791803f1013f1481d58ca50992551131483b7fac416ab
5
5
  SHA512:
6
- metadata.gz: e63d4adb3aff65c339dc11359b908b93afd8f3cf142862b27868238af14f7e885a0b9076ca7ac4915090caa4dad591b7ad809d9177c1d4433a2b9f35d526808c
7
- data.tar.gz: '097d51f1401b7112455748cdd3be4e6024c87f6ffef95005c74dc384d67726b0451de624053e8d7d4e19dfe03b59c7387df4ab16e24643fe63ab0b91e4f0487c'
6
+ metadata.gz: 750c882a7d5836848cfd7d536896403cb619868121a817d9aa89ac2aed7e36d6f3d9cf70be5be04e1dd428e35484957b1f49ba17a2e7ef50f2a67adc271d7510
7
+ data.tar.gz: d14dba688a46a5e48507a082d7b65071aa8e0197df657156c3859652fcabd8eca5e0c5256033f7a9c4665d197c87177f0d9107c010e811d671fc1de2011b4d1f
data/CHANGELOG.md CHANGED
@@ -0,0 +1,98 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
6
+ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.1.0] - 2026-08-22
9
+
10
+ ### Added
11
+
12
+ - A migration adding `taggings_unowned_idx`, a partial unique index that stops duplicate unowned
13
+ taggings at the database level. `taggings_idx` never could: it spans the nullable tagger columns,
14
+ and SQL compares nulls as distinct, so only the model validation stood in the way and a validation
15
+ cannot win a race. MySQL has no partial indexes, so the migration is a no-op there.
16
+
17
+ Install it with `rails make_taggable_engine:install:migrations`. If it fails, the table already
18
+ holds duplicates -- see [docs/database.md](docs/database.md).
19
+
20
+ ### Internal
21
+
22
+ - The suite runs in random order. Examples were leaking state into each other: tagging declarations
23
+ on the shared models, and the library configuration -- one example leaving `remove_unused_tags`
24
+ on could make an unrelated example fail a foreign key check. Both are now snapshotted and restored
25
+ around every example.
26
+
27
+ ## [1.0.0] - 2026-08-22
28
+
29
+ ### Breaking
30
+
31
+ - **Removed the `acts_as_*` method names.** Use `make_taggable`, `make_ordered_taggable` and
32
+ `make_tagger` in place of `acts_as_taggable`, `acts_as_taggable_on`, `acts_as_ordered_taggable`,
33
+ `acts_as_ordered_taggable_on` and `acts_as_tagger`.
34
+ - **Delimiters are literal strings.** They were previously interpolated into a pattern unescaped,
35
+ so a delimiter containing a regular expression metacharacter had to be escaped by hand. Pass
36
+ `"|"` where you previously passed `'\|'`.
37
+ - **`make_taggable` with no arguments now tags on `:tags`.** It previously added no contexts at
38
+ all, despite the README documenting otherwise.
39
+ - **Raised the minimum versions** to Ruby 3.2 and Active Record 7.2, and removed the Active Record
40
+ upper bound.
41
+
42
+ See [UPGRADING.md](UPGRADING.md).
43
+
44
+ ### Fixed
45
+
46
+ - Tags containing non-ASCII characters no longer raise
47
+ `Encoding::UndefinedConversionError`. `Tag.named_any` was forcing sanitised SQL to `BINARY`.
48
+ - A delimiter containing a regular expression metacharacter no longer corrupts parsing. A `"."`
49
+ delimiter previously discarded every tag.
50
+ - `MakeTaggable::Dirty` and `MakeTaggable::Compatibility` no longer raise `LoadError`. Both were
51
+ declared as autoloads pointing at files that do not exist.
52
+ - `MakeTaggable.delimiter=` no longer raises `NoMethodError` when Active Record has no logger,
53
+ which is the case in a plain Active Record process or an initializer that runs early.
54
+ - Class names are parameterised through `sanitize_sql` rather than interpolated into SQL.
55
+ - `Tag.find_or_create_with_like_by_name` matches the whole name rather than a substring of it.
56
+ Asking for `"ruby"` while a tag named `"ruby on rails"` existed returned that tag instead of
57
+ creating the one requested. It is also no longer at the mercy of the column's collation, which
58
+ the MySQL migration sets to `utf8mb4_bin` -- on MySQL the method created a duplicate row for a
59
+ name differing only in case, despite `strict_case_match` being off.
60
+ - `Tag.find_or_create_all_with_like_by_name` no longer creates two rows for a list holding two
61
+ spellings of one name, such as `["Ruby", "ruby"]`. Tags created during the call were invisible to
62
+ the names that followed. Tagging through a tag list was never affected, since the list dedupes
63
+ before the lookup.
64
+
65
+ ### Changed
66
+
67
+ - Replaced `String#mb_chars` and `ActiveSupport::Multibyte::Chars`, both removed in Rails 8.2, with
68
+ plain String methods.
69
+ - Removed the Active Record 5 compatibility branches and the Rails 5 `count` workaround's dead
70
+ argument.
71
+ - Added `frozen_string_literal` to every file in `lib`.
72
+ - The deprecation warning on `MakeTaggable.delimiter=` no longer refers to a "v4.0" that does not
73
+ exist in this gem's history.
74
+
75
+ ### Documentation
76
+
77
+ - Public API documentation coverage raised from 38.65% to 100%, with no YARD warnings.
78
+ - Rewrote the README against the actual API, and added a `docs/` directory covering contexts,
79
+ querying, ownership, parsers, caching, tag clouds, configuration, the database schema, and
80
+ migrating from acts-as-taggable-on.
81
+
82
+ ### Internal
83
+
84
+ - Replaced the test harness. The suite runs against bare Active Record instead of a generated dummy
85
+ application, dropping the `rails-dummy` dependency and the `create_test_app` step, and builds its
86
+ schema from the gem's own migrations.
87
+ - Replaced `spec/make_taggable/tag_spec.rb`. The file of that name contained no tests: it was a
88
+ stale copy of `lib/make_taggable/tag.rb` that RSpec loaded, silently redefining
89
+ `MakeTaggable::Tag` and reverting it part way through the suite. `MakeTaggable::Tag` now has 45
90
+ unit specs, covering validations, every lookup and creation method, comparison, the scopes, and
91
+ the taggings association.
92
+ - CI covers Rails 7.2, 8.0, 8.1 and main on Ruby 3.2 through 4.0.
93
+
94
+ ## [0.7.5] - 2021-03-17
95
+
96
+ Earlier releases predate this changelog. See the
97
+ [commit history](https://github.com/MatthewKennedy/make_taggable/commits/master) for 0.7.x and
98
+ below.
data/CONTRIBUTING.md CHANGED
@@ -1,31 +1,80 @@
1
- # How to contribute:
1
+ # Contributing
2
2
 
3
- ## Bug reports / Issues
3
+ ## Bug reports
4
4
 
5
- * Is something broken or not working as expected? Check for an existing issue or [create a new one](https://github.com/MatthewKennedy/make_taggable/issues/new)
6
- * IMPORTANT: Include the version of the gem, if you've install from git, what Ruby and Rails you are running, etc.
5
+ Check for an [existing issue](https://github.com/MatthewKennedy/make_taggable/issues) first, then
6
+ [open a new one](https://github.com/MatthewKennedy/make_taggable/issues/new).
7
7
 
8
- ## Code
8
+ Please include the version of the gem, your Ruby and Rails versions, your database adapter, and the
9
+ smallest model and code that reproduce the problem.
9
10
 
10
- 1. [Fork and clone the repo](https://help.github.com/articles/fork-a-repo)
11
- 2. Install the gem dependencies: `bundle install`
12
- 3. Make the changes you want and back them up with tests.
13
- 4. Run the tests](https://github.com/MatthewKennedy/make_taggable#testing)
14
- 5. Update the CHANGELOG.md file with your changes and give yourself credit
15
- 6. Commit and create a pull request with details as to what has been changed and why
16
- * Use well-described, small (atomic) commits.
17
- * Include links to any relevant github issues.
18
- * *Don't* change the VERSION file.
11
+ ## Making a change
19
12
 
20
- ## How I handle pull requests:
13
+ 1. [Fork and clone the repo](https://help.github.com/articles/fork-a-repo).
14
+ 2. `bundle install`.
15
+ 3. Write a failing test first, then make it pass.
16
+ 4. Run the suite: `bundle exec rake`.
17
+ 5. Format: `bundle exec standardrb --fix`.
18
+ 6. Document any public API you added: `bundle exec yard stats --list-undoc` should report 100%.
19
+ 7. Add an entry to [CHANGELOG.md](CHANGELOG.md) under "unreleased".
20
+ 8. Open a pull request explaining what changed and why.
21
21
 
22
- * If the tests pass and the pull request looks good, I will merge it.
23
- * If the pull request needs to be changed,
24
- * you can change it by updating the branch you generated the pull request from
25
- * either by adding more commits, or
26
- * by force pushing to it
27
- * I can make any changes myself and manually merge the code in.
22
+ Keep commits small and well described, and link any relevant issues. Don't bump the version — that
23
+ happens at release.
24
+
25
+ ## Running the tests
26
+
27
+ The suite runs against bare Active Record, using in-memory SQLite by default. There is no dummy
28
+ application to generate.
29
+
30
+ ```shell
31
+ bundle exec rake
32
+ ```
33
+
34
+ Against another adapter:
35
+
36
+ ```shell
37
+ DATABASE_ADAPTER=postgresql DATABASE_URL=postgres://localhost/make_taggable_test bundle exec rake
38
+ DATABASE_ADAPTER=mysql2 DATABASE_URL=mysql2://root@127.0.0.1/make_taggable_test bundle exec rake
39
+ ```
40
+
41
+ Across every supported Rails version:
42
+
43
+ ```shell
44
+ bundle exec appraisal install
45
+ bundle exec appraisal rake
46
+ ```
47
+
48
+ ### A note on test ordering
49
+
50
+ The suite runs in random order, so an example that depends on a sibling having run first will fail
51
+ sooner or later. Reproduce a failure with the seed it reports:
52
+
53
+ ```shell
54
+ bundle exec rspec --order random:12345
55
+ ```
56
+
57
+ Examples are free to change global state — the tagging declarations on the shared models, and the
58
+ `MakeTaggable` configuration — because `spec_helper.rb` snapshots both and restores them after every
59
+ example. Anything else you make global is yours to clean up.
28
60
 
29
61
  ## Documentation
30
62
 
31
- * Update the wiki
63
+ Prose documentation lives in [docs/](docs). API documentation is YARD comments in `lib`, following
64
+ the style already there: a `##` opening line, a description, a blank line, then tags with real Ruby
65
+ types.
66
+
67
+ Build it locally with `bundle exec yard doc`.
68
+
69
+ ## Releasing
70
+
71
+ Maintainers only. Bump `lib/make_taggable/version.rb`, move the "unreleased" changelog heading to
72
+ the new version, then tag:
73
+
74
+ ```shell
75
+ git tag v1.0.0
76
+ git push origin v1.0.0
77
+ ```
78
+
79
+ The release workflow runs the suite, checks formatting and documentation coverage, and publishes to
80
+ RubyGems via trusted publishing.
data/LICENSE.md CHANGED
@@ -1,20 +1,21 @@
1
- __Copyright (c) 2020 Matthew Kennedy.__
1
+ The MIT License (MIT)
2
2
 
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
3
+ Copyright (c) 2021 Matthew Kennedy
10
4
 
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
13
11
 
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.