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 +4 -4
- data/CHANGELOG.md +5 -0
- data/CLAUDE.md +62 -0
- data/Gemfile.lock +49 -41
- data/README.md +1 -1
- data/bp3-request_state.gemspec +1 -0
- data/lib/bp3/request_state/base.rb +1 -2
- data/lib/bp3/request_state/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: df0c3852fcdfcee1a0ff7d9c703e3afe5e60165df36758de5e017bf95eb06982
|
|
4
|
+
data.tar.gz: 9883f750f5eb32271d7a16a39589db7615cc1602fb2660c8f7c6f586be23b9ec
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e70ee9cfd542c162ce1c8511e681732f1ca1a8ff90136f951d11c052db225d6203d6b4c41938891cf4b43b3915ab80dedc694dc5e65febf4ddc75f13e20e81a4
|
|
7
|
+
data.tar.gz: 75d1906b23737d48cccf5284643ab8bbf35ac15f18b9cabf107b8e0d17dd0ef03a2193516f49ca13d1f474968767cb0402944e8a2eacfd35406ebadce0b59071
|
data/CHANGELOG.md
CHANGED
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.
|
|
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.
|
|
13
|
-
actionview (= 8.1.
|
|
14
|
-
activesupport (= 8.1.
|
|
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.
|
|
23
|
-
activesupport (= 8.1.
|
|
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.
|
|
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.
|
|
44
|
+
bigdecimal (4.1.3)
|
|
44
45
|
builder (3.3.0)
|
|
45
|
-
byebug (
|
|
46
|
-
|
|
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.
|
|
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.
|
|
54
|
+
i18n (1.15.2)
|
|
53
55
|
concurrent-ruby (~> 1.0)
|
|
54
|
-
|
|
55
|
-
|
|
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.
|
|
61
|
+
loofah (2.25.2)
|
|
59
62
|
crass (~> 1.0.2)
|
|
60
63
|
nokogiri (>= 1.12.0)
|
|
61
|
-
minitest (6.0.
|
|
64
|
+
minitest (6.0.6)
|
|
65
|
+
drb (~> 2.0)
|
|
62
66
|
prism (~> 1.5)
|
|
63
|
-
nokogiri (1.19.
|
|
67
|
+
nokogiri (1.19.4-x86_64-darwin)
|
|
64
68
|
racc (~> 1.4)
|
|
65
|
-
|
|
66
|
-
|
|
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.
|
|
74
|
+
prism (1.9.0)
|
|
70
75
|
racc (1.8.1)
|
|
71
|
-
rack (3.2.
|
|
72
|
-
rack-session (2.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.
|
|
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.
|
|
82
|
-
loofah (~> 2.
|
|
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.
|
|
86
|
-
regexp_parser (2.
|
|
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.
|
|
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.
|
|
102
|
-
rubocop (1.
|
|
103
|
-
json (
|
|
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 (
|
|
113
|
+
parallel (>= 1.10)
|
|
107
114
|
parser (>= 3.3.0.2)
|
|
108
115
|
rainbow (>= 2.2.2, < 4.0)
|
|
109
|
-
regexp_parser (>= 2.
|
|
110
|
-
rubocop-ast (>= 1.
|
|
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.
|
|
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.
|
|
126
|
+
rubocop-rspec (3.10.2)
|
|
120
127
|
lint_roller (~> 1.1)
|
|
121
|
-
|
|
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.
|
|
127
|
-
unicode-emoji (~> 4.
|
|
128
|
-
unicode-emoji (4.
|
|
129
|
-
uri (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::
|
|
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
|
data/bp3-request_state.gemspec
CHANGED
|
@@ -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
|
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.
|
|
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:
|
|
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: []
|