plutonium 0.6.0 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/generators/pu/core/install/templates/config/initializers/plutonium.rb +4 -1
- data/lib/generators/pu/resource/model/templates/policy.rb.tt +19 -0
- data/lib/generators/pu/resource/model/templates/presenter.rb.tt +14 -0
- data/lib/plutonium/railtie.rb +0 -2
- data/lib/plutonium/reactor/resource_policy.rb +8 -8
- data/lib/plutonium/reactor/resource_record.rb +25 -8
- data/lib/plutonium/version.rb +1 -1
- metadata +2 -3
- data/plutonium.gemspec +0 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe1b52c5dbab833dce2d44ad1a133f97458051032c9e2ffeae6d711e33b8905a
|
4
|
+
data.tar.gz: 0d8a0c2cd5303360eb63afe3f589707d13f87633c4d27b969fff585e63d2ce01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b75c657f16496971051c751f2cedabad4c563cee6ebcc2ac6ccbf5cfea8c3fc969208ea788ab2db3fffd960bf618bf4fd74cb35fe79f2cf8c7b57a67b51c8a13
|
7
|
+
data.tar.gz: c199e3f8bd508a9998046ac2621587b2c41838b1de96de5f9271acc49be335caa5f90795b02a6aeacc5d4fcf07a750f9d6656361625c2695b4f900c3e99db45e
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Plutonium: Take Your Rails Productivity Nuclear
|
1
|
+
# Plutonium: Take Your Rails Productivity Nuclear🚀
|
2
2
|
|
3
3
|
**Plutonium** picks up where Rails left off, introducing application level concepts and tooling, transforming the way you build applications with Rails.
|
4
4
|
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.
|
@@ -1,4 +1,23 @@
|
|
1
1
|
<% module_namespacing do -%>
|
2
2
|
class <%= class_name %>Policy < <%= [feature_package_name, "ResourcePolicy"].join "::" %>
|
3
|
+
# Core actions
|
4
|
+
|
5
|
+
def create?
|
6
|
+
true
|
7
|
+
end
|
8
|
+
|
9
|
+
def read?
|
10
|
+
true
|
11
|
+
end
|
12
|
+
|
13
|
+
# Core attributes
|
14
|
+
|
15
|
+
def permitted_attributes_for_create
|
16
|
+
<%= (class_name.constantize.resource_field_names - [:created_at, :updated_at]).inspect %>
|
17
|
+
end
|
18
|
+
|
19
|
+
def permitted_attributes_for_read
|
20
|
+
<%= class_name.constantize.resource_field_names.inspect %>
|
21
|
+
end
|
3
22
|
end
|
4
23
|
<% end -%>
|
@@ -1,4 +1,18 @@
|
|
1
1
|
<% module_namespacing do -%>
|
2
2
|
class <%= class_name %>Presenter < <%= [feature_package_name, "ResourcePresenter"].join "::" %>
|
3
|
+
def search_field
|
4
|
+
# ransack search field
|
5
|
+
nil
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def define_fields
|
11
|
+
# custom field definitions
|
12
|
+
end
|
13
|
+
|
14
|
+
def define_actions
|
15
|
+
# custom action definitions
|
16
|
+
end
|
3
17
|
end
|
4
18
|
<% end -%>
|
data/lib/plutonium/railtie.rb
CHANGED
@@ -9,19 +9,19 @@ module Plutonium
|
|
9
9
|
# Core actions
|
10
10
|
|
11
11
|
def create?
|
12
|
-
|
12
|
+
false
|
13
13
|
end
|
14
14
|
|
15
15
|
def read?
|
16
|
-
|
16
|
+
false
|
17
17
|
end
|
18
18
|
|
19
19
|
def update?
|
20
|
-
|
20
|
+
create?
|
21
21
|
end
|
22
22
|
|
23
23
|
def destroy?
|
24
|
-
|
24
|
+
create?
|
25
25
|
end
|
26
26
|
|
27
27
|
# Inferred actions
|
@@ -45,7 +45,7 @@ module Plutonium
|
|
45
45
|
# Core attributes
|
46
46
|
|
47
47
|
def permitted_attributes_for_create
|
48
|
-
autodetect_fields_for :
|
48
|
+
autodetect_fields_for(:permitted_attributes_for_create) - [context.resource_context.resource_class.primary_key.to_sym, :created_at, :updated_at]
|
49
49
|
end
|
50
50
|
|
51
51
|
def permitted_attributes_for_read
|
@@ -74,9 +74,9 @@ module Plutonium
|
|
74
74
|
permitted_attributes_for_update
|
75
75
|
end
|
76
76
|
|
77
|
-
def permitted_associations
|
78
|
-
|
79
|
-
end
|
77
|
+
# def permitted_associations
|
78
|
+
# []
|
79
|
+
# end
|
80
80
|
|
81
81
|
private
|
82
82
|
|
@@ -94,7 +94,16 @@ module Plutonium
|
|
94
94
|
# [:title, :body, {:images=>[]}, {:docs=>[]}]
|
95
95
|
#
|
96
96
|
def strong_parameters_for(*attributes)
|
97
|
-
|
97
|
+
# {:name=>{:name=>nil}, :body=>{:body=>nil}, :cover_image=>{:cover_image=>nil}, :comments=>{:comment_ids=>[]}}
|
98
|
+
strong_parameters_definition
|
99
|
+
# {:name=>{:name=>nil}, :comments=>{:comment_ids=>[]}, :cover_image=>{:cover_image=>nil}}
|
100
|
+
.slice(*attributes)
|
101
|
+
# [{:name=>nil}, {:comment_ids=>[]}, {:cover_image=>nil}]
|
102
|
+
.values
|
103
|
+
# {:name=>nil, :comment_ids=>[], :cover_image=>nil}
|
104
|
+
.reduce(:merge)
|
105
|
+
# [:name, {:comment_ids=>[]}, :cover_image]
|
106
|
+
&.map { |key, value| value.nil? ? key : {key => value} } || {}
|
98
107
|
end
|
99
108
|
|
100
109
|
# Ransack
|
@@ -127,20 +136,28 @@ module Plutonium
|
|
127
136
|
type = [] if column&.try(:array?)
|
128
137
|
type = {} if [:json, :jsonb].include?(column&.type)
|
129
138
|
|
130
|
-
[name, type]
|
139
|
+
[name, {name => type}]
|
131
140
|
end
|
132
141
|
parameters = content_column_parameters.to_h
|
133
142
|
|
134
143
|
# TODO: add nested support
|
135
144
|
|
136
|
-
|
137
|
-
parameters.merge!
|
138
|
-
|
145
|
+
# TODO:
|
146
|
+
parameters.merge! reflect_on_all_associations(:belongs_to)
|
147
|
+
.map { |reflection|
|
148
|
+
input_param = (reflection.respond_to?(:options) && reflection.options[:foreign_key]) || :"#{reflection.name}_id"
|
149
|
+
[reflection.name, {input_param => nil}]
|
150
|
+
}
|
151
|
+
.to_h
|
139
152
|
|
140
|
-
parameters.merge!
|
141
|
-
parameters.merge!
|
153
|
+
parameters.merge! has_one_association_field_names.map { |name| [name, {name => nil}] }.to_h
|
154
|
+
parameters.merge! has_one_attached_field_names.map { |name| [name, {name => nil}] }.to_h
|
142
155
|
|
143
|
-
|
156
|
+
parameters.merge! has_many_association_field_names.map { |name| [name, {"#{name.to_s.singularize}_ids": []}] }.to_h
|
157
|
+
parameters.merge! has_many_attached_field_names.map { |name| [name, {name: []}] }.to_h
|
158
|
+
|
159
|
+
# e.g.
|
160
|
+
# {:name=>{:name=>nil}, :cover_image=>{:cover_image=>nil}, :user=>{:user_id=>nil} :comments=>{:comment_ids=>[]}}
|
144
161
|
parameters
|
145
162
|
end
|
146
163
|
end
|
data/lib/plutonium/version.rb
CHANGED
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.6.
|
4
|
+
version: 0.6.2
|
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-02-
|
11
|
+
date: 2024-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -486,7 +486,6 @@ files:
|
|
486
486
|
- lib/plutonium/simple_form_components/attachment_component.rb
|
487
487
|
- lib/plutonium/simple_form_components/input_group_component.rb
|
488
488
|
- lib/plutonium/version.rb
|
489
|
-
- plutonium.gemspec
|
490
489
|
- public/.keep
|
491
490
|
- public/plutonium-assets/application.css
|
492
491
|
- public/plutonium-assets/application.js
|
data/plutonium.gemspec
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
require_relative "lib/plutonium/version"
|
2
|
-
|
3
|
-
Gem::Specification.new do |spec|
|
4
|
-
spec.name = "plutonium"
|
5
|
-
spec.version = Plutonium::VERSION
|
6
|
-
spec.authors = ["Stefan Froelich"]
|
7
|
-
spec.email = ["sfroelich01@gmail.com"]
|
8
|
-
|
9
|
-
spec.summary = "The ultimate Rapid Application Development Toolkit (RADKit) for Rails application development"
|
10
|
-
spec.description = "Plutonium extends Rails' capabilities with a powerful, generator-driven toolkit designed to supercharge your development process. " \
|
11
|
-
"It transforms the way you build applications with Rails, optimizing for rapid application development."
|
12
|
-
spec.homepage = "https://github.com/radioactive-labs/plutonium-core"
|
13
|
-
spec.license = nil
|
14
|
-
spec.required_ruby_version = ">= 3.2.2"
|
15
|
-
|
16
|
-
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
17
|
-
|
18
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
19
|
-
spec.metadata["source_code_uri"] = "https://github.com/radioactive-labs/plutonium-core"
|
20
|
-
# spec.metadata["changelog_uri"] = "https://google.com"
|
21
|
-
|
22
|
-
# Specify which files should be added to the gem when it is released.
|
23
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
-
spec.files = Dir.chdir(__dir__) do
|
25
|
-
`git ls-files -z`.split("\x0").reject do |f|
|
26
|
-
(File.expand_path(f) == __FILE__) ||
|
27
|
-
f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile])
|
28
|
-
end
|
29
|
-
end
|
30
|
-
spec.bindir = "exe"
|
31
|
-
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
32
|
-
spec.require_paths = ["lib"]
|
33
|
-
|
34
|
-
spec.add_dependency "rails", ">= 7.1.2"
|
35
|
-
spec.add_dependency "listen", "~> 3.8"
|
36
|
-
spec.add_dependency "active_interaction", "~> 5.3"
|
37
|
-
spec.add_dependency "pundit", "~> 2.3"
|
38
|
-
spec.add_dependency "pagy", "~> 6.2"
|
39
|
-
spec.add_dependency "ransack", "~> 4.1"
|
40
|
-
spec.add_dependency "simple_form", "~> 5.3"
|
41
|
-
spec.add_dependency "rabl", "~> 0.16.1" # TODO: what to do with RABL
|
42
|
-
|
43
|
-
spec.add_development_dependency "brakeman"
|
44
|
-
|
45
|
-
# For more information and examples about making a new gem, check out our
|
46
|
-
# guide at: https://bundler.io/guides/creating_gem.html
|
47
|
-
end
|