bp3-formtastic 0.2.2 → 0.2.3

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: 6df14b045f68ffc88553213ee3ac84834dcd348efaf907b549f71caac3795fad
4
- data.tar.gz: bbb7a190958ebe6344dd90c963b9e3178347f80f411e89e0481976e0f13ead2d
3
+ metadata.gz: 216b360f847493e75ddd8d062e4bdd08b62d3a60225d1451b1ab28b9bb7feece
4
+ data.tar.gz: 5901b44319c1ee9031d8e89e7ab009f95bdc67f13895b5c4108baf1bf40e56fc
5
5
  SHA512:
6
- metadata.gz: e2ceea941ac3eb3fa853d9ed9a99ea7d85b9ef862489277e7e5c051318a46547027d6141ef7528c9a1a60f29ae714b3fe23c67942b1db21f901625423bdb528a
7
- data.tar.gz: 4c9b26d1edd7485973ea59f4cb5503d2c7485d84000076bbd32bf68d19aee358014e617effe6a54b7695db8167547a0a0de779e8f7cc844432ecc94dd8262257
6
+ metadata.gz: 0bb8504a768073d5e0047a57a9127c444c40f8a8cd3e1617b3508d84faa9252d95f4ebd1b71fb8cfaf27c2de94d3319e284cfc6c3c1ae2c2e4bf6b1f2b2c158d
7
+ data.tar.gz: 290418d35e22607a158290e71c501a232a97c75186fea933ab99a712ae618d6bb16d93393ef8ac1c62658710c030688a6bab359f17b694165a8f96192b080f6e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.3] - 2026-10-28
4
+
5
+ - Ensure tenant and workspace for Vizfact::Input records
6
+ File created input control records under the controller's current site, tenant and workspace
7
+ - Remove a no-op builder id substitution and its UUID_REGEX
8
+
3
9
  ## [0.2.2] - 2026-01-12
4
10
 
5
11
  - Update gems
data/CLAUDE.md ADDED
@@ -0,0 +1,65 @@
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-formtastic adapts `formtastic` for BP3 (persuavis/black_phoebe_3), a multi-site multi-tenant Rails
8
+ application. It lets each site hide individual form inputs, controlled by records of an "input control"
9
+ class (`Vizfact::Input` in the application), keyed by controller, action and field.
10
+
11
+ ## Commands
12
+
13
+ The gems run on Ruby 3.4.6 (`.ruby-version`). Prefix commands with `~/.rvm/bin/rvm 3.4.6 do` when the
14
+ shell is not already on it; a missing `rspec` means the wrong Ruby, not a missing bundle.
15
+
16
+ - `bundle exec rake` - specs and RuboCop (the default task)
17
+ - `bundle exec rspec spec/path/to/file_spec.rb[:LINE]` - one file or example
18
+ - `bundle exec rubocop` / `bundle exec rubocop -a`
19
+ - `bin/setup`, `bin/console`, `rake install`
20
+
21
+ ## Architecture
22
+
23
+ **VizFormBuilder** (`lib/bp3/formtastic/viz_form_builder.rb`), a `Formtastic::FormBuilder`
24
+ - on initialize, loads the input control records for the controller's `current_site`, controller class and
25
+ action into `vizfacts`
26
+ - `viz(element_name, element_ident)` finds the record matching the field name (`object[attribute]`) or
27
+ DOM id
28
+
29
+ **VizFormBuilderWithCreate** (`viz_form_builder_with_create.rb`)
30
+ - creates a missing record (`show_element: true`) for every input it meets, so operators can then hide it.
31
+ It names `Vizfact::Input` directly. The application uses it outside the test environment
32
+
33
+ **Railtie** (`railtie.rb`), in an `after_initialize` block, only when `Rails.env` is defined
34
+ - prepends `PrependInputs` to `Formtastic::Inputs::Base`. `input_wrapping` renders nothing for the `rqid`
35
+ and `sqnr` columns, and nothing when the matching record has `show_element` false
36
+ - it falls through to formtastic when there is no column, no input control class, or a builder without
37
+ `viz`, so plain formtastic builders are unaffected
38
+
39
+ **Configuration** (`lib/bp3/formtastic.rb`): `Bp3::Formtastic.input_control_class_name`; `.input_control_class`
40
+ constantizes and caches it, and returns nil when unset. The application sets it in
41
+ `config/initializers/bp3-formtastic.rb` and also redefines `input_control_class` in a `to_prepare` block so
42
+ code reloading in development does not leave a stale class. It picks the builder in
43
+ `config/initializers/formtastic.rb`.
44
+
45
+ `lib/bp3/formtastic.rb` requires `action_dispatch` first to avoid an
46
+ `uninitialized constant Rails::Engine::Configuration::ActionDispatch` error when loading formtastic.
47
+
48
+ ## Testing
49
+
50
+ The spec only checks the version; the builders and the Railtie need a Rails view context to exercise. Try
51
+ a change against the application (black_phoebe_3) by putting this repo's `lib` ahead of the bundled gem.
52
+
53
+ ## Code Style
54
+
55
+ - RuboCop (`.rubocop.yml`): target Ruby 3.2.2, NewCops, rubocop-rake and rubocop-rspec; AbcSize 26,
56
+ MethodLength 15, BlockLength 66, ModuleLength 150; `Lint/ConstantDefinitionInBlock` and `Lint/Void`
57
+ are off for `lib/bp3/**/railtie.rb`, where classes are reopened inside a block
58
+ - Constants holding a regex end in `_REGEX`
59
+ - Every file starts with `# frozen_string_literal: true`
60
+ - American English; no trailing whitespace on any added or modified line
61
+
62
+ ## Release
63
+
64
+ Bump `lib/bp3/formtastic/version.rb` and add a `CHANGELOG.md` entry. `rake release` tags, pushes and
65
+ publishes to rubygems.org; leave releasing and committing to the user.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bp3-formtastic (0.2.2)
4
+ bp3-formtastic (0.2.3)
5
5
  actionpack (~> 8.1)
