bp3-request_state 0.1.2 → 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: 2e4e63e876bb980fdb59b08b0bbe4e8c52f3e3a9876c7213b1a2b923388b9a0f
4
- data.tar.gz: 8cdfd2e8994382b78e6dbe374eff0cc93efa1054824d236711bfcfad8cfee49b
3
+ metadata.gz: df0c3852fcdfcee1a0ff7d9c703e3afe5e60165df36758de5e017bf95eb06982
4
+ data.tar.gz: 9883f750f5eb32271d7a16a39589db7615cc1602fb2660c8f7c6f586be23b9ec
5
5
  SHA512:
6
- metadata.gz: 77a6a15708b2dc3066b3707366b4b9cba4855f1d6dc453642c77be724e2dd02860e09ce1099eaa8736344d7a0567b692cd189fd04a8676eedab9965c55a82033
7
- data.tar.gz: 0770d90f31d7644afc1e282631b8adba4009df7e60fcca43537b3ed8c80f5040c47aa6fedf7e2700cb3fb94754d0e448347837ea3fb671c30c2cd59ac75838e1
6
+ metadata.gz: e70ee9cfd542c162ce1c8511e681732f1ca1a8ff90136f951d11c052db225d6203d6b4c41938891cf4b43b3915ab80dedc694dc5e65febf4ddc75f13e20e81a4
7
+ data.tar.gz: 75d1906b23737d48cccf5284643ab8bbf35ac15f18b9cabf107b8e0d17dd0ef03a2193516f49ca13d1f474968767cb0402944e8a2eacfd35406ebadce0b59071
data/.rubocop.yml CHANGED
@@ -1,4 +1,4 @@
1
- require:
1
+ plugins:
2
2
  - rubocop-rake
3
3
  - rubocop-rspec
4
4
 
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.4] - 2026-11-01
4
+
5
+ - Add ostruct dependency
6
+ - Update gems
7
+
8
+ ## [0.1.3] - 2026-01-09
9
+
10
+ - Update gems
11
+
3
12
  ## [0.1.2] - 2024-11-18
4
13
 
5
14
  - Use ruby 3.3.5 and relax gem constraints
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.2)
5
- actionpack (>= 7.1.2)
6
- activesupport (>= 7.1.2)
4
+ bp3-request_state (0.1.4)
5
+ actionpack (~> 8.1)
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.0.0)
13
- actionview (= 8.0.0)
14
- activesupport (= 8.0.0)
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,109 +20,127 @@ GEM
19
20
  rails-dom-testing (~> 2.2)
20
21
  rails-html-sanitizer (~> 1.6)
21
22
  useragent (~> 0.16)
22
- actionview (8.0.0)
23
- activesupport (= 8.0.0)
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.0.0)
29
+ activesupport (8.1.4)
29
30
  base64
30
- benchmark (>= 0.3)
31
31
  bigdecimal
32
32
  concurrent-ruby (~> 1.0, >= 1.3.1)
33
33
  connection_pool (>= 2.2.5)
34
34
  drb
35
35
  i18n (>= 1.6, < 2)
36
+ json
36
37
  logger (>= 1.4.2)
37
38
  minitest (>= 5.1)
38
39
  securerandom (>= 0.3)
39
40
  tzinfo (~> 2.0, >= 2.0.5)
40
41
  uri (>= 0.13.1)
41
- ast (2.4.2)
42
- base64 (0.2.0)
43
- benchmark (0.4.0)
44
- bigdecimal (3.1.8)
42
+ ast (2.4.3)
43
+ base64 (0.3.0)
44
+ bigdecimal (4.1.3)
45
45
  builder (3.3.0)
46
- byebug (11.1.3)
47
- concurrent-ruby (1.3.4)
48
- connection_pool (2.4.1)
49
- crass (1.0.6)
50
- diff-lcs (1.5.1)
51
- drb (2.2.1)
52
- erubi (1.13.0)
53
- i18n (1.14.6)
46
+ byebug (13.0.0)
47
+ reline (>= 0.6.0)
48
+ concurrent-ruby (1.3.8)
49
+ connection_pool (3.0.2)
50
+ crass (1.0.8)
51
+ diff-lcs (1.6.2)
52
+ drb (2.2.3)
53
+ erubi (1.13.1)
54
+ i18n (1.15.2)
54
55
  concurrent-ruby (~> 1.0)
55
- json (2.8.2)
56
- language_server-protocol (3.17.0.3)
57
- logger (1.6.1)
58
- loofah (2.23.1)
56
+ io-console (0.9.4)
57
+ json (3.1.0)
58
+ language_server-protocol (3.17.0.6)
59
+ lint_roller (1.1.0)
60
+ logger (1.7.0)
61
+ loofah (2.25.2)
59
62
  crass (~> 1.0.2)
