bp3-request_state 0.1.3 → 0.1.4

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: a94a3e6bacbd1d73edd2db167c54ba3e8af9e6d4f88763453f6a104a541e6b60
4
- data.tar.gz: 4943fc4b23ae39b5c3150057fbc521eba2f7a0f82686bd9619522ef1add774a1
3
+ metadata.gz: df0c3852fcdfcee1a0ff7d9c703e3afe5e60165df36758de5e017bf95eb06982
4
+ data.tar.gz: 9883f750f5eb32271d7a16a39589db7615cc1602fb2660c8f7c6f586be23b9ec
5
5
  SHA512:
6
- metadata.gz: 63db363e87856e8224c90fae505fb313f1e9aae2e7ae3041e25c39800d375f68ec3d99a43b1d209af5c2ca638d4b8a8b44a9cd645361ea69614ee8d328bd10b9
7
- data.tar.gz: dafc593792e8853c77f936cb158ef0f987be0acd3e75a7fe23fd5b98ca7b7a2afa81fcdd1f4b5470817884924777785fcc910cceb0e45dfef95ec6512115124a
6
+ metadata.gz: e70ee9cfd542c162ce1c8511e681732f1ca1a8ff90136f951d11c052db225d6203d6b4c41938891cf4b43b3915ab80dedc694dc5e65febf4ddc75f13e20e81a4
7
+ data.tar.gz: 75d1906b23737d48cccf5284643ab8bbf35ac15f18b9cabf107b8e0d17dd0ef03a2193516f49ca13d1f474968767cb0402944e8a2eacfd35406ebadce0b59071
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.4] - 2026-11-01
4
+
5
+ - Add ostruct dependency
6
+ - Update gems
7
+
3
8
  ## [0.1.3] - 2026-01-09
4
9
 
5
10
  - Update gems
data/CLAUDE.md ADDED
@@ -0,0 +1,62 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ bp3-request_state provides `Bp3::RequestState::Base`, the parent of BP3's `GlobalRequestState`. BP3
8
+ (persuavis/black_phoebe_3) is a multi-site multi-tenant Rails application, and the request state is how
9
+ every layer knows the current site, tenant, workspace and login without passing them around. bp3-core's
10
+ Tenantable default scopes, Rqid and the job wrappers in bp3-noticed are all built on this API.
11
+
12
+ ## Commands
13
+
14
+ The gems run on Ruby 3.4.6 (`.ruby-version`). Prefix commands with `~/.rvm/bin/rvm 3.4.6 do` when the
15
+ shell is not already on it; a missing `rspec` means the wrong Ruby, not a missing bundle.
16
+
17
+ - `bundle exec rake` - specs and RuboCop (the default task)
18
+ - `bundle exec rspec spec/path/to/file_spec.rb[:LINE]` - one file or example
19
+ - `bundle exec rubocop` / `bundle exec rubocop -a`
20
+ - `bin/setup`, `bin/console`, `rake install`
21
+
22
+ ## Architecture
23
+
24
+ `lib/bp3/request_state/base.rb`. Everything is class-level state in `RequestStore` under
25
+ `:bp3_request_state`, so it is per request (and per job, once the job sets it) and thread-safe.
26
+
27
+ **What a subclass declares**, then calls `define_accessors`:
28
+ - `hash_key_map`: state member to class name, used to load records back from ids
29
+ - `base_attrs`: the members; each gets a class getter and setter, an `_id` getter and setter, and an
30
+ instance getter
31
+ - `hash_attrs`: the `_id` members `to_hash` serializes
32
+
33
+ **What the base provides**
34
+ - `current`, `clear!`, `request_id`, `started`, `duration`, `now`
35
+ - `to_hash` / `from_hash`: string-keyed hash of ids, request id, start time and locale, and back. This is
36
+ how jobs carry the caller's state
37
+ - `either_site`, `either_tenant`, `either_workspace` (and `_id`): the `target_*` member if set, else
38
+ `current_*`. `target_*` only exists in subclasses that declare it, as the application's does
39
+ - `either_admin`: `current_root || current_admin`
40
+ - `current_login`: `current_user || current_admin || current_root`, the least privileged login signed in.
41
+ bp3-core decides how far default scopes reach from it
42
+ - `highest_privilege`: the reverse order. Neither includes `current_visitor`, who is not logged in
43
+ - `with_current(site:, tenant:, workspace:)`: clears and sets the state, then yields. It does not restore
44
+ the previous state; the application's override does
45
+
46
+ `lib/bp3/request_state/test.rb` is a subclass with only `current_site` and `target_site`, backed by the
47
+ id-only stand-in `site.rb`. Neither is required by `lib/bp3/request_state.rb`; specs require them.
48
+
49
+ The application's `GlobalRequestState` (black_phoebe_3, `app/services/global_request_state.rb`) adds the
50
+ target members, `inbound_request`, and a `with_current` that restores the previous state; the README shows
51
+ it. A change to the names or semantics here reaches every bp3 gem that reads the state.
52
+
53
+ ## Code Style
54
+
55
+ - RuboCop (`.rubocop.yml`): target Ruby 3.2.2, NewCops, rubocop-rake and rubocop-rspec
56
+ - Every file starts with `# frozen_string_literal: true`
57
+ - American English; no trailing whitespace on any added or modified line
58
+
59
+ ## Release
60
+
61
+ Bump `lib/bp3/request_state/version.rb` and add a `CHANGELOG.md` entry. `rake release` tags, pushes and
62
+ publishes to rubygems.org; leave releasing and committing to the user.
data/Gemfile.lock CHANGED
@@ -1,17 +1,18 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bp3-request_state (0.1.3)
4
+ bp3-request_state (0.1.4)
5
5
  actionpack (~> 8.1)