6
6
  actionview (~> 8.1)
7
7
  activesupport (~> 8.1)
@@ -11,9 +11,9 @@ PATH
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- actionpack (8.1.2)
15
- actionview (= 8.1.2)
16
- activesupport (= 8.1.2)
14
+ actionpack (8.1.4)
15
+ actionview (= 8.1.4)
16
+ activesupport (= 8.1.4)
17
17
  nokogiri (>= 1.8.5)
18
18
  rack (>= 2.2.4)
19
19
  rack-session (>= 1.0.1)
@@ -21,13 +21,13 @@ GEM
21
21
  rails-dom-testing (~> 2.2)
22
22
  rails-html-sanitizer (~> 1.6)
23
23
  useragent (~> 0.16)
24
- actionview (8.1.2)
25
- activesupport (= 8.1.2)
24
+ actionview (8.1.4)
25
+ activesupport (= 8.1.4)
26
26
  builder (~> 3.1)
27
27
  erubi (~> 1.11)
28
28
  rails-dom-testing (~> 2.2)
29
29
  rails-html-sanitizer (~> 1.6)
30
- activesupport (8.1.2)
30
+ activesupport (8.1.4)
31
31
  base64
32
32
  bigdecimal
33
33
  concurrent-ruby (~> 1.0, >= 1.3.1)
@@ -42,54 +42,53 @@ GEM
42
42
  uri (>= 0.13.1)
43
43
  ast (2.4.3)
44
44
  base64 (0.3.0)
45
- bigdecimal (4.0.1)
45
+ bigdecimal (4.1.3)
46
46
  builder (3.3.0)
47
- byebug (12.0.0)
48
- concurrent-ruby (1.3.6)
47
+ byebug (13.0.0)
48
+ reline (>= 0.6.0)
49
+ concurrent-ruby (1.3.8)
49
50
  connection_pool (3.0.2)
50
- crass (1.0.6)
51
- date (3.5.1)
51
+ crass (1.0.8)
52
52
  diff-lcs (1.6.2)
53
53
  drb (2.2.3)
54
- erb (6.0.1)
54
+ erb (6.0.7)
55
55
  erubi (1.13.1)
56
- formtastic (5.0.0)
57
- actionpack (>= 6.0.0)
58
- i18n (1.14.8)
56
+ formtastic (6.0.0)
57
+ actionpack (>= 7.2.0)
58
+ i18n (1.15.2)
59
59
  concurrent-ruby (~> 1.0)
60
- io-console (0.8.2)
61
- irb (1.16.0)
60
+ io-console (0.9.4)
61
+ irb (1.18.0)
62
62
  pp (>= 0.6.0)
63
+ prism (>= 1.3.0)
63
64
  rdoc (>= 4.0.0)
64
65
  reline (>= 0.4.2)
65
- json (2.18.0)
66
- language_server-protocol (3.17.0.5)
66
+ json (3.1.0)
67
+ language_server-protocol (3.17.0.6)
67
68
  lint_roller (1.1.0)
68
69
  logger (1.7.0)