60
63
  nokogiri (>= 1.12.0)
61
- minitest (5.25.1)
62
- nokogiri (1.16.7-x86_64-darwin)
64
+ minitest (6.0.6)
65
+ drb (~> 2.0)
66
+ prism (~> 1.5)
67
+ nokogiri (1.19.4-x86_64-darwin)
63
68
  racc (~> 1.4)
64
- parallel (1.26.3)
65
- parser (3.3.6.0)
69
+ ostruct (0.6.3)
70
+ parallel (2.3.0)
71
+ parser (3.3.13.0)
66
72
  ast (~> 2.4.1)
67
73
  racc
74
+ prism (1.9.0)
68
75
  racc (1.8.1)
69
- rack (3.1.8)
70
- rack-session (2.0.0)
76
+ rack (3.2.7)
77
+ rack-session (2.1.2)
78
+ base64 (>= 0.1.0)
71
79
  rack (>= 3.0.0)
72
- rack-test (2.1.0)
80
+ rack-test (2.3.0)
73
81
  rack (>= 1.3)
74
- rails-dom-testing (2.2.0)
82
+ rails-dom-testing (2.3.0)
75
83
  activesupport (>= 5.0.0)
76
84
  minitest
77
85
  nokogiri (>= 1.6)
78
- rails-html-sanitizer (1.6.0)
79
- loofah (~> 2.21)
80
- nokogiri (~> 1.14)
86
+ rails-html-sanitizer (1.7.1)
87
+ loofah (~> 2.25, >= 2.25.2)
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)
81
89
  rainbow (3.1.1)
82
- rake (13.2.1)
83
- regexp_parser (2.9.2)
90
+ rake (13.4.2)
91
+ regexp_parser (2.13.1)
92
+ reline (0.7.0)
93
+ io-console (~> 0.5)
84
94
  request_store (1.7.0)
85
95
  rack (>= 1.4)
86
- rspec (3.13.0)
96
+ rspec (3.13.2)
87
97
  rspec-core (~> 3.13.0)
88
98
  rspec-expectations (~> 3.13.0)
89
99
  rspec-mocks (~> 3.13.0)
90
- rspec-core (3.13.2)
100
+ rspec-core (3.13.6)
91
101
  rspec-support (~> 3.13.0)
92
- rspec-expectations (3.13.3)
102
+ rspec-expectations (3.13.5)
93
103
  diff-lcs (>= 1.2.0, < 2.0)
94
104
  rspec-support (~> 3.13.0)
95
- rspec-mocks (3.13.2)
105
+ rspec-mocks (3.13.8)
96
106
  diff-lcs (>= 1.2.0, < 2.0)
97
107
  rspec-support (~> 3.13.0)
98
- rspec-support (3.13.1)
99
- rubocop (1.68.0)
100
- json (~> 2.3)
101
- language_server-protocol (>= 3.17.0)
102
- parallel (~> 1.10)
108
+ rspec-support (3.13.7)
109
+ rubocop (1.92.1)
110
+ json (>= 2.3)
111
+ language_server-protocol (~> 3.17.0.2)
112
+ lint_roller (~> 1.1.0)
113
+ parallel (>= 1.10)
103
114
  parser (>= 3.3.0.2)
104
115
  rainbow (>= 2.2.2, < 4.0)
105
- regexp_parser (>= 2.4, < 3.0)
106
- rubocop-ast (>= 1.32.2, < 2.0)
116
+ regexp_parser (>= 2.11.3, < 3.0)
117
+ rubocop-ast (>= 1.49.0, < 2.0)
107
118
  ruby-progressbar (~> 1.7)
108
- unicode-display_width (>= 2.4.0, < 3.0)
109
- rubocop-ast (1.36.1)
110
- parser (>= 3.3.1.0)
111
- rubocop-rake (0.6.0)
112
- rubocop (~> 1.0)
113
- rubocop-rspec (3.2.0)
114
- rubocop (~> 1.61)
119
+ unicode-display_width (>= 2.4.0, < 4.0)
120
+ rubocop-ast (1.50.0)
121
+ parser (>= 3.3.7.2)
122
+ prism (~> 1.7)
123
+ rubocop-rake (0.7.1)
124
+ lint_roller (~> 1.1)
125
+ rubocop (>= 1.72.1)
126
+ rubocop-rspec (3.10.2)
127
+ lint_roller (~> 1.1)
128
+ regexp_parser (>= 2.0)
129
+ rubocop (~> 1.86, >= 1.86.2)
115
130
  ruby-progressbar (1.13.0)
