metka 3.0.0 → 3.0.1

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.
@@ -1,105 +0,0 @@
1
- # Table-Strategy Summary Table Naming: `<source_table>_<columns>_cloud`
2
-
3
- **Date:** 2026-08-18
4
- **Status:** Approved by user
5
- **Target:** 3.0 release
6
-
7
- ## Problem
8
-
9
- The table strategy generator derives its summary table name as
10
- `tagged_<source_table>` (e.g. `tagged_songs`), or
11
- `tagged_with_<columns>_<source_table>` when non-default source columns are
12
- given (e.g. `tagged_with_tags_and_genres_posts`). The prefix style reads
13
- poorly, sorts the table away from its source table in the schema, and is
14
- inconsistent with the index strategy, which names its tables
15
- `<source_table>_<column>_index` (e.g. `posts_tags_index`).
16
-
17
- The summary table is not a taggings join table: it holds one row per tag
18
- (`tag_name varchar PRIMARY KEY, taggings_count bigint`) — a tag-cloud
19
- aggregate maintained by triggers. The name should describe that.
20
-
21
- ## Decision
22
-
23
- Rename the derived default to `<source_table>_<columns>_cloud`, with columns
24
- joined by `_and_`, uniformly — no special case for the default `tags` column:
25
-
26
- | Input | Old derived name | New derived name |
27
- |---|---|---|
28
- | `--source-table-name=songs` | `tagged_songs` | `songs_tags_cloud` |
29
- | `--source-table-name=posts --source-columns=tags genres` | `tagged_with_tags_and_genres_posts` | `posts_tags_and_genres_cloud` |
30
-
31
- This mirrors the index strategy's `<source_table>_<column>_index` pattern, so
32
- the two strategies' tables read as siblings in the schema
33
- (`songs_tags_cloud`, `songs_tags_index`), and matches the feature's name
34
- throughout the README and API (`tag_cloud`).
35
-
36
- Alternatives considered and rejected:
37
-
38
- - `song_taggings` (`<singular>_taggings`): Rails-idiomatic, but in the Rails
39
- ecosystem "taggings" implies a join table with one row per tagging;
40
- this table holds per-tag counts, so the name misleads schema readers.
41
- - `song_tag_counts`: semantically precise but breaks symmetry with the index
42
- strategy and derives awkwardly for non-default columns.
43
-
44
- ## Changes
45
-
46
- ### Generator (the only code change)
47
-
48
- `lib/generators/metka/strategies/table/table_generator.rb` — `table_name`
49
- becomes:
50
-
51
- ```ruby
52
- def table_name
53
- return options[:table_name] if options[:table_name]
54
-
55
- "#{source_table_name}_#{source_columns_names}_cloud"
56
- end
57
- ```
58
-
59
- - The migration name keeps its existing `create_#{table_name}_table`
60
- derivation (→ `create_songs_tags_cloud_table`).
61
- - The `--table-name` option remains as the override, unchanged.
62
-
63
- ### Templates: no changes
64
-
65
- Both `migration.rb.erb` (PostgreSQL) and `migration.sqlite.rb.erb` (SQLite)
66
- interpolate `<%= table_name %>` throughout — trigger function names become
67
- `metka_ins_songs_tags_cloud()` etc. automatically. Trigger names derive from
68
- the source table and columns, not the summary table, so they are untouched.
69
-
70
- ### Docs and fixtures (model the new convention)
71
-
72
- - `test/generators/strategies/table_generator_test.rb`: expected table and
73
- migration names, including the trigger-function name assertions
74
- (`metka_ins_tagged_notes` → `metka_ins_notes_tags_cloud`); trigger-name
75
- assertions (`metka_ins_on_notes_...`) stay as they are.
76
- - `README.md` table-strategy section: `tagged_notes` → `notes_tags_cloud`,
77
- `TaggedNote` → `NotesTagsCloud`, and the derived-name explanation.
78
- - Dummy app: `test/dummy/db/migrate/11_create_tagged_table_posts_table.rb`
79
- and the `TaggedTablePost` model/test rename to the new convention
80
- (summary table `table_posts_tags_cloud`).
81
- - `benchmark/benchmark.rb`: table strategy table (`tagged_metka_table_posts`)
82
- renamed to match. `benchmark/README.md` never names the table literally, so
83
- it needs no change.
84
-
85
- Pluralization note: Rails infers `notes_tags_clouds` (plural) from a model
86
- named `NotesTagsCloud`, so the renamed dummy model and the README example
87
- model must set `self.table_name = "notes_tags_cloud"` explicitly — the old
88
- `TaggedNote` → `tagged_notes` inference worked by accident of the naming.
89
-
90
- ## Compatibility
91
-
92
- Generation-time only. The table name is baked into a migration when the user
93
- runs the generator; no runtime code derives or reads the `tagged_` prefix.
94
- Existing installs keep their `tagged_*` tables and working triggers untouched;
95
- only newly generated migrations change. No deprecation shim is needed. The
96
- README is the only doc surface (no CHANGELOG file in the repo).
97
-
98
- ## Testing
99
-
100
- - Updated generator tests assert the new derived names for the default and
101
- multi-column cases, and that `--table-name` still overrides.
102
- - Existing dummy-app trigger tests run against the renamed summary table,
103
- proving the templates work unchanged with the new name.
104
-
105
- No new test types are needed.
data/forspell.dict DELETED
@@ -1,9 +0,0 @@
1
- # Format: one word per line. Empty lines and #-comments are supported too.
2
- # If you want to add word with its forms, you can write 'word: example' (without quotes) on the line,
3
- # where 'example' is existing word with the same possible forms (endings) as your word.
4
- # Example: deduplicate: duplicate
5
- Metka
6
- taggings
7
- benchmarked
8
- gutentag
9
- backfill: fill
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem 'rails', '~> 7.1.0'
4
- gem 'activerecord', '~> 7.1.0'
5
-
6
- gemspec path: '..'
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem 'rails', '~> 7.2.0'
4
- gem 'activerecord', '~> 7.2.0'
5
-
6
- gemspec path: '..'
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem 'rails', '~> 8.0.0'
4
- gem 'activerecord', '~> 8.0.0'
5
-
6
- gemspec path: '..'
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem 'rails', '~> 8.1.0'
4
- gem 'activerecord', '~> 8.1.0'
5
-
6
- gemspec path: '..'
@@ -1,5 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem 'rails', github: 'rails/rails', branch: 'main'
4
-
5
- gemspec path: '..'
@@ -1,4 +0,0 @@
1
- source "https://rubygems.org" do
2
- gem "rubocop-md", "~> 1.0"
3
- gem "rubocop-rails-omakase", "~> 1.1"
4
- end
data/metka.gemspec DELETED
@@ -1,46 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- lib = File.expand_path('../lib', __FILE__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'metka/version'
6
-
7
- Gem::Specification.new do |spec|
8
- spec.name = 'metka'
9
- spec.version = Metka::VERSION
10
- spec.authors = [ 'Igor Alexandrov', 'Andrey Morozov' ]
11
- spec.email = [ 'igor.alexandrov@gmail.com', 'andrey.morozov@jetrockets.ru' ]
12
-
13
- spec.summary = 'Rails tagging system based on PostgreSQL arrays'
14
- spec.description = 'Rails tagging system based on PostgreSQL arrays'
15
- spec.homepage = 'https://github.com/metka-ruby/metka'
16
- spec.license = 'MIT'
17
-
18
- spec.metadata = {
19
- 'homepage_uri' => spec.homepage,
20
- 'source_code_uri' => spec.homepage,
21
- 'bug_tracker_uri' => "#{spec.homepage}/issues",
22
- 'rubygems_mfa_required' => 'true'
23
- }
24
-
25
- # Specify which files should be added to the gem when it is released.
26
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
27
- spec.files =
28
- Dir.chdir(File.expand_path('..', __FILE__)) do
29
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
30
- end
31
- spec.bindir = 'exe'
32
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
33
- spec.require_paths = [ 'lib' ]
34
-
35
- # `setting :name, default: value` is only supported since 0.13
36
- spec.add_dependency 'rails', '>= 7.1'
37
-
38
- spec.add_development_dependency 'pry', '>= 0.12.2'
39
- spec.add_development_dependency 'bundler', '>= 1.3'
40
- spec.add_development_dependency 'minitest', '>= 5.15'
41
- spec.add_development_dependency 'pg', '>= 1.1'
42
- spec.add_development_dependency 'sqlite3', '>= 2.1'
43
- spec.add_development_dependency 'rake', '>= 0.8.7'
44
- spec.add_development_dependency 'rubocop-rails-omakase', '>= 1.1'
45
- spec.required_ruby_version = '>= 3.2'
46
- end