6
6
  activesupport (~> 8.1)
7
+ ostruct (>= 0.6)
7
8
  request_store (>= 1.5.1)
8
9
 
9
10
  GEM
10
11
  remote: https://rubygems.org/
11
12
  specs:
12
- actionpack (8.1.2)
13
- actionview (= 8.1.2)
14
- activesupport (= 8.1.2)
13
+ actionpack (8.1.4)
14
+ actionview (= 8.1.4)
15
+ activesupport (= 8.1.4)
15
16
  nokogiri (>= 1.8.5)
16
17
  rack (>= 2.2.4)
17
18
  rack-session (>= 1.0.1)
@@ -19,13 +20,13 @@ GEM
19
20
  rails-dom-testing (~> 2.2)
20
21
  rails-html-sanitizer (~> 1.6)
21
22
  useragent (~> 0.16)
22
- actionview (8.1.2)
23
- activesupport (= 8.1.2)
23
+ actionview (8.1.4)
24
+ activesupport (= 8.1.4)
24
25
  builder (~> 3.1)
25
26
  erubi (~> 1.11)
26
27
  rails-dom-testing (~> 2.2)
27
28
  rails-html-sanitizer (~> 1.6)
28
- activesupport (8.1.2)
29
+ activesupport (8.1.4)
29
30
  base64
30
31
  bigdecimal
31
32
  concurrent-ruby (~> 1.0, >= 1.3.1)
@@ -40,50 +41,56 @@ GEM
40
41
  uri (>= 0.13.1)
41
42
  ast (2.4.3)
42
43
  base64 (0.3.0)
43
- bigdecimal (4.0.1)
44
+ bigdecimal (4.1.3)
44
45
  builder (3.3.0)
45
- byebug (12.0.0)
46
- concurrent-ruby (1.3.6)
46
+ byebug (13.0.0)
47
+ reline (>= 0.6.0)
48
+ concurrent-ruby (1.3.8)
47
49
  connection_pool (3.0.2)
48
- crass (1.0.6)
50
+ crass (1.0.8)
49
51
  diff-lcs (1.6.2)