116
- securerandom (0.3.2)
131
+ securerandom (0.4.1)
117
132
  tzinfo (2.0.6)
118
133
  concurrent-ruby (~> 1.0)
119
- unicode-display_width (2.6.0)
120
- uri (1.0.2)
121
- useragent (0.16.10)
134
+ unicode-display_width (3.3.0)
135
+ unicode-emoji (~> 4.3)
136
+ unicode-emoji (4.3.0)
137
+ uri (1.1.2)
138
+ useragent (0.16.11)
122
139
 
123
140
  PLATFORMS
124
141
  x86_64-darwin-22
142
+ x86_64-darwin-23
143
+ x86_64-darwin-24
125
144
 
126
145
  DEPENDENCIES
127
146
  bp3-request_state!
@@ -133,4 +152,4 @@ DEPENDENCIES
133
152
  rubocop-rspec (>= 2.25)
134
153
 
135
154
  BUNDLED WITH
136
- 2.5.17
155
+ 2.7.2
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
@@ -31,8 +31,9 @@ Gem::Specification.new do |spec|
31
31
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32
32
  spec.require_paths = ['lib']
33
33
 
34
- spec.add_dependency 'actionpack', '>= 7.1.2'
35
- spec.add_dependency 'activesupport', '>= 7.1.2'
34
+ spec.add_dependency 'actionpack', '~> 8.1'
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,9 +11,10 @@ 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
18
  cattr_accessor :hash_key_map, :base_attrs, :hash_attrs
18
19
 
19
20
  @@hash_key_map =
@@ -209,6 +210,5 @@ module Bp3
209
210
  end
210
211
  end
211
212
  end
212
- # rubocop:enable Metrics/ClassLength, Style/ClassVars
213
213
  end
214
214
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bp3
4
4
  module RequestState
5
- VERSION = '0.1.2'
5
+ VERSION = '0.1.4'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,43 +1,56 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bp3-request_state
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wim den Braven
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-11-18 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: actionpack
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
- - - ">="
16
+ - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: 7.1.2
18
+ version: '8.1'
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
- - - ">="
23
+ - - "~>"
25
24
  - !ruby/object:Gem::Version
26
- version: 7.1.2
25
+ version: '8.1'
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: activesupport
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '8.1'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '8.1'
40
+ - !ruby/object:Gem::Dependency
41
+ name: ostruct
29
42
  requirement: !ruby/object:Gem::Requirement
30
43
  requirements:
31
44
  - - ">="
32
45
  - !ruby/object:Gem::Version
33
- version: 7.1.2
46
+ version: '0.6'
34
47
  type: :runtime
35
48
  prerelease: false
36
49
  version_requirements: !ruby/object:Gem::Requirement
37
50
  requirements:
38
51
  - - ">="
39
52
  - !ruby/object:Gem::Version
40
- version: 7.1.2
53
+ version: '0.6'
41
54
  - !ruby/object:Gem::Dependency
42
55
  name: request_store
43
56
  requirement: !ruby/object:Gem::Requirement
@@ -136,7 +149,6 @@ dependencies:
136
149
  - - ">="
137
150
  - !ruby/object:Gem::Version
138
151
  version: '2.25'
139
- description:
140
152
  email:
141
153
  - wimdenbraven@persuavis.com
142
154
  executables: []
@@ -147,6 +159,7 @@ files:
147
159
  - ".rubocop.yml"
148
160
  - ".yardopts"
149
161
  - CHANGELOG.md
162
+ - CLAUDE.md
150
163
  - Gemfile
151
164
  - Gemfile.lock
152
165
  - LICENSE.txt
@@ -169,7 +182,6 @@ metadata:
169
182
  source_code_uri: https://github.com/persuavis/bp3-request_state
170
183
  changelog_uri: https://github.com/persuavis/bp3-request_state/blob/main/CHANGELOG.md
171
184
  rubygems_mfa_required: 'true'
172
- post_install_message:
173
185
  rdoc_options: []
174
186
  require_paths:
175
187
  - lib
@@ -184,8 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
196
  - !ruby/object:Gem::Version
185
197
  version: '0'
186
198
  requirements: []
187
- rubygems_version: 3.5.17
188
- signing_key:
199
+ rubygems_version: 4.0.23
189
200
  specification_version: 4
190
201
  summary: bp3-request_state provides the Bp3::RequestState::Base class for BP3 (persuavis/black_phoebe_3).
191
202
  test_files: []