plutonium 0.6.0 → 0.6.2

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: c8fb31a8eb4837634d28b3b0f602b06494991cdcdc02fc600888d0fecf8c497e
4
- data.tar.gz: 4c62d88f641d1890785cac1f6bf483b78e334fd2646bf91b21b3a5a53bd20b2c
3
+ metadata.gz: fe1b52c5dbab833dce2d44ad1a133f97458051032c9e2ffeae6d711e33b8905a
4
+ data.tar.gz: 0d8a0c2cd5303360eb63afe3f589707d13f87633c4d27b969fff585e63d2ce01
5
5
  SHA512:
6
- metadata.gz: cdc10f0c4d1f23a8fe565968d674d41fd8f9ee0aa43b6a1007ac8bca40897d1f0ee48189230b6aa742d1df53c7055e57eee960a29f265cebeb18160d6b8b73c3
7
- data.tar.gz: 745dfeb89b822d2ba1181050ad3a78de32084361a19664b2f8dc8ab3bbdbff87e4eebae40cec02ebeaed1b966654edab646d6b1570a29eb64147b557ff8d75d8
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 +1,4 @@
1
- # Configure plutonium here
1
+ # Configure plutonium
2
+
3
+ # Spin up the reactor!
4
+ Plutonium::Reactor::Core.achieve_criticality!
@@ -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 -%>
@@ -5,8 +5,6 @@ module Plutonium
5
5
  # add railties here
6
6
 
7
7
  initializer "plutonium.achieve_criticality" do
8
- # get the ball rolling
9
- Plutonium::Reactor::Core.achieve_criticality!
10
8
  end
11
9
  end
12
10
  end
@@ -9,19 +9,19 @@ module Plutonium
9
9
  # Core actions
10
10
 
11
11
  def create?
12
- true
12
+ false
13
13
  end
14
14
 
15
15
  def read?
16
- true
16
+ false
17
17
  end
18
18
 
19
19
  def update?
20
- true
20
+ create?
21
21
  end
22
22
 
23
23
  def destroy?
24
- true
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 :permitted_attributes_for_create
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
- strong_parameters_definition.slice(*attributes).map { |key, value| value.nil? ? key : {key => value} }
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
- parameters.merge! belongs_to_association_field_names.map { |name| [name, nil] }.to_h
137
- parameters.merge! has_one_association_field_names.map { |name| [name, nil] }.to_h
138
- parameters.merge! has_one_attached_field_names.map { |name| [name, nil] }.to_h
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! has_many_association_field_names.map { |name| [name, []] }.to_h
141
- parameters.merge! has_many_attached_field_names.map { |name| [name, []] }.to_h
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
- # e.g. {:title=>nil, :body=>nil, :state=>nil, :created_at=>nil, :updated_at=>nil, :image=>nil, :images=>[]}
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
@@ -1,3 +1,3 @@
1
1
  module Plutonium
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.2"
3
3
  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.6.0
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-20 00:00:00.000000000 Z
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