50
52
  drb (2.2.3)
51
53
  erubi (1.13.1)
52
- i18n (1.14.8)
54
+ i18n (1.15.2)
53
55
  concurrent-ruby (~> 1.0)
54
- json (2.18.0)
55
- language_server-protocol (3.17.0.5)
56
+ io-console (0.9.4)
57
+ json (3.1.0)
58
+ language_server-protocol (3.17.0.6)
56
59
  lint_roller (1.1.0)
57
60
  logger (1.7.0)
58
- loofah (2.25.0)
61
+ loofah (2.25.2)
59
62
  crass (~> 1.0.2)
60
63
  nokogiri (>= 1.12.0)
61
- minitest (6.0.1)
64
+ minitest (6.0.6)
65
+ drb (~> 2.0)
62
66
  prism (~> 1.5)
63
- nokogiri (1.19.0-x86_64-darwin)
67
+ nokogiri (1.19.4-x86_64-darwin)
64
68
  racc (~> 1.4)
65
- parallel (1.27.0)
66
- parser (3.3.10.0)
69
+ ostruct (0.6.3)
70
+ parallel (2.3.0)
71
+ parser (3.3.13.0)
67
72
  ast (~> 2.4.1)
68
73
  racc
69
- prism (1.7.0)
74
+ prism (1.9.0)
70
75
  racc (1.8.1)
71
- rack (3.2.4)
72
- rack-session (2.1.1)
76
+ rack (3.2.7)
77
+ rack-session (2.1.2)
73
78
  base64 (>= 0.1.0)
74
79
  rack (>= 3.0.0)
75
- rack-test (2.2.0)
80
+ rack-test (2.3.0)
76
81
  rack (>= 1.3)
77
82
  rails-dom-testing (2.3.0)
78
83
  activesupport (>= 5.0.0)
79
84
  minitest
80
85
  nokogiri (>= 1.6)
81
- rails-html-sanitizer (1.6.2)
82
- loofah (~> 2.21)
86
+ rails-html-sanitizer (1.7.1)
87
+ loofah (~> 2.25, >= 2.25.2)
83
88
  nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
84
89
  rainbow (3.1.1)
85
- rake (13.3.1)
86
- regexp_parser (2.11.3)
90
+ rake (13.4.2)
91
+ regexp_parser (2.13.1)
92
+ reline (0.7.0)
93
+ io-console (~> 0.5)
87
94
  request_store (1.7.0)
88
95
  rack (>= 1.4)
89
96
  rspec (3.13.2)
@@ -95,38 +102,39 @@ GEM
95
102
  rspec-expectations (3.13.5)
96
103
  diff-lcs (>= 1.2.0, < 2.0)
97
104
  rspec-support (~> 3.13.0)
98
- rspec-mocks (3.13.7)
105
+ rspec-mocks (3.13.8)
99
106
  diff-lcs (>= 1.2.0, < 2.0)
100
107
  rspec-support (~> 3.13.0)
101
- rspec-support (3.13.6)
102
- rubocop (1.82.1)
103
- json (~> 2.3)
108
+ rspec-support (3.13.7)
109
+ rubocop (1.92.1)
110
+ json (>= 2.3)
104
111
  language_server-protocol (~> 3.17.0.2)
105
112
  lint_roller (~> 1.1.0)
106
- parallel (~> 1.10)
113
+ parallel (>= 1.10)
107
114
  parser (>= 3.3.0.2)
108
115
  rainbow (>= 2.2.2, < 4.0)
109
- regexp_parser (>= 2.9.3, < 3.0)
110
- rubocop-ast (>= 1.48.0, < 2.0)
116
+ regexp_parser (>= 2.11.3, < 3.0)
117
+ rubocop-ast (>= 1.49.0, < 2.0)
111
118
  ruby-progressbar (~> 1.7)
112
119
  unicode-display_width (>= 2.4.0, < 4.0)