69
- loofah (2.25.0)
70
+ loofah (2.25.2)
70
71
  crass (~> 1.0.2)
71
72
  nokogiri (>= 1.12.0)
72
- minitest (6.0.1)
73
+ minitest (6.0.6)
74
+ drb (~> 2.0)
73
75
  prism (~> 1.5)
74
- nokogiri (1.19.0-x86_64-darwin)
76
+ nokogiri (1.19.4-x86_64-darwin)
75
77
  racc (~> 1.4)
76
- parallel (1.27.0)
77
- parser (3.3.10.0)
78
+ parallel (2.3.0)
79
+ parser (3.3.13.0)
78
80
  ast (~> 2.4.1)
79
81
  racc
80
- pp (0.6.3)
82
+ pp (0.6.4)
81
83
  prettyprint
82
- prettyprint (0.2.0)
83
- prism (1.7.0)
84
- psych (5.3.1)
85
- date
86
- stringio
84
+ prettyprint (0.2.1)
85
+ prism (1.9.0)
87
86
  racc (1.8.1)
88
- rack (3.2.4)
89
- rack-session (2.1.1)
87
+ rack (3.2.7)
88
+ rack-session (2.1.2)
90
89
  base64 (>= 0.1.0)
91
90
  rack (>= 3.0.0)
92
- rack-test (2.2.0)
91
+ rack-test (2.3.0)
93
92
  rack (>= 1.3)
94
93
  rackup (2.3.1)
95
94
  rack (>= 3)
@@ -97,12 +96,12 @@ GEM
97
96
  activesupport (>= 5.0.0)
98
97
  minitest
99
98
  nokogiri (>= 1.6)
100
- rails-html-sanitizer (1.6.2)
101
- loofah (~> 2.21)
99
+ rails-html-sanitizer (1.7.1)
100
+ loofah (~> 2.25, >= 2.25.2)
102
101
  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)
103
- railties (8.1.2)
104
- actionpack (= 8.1.2)
105
- activesupport (= 8.1.2)
102
+ railties (8.1.4)
103
+ actionpack (= 8.1.4)
104
+ activesupport (= 8.1.4)
106
105
  irb (~> 1.13)
107
106
  rackup (>= 1.0.0)
108
107
  rake (>= 12.2)
@@ -110,13 +109,18 @@ GEM
110
109
  tsort (>= 0.2)
111
110
  zeitwerk (~> 2.6)
112
111
  rainbow (3.1.1)
113
- rake (13.3.1)
114
- rdoc (7.0.3)
112
+ rake (13.4.2)
113
+ rbs (4.2.0)
114
+ logger
115
+ prism (>= 1.6.0)
116
+ tsort
117
+ rdoc (8.1.0)
115
118
  erb
116
- psych (>= 4.0.0)
119
+ prism (>= 1.6.0)
120
+ rbs (>= 4.0.0)
117
121
  tsort
118
- regexp_parser (2.11.3)
119
- reline (0.6.3)
122
+ regexp_parser (2.13.1)
123
+ reline (0.7.0)
120
124
  io-console (~> 0.5)
121
125
  rspec (3.13.2)
122
126
  rspec-core (~> 3.13.0)
@@ -127,43 +131,43 @@ GEM
127
131
  rspec-expectations (3.13.5)
128
132
  diff-lcs (>= 1.2.0, < 2.0)
129
133
  rspec-support (~> 3.13.0)
130
- rspec-mocks (3.13.7)
134
+ rspec-mocks (3.13.8)
131
135
  diff-lcs (>= 1.2.0, < 2.0)
132
136
  rspec-support (~> 3.13.0)
133
- rspec-support (3.13.6)
134
- rubocop (1.82.1)
135
- json (~> 2.3)
137
+ rspec-support (3.13.7)
138
+ rubocop (1.92.1)
139
+ json (>= 2.3)
136
140
  language_server-protocol (~> 3.17.0.2)
137
141
  lint_roller (~> 1.1.0)
138
- parallel (~> 1.10)
142
+ parallel (>= 1.10)
139
143
  parser (>= 3.3.0.2)
140
144
  rainbow (>= 2.2.2, < 4.0)
141
- regexp_parser (>= 2.9.3, < 3.0)
142
- rubocop-ast (>= 1.48.0, < 2.0)
145
+ regexp_parser (>= 2.11.3, < 3.0)
146
+ rubocop-ast (>= 1.49.0, < 2.0)
143
147
  ruby-progressbar (~> 1.7)
144
148
  unicode-display_width (>= 2.4.0, < 4.0)
