railbow 0.1.0 → 0.2.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 +24 -0
- data/README.md +12 -12
- data/lib/railbow/init.rb +13 -13
- data/lib/railbow/migration_parser.rb +21 -1
- data/lib/railbow/notes_formatter.rb +5 -5
- data/lib/railbow/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e976b8252fe6a3ad465f8df1ae11fa0bcdca3baaa03883d7aa2c3ff4dc1f073f
|
|
4
|
+
data.tar.gz: e6e498789b4c15c1932b3a96db8b429a18194336119ad56d5bfeaf9ddb85ca25
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0f1eaa898dfc630a06d9a7515603eb46537ee06ede2d92ac2ba45a0de4ad6413b54d9d0b2c4afa9eb8538ad656e1b94829f828fa4de370cd7cbb4060f8bd2d14
|
|
7
|
+
data.tar.gz: 0ae1860fe55db53d8b3d9eb47459838101ebb056d8b942dcfe9d7cfc1e2d0201e8e7afccb98896c4f0bf2ec0a450128e0d6fa48bfb710d82d6b0f9437d302260
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,30 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.2.0] - 2026-07-23
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Affected-table detection now recognizes tables passed via keyword
|
|
13
|
+
arguments (`table:`, `to_table:`, `from_table:`), covering project-level
|
|
14
|
+
migration helpers and DSLs that the ActiveRecord method allow-list missed.
|
|
15
|
+
- `change_column_default` and `change_column_null` are recognized, and
|
|
16
|
+
foreign-key methods contribute their first table even when the target is
|
|
17
|
+
given as `to_table:`.
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
|
|
21
|
+
- Ruby comments no longer produce phantom tables: content is stripped of
|
|
22
|
+
`#` comments (preserving `#{}` interpolation) before scanning, so a
|
|
23
|
+
comment mentioning `ALTER TABLE` or a commented-out `create_table` does
|
|
24
|
+
not count.
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- Ghost recovery integration targets [mighost](https://github.com/amberpixels/mighost)
|
|
29
|
+
0.5, which classifies superseded ghosts and reports accurate branch
|
|
30
|
+
attribution.
|
|
31
|
+
|
|
8
32
|
## [0.1.0] - 2026-07-08
|
|
9
33
|
|
|
10
34
|
First public release.
|
data/README.md
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
- **About** - polished `rails about` output
|
|
23
23
|
- **Git Integration** - authors, diffs, branch origin, landing dates, uncommitted file indicators
|
|
24
24
|
- **Calendar View** - month separators and week tick markers for migration timelines
|
|
25
|
-
- **Ghost Recovery** -
|
|
25
|
+
- **Ghost Recovery** - uses the [mighost](https://github.com/amberpixels/mighost) gem (optional) to recover names, authors, and branch badges for `NO FILE` migrations
|
|
26
26
|
- **Smart Defaults** - auto-disables in CI, piped output, `NO_COLOR`, and LLM agents
|
|
27
27
|
|
|
28
28
|
## Installation
|
|
@@ -97,16 +97,16 @@ becomes a rich, information-dense dashboard (with default config):
|
|
|
97
97
|
|
|
98
98
|
Out of the box you get:
|
|
99
99
|
|
|
100
|
-
- **Calendar separators**
|
|
101
|
-
- **Status aliases**
|
|
102
|
-
- **Created At**
|
|
103
|
-
- **Landing dates**
|
|
104
|
-
- **Branch badges**
|
|
105
|
-
- **Affected tables**
|
|
106
|
-
- **Time filtering**
|
|
107
|
-
- **Your migrations highlighted**
|
|
100
|
+
- **Calendar separators** - month + ISO week headers to orient you in time
|
|
101
|
+
- **Status aliases** - `↑↑` / `↓↓` instead of `up` / `down` (customizable)
|
|
102
|
+
- **Created At** - timestamp parsed from the migration ID
|
|
103
|
+
- **Landing dates** - `⤻ Mar 04` badge when a migration was merged to main after its creation
|
|
104
|
+
- **Branch badges** - `⎇ PS-142` showing the source branch/ticket
|
|
105
|
+
- **Affected tables** - color-coded table names extracted from migration files
|
|
106
|
+
- **Time filtering** - only the last 70 days shown by default (`since: 70d`)
|
|
107
|
+
- **Your migrations highlighted** - rows authored by you are visually distinct
|
|
108
108
|
|
|
109
|
-
If the [mighost](https://github.com/amberpixels/mighost) gem is installed, migrations whose files were deleted (e.g. after switching branches) show up with a 👻 status and their recovered name and origin branch instead of a bare `********** NO FILE **********` row
|
|
109
|
+
If the [mighost](https://github.com/amberpixels/mighost) gem is installed (`gem "mighost", group: [:development, :test]`), migrations whose files were deleted (e.g. after switching branches) show up with a 👻 status and their recovered name and origin branch instead of a bare `********** NO FILE **********` row - Railbow talks to it through the stable `Mighost::API`.
|
|
110
110
|
|
|
111
111
|
### `rails db:migrate:down`
|
|
112
112
|
|
|
@@ -126,7 +126,7 @@ Code statistics rendered as a colorful table with highlighted totals and code-to
|
|
|
126
126
|
|
|
127
127
|
### `rails notes`
|
|
128
128
|
|
|
129
|
-
Annotations enriched with git blame data
|
|
129
|
+
Annotations enriched with git blame data - author names, commit dates, and color-coded tags (TODO=yellow, FIXME=red, OPTIMIZE=cyan, HACK=red, NOTE=green).
|
|
130
130
|
|
|
131
131
|
## Configuration
|
|
132
132
|
|
|
@@ -207,7 +207,7 @@ RBW_SORT=date rails notes
|
|
|
207
207
|
|
|
208
208
|
## How It Works
|
|
209
209
|
|
|
210
|
-
Railbow integrates through a Rails Railtie
|
|
210
|
+
Railbow integrates through a Rails Railtie - it prepends formatter modules onto existing Rails classes without modifying your code:
|
|
211
211
|
|
|
212
212
|
- `ActiveRecord::Migration` - migration output
|
|
213
213
|
- `ActiveRecord::Tasks::DatabaseTasks` - migration status
|
data/lib/railbow/init.rb
CHANGED
|
@@ -26,16 +26,16 @@ module Railbow
|
|
|
26
26
|
# sort: "file"
|
|
27
27
|
|
|
28
28
|
# Git integration (comma-separated compound value):
|
|
29
|
-
# author
|
|
30
|
-
# author:me
|
|
31
|
-
# author:all
|
|
32
|
-
# diff
|
|
33
|
-
# base:<branch>
|
|
34
|
-
# mask:auto
|
|
35
|
-
# mask:<re>
|
|
29
|
+
# author - add Author column (same as author:all)
|
|
30
|
+
# author:me - highlight your own migrations
|
|
31
|
+
# author:all - show all authors
|
|
32
|
+
# diff - tag migrations by git origin branch
|
|
33
|
+
# base:<branch> - base branch for diff (default: auto-detected)
|
|
34
|
+
# mask:auto - auto-extract ticket id from branch name
|
|
35
|
+
# mask:<re> - custom regex to extract branch label, e.g. mask:(WS-[^/]+)/
|
|
36
36
|
git: "author:all,diff,mask:auto"
|
|
37
37
|
|
|
38
|
-
# Author display format
|
|
38
|
+
# Author display format - preset or custom pattern (FF L, FFF LL, etc.):
|
|
39
39
|
# initials (J D), short (Jo D), first_name (John), last_name (Doe),
|
|
40
40
|
# full_name (John Doe), full_name_short (John D.)
|
|
41
41
|
author_format: "short"
|
|
@@ -50,11 +50,11 @@ module Railbow
|
|
|
50
50
|
# date: "full"
|
|
51
51
|
|
|
52
52
|
# Compact mode (comma-separated):
|
|
53
|
-
# oneline
|
|
54
|
-
# dense
|
|
55
|
-
# noheader
|
|
56
|
-
# maxw:<N>
|
|
57
|
-
# hide:<col>
|
|
53
|
+
# oneline - one line per migration
|
|
54
|
+
# dense - reduce padding
|
|
55
|
+
# noheader - hide table headers
|
|
56
|
+
# maxw:<N> - max column width
|
|
57
|
+
# hide:<col> - hide a column (repeatable)
|
|
58
58
|
# compact: ""
|
|
59
59
|
|
|
60
60
|
# Rename column headers and cell values in table output
|
|
@@ -8,6 +8,7 @@ module Railbow
|
|
|
8
8
|
SINGLE_TABLE_METHODS = %w[
|
|
9
9
|
create_table drop_table change_table
|
|
10
10
|
add_column remove_column rename_column change_column
|
|
11
|
+
change_column_default change_column_null
|
|
11
12
|
add_index remove_index
|
|
12
13
|
add_reference remove_reference
|
|
13
14
|
add_belongs_to remove_belongs_to
|
|
@@ -19,7 +20,9 @@ module Railbow
|
|
|
19
20
|
add_foreign_key remove_foreign_key
|
|
20
21
|
].freeze
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
# Dual-table methods are included here too: their first argument is always a
|
|
24
|
+
# table, even when the second is passed as `to_table:` instead of positionally.
|
|
25
|
+
SINGLE_TABLE_PATTERN = /\b(?:#{(SINGLE_TABLE_METHODS + DUAL_TABLE_METHODS).join("|")})\s+[:"](\w+)/
|
|
23
26
|
DUAL_TABLE_PATTERN = /\b(?:#{DUAL_TABLE_METHODS.join("|")})\s+[:"](\w+)["\s,]+[:"](\w+)/
|
|
24
27
|
|
|
25
28
|
# SQL keywords followed by a table name
|
|
@@ -33,6 +36,17 @@ module Railbow
|
|
|
33
36
|
/\bCREATE\s+TABLE\s+(?:IF\s+NOT\s+EXISTS\s+)?["']?(\w+)["']?/i
|
|
34
37
|
].freeze
|
|
35
38
|
|
|
39
|
+
# Helper/DSL calls that name their target table via a keyword argument, e.g.
|
|
40
|
+
# `convert_to_monthly_partitions(table: :apples)` or
|
|
41
|
+
# `remove_foreign_key :accounts, to_table: :owners`. Catches project-level
|
|
42
|
+
# migration helpers regardless of the method name. Bare `from:`/`to:` are
|
|
43
|
+
# deliberately not matched — `change_column_default :users, :status,
|
|
44
|
+
# from: nil, to: "active"` would yield phantom tables.
|
|
45
|
+
KEYWORD_TABLE_PATTERN = /\b(?:table|to_table|from_table):\s*[:"']?(\w+)/
|
|
46
|
+
|
|
47
|
+
# Ruby `#` comments up to end of line, but not `#{}` interpolation.
|
|
48
|
+
COMMENT_PATTERN = /#(?!\{).*/
|
|
49
|
+
|
|
36
50
|
# AR class-level query/mutation methods that strongly signal a constant is a model.
|
|
37
51
|
# Kept narrow on purpose — methods like `find`, `all`, `first`, `count`, `create`,
|
|
38
52
|
# `new`, `transaction`, `order`, `includes` collide with stdlib/non-model constants
|
|
@@ -60,6 +74,11 @@ module Railbow
|
|
|
60
74
|
def self.extract_tables_from_content(content)
|
|
61
75
|
return [] if content.nil? || content.empty?
|
|
62
76
|
|
|
77
|
+
# Comments would otherwise produce phantom tables — an explanatory
|
|
78
|
+
# "# ALTER TABLE foo ..." or a commented-out create_table reads exactly
|
|
79
|
+
# like the real thing to the patterns below.
|
|
80
|
+
content = content.gsub(COMMENT_PATTERN, "")
|
|
81
|
+
|
|
63
82
|
tables = []
|
|
64
83
|
|
|
65
84
|
content.scan(SINGLE_TABLE_PATTERN) { |match| tables << match[0] }
|
|
@@ -67,6 +86,7 @@ module Railbow
|
|
|
67
86
|
SQL_TABLE_PATTERNS.each do |pattern|
|
|
68
87
|
content.scan(pattern) { |match| tables << match[0] }
|
|
69
88
|
end
|
|
89
|
+
content.scan(KEYWORD_TABLE_PATTERN) { |match| tables << match[0] }
|
|
70
90
|
tables.uniq!
|
|
71
91
|
|
|
72
92
|
# Model-based detection is heuristic (a constant that happens to respond
|
|
@@ -256,17 +256,17 @@ module Railbow
|
|
|
256
256
|
|
|
257
257
|
\e[1mOptions:\e[0m
|
|
258
258
|
RBW_GIT=<options> Git integration (comma-separated):
|
|
259
|
-
author
|
|
260
|
-
author:all
|
|
261
|
-
author:me
|
|
259
|
+
author - show all authors (same as author:all)
|
|
260
|
+
author:all - show author + date on each annotation
|
|
261
|
+
author:me - highlight your own annotations
|
|
262
262
|
|
|
263
263
|
RBW_SINCE=<period> Filter annotations by blame date (default: all)
|
|
264
264
|
Values: all, 2mo, 1w, 30d, 1y, etc.
|
|
265
265
|
Units: d (days), w (weeks), mo/m (months), y (years)
|
|
266
266
|
|
|
267
267
|
RBW_SORT=<mode> Sort order (default: file)
|
|
268
|
-
file
|
|
269
|
-
date
|
|
268
|
+
file - group by file (default Rails order)
|
|
269
|
+
date - sort by blame date (newest first)
|
|
270
270
|
|
|
271
271
|
RBW_PLAIN=1 Disable Railbow formatting (plain Rails output)
|
|
272
272
|
|
data/lib/railbow/version.rb
CHANGED