113
- rubocop-ast (1.49.0)
120
+ rubocop-ast (1.50.0)
114
121
  parser (>= 3.3.7.2)
115
122
  prism (~> 1.7)
116
123
  rubocop-rake (0.7.1)
117
124
  lint_roller (~> 1.1)
118
125
  rubocop (>= 1.72.1)
119
- rubocop-rspec (3.9.0)
126
+ rubocop-rspec (3.10.2)
120
127
  lint_roller (~> 1.1)
121
- rubocop (~> 1.81)
128
+ regexp_parser (>= 2.0)
129
+ rubocop (~> 1.86, >= 1.86.2)
122
130
  ruby-progressbar (1.13.0)
123
131
  securerandom (0.4.1)
124
132
  tzinfo (2.0.6)
125
133
  concurrent-ruby (~> 1.0)
126
- unicode-display_width (3.2.0)
127
- unicode-emoji (~> 4.1)
128
- unicode-emoji (4.2.0)
129
- uri (1.1.1)
134
+ unicode-display_width (3.3.0)
135
+ unicode-emoji (~> 4.3)
136
+ unicode-emoji (4.3.0)
137
+ uri (1.1.2)
130
138
  useragent (0.16.11)
131
139
 
132
140
  PLATFORMS
data/README.md CHANGED
@@ -24,7 +24,7 @@ Or install it yourself as:
24
24
 
25
25
  ## Usage
26
26
 
27
- In your app, create a model or service that inherits from `Bp3::Request::State`, and
27
+ In your app, create a model or service that inherits from `Bp3::RequestState::Base`, and
28
28
  specify
29
29
  - `hash_key_map`, mapping members of the global state to their class,
30
30
  - `base_attrs`, defining the list of global state member objects, and
@@ -33,6 +33,7 @@ Gem::Specification.new do |spec|
33
33
 
34
34
  spec.add_dependency 'actionpack', '~> 8.1'
35
35
  spec.add_dependency 'activesupport', '~> 8.1'
36
+ spec.add_dependency 'ostruct', '>= 0.6'
36
37
  spec.add_dependency 'request_store', '>= 1.5.1'
37
38
 
38
39
  spec.add_development_dependency 'byebug'
@@ -11,7 +11,7 @@ require 'ostruct'
11
11
 
12
12
  module Bp3
13
13
  module RequestState
14
- # rubocop:disable Metrics/ClassLength, Style/ClassVars
14
+ # rubocop:disable-next Metrics/ClassLength, Style/ClassVars
15
15
  class Base
16
16
  extend Forwardable
17
17
 
@@ -210,6 +210,5 @@ module Bp3
210
210
  end
211
211
  end
212
212
  end
213
- # rubocop:enable Metrics/ClassLength, Style/ClassVars
214
213
  end
215
214
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bp3
4
4
  module RequestState
5
- VERSION = '0.1.3'
5
+ VERSION = '0.1.4'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bp3-request_state
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wim den Braven
@@ -37,6 +37,20 @@ dependencies:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
39
  version: '8.1'
40
+ - !ruby/object:Gem::Dependency
41
+ name: ostruct
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0.6'
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0.6'
40
54
  - !ruby/object:Gem::Dependency
41
55
  name: request_store
42
56
  requirement: !ruby/object:Gem::Requirement
@@ -145,6 +159,7 @@ files:
145
159
  - ".rubocop.yml"
146
160
  - ".yardopts"
147
161
  - CHANGELOG.md
162
+ - CLAUDE.md
148
163
  - Gemfile
149
164
  - Gemfile.lock
150
165
  - LICENSE.txt
@@ -181,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
196
  - !ruby/object:Gem::Version
182
197
  version: '0'
183
198
  requirements: []
184
- rubygems_version: 3.6.9
199
+ rubygems_version: 4.0.23
185
200
  specification_version: 4
186
201
  summary: bp3-request_state provides the Bp3::RequestState::Base class for BP3 (persuavis/black_phoebe_3).
187
202
  test_files: []