145
- rubocop-ast (1.49.0)
149
+ rubocop-ast (1.50.0)
146
150
  parser (>= 3.3.7.2)
147
151
  prism (~> 1.7)
148
152
  rubocop-rake (0.7.1)
149
153
  lint_roller (~> 1.1)
150
154
  rubocop (>= 1.72.1)
151
- rubocop-rspec (3.9.0)
155
+ rubocop-rspec (3.10.2)
152
156
  lint_roller (~> 1.1)
153
- rubocop (~> 1.81)
157
+ regexp_parser (>= 2.0)
158
+ rubocop (~> 1.86, >= 1.86.2)
154
159
  ruby-progressbar (1.13.0)
155
160
  securerandom (0.4.1)
156
- stringio (3.2.0)
157
161
  thor (1.5.0)
158
162
  tsort (0.2.0)
159
163
  tzinfo (2.0.6)
160
164
  concurrent-ruby (~> 1.0)
161
- unicode-display_width (3.2.0)
162
- unicode-emoji (~> 4.1)
163
- unicode-emoji (4.2.0)
164
- uri (1.1.1)
165
+ unicode-display_width (3.3.0)
166
+ unicode-emoji (~> 4.3)
167
+ unicode-emoji (4.3.0)
168
+ uri (1.1.2)
165
169
  useragent (0.16.11)
166
- zeitwerk (2.7.4)
170
+ zeitwerk (2.8.3)
167
171
 
168
172
  PLATFORMS
169
173
  x86_64-darwin-22
@@ -10,7 +10,6 @@ module Bp3
10
10
  module ::Formtastic
11
11
  module Inputs
12
12
  EXCLUDED_COLUMNS = %w[rqid sqnr].freeze
13
- UUID_REGEX = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/
14
13
 
15
14
  # PrependInputs provides formtastic input overrides
16
15
  module PrependInputs
@@ -20,7 +19,6 @@ module Bp3
20
19
  return super unless builder.respond_to?(:viz)
21
20
  return nil if column.name.in?(EXCLUDED_COLUMNS)
22
21
 
23
- builder.id&.gsub(/_#{UUID_REGEX}/, '')
24
22
  viz = builder.viz(field_name, dom_id)
25
23
  return nil if viz.present? && !viz.show_element
26
24
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bp3
4
4
  module Formtastic
5
- VERSION = '0.2.2'
5
+ VERSION = '0.2.3'
6
6
  end
7
7
  end
@@ -27,8 +27,14 @@ module Bp3
27
27
 
28
28
  private
29
29
 
30
+ # Filed under the site load_vizfacts reads from, so the next render finds the record, and under
31
+ # that site's tenant and workspace. Left to the model's defaults, a page acting on a target site
32
+ # would take its site, tenant or workspace from the target instead.
30
33
  def vizfact_attrs(element_name, element_ident)
31
34
  {
35
+ sites_site: site,
36
+ tenant: template.controller.send(:current_tenant),
37
+ workspaces_workspace: template.controller.send(:current_workspace),
32
38
  element_controller: template.controller.class.name,
33
39
  element_action: template.controller.action_name,
34
40
  element_name:,
@@ -40,13 +46,16 @@ module Bp3
40
46
  def load_vizfacts
41
47
  return if input_control_class.nil?
42
48
 
43
- site = template.controller.send(:current_site)
44
49
  controller = template.controller.class.name
45
50
  action = template.controller.action_name
46
51
  @vizfacts = input_control_class.where(sites_site: site, element_controller: controller,
47
52
  element_action: action).to_a
48
53
  end
49
54
 
55
+ def site
56
+ @site ||= template.controller.send(:current_site)
57
+ end
58
+
50
59
  def input_control_class
51
60
  Bp3::Formtastic.input_control_class
52
61
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bp3-formtastic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wim den Braven
@@ -173,6 +173,7 @@ files:
173
173
  - ".rubocop.yml"
174
174
  - ".yardopts"
175
175
  - CHANGELOG.md
176
+ - CLAUDE.md
176
177
  - Gemfile
177
178
  - Gemfile.lock
178
179
  - LICENSE.txt
@@ -209,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
210
  - !ruby/object:Gem::Version
210
211
  version: '0'
211
212
  requirements: []
212
- rubygems_version: 3.6.9
213
+ rubygems_version: 4.0.4
213
214
  specification_version: 4
214
215
  summary: bp3-formtastic adapts formtastic for BP3 (persuavis/black_phoebe_3).
215
216
  test_files: []