plutonium 0.12.13 → 0.12.14

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: 0c1a74bfd77765d7aeb19904303c8cf548d2fbd1f98bc66ea5a6fa5abae855ef
4
- data.tar.gz: cb49f49ed6f309e9afe7f922f968d2833cef6da89af2cab1fe8fcd4d893f4ee1
3
+ metadata.gz: f4b31c772d5b1e3f12bf1fb06a7afac636e4e6e57c111696a55b556b5b8d60bd
4
+ data.tar.gz: e6550284a757229c4ec8224cfad143fa53ef16df34b39027339377564d9fbd3c
5
5
  SHA512:
6
- metadata.gz: 91d30795a525042b1d63b605ad57d4b5bda2e7a3367e488244dad219024797f02281c51e0974d2e443390d98beef5eaaada1a82dcaa6d243f6b77095339d6064
7
- data.tar.gz: 79269b68bb7411b330b07e7b9e62f31d4c8a3d1ba5bff5a5bdc23cbe30f5a2e347484c7764c8b1582bfccdf217d5a6d0f21689f5658534632fe22ad127fb1e71
6
+ metadata.gz: 93cc559ce299fb4faeca4a3b34fa27d2ce8005e857f500d2b9c260be29b522ce098d03ce52dc772ae8ceed7ca1c2ee2327b3f4360aab99b0417ef7a1d5c705d4
7
+ data.tar.gz: 1bd4ed50f0f6f356ff9ed4f207d9b7c0abb07f99d803d8ea5c05c77d3349ef3909411e98549657bffe8198d64620341164225253c1ace1a51cecd5d9f90b2382
data/Appraisals ADDED
@@ -0,0 +1,11 @@
1
+ appraise "rails-7" do
2
+ gem "rails", "~> 7.1.3", ">= 7.1.3.4"
3
+ # gem "sprockets-rails"
4
+ gem "sqlite3", "~> 1.4"
5
+ gem "puma", ">= 5.0"
6
+ gem "importmap-rails"
7
+ gem "turbo-rails"
8
+ gem "stimulus-rails"
9
+ gem "tzinfo-data", platforms: %i[ windows jruby ]
10
+ # gem "bootsnap", require: false
11
+ end
data/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  [![Ruby](https://github.com/radioactive-labs/plutonium-core/actions/workflows/main.yml/badge.svg)](https://github.com/radioactive-labs/plutonium-core/actions/workflows/main.yml)
4
4
 
5
+ Watch the introduction video: [Plutonium in 30 minutes](https://www.youtube.com/watch?v=HMjzj-vVLIU)
6
+
7
+ ---
8
+
5
9
  **Plutonium** picks up where Rails left off, introducing application level concepts and tooling, transforming the way you build applications with Rails.
6
10
  It's a culmination of lessons learned from years of developing nearly identical applications and is designed to save you from the drudgery of re-implementation.
7
11
 
data/Rakefile CHANGED
@@ -1,11 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
2
+ require "rake/testtask"
6
3
  require "standard/rake"
7
4
 
8
- task default: %i[spec standard]
5
+ task default: %i[test standard]
9
6
 
10
7
  task :assets do
11
8
  `npm run build`
@@ -13,3 +10,10 @@ end
13
10
 
14
11
  # https://stackoverflow.com/questions/15707940/rake-before-task-hook
15
12
  Rake::Task["build"].enhance ["assets"]
13
+
14
+ # https://juincc.medium.com/how-to-setup-minitest-for-your-gems-development-f29c4bee13c2
15
+ Rake::TestTask.new do |t|
16
+ t.libs << "test"
17
+ t.test_files = FileList["test/**/*_test.rb"]
18
+ t.verbose = true
19
+ end
@@ -1,4 +1,4 @@
1
- <%= render_component(:sidebar) do %>
1
+ <%= render_component(:sidebar, id: "#{current_engine.dom_id}-drawer") do %>
2
2
  <%=
3
3
  render_component(:sidebar_menu) do |menu|
4
4
  menu.with_item(name: "Dashboard", url: root_path, icon: "outline/home")
@@ -1,4 +1,4 @@
1
- <%= resource_form_for resource_url_args_for(form.record), html: {class: "flex flex-col space-y-6 px-4 py-2"} do |f| %>
1
+ <%= resource_form_for form.record, html: {class: "flex flex-col space-y-6 px-4 py-2"} do |f| %>
2
2
  <h2 class="mb-4 text-xl font-bold text-gray-900 dark:text-gray-200"><%= f.submit_default_value %></h2>
3
3
 
4
4
  <% if f.object.errors.present? %>
@@ -70,5 +70,4 @@
70
70
  </div>
71
71
  </div>
72
72
  </div>
73
-
74
73
  <% end %>
@@ -1,4 +1,4 @@
1
- <%= resource_form_for interaction, as: :interaction, method: :post, url: "", html: {class: "flex flex-col space-y-6 px-4 py-2"} do |f| %>
1
+ <%= resource_form_for interaction, url: "", as: :interaction, method: :post, html: {class: "flex flex-col space-y-6 px-4 py-2"} do |f| %>
2
2
  <h2 class="mb-4 text-xl font-bold text-gray-900 dark:text-gray-200"><%= interactive_action.name.to_s.titleize %></h2>
3
3
 
4
4
  <% if f.object.errors.present? %>
@@ -3,9 +3,9 @@
3
3
  <div class="flex justify-start items-center">
4
4
  <% if sidebar_toggle %>
5
5
  <button
6
- data-drawer-target="drawer-navigation"
7
- data-drawer-toggle="drawer-navigation"
8
- aria-controls="drawer-navigation"
6
+ data-drawer-target="<%= sidebar_toggle %>"
7
+ data-drawer-toggle="<%= sidebar_toggle %>"
8
+ aria-controls="<%= sidebar_toggle %>"
9
9
  class="p-2 mr-2 text-gray-600 rounded-lg cursor-pointer lg:hidden hover:text-gray-900 hover:bg-gray-100 focus:bg-gray-100 dark:focus:bg-gray-700 focus:ring-2 focus:ring-gray-100 dark:focus:ring-gray-700 dark:text-gray-200 dark:hover:bg-gray-700 dark:hover:text-white">
10
10
  <svg
11
11
  aria-hidden="true"
@@ -5,7 +5,7 @@ module PlutoniumUi
5
5
 
6
6
  option :brand_name, optional: true
7
7
  option :default_brand_logo, default: -> { true }
8
- option :sidebar_toggle, default: -> { false }
8
+ option :sidebar_toggle, default: -> {}
9
9
 
10
10
  private
11
11
 
@@ -1,9 +1,4 @@
1
- <aside
2
- id="drawer-navigation"
3
- class="<%= sidebar_class %>"
4
- aria-label="Sidenav"
5
- data-turbo-permanent
6
- >
1
+ <aside <%= attributes_html %>>
7
2
  <div class="<%= sidebar_container_class %>">
8
3
  <%= content %>
9
4
  </div>
@@ -2,12 +2,20 @@ module PlutoniumUi
2
2
  class SidebarComponent < PlutoniumUi::Base
3
3
  private
4
4
 
5
- def sidebar_class
6
- "fixed top-0 left-0 z-40 w-64 h-screen pt-14 transition-transform -translate-x-full lg:translate-x-0"
5
+ def base_attributes
6
+ # base attributes go here
7
+ {
8
+ id: "sidebar-navigation",
9
+ controller: "",
10
+ aria: {label: "Sidebar Navigation"},
11
+ data: {turbo_permanent: true},
12
+ class: "fixed top-0 left-0 z-40 w-64 h-screen pt-14 transition-transform -translate-x-full lg:translate-x-0",
13
+ sidebar_container_class: "overflow-y-auto py-5 px-3 h-full bg-white border-r border-gray-200 dark:bg-gray-800 dark:border-gray-700"
14
+ }
7
15
  end
8
16
 
9
17
  def sidebar_container_class
10
- "overflow-y-auto py-5 px-3 h-full bg-white border-r border-gray-200 dark:bg-gray-800 dark:border-gray-700"
18
+ raw_attributes_hash[:sidebar_container_class]
11
19
  end
12
20
  end
13
21
  end
@@ -5,7 +5,7 @@
5
5
  <% end %>
6
6
 
7
7
  <% layout.with_header do %>
8
- <%= render("resource_header", sidebar_toggle: true) %>
8
+ <%= render("resource_header", sidebar_toggle: "#{current_engine.dom_id}-drawer") %>
9
9
  <% end %>
10
10
 
11
11
  <% layout.with_sidebar do %>
@@ -4,10 +4,10 @@
4
4
  <%= turbo_frame_tag "modal" do %>
5
5
  <div class="modal" tabindex="-1" data-controller="modal">
6
6
  <div class="modal-dialog modal-dialog-scrollable modal-lg">
7
- <%= resource_form_for @interaction, as: :interaction,
8
- method: :post,
9
- turbo_frame: :modal,
10
- url: "" do |f| %>
7
+ <%= resource_form_for @interaction, url: "",
8
+ as: :interaction,
9
+ method: :post,
10
+ turbo_frame: :modal do |f| %>
11
11
  <div class="modal-content">
12
12
  <div class="modal-header">
13
13
  <h1 class="modal-title fs-5"><%= interactive_action.name.to_s.titleize %></h1>
data/config.ru ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rubygems"
4
+ require "bundler"
5
+
6
+ Bundler.require :default, :development
7
+
8
+ Combustion.initialize! :all
9
+ run Combustion::Application
@@ -0,0 +1,13 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 7.1.3", ">= 7.1.3.4"
6
+ gem "sqlite3", "~> 1.4"
7
+ gem "puma", ">= 5.0"
8
+ gem "importmap-rails"
9
+ gem "turbo-rails"
10
+ gem "stimulus-rails"
11
+ gem "tzinfo-data", platforms: [:windows, :jruby]
12
+
13
+ gemspec path: "../"
@@ -0,0 +1,335 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ plutonium (0.12.13)
5
+ active_interaction (~> 5.3)
6
+ dry-initializer (~> 3.1)
7
+ listen (~> 3.8)
8
+ pagy (~> 7.0)
9
+ pundit (~> 2.3)
10
+ rabl (~> 0.16.1)
11
+ rails (>= 7.1, < 8.0)
12
+ semantic_range (~> 3.0)
13
+ simple_form (~> 5.3)
14
+ tty-prompt (~> 0.23.1)
15
+ view_component (~> 3)
16
+ view_component-form (~> 0.2.6)
17
+ zeitwerk
18
+
19
+ GEM
20
+ remote: https://rubygems.org/
21
+ specs:
22
+ actioncable (7.1.3.4)
23
+ actionpack (= 7.1.3.4)
24
+ activesupport (= 7.1.3.4)
25
+ nio4r (~> 2.0)
26
+ websocket-driver (>= 0.6.1)
27
+ zeitwerk (~> 2.6)
28
+ actionmailbox (7.1.3.4)
29
+ actionpack (= 7.1.3.4)
30
+ activejob (= 7.1.3.4)
31
+ activerecord (= 7.1.3.4)
32
+ activestorage (= 7.1.3.4)
33
+ activesupport (= 7.1.3.4)
34
+ mail (>= 2.7.1)
35
+ net-imap
36
+ net-pop
37
+ net-smtp
38
+ actionmailer (7.1.3.4)
39
+ actionpack (= 7.1.3.4)
40
+ actionview (= 7.1.3.4)
41
+ activejob (= 7.1.3.4)
42
+ activesupport (= 7.1.3.4)
43
+ mail (~> 2.5, >= 2.5.4)
44
+ net-imap
45
+ net-pop
46
+ net-smtp
47
+ rails-dom-testing (~> 2.2)
48
+ actionpack (7.1.3.4)
49
+ actionview (= 7.1.3.4)
50
+ activesupport (= 7.1.3.4)
51
+ nokogiri (>= 1.8.5)
52
+ racc
53
+ rack (>= 2.2.4)
54
+ rack-session (>= 1.0.1)
55
+ rack-test (>= 0.6.3)
56
+ rails-dom-testing (~> 2.2)
57
+ rails-html-sanitizer (~> 1.6)
58
+ actiontext (7.1.3.4)
59
+ actionpack (= 7.1.3.4)
60
+ activerecord (= 7.1.3.4)
61
+ activestorage (= 7.1.3.4)
62
+ activesupport (= 7.1.3.4)
63
+ globalid (>= 0.6.0)
64
+ nokogiri (>= 1.8.5)
65
+ actionview (7.1.3.4)
66
+ activesupport (= 7.1.3.4)
67
+ builder (~> 3.1)
68
+ erubi (~> 1.11)
69
+ rails-dom-testing (~> 2.2)
70
+ rails-html-sanitizer (~> 1.6)
71
+ active_interaction (5.3.0)
72
+ activemodel (>= 5.2, < 8)
73
+ activesupport (>= 5.2, < 8)
74
+ activejob (7.1.3.4)
75
+ activesupport (= 7.1.3.4)
76
+ globalid (>= 0.3.6)
77
+ activemodel (7.1.3.4)
78
+ activesupport (= 7.1.3.4)
79
+ activerecord (7.1.3.4)
80
+ activemodel (= 7.1.3.4)
81
+ activesupport (= 7.1.3.4)
82
+ timeout (>= 0.4.0)
83
+ activestorage (7.1.3.4)
84
+ actionpack (= 7.1.3.4)
85
+ activejob (= 7.1.3.4)
86
+ activerecord (= 7.1.3.4)
87
+ activesupport (= 7.1.3.4)
88
+ marcel (~> 1.0)
89
+ activesupport (7.1.3.4)
90
+ base64
91
+ bigdecimal
92
+ concurrent-ruby (~> 1.0, >= 1.0.2)
93
+ connection_pool (>= 2.2.5)
94
+ drb
95
+ i18n (>= 1.6, < 2)
96
+ minitest (>= 5.1)
97
+ mutex_m
98
+ tzinfo (~> 2.0)
99
+ ansi (1.5.0)
100
+ appraisal (2.5.0)
101
+ bundler
102
+ rake
103
+ thor (>= 0.14.0)
104
+ ast (2.4.2)
105
+ base64 (0.2.0)
106
+ bigdecimal (3.1.8)
107
+ brakeman (6.1.2)
108
+ racc
109
+ builder (3.3.0)
110
+ bundle-audit (0.1.0)
111
+ bundler-audit
112
+ bundler-audit (0.9.1)
113
+ bundler (>= 1.2.0, < 3)
114
+ thor (~> 1.0)
115
+ combustion (1.4.0)
116
+ activesupport (>= 3.0.0)
117
+ railties (>= 3.0.0)
118
+ thor (>= 0.14.6)
119
+ concurrent-ruby (1.3.3)
120
+ connection_pool (2.4.1)
121
+ crass (1.0.6)
122
+ date (3.3.4)
123
+ drb (2.2.1)
124
+ dry-initializer (3.1.1)
125
+ erubi (1.12.0)
126
+ ffi (1.17.0-x86_64-darwin)
127
+ globalid (1.2.1)
128
+ activesupport (>= 6.1)
129
+ i18n (1.14.5)
130
+ concurrent-ruby (~> 1.0)
131
+ importmap-rails (2.0.1)
132
+ actionpack (>= 6.0.0)
133
+ activesupport (>= 6.0.0)
134
+ railties (>= 6.0.0)
135
+ io-console (0.7.2)
136
+ irb (1.13.1)
137
+ rdoc (>= 4.0.0)
138
+ reline (>= 0.4.2)
139
+ json (2.7.2)
140
+ language_server-protocol (3.17.0.3)
141
+ lint_roller (1.1.0)
142
+ listen (3.9.0)
143
+ rb-fsevent (~> 0.10, >= 0.10.3)
144
+ rb-inotify (~> 0.9, >= 0.9.10)
145
+ loofah (2.22.0)
146
+ crass (~> 1.0.2)
147
+ nokogiri (>= 1.12.0)
148
+ mail (2.8.1)
149
+ mini_mime (>= 0.1.1)
150
+ net-imap
151
+ net-pop
152
+ net-smtp
153
+ marcel (1.0.4)
154
+ method_source (1.1.0)
155
+ mini_mime (1.1.5)
156
+ minitest (5.23.1)
157
+ minitest-reporters (1.6.1)
158
+ ansi
159
+ builder
160
+ minitest (>= 5.0)
161
+ ruby-progressbar
162
+ mutex_m (0.2.0)
163
+ net-imap (0.4.12)
164
+ date
165
+ net-protocol
166
+ net-pop (0.1.2)
167
+ net-protocol
168
+ net-protocol (0.2.2)
169
+ timeout
170
+ net-smtp (0.5.0)
171
+ net-protocol
172
+ nio4r (2.7.3)
173
+ nokogiri (1.16.5-x86_64-darwin)
174
+ racc (~> 1.4)
175
+ pagy (7.0.11)
176
+ parallel (1.25.1)
177
+ parser (3.3.2.0)
178
+ ast (~> 2.4.1)
179
+ racc
180
+ pastel (0.8.0)
181
+ tty-color (~> 0.5)
182
+ psych (5.1.2)
183
+ stringio
184
+ puma (6.4.2)
185
+ nio4r (~> 2.0)
186
+ pundit (2.3.2)
187
+ activesupport (>= 3.0.0)
188
+ rabl (0.16.1)
189
+ activesupport (>= 2.3.14)
190
+ racc (1.8.0)
191
+ rack (3.1.3)
192
+ rack-session (2.0.0)
193
+ rack (>= 3.0.0)
194
+ rack-test (2.1.0)
195
+ rack (>= 1.3)
196
+ rackup (2.1.0)
197
+ rack (>= 3)
198
+ webrick (~> 1.8)
199
+ rails (7.1.3.4)
200
+ actioncable (= 7.1.3.4)
201
+ actionmailbox (= 7.1.3.4)
202
+ actionmailer (= 7.1.3.4)
203
+ actionpack (= 7.1.3.4)
204
+ actiontext (= 7.1.3.4)
205
+ actionview (= 7.1.3.4)
206
+ activejob (= 7.1.3.4)
207
+ activemodel (= 7.1.3.4)
208
+ activerecord (= 7.1.3.4)
209
+ activestorage (= 7.1.3.4)
210
+ activesupport (= 7.1.3.4)
211
+ bundler (>= 1.15.0)
212
+ railties (= 7.1.3.4)
213
+ rails-dom-testing (2.2.0)
214
+ activesupport (>= 5.0.0)
215
+ minitest
216
+ nokogiri (>= 1.6)
217
+ rails-html-sanitizer (1.6.0)
218
+ loofah (~> 2.21)
219
+ nokogiri (~> 1.14)
220
+ railties (7.1.3.4)
221
+ actionpack (= 7.1.3.4)
222
+ activesupport (= 7.1.3.4)
223
+ irb
224
+ rackup (>= 1.0.0)
225
+ rake (>= 12.2)
226
+ thor (~> 1.0, >= 1.2.2)
227
+ zeitwerk (~> 2.6)
228
+ rainbow (3.1.1)
229
+ rake (13.2.1)
230
+ rb-fsevent (0.11.2)
231
+ rb-inotify (0.11.1)
232
+ ffi (~> 1.0)
233
+ rdoc (6.7.0)
234
+ psych (>= 4.0.0)
235
+ regexp_parser (2.9.2)
236
+ reline (0.5.9)
237
+ io-console (~> 0.5)
238
+ rexml (3.3.0)
239
+ strscan
240
+ rubocop (1.63.5)
241
+ json (~> 2.3)
242
+ language_server-protocol (>= 3.17.0)
243
+ parallel (~> 1.10)
244
+ parser (>= 3.3.0.2)
245
+ rainbow (>= 2.2.2, < 4.0)
246
+ regexp_parser (>= 1.8, < 3.0)
247
+ rexml (>= 3.2.5, < 4.0)
248
+ rubocop-ast (>= 1.31.1, < 2.0)
249
+ ruby-progressbar (~> 1.7)
250
+ unicode-display_width (>= 2.4.0, < 3.0)
251
+ rubocop-ast (1.31.3)
252
+ parser (>= 3.3.1.0)
253
+ rubocop-performance (1.21.0)
254
+ rubocop (>= 1.48.1, < 2.0)
255
+ rubocop-ast (>= 1.31.1, < 2.0)
256
+ ruby-progressbar (1.13.0)
257
+ semantic_range (3.0.0)
258
+ simple_form (5.3.1)
259
+ actionpack (>= 5.2)
260
+ activemodel (>= 5.2)
261
+ sqlite3 (1.7.3-x86_64-darwin)
262
+ standard (1.36.0)
263
+ language_server-protocol (~> 3.17.0.2)
264
+ lint_roller (~> 1.0)
265
+ rubocop (~> 1.63.0)
266
+ standard-custom (~> 1.0.0)
267
+ standard-performance (~> 1.4)
268
+ standard-custom (1.0.2)
269
+ lint_roller (~> 1.0)
270
+ rubocop (~> 1.50)
271
+ standard-performance (1.4.0)
272
+ lint_roller (~> 1.1)
273
+ rubocop-performance (~> 1.21.0)
274
+ stimulus-rails (1.3.3)
275
+ railties (>= 6.0.0)
276
+ stringio (3.1.0)
277
+ strscan (3.1.0)
278
+ thor (1.3.1)
279
+ timeout (0.4.1)
280
+ tty-color (0.6.0)
281
+ tty-cursor (0.7.1)
282
+ tty-prompt (0.23.1)
283
+ pastel (~> 0.8)
284
+ tty-reader (~> 0.8)
285
+ tty-reader (0.9.0)
286
+ tty-cursor (~> 0.7)
287
+ tty-screen (~> 0.8)
288
+ wisper (~> 2.0)
289
+ tty-screen (0.8.2)
290
+ turbo-rails (2.0.5)
291
+ actionpack (>= 6.0.0)
292
+ activejob (>= 6.0.0)
293
+ railties (>= 6.0.0)
294
+ tzinfo (2.0.6)
295
+ concurrent-ruby (~> 1.0)
296
+ unicode-display_width (2.5.0)
297
+ view_component (3.12.1)
298
+ activesupport (>= 5.2.0, < 8.0)
299
+ concurrent-ruby (~> 1.0)
300
+ method_source (~> 1.0)
301
+ view_component-form (0.2.6)
302
+ actionview (>= 6.0.0, < 7.2)
303
+ activesupport (>= 6.0.0, < 7.2)
304
+ view_component (>= 2.34.0, < 4.0)
305
+ zeitwerk (~> 2.5)
306
+ webrick (1.8.1)
307
+ websocket-driver (0.7.6)
308
+ websocket-extensions (>= 0.1.0)
309
+ websocket-extensions (0.1.5)
310
+ wisper (2.0.1)
311
+ zeitwerk (2.6.15)
312
+
313
+ PLATFORMS
314
+ x86_64-darwin
315
+
316
+ DEPENDENCIES
317
+ appraisal
318
+ brakeman
319
+ bundle-audit
320
+ combustion
321
+ importmap-rails
322
+ minitest
323
+ minitest-reporters
324
+ plutonium!
325
+ puma (>= 5.0)
326
+ rails (~> 7.1.3, >= 7.1.3.4)
327
+ rake
328
+ sqlite3 (~> 1.4)
329
+ standard
330
+ stimulus-rails
331
+ turbo-rails
332
+ tzinfo-data
333
+
334
+ BUNDLED WITH
335
+ 2.5.6
@@ -35,18 +35,18 @@ module Plutonium
35
35
  end
36
36
 
37
37
  #
38
- # Returns a dynamic list of args to be used with `url_for` which considers the route namespace and nesting.
39
- # The current entity and parent record (for nested routes) are inserted appropriately, ensuring that generated urls
38
+ # Returns a dynamic list of args to be used with `url_for`, which considers the route namespace and nesting.
39
+ # The current entity and parent record (for nested routes) are inserted appropriately, ensuring that generated URLs
40
40
  # obey the current routing.
41
41
  #
42
- # e.g. of route helpers that will be invoked given the output of this method
42
+ # e.g., of route helpers that will be invoked given the output of this method
43
43
  #
44
44
  # - when invoked in a root route (/acme/dashboard/users)
45
45
  #
46
46
  # `resource_url_args_for User` => `entity_users_*`
47
47
  # `resource_url_args_for @user` => `entity_user_*`
48
48
  # `resource_url_args_for @user, action: :edit` => `edit_entity_user_*`
49
- # `resource_url_args_for @user, Post => `entity_user_posts_*`
49
+ # `resource_url_args_for @user, Post` => `entity_user_posts_*`
50
50
  #
51
51
  # - when invoked in a nested route (/acme/dashboard/users/1/post/1)
52
52
  #
@@ -55,26 +55,36 @@ module Plutonium
55
55
  # `resource_url_args_for @post, action: :edit` => `edit_entity_user_post_*`
56
56
  #
57
57
  # @param [Class, ApplicationRecord] *args arguments you would normally pass to `url_for`
58
- # @param [Symbol] action optional action to invoke e.g. :new, :edit
58
+ # @param [Symbol] action optional action to invoke, e.g., :new, :edit
59
+ # @param [ApplicationRecord] parent the parent record for nested routes, if any
60
+ # @param [Hash] kwargs additional keyword arguments to pass to `url_for`
59
61
  #
60
- # @return [Array[Class, ApplicationRecord, Symbol]] args to pass to `url_for`
62
+ # @return [Hash] args to pass to `url_for`
61
63
  #
62
64
  def resource_url_args_for(*args, action: nil, parent: nil, **kwargs)
63
- # If the last item is a class and the action is :new e.g. `resource_url User, action: :new`,
64
- # it must be converted into a symbol to generate the appropriate helper i.e `new_user_*`
65
- # to match the url helper generated by `resources :users`
66
- resource = args.pop
67
- resource = resource.model_name.singular_route_key.to_sym if action == :new && resource.is_a?(Class)
68
- args.push resource
69
-
70
- base_args = if scoped_to_entity? && scoped_entity_strategy == :path
71
- [action, current_scoped_entity.becomes(scoped_entity_class), parent]
72
- else
73
- [action, parent]
65
+ url_args = {**kwargs, action: action}.compact
66
+
67
+ controller_chain = [current_package.to_s]
68
+ [parent, *args].compact.each_with_index do |element, index|
69
+ if element.is_a?(Class)
70
+ controller_chain << element.to_s.pluralize
71
+ else
72
+ controller_chain << element.class.to_s.pluralize
73
+ if index == args.length - 1
74
+ url_args[:id] = element.to_param
75
+ url_args[:action] ||= :show
76
+ else
77
+ url_args[element.model_name.singular_route_key.to_sym] = element.to_param
78
+ end
79
+ end
80
+ end
81
+ url_args[:controller] = controller_chain.join("::").underscore
82
+
83
+ if scoped_to_entity? && scoped_entity_strategy == :path
84
+ url_args[scoped_entity_param_key] = current_scoped_entity
74
85
  end
75
86
 
76
- # rails compacts this list. no need to handle nils
77
- base_args + args + [**kwargs]
87
+ url_args
78
88
  end
79
89
 
80
90
  def resource_url_for(...)
@@ -6,7 +6,7 @@ module Plutonium
6
6
  private
7
7
 
8
8
  def input_options
9
- {wrapper: :resource_multi_select}
9
+ {wrapper: :resource_multi_select, include_blank: true}
10
10
  end
11
11
  end
12
12
  end
@@ -45,9 +45,9 @@ module Plutonium
45
45
  tag.span rendered, title:
46
46
  end
47
47
 
48
- def display_association_value(association)
49
- display_name = display_name_of(association)
50
- link_to display_name, resource_url_for(association, parent: nil),
48
+ def display_association_value(association_class)
49
+ display_name = display_name_of(association_class)
50
+ link_to display_name, resource_url_for(association_class, parent: nil),
51
51
  class: "font-medium text-primary-600 dark:text-primary-500"
52
52
  rescue NoMethodError
53
53
  display_name
@@ -5,13 +5,12 @@ module Plutonium
5
5
  module FormHelper
6
6
  include ActionView::Helpers::FormHelper
7
7
 
8
- def resource_form_for(record, options = {}, &block)
8
+ def resource_form_for(record, **options, &block)
9
+ options[:url] ||= resource_url_args_for(record, action: record.new_record? ? :create : :update)
9
10
  options[:builder] ||= PlutoniumUi::FormBuilder
10
11
  options[:wrapper] ||= :default_resource_form
11
12
  options[:html] ||= {}
12
- unless options[:html].key?(:novalidate)
13
- options[:html][:novalidate] = false
14
- end
13
+ options[:html][:novalidate] = false unless options[:html].key?(:novalidate)
15
14
 
16
15
  with_resource_form_field_error_proc do
17
16
  form_for(record, options, &block)
@@ -56,6 +56,10 @@ module Plutonium
56
56
  end
57
57
  end
58
58
 
59
+ def dom_id
60
+ module_parent_name.underscore.dasherize
61
+ end
62
+
59
63
  private
60
64
 
61
65
  def draw_resource_routes_internal
@@ -1,3 +1,3 @@
1
1
  module Plutonium
2
- VERSION = "0.12.13"
2
+ VERSION = "0.12.14"
3
3
  end
data/lib/plutonium.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "zeitwerk"
2
2
 
3
+ # Zeitwerk loader setup for the Plutonium gem
3
4
  loader = Zeitwerk::Loader.for_gem(warn_on_extra_files: false)
4
5
  loader.ignore("#{__dir__}/generators")
5
6
  loader.ignore("#{__dir__}/plutonium/railtie.rb")
@@ -9,37 +10,47 @@ loader.setup
9
10
  require_relative "plutonium/railtie" if defined?(Rails::Railtie)
10
11
 
11
12
  module Plutonium
13
+ # Custom error class for the Plutonium module
12
14
  class Error < StandardError; end
13
15
 
14
- def self.root
15
- Pathname.new File.expand_path("../", __dir__)
16
- end
17
-
18
- def self.lib_root
19
- root.join("lib", "plutonium")
20
- end
21
-
22
- def self.logger
23
- Rails.logger
24
- end
25
-
26
- def self.application_name
27
- @application_name || Rails.application.class.module_parent.name
28
- end
29
-
30
- def self.application_name=(application_name)
31
- @application_name = application_name
32
- end
33
-
34
- def self.development?
35
- ActiveModel::Type::Boolean.new.cast(ENV["PLUTONIUM_DEV"]).present?
36
- end
37
-
38
- def self.eager_load_rails!
39
- return if Rails.env.production? && defined?(@rails_eager_loaded)
40
-
41
- Rails.application.eager_load! unless Rails.application.config.eager_load
42
- @rails_eager_loaded = true
16
+ class << self
17
+ # @return [Pathname] the root directory of the gem
18
+ def root
19
+ Pathname.new(File.expand_path("..", __dir__))
20
+ end
21
+
22
+ # @return [Pathname] the root directory of the lib folder of the gem
23
+ def lib_root
24
+ root.join("lib", "plutonium")
25
+ end
26
+
27
+ # @return [Logger] the Rails logger
28
+ def logger
29
+ Rails.logger
30
+ end
31
+
32
+ # @return [String] the name of the application
33
+ def application_name
34
+ @application_name || Rails.application.class.module_parent_name
35
+ end
36
+
37
+ # @param [String] application_name the name of the application
38
+ # @return [void]
39
+ attr_writer :application_name
40
+
41
+ # @return [Boolean] whether the gem is in development mode
42
+ def development?
43
+ ActiveModel::Type::Boolean.new.cast(ENV["PLUTONIUM_DEV"]).present?
44
+ end
45
+
46
+ # Eager loads Rails application if not already eager loaded
47
+ # @return [void]
48
+ def eager_load_rails!
49
+ return if Rails.env.production? && defined?(@rails_eager_loaded)
50
+
51
+ Rails.application.eager_load! unless Rails.application.config.eager_load
52
+ @rails_eager_loaded = true
53
+ end
43
54
  end
44
55
  end
45
56
 
data/sig/plutonium.rbs CHANGED
@@ -1,4 +1,12 @@
1
+ # plutonium.rbs
1
2
  module Plutonium
2
- VERSION: String
3
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
3
+ class Error < StandardError; end
4
+
5
+ def self.root: () -> Pathname
6
+ def self.lib_root: () -> Pathname
7
+ def self.logger: () -> Logger
8
+ def self.application_name: () -> String
9
+ def self.application_name=: (String) -> void
10
+ def self.development?: () -> bool
11
+ def self.eager_load_rails!: () -> void
4
12
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plutonium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.13
4
+ version: 0.12.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Froelich
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-06-12 00:00:00.000000000 Z
11
+ date: 2024-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk
@@ -198,6 +198,118 @@ dependencies:
198
198
  - - "~>"
199
199
  - !ruby/object:Gem::Version
200
200
  version: 0.23.1
201
+ - !ruby/object:Gem::Dependency
202
+ name: rake
203
+ requirement: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - ">="
206
+ - !ruby/object:Gem::Version
207
+ version: '0'
208
+ type: :development
209
+ prerelease: false
210
+ version_requirements: !ruby/object:Gem::Requirement
211
+ requirements:
212
+ - - ">="
213
+ - !ruby/object:Gem::Version
214
+ version: '0'
215
+ - !ruby/object:Gem::Dependency
216
+ name: minitest
217
+ requirement: !ruby/object:Gem::Requirement
218
+ requirements:
219
+ - - ">="
220
+ - !ruby/object:Gem::Version
221
+ version: '0'
222
+ type: :development
223
+ prerelease: false
224
+ version_requirements: !ruby/object:Gem::Requirement
225
+ requirements:
226
+ - - ">="
227
+ - !ruby/object:Gem::Version
228
+ version: '0'
229
+ - !ruby/object:Gem::Dependency
230
+ name: minitest-reporters
231
+ requirement: !ruby/object:Gem::Requirement
232
+ requirements:
233
+ - - ">="
234
+ - !ruby/object:Gem::Version
235
+ version: '0'
236
+ type: :development
237
+ prerelease: false
238
+ version_requirements: !ruby/object:Gem::Requirement
239
+ requirements:
240
+ - - ">="
241
+ - !ruby/object:Gem::Version
242
+ version: '0'
243
+ - !ruby/object:Gem::Dependency
244
+ name: standard
245
+ requirement: !ruby/object:Gem::Requirement
246
+ requirements:
247
+ - - ">="
248
+ - !ruby/object:Gem::Version
249
+ version: '0'
250
+ type: :development
251
+ prerelease: false
252
+ version_requirements: !ruby/object:Gem::Requirement
253
+ requirements:
254
+ - - ">="
255
+ - !ruby/object:Gem::Version
256
+ version: '0'
257
+ - !ruby/object:Gem::Dependency
258
+ name: brakeman
259
+ requirement: !ruby/object:Gem::Requirement
260
+ requirements:
261
+ - - ">="
262
+ - !ruby/object:Gem::Version
263
+ version: '0'
264
+ type: :development
265
+ prerelease: false
266
+ version_requirements: !ruby/object:Gem::Requirement
267
+ requirements:
268
+ - - ">="
269
+ - !ruby/object:Gem::Version
270
+ version: '0'
271
+ - !ruby/object:Gem::Dependency
272
+ name: bundle-audit
273
+ requirement: !ruby/object:Gem::Requirement
274
+ requirements:
275
+ - - ">="
276
+ - !ruby/object:Gem::Version
277
+ version: '0'
278
+ type: :development
279
+ prerelease: false
280
+ version_requirements: !ruby/object:Gem::Requirement
281
+ requirements:
282
+ - - ">="
283
+ - !ruby/object:Gem::Version
284
+ version: '0'
285
+ - !ruby/object:Gem::Dependency
286
+ name: appraisal
287
+ requirement: !ruby/object:Gem::Requirement
288
+ requirements:
289
+ - - ">="
290
+ - !ruby/object:Gem::Version
291
+ version: '0'
292
+ type: :development
293
+ prerelease: false
294
+ version_requirements: !ruby/object:Gem::Requirement
295
+ requirements:
296
+ - - ">="
297
+ - !ruby/object:Gem::Version
298
+ version: '0'
299
+ - !ruby/object:Gem::Dependency
300
+ name: combustion
301
+ requirement: !ruby/object:Gem::Requirement
302
+ requirements:
303
+ - - ">="
304
+ - !ruby/object:Gem::Version
305
+ version: '0'
306
+ type: :development
307
+ prerelease: false
308
+ version_requirements: !ruby/object:Gem::Requirement
309
+ requirements:
310
+ - - ">="
311
+ - !ruby/object:Gem::Version
312
+ version: '0'
201
313
  description: Plutonium extends Rails' capabilities with a powerful, generator-driven
202
314
  toolkit designed to supercharge your development process. It transforms the way
203
315
  you build applications with Rails, optimizing for rapid application development.
@@ -216,6 +328,7 @@ files:
216
328
  - ".vscode/extensions.json"
217
329
  - ".vscode/launch.json"
218
330
  - ".vscode/settings.json"
331
+ - Appraisals
219
332
  - CHANGELOG.md
220
333
  - LICENSE.txt
221
334
  - README copy.md
@@ -844,12 +957,15 @@ files:
844
957
  - app/views/rodauth/webauthn_remove.html.erb
845
958
  - app/views/rodauth/webauthn_setup.html.erb
846
959
  - brakeman.ignore
960
+ - config.ru
847
961
  - config/initializers/hotwire_turbo_monkey_patches.rb
848
962
  - config/initializers/pagy.rb
849
963
  - config/initializers/rabl.rb
850
964
  - config/initializers/simple_form.rb
851
965
  - esbuild.config.js
852
966
  - exe/pug
967
+ - gemfiles/rails_7.gemfile
968
+ - gemfiles/rails_7.gemfile.lock
853
969
  - lib/active_model/validations/array_validator.rb
854
970
  - lib/active_model/validations/attached_validator.rb
855
971
  - lib/active_model/validations/url_validator.rb