mcp_authorization 0.5.5 → 0.5.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d6b7e3511b7790b3da9c74c48f4df83c87adc11a875fc0e822c153c33b6a72e9
4
- data.tar.gz: c00c25c116df33f17126a8b45105db079e8180c9b4b2895f1e50db0131fb9dfe
3
+ metadata.gz: d12320957dc293fd39e12e752fc62783a38fba78543d2df56f4cdb382947b262
4
+ data.tar.gz: 05ab5308639f0612edc056c145cea34a7a220c51b31a03cfc746646b5c58ca9e
5
5
  SHA512:
6
- metadata.gz: 2784b842b815610bf06752607b26332568076ce84b675dbc902e1ea0a858eac18e1e41d3b8cce812bce64b95f76266885fb6b43c4388742ac89e861d9d4f4639
7
- data.tar.gz: 5fcb42dac47e116c9223c23aabc5c76884e756c06c2b8dc1ace1be6014fbd44560746458f54890653e597aaa4152bdb2e881c6b32d5ec1fba7f957e86939a2ed
6
+ metadata.gz: 4d10be243138d57af94278d70dcf0af30d8d09f6c7b7bee69da31c42155d1e2f46361c45ef2d1aeda1d4631ae661dca96dd200f961207bf1826b458bba243e2b
7
+ data.tar.gz: 5a8f3df13aa95bc67c6c5044137b8d0c43fb72fc74553075eaf254944623c2fe038ab784d3773f87239046d40ee32096976d65c0d738a84817a2c9a826b4e980
data/CHANGELOG.md CHANGED
@@ -4,6 +4,11 @@ All notable changes to this gem are documented here. The format follows
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and this project
5
5
  adheres to [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## [0.5.6] - 2026-06-08
8
+
9
+ ### Fixed
10
+ - **Single-line and column-aligned `# @rbs type` record aliases are now collected.** A record alias written on one line — `# @rbs type ok = { a: String, b: Integer }` — was silently dropped: `collect_inline_aliases` truncated the body to a bare `{` and only a closing brace on a *following* line ever balanced it. Any union or field referencing such an alias resolved to the `{type: "object"}` fallback (no properties, no per-request gating), so the advertised schema and runtime projection both lost the type's shape. The opening-line body is now captured whole and stored immediately when its braces balance. Relatedly, the alias regex now tolerates arbitrary whitespace around `=`, so column-aligned blocks (`# @rbs type success = { ... }`) parse instead of being skipped. Multi-line aliases are unaffected.
11
+
7
12
  ## [0.5.5] - 2026-06-04
8
13
 
9
14
  ### Fixed
data/README.md CHANGED
@@ -4,6 +4,8 @@ Rails engine for serving MCP tools with per-request schema discrimination compil
4
4
 
5
5
  Add it to your Gemfile and your Rails app speaks [MCP](https://modelcontextprotocol.io). Write `@rbs type` comments in plain Ruby service classes, tag fields and variants with `@requires(:flag)`, and the gem compiles tailored JSON Schema per request. The type definitions are the authorization policy.
6
6
 
7
+ > Looking for task-oriented "how do I X?" recipes rather than reference? See the **[Cookbook](COOKBOOK.md)**.
8
+
7
9
  ## Three layers of authorization
8
10
 
9
11
  The gem gives you three independent controls over what each user sees:
@@ -1476,10 +1476,22 @@ module McpAuthorization
1476
1476
  current_body = +""
1477
1477
 
1478
1478
  content.each_line do |line|
1479
- if line =~ /# @rbs type (\w+) = \{/
1479
+ if line =~ /#\s*@rbs type (\w+)\s*=\s*(\{.*)$/
1480
+ # Start of a record alias. Capture the body from the first `{` to
1481
+ # end of line (minus any trailing comment), so a record written on
1482
+ # one line — `# @rbs type ok = { a: String }` — is captured whole
1483
+ # rather than truncated to a bare `{` (which silently dropped the
1484
+ # alias). If the braces already balance it's a single-line record;
1485
+ # otherwise keep accumulating on the following lines. Whitespace
1486
+ # around `=` is tolerated so column-aligned aliases still parse.
1480
1487
  current_name = $1.to_s
1481
- current_body = "{"
1482
- elsif line =~ /# @rbs type (\w+) = "([^"]+)"/
1488
+ current_body = +strip_rbs_comment($2.to_s)
1489
+ if brace_balanced?(current_body)
1490
+ aliases[current_name] = current_body
1491
+ current_name = nil
1492
+ current_body = +""
1493
+ end
1494
+ elsif line =~ /#\s*@rbs type (\w+)\s*=\s*"([^"]+)"/
1483
1495
  aliases[$1.to_s] = parse_string_union($2.to_s, line, content)
1484
1496
  elsif current_name
1485
1497
  stripped = strip_rbs_comment(line.strip.sub(/^#\s*/, ""))
@@ -1,3 +1,3 @@
1
1
  module McpAuthorization
2
- VERSION = "0.5.5"
2
+ VERSION = "0.5.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mcp_authorization
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyGauge
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-06-05 00:00:00.000000000 Z
11
+ date: 2026-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails