briefly 0.1.0 → 0.2.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +95 -10
- data/README.md +235 -115
- data/briefly.gemspec +1 -1
- data/lib/briefly/builder.rb +58 -42
- data/lib/briefly/errors.rb +1 -1
- data/lib/briefly/facade.rb +79 -31
- data/lib/briefly/rails/config.rb +35 -0
- data/lib/briefly/rails/db.rb +33 -8
- data/lib/briefly/rails/env.rb +27 -0
- data/lib/briefly/rails/instrument.rb +29 -0
- data/lib/briefly/rails/reload.rb +1 -1
- data/lib/briefly/rails/view.rb +27 -0
- data/lib/briefly/rails.rb +7 -50
- data/lib/briefly/rescues.rb +47 -0
- data/lib/briefly/shortcut.rb +104 -0
- data/lib/briefly/version.rb +1 -1
- data/lib/briefly.rb +26 -9
- data/lib/generators/briefly/install/install_generator.rb +29 -0
- data/lib/generators/briefly/install/templates/briefly.rb.tt +47 -0
- data/sig/briefly/builder.rbs +18 -8
- data/sig/briefly/facade.rbs +26 -12
- data/sig/briefly/rails.rbs +7 -2
- data/sig/briefly/rescues.rbs +21 -0
- data/sig/briefly/{definition.rbs → shortcut.rbs} +8 -4
- data/sig/briefly.rbs +7 -10
- metadata +12 -6
- data/lib/briefly/definition.rb +0 -64
- data/lib/briefly/error_registry.rb +0 -40
- data/sig/briefly/error_registry.rbs +0 -22
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f6c561612c29ff83aaaccdf483e6e563633e54d3dc81c92856857db2f26978b3
|
|
4
|
+
data.tar.gz: a257e3be54bb8e1bb076009dc5982a7c15a6add60f16225bb774e9e3100f3db4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4496b43e5d42fb6b90d0b8f528092207ff867dfbab5febe1d36b69451c307527bd1a056da118a20a48770b77601c49c8965018fa76c904fc203642a4bd5dc178
|
|
7
|
+
data.tar.gz: 430188265df3b33c124f90cbf28de0b34f27fa3090174e74d60a94a63d32a97a4bb905bfb46a72e50263977a44c89cecd29a66799f25847e520ee268071ea18e
|
data/CHANGELOG.md
CHANGED
|
@@ -6,38 +6,123 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
|
6
6
|
|
|
7
7
|
## Unreleased
|
|
8
8
|
|
|
9
|
+
## v0.2.1 (2026-07-31)
|
|
10
|
+
|
|
11
|
+
No change to `lib/` or `sig/`: this release carries the documentation the gem ships and the process
|
|
12
|
+
that publishes it. `Briefly::VERSION` is the only Ruby file that differs from v0.2.0.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
- The README declares the public API that Semantic Versioning covers, and what falls outside it, so
|
|
16
|
+
a MINOR bump before `1.0.0` now has a stated scope rather than an implied one.
|
|
17
|
+
- CONTRIBUTING.md states the deprecation policy: a public item ships deprecated in one release, with
|
|
18
|
+
a runtime warning naming its replacement and the earliest removal version, before a later release
|
|
19
|
+
removes it. v0.2.0's three removals predate the policy and are named there.
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
- Development now resolves through committed lockfiles. `gemfiles/` holds one file per Rails line,
|
|
23
|
+
each pinning that line and evaluating the root `Gemfile`, and 7.2, 8.0 and 8.1 commit a lockfile
|
|
24
|
+
beside theirs; CI installs from them frozen instead of deleting `Gemfile.lock` and re-resolving.
|
|
25
|
+
Contributors testing another Rails version now pass `BUNDLE_GEMFILE` rather than `RAILS_VERSION`.
|
|
26
|
+
Nothing an application installs changed.
|
|
27
|
+
- Releases are published by CI from a pushed tag, authenticating to RubyGems through OIDC, gated on
|
|
28
|
+
a manual approval, and signed with sigstore. No publishing credential exists on any machine.
|
|
29
|
+
`bundle exec rake release` no longer publishes; it prints the tag steps and exits.
|
|
30
|
+
|
|
31
|
+
## v0.2.0 (2026-07-14)
|
|
32
|
+
|
|
33
|
+
### Added
|
|
34
|
+
- `rails g briefly:install`, a Rails generator that writes `config/initializers/briefly.rb`: a
|
|
35
|
+
working `App` facade plus a commented, concern-grouped map of every shortcut `use "rails"` installs.
|
|
36
|
+
Pass a name (`rails g briefly:install Facade`) to rename the constant; re-run it after upgrading to
|
|
37
|
+
refresh the map, as Rails prompts before overwriting. It loads only under `rails generate`, so no
|
|
38
|
+
Rails runtime dependency is added.
|
|
39
|
+
- `Briefly::Rails::Config` gains `error` (`Rails.error`, the framework's handled-error reporter) and
|
|
40
|
+
`config_for` (per-environment YAML via `Rails.application.config_for`). Both are live lookups;
|
|
41
|
+
`config_for` takes an argument, so it never memoizes. Compose one that does by chaining `.memoize`
|
|
42
|
+
onto a shortcut: `shortcut(:x) { config_for(:x) }.memoize`.
|
|
43
|
+
- `Briefly::Rails::DB` gains `connected_to`, `reading` and `writing` for multi-database routing.
|
|
44
|
+
`connected_to` forwards the full Rails surface (`role:`, `shard:`, `prevent_writes:`, custom roles);
|
|
45
|
+
`reading`/`writing` are sugar that pin their role and forward the rest. `base` must be
|
|
46
|
+
`ActiveRecord::Base` or an abstract connection class; a concrete model raises `NotImplementedError`.
|
|
47
|
+
- `Briefly::Rails::DB` gains `select`, a raw-SQL read through `select_all`, returning an
|
|
48
|
+
`ActiveRecord::Result` on the query-cache-preserving path, with the same positional and named
|
|
49
|
+
bind-safety as `query`. `query` keeps running arbitrary SQL (writes and DDL included) via `exec_query`.
|
|
50
|
+
- `Briefly::Rails::Env` gains `dev?` and `prod?`, aliases of `development?` and `production?`.
|
|
51
|
+
- `Briefly::Rails::Instrument`, a new `"rails/instrument"` pack with one `instrument` shortcut over
|
|
52
|
+
`ActiveSupport::Notifications.instrument(name, payload) { }`. Usable on its own; `use "rails"`
|
|
53
|
+
includes it, so `App.instrument` comes for free.
|
|
54
|
+
|
|
55
|
+
### Changed
|
|
56
|
+
- **BREAKING:** Facade management moved behind a single `App.briefly` accessor:
|
|
57
|
+
`App.briefly.configure`, `App.briefly.shortcuts`, `App.briefly.shortcut?` and
|
|
58
|
+
`App.briefly.clear_memos!`. This frees `configure`, `shortcuts`, `shortcut?` and `clear_memos!` for
|
|
59
|
+
use as your own shortcut names; only `briefly`, `inspect` and `to_s` stay reserved on the facade's
|
|
60
|
+
public surface.
|
|
61
|
+
- **BREAKING:** `Briefly::Rails::DB#connection`/`#conn` is now an auto-releasing block that forwards to
|
|
62
|
+
`base.with_connection`, yielding the leased connection and releasing it at block exit, the shape of
|
|
63
|
+
`transaction`. It requires a block; the old bare `base.lease_connection` accessor (held on the thread
|
|
64
|
+
and never released, a leak outside a request) is gone, with no compatibility shim. Anyone needing a
|
|
65
|
+
held raw lease calls `lease_connection` on their model directly.
|
|
66
|
+
- The DB pack's tests now run against real Active Record on in-memory SQLite, so its Active Record
|
|
67
|
+
calls are verified rather than mocked. `activerecord` and `sqlite3` join `activesupport` as dev-only
|
|
68
|
+
dependencies; the gem still declares no Rails runtime dependency.
|
|
69
|
+
- **BREAKING:** `shortcut` now returns the `Briefly::Shortcut` it declares instead of the canonical
|
|
70
|
+
name Symbol. Refine it in place (`shortcut(:x) { ... }.memoize`, `.rescue_from(Error) { fallback }`,
|
|
71
|
+
in any order) so a shortcut's name is never written twice to annotate it. A bodiless `shortcut(:x)`
|
|
72
|
+
fetches an already-declared shortcut (canonical or alias) to refine, raising
|
|
73
|
+
`Briefly::UnknownShortcutError` on an unknown name; it never re-declares. A shortcut's memoization
|
|
74
|
+
and its own error handlers live on the shortcut itself, so refining it after a redeclaration affects
|
|
75
|
+
the declaration you named, exactly as its body does.
|
|
76
|
+
- **BREAKING:** The top-level `rescue_from(error_class)` verb is now facade-wide only and takes no
|
|
77
|
+
shortcut names; passing any raises `ArgumentError` pointing at `shortcut(name).rescue_from(...)`.
|
|
78
|
+
Scope a handler to a shortcut by chaining `.rescue_from` onto it. Global `Briefly.rescue_from` is
|
|
79
|
+
unchanged.
|
|
80
|
+
- **BREAKING:** the rescue-handler registry is now `Briefly::Rescues` (was
|
|
81
|
+
`Briefly::ErrorRegistry`), reached through `Briefly.rescues` (was `Briefly.errors`), because it holds
|
|
82
|
+
`rescue_from` handlers, not errors. `Briefly.rescues.clear` still resets globally registered
|
|
83
|
+
handlers; the internal `#wide` enumerator is gone, replaced by `#size` for counting registrations.
|
|
84
|
+
|
|
85
|
+
### Removed
|
|
86
|
+
- **BREAKING:** `App.reset!`. Use `App.briefly.clear_memos!`. It was a pure alias for `clear_memos!`
|
|
87
|
+
with no internal callers.
|
|
88
|
+
- **BREAKING:** The top-level `memoize` DSL verb. Chain `.memoize` onto the shortcut `shortcut`
|
|
89
|
+
returns (`shortcut(:x) { ... }.memoize`), or `shortcut(:x).memoize` for one declared elsewhere.
|
|
90
|
+
- **BREAKING:** Scoping `rescue_from` by shortcut name on the top-level verb, both single-name
|
|
91
|
+
`rescue_from(Error, :x)` and multi-name `rescue_from(Error, :a, :b)`. Scope on the shortcut instead:
|
|
92
|
+
`shortcut(:x).rescue_from(Error) { ... }`, chaining onto each of several.
|
|
93
|
+
|
|
9
94
|
## v0.1.0 (2026-07-10)
|
|
10
95
|
|
|
11
96
|
### Added
|
|
12
|
-
- `Briefly.define` builds a facade of real, introspectable, stubbable methods
|
|
97
|
+
- `Briefly.define` builds a facade of real, introspectable, stubbable methods, with no `method_missing`.
|
|
13
98
|
- `shortcut(canonical, *aliases, &body)` with argument, keyword and block forwarding; predicate and
|
|
14
99
|
bang names; last-declaration-wins overrides. Each shortcut compiles to a real method carrying its
|
|
15
|
-
body's `arity` and parameter kinds, with a `source_location` pointing at the block you declared
|
|
16
|
-
|
|
100
|
+
body's `arity` and parameter kinds, with a `source_location` pointing at the block you declared.
|
|
101
|
+
Keyword names are exact, positionals get generated ones (`__p0`, `__r1`, …). A wrong-arity call, a
|
|
17
102
|
missing required keyword and an unknown keyword raise `ArgumentError` at the call site, before any
|
|
18
103
|
`rescue_from` handler is consulted.
|
|
19
|
-
- `namespace(name) { ... }`
|
|
104
|
+
- `namespace(name) { ... }` groups shortcuts behind a child facade, so `App.db.query` works without
|
|
20
105
|
burning root-level names. Takes the whole DSL, including nested namespaces. `clear_memos!` cascades
|
|
21
106
|
into it. `configure` stays atomic across the whole tree: a pass that raises anywhere leaves the root
|
|
22
107
|
and every namespace untouched. A `shortcut` of the same name overrides a namespace and drops the child.
|
|
23
|
-
- `memoize
|
|
24
|
-
- `rescue_from
|
|
108
|
+
- `memoize`, permanent per-process caching, correct for `nil`/`false`, never caching a rescued fallback.
|
|
109
|
+
- `rescue_from`, with facade-scoped, facade-wide and global (`Briefly.rescue_from`) handlers whose return
|
|
25
110
|
value becomes the shortcut's value.
|
|
26
111
|
- `clear_memos!` / `reset!`, `configure`, `shortcuts`, `shortcut?`, `inspect`.
|
|
27
112
|
- Pack protocol: any object responding to `#install(builder, **opts)`. `use` accepts keywords,
|
|
28
113
|
forwarded to the pack's `install`. `Briefly.register(name, pack)` / `Briefly.pack(name)` provide a
|
|
29
114
|
pack registry, so `use "rails/db"` resolves; values may be a pack or a constant path resolved on
|
|
30
115
|
first use, and an unknown name raises `Briefly::UnknownPackError`.
|
|
31
|
-
- Method fabrication
|
|
116
|
+
- Method fabrication, meaning the arity, `parameters` and `source_location` each shortcut reports, is
|
|
32
117
|
provided by [candor](https://github.com/svyatov/candor), the sole runtime dependency (candor itself
|
|
33
118
|
has none). Compiled bodies live under `Candor::BODY_PREFIX`; a shortcut may not take a name there.
|
|
34
|
-
- `Briefly::Rails
|
|
119
|
+
- `Briefly::Rails`, with `config`/`c`, `config_x`/`x`, `env` and its predicates, `root`, `cache`,
|
|
35
120
|
`logger`/`log`, `credentials`/`cred`, `helpers`/`h`, `routes`/`r`, `renderer`, `render`, plus a `db`
|
|
36
121
|
namespace. Nothing in the pack is memoized. Its `Config`, `Env` and `View` groups are usable alone.
|
|
37
|
-
- `Briefly::Rails::DB
|
|
122
|
+
- `Briefly::Rails::DB`, with `connection`/`conn`, `transaction`/`txn`, `query`. `query` takes positional
|
|
38
123
|
(`query(sql, 1)`) or named (`query(sql, id: 1)`) binds, and passes a bindless statement through
|
|
39
124
|
unsanitized. Takes `base:` (default `"ApplicationRecord"`), resolved on every call so a reloaded
|
|
40
125
|
class is never captured. Memoizes nothing and wires no lifecycle hook, so it works without a booted
|
|
41
126
|
application.
|
|
42
|
-
- `Briefly::Rails::Reload`
|
|
127
|
+
- `Briefly::Rails::Reload` clears memos via `Rails.application.reloader.to_prepare`.
|
|
43
128
|
- RBS signatures in `sig/`.
|