compony 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/.ruby-version +1 -0
  4. data/.yardopts +2 -0
  5. data/Gemfile +3 -0
  6. data/Gemfile.lock +208 -0
  7. data/LICENSE +165 -0
  8. data/README.md +33 -0
  9. data/Rakefile +34 -0
  10. data/app/controllers/compony_controller.rb +31 -0
  11. data/compony.gemspec +32 -0
  12. data/config/locales/de.yml +29 -0
  13. data/config/locales/en.yml +29 -0
  14. data/config/routes.rb +18 -0
  15. data/doc/resourceful_lifecycle.graphml +819 -0
  16. data/doc/resourceful_lifecycle.pdf +1564 -0
  17. data/lib/compony/component.rb +225 -0
  18. data/lib/compony/component_mixins/default/labelling.rb +77 -0
  19. data/lib/compony/component_mixins/default/standalone/resourceful_verb_dsl.rb +55 -0
  20. data/lib/compony/component_mixins/default/standalone/standalone_dsl.rb +56 -0
  21. data/lib/compony/component_mixins/default/standalone/verb_dsl.rb +47 -0
  22. data/lib/compony/component_mixins/default/standalone.rb +117 -0
  23. data/lib/compony/component_mixins/resourceful.rb +92 -0
  24. data/lib/compony/components/button.rb +59 -0
  25. data/lib/compony/components/form.rb +138 -0
  26. data/lib/compony/components/resourceful/destroy.rb +77 -0
  27. data/lib/compony/components/resourceful/edit.rb +96 -0
  28. data/lib/compony/components/resourceful/new.rb +95 -0
  29. data/lib/compony/components/with_form.rb +37 -0
  30. data/lib/compony/controller_mixin.rb +12 -0
  31. data/lib/compony/engine.rb +19 -0
  32. data/lib/compony/method_accessible_hash.rb +43 -0
  33. data/lib/compony/model_fields/anchormodel.rb +28 -0
  34. data/lib/compony/model_fields/association.rb +53 -0
  35. data/lib/compony/model_fields/base.rb +63 -0
  36. data/lib/compony/model_fields/boolean.rb +9 -0
  37. data/lib/compony/model_fields/currency.rb +9 -0
  38. data/lib/compony/model_fields/date.rb +9 -0
  39. data/lib/compony/model_fields/datetime.rb +9 -0
  40. data/lib/compony/model_fields/decimal.rb +6 -0
  41. data/lib/compony/model_fields/float.rb +6 -0
  42. data/lib/compony/model_fields/integer.rb +6 -0
  43. data/lib/compony/model_fields/phone.rb +15 -0
  44. data/lib/compony/model_fields/rich_text.rb +9 -0
  45. data/lib/compony/model_fields/string.rb +6 -0
  46. data/lib/compony/model_fields/text.rb +6 -0
  47. data/lib/compony/model_fields/time.rb +6 -0
  48. data/lib/compony/model_mixin.rb +88 -0
  49. data/lib/compony/request_context.rb +45 -0
  50. data/lib/compony/version.rb +11 -0
  51. data/lib/compony/view_helpers.rb +36 -0
  52. data/lib/compony.rb +268 -0
  53. data/lib/generators/component/USAGE +8 -0
  54. data/lib/generators/component/component_generator.rb +14 -0
  55. data/lib/generators/component/templates/component.rb.erb +4 -0
  56. metadata +236 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 85db41ccf7cece62891a703bb4e79c1e4e4a5a14fd87cc5ea0955df633184d60
4
+ data.tar.gz: 15bbcb498d877f9b9932c77b867f3ae28215f21b37db213a05e6073752674f8a
5
+ SHA512:
6
+ metadata.gz: b84a06879a6e6c85682f92bfdfd0afd3243614312231e12b3c8f201b75799eb4b077a953b945f3da8c581011e9d0a3e9a27721b5ffe3087a4d6aca1831940e9a
7
+ data.tar.gz: 403aaad21bb3853be4cfd8ed19c571910e6fac0a1e27193fc4e9177f48d9a313d6adac2339dd8e4ec530e064f8262e1de75283117583e8ef83292bdc0c1188bf
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ .rubocop.yml
2
+ .yardoc
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.1.3
data/.yardopts ADDED
@@ -0,0 +1,2 @@
1
+ --markup=markdown
2
+ --protected
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,208 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ compony (0.0.1.edge)
5
+ anchormodel (~> 0.1.2)
6
+ cancancan (~> 3.4.0)
7
+ dslblend (>= 0.0.3)
8
+ dyny (>= 0.0.3)
9
+ request_store (>= 1.5)
10
+ schemacop (>= 3.0.17)
11
+ simple_form (>= 5.1.0)
12
+
13
+ GEM
14
+ remote: https://rubygems.org/
15
+ specs:
16
+ actioncable (7.0.4.2)
17
+ actionpack (= 7.0.4.2)
18
+ activesupport (= 7.0.4.2)
19
+ nio4r (~> 2.0)
20
+ websocket-driver (>= 0.6.1)
21
+ actionmailbox (7.0.4.2)
22
+ actionpack (= 7.0.4.2)
23
+ activejob (= 7.0.4.2)
24
+ activerecord (= 7.0.4.2)
25
+ activestorage (= 7.0.4.2)
26
+ activesupport (= 7.0.4.2)
27
+ mail (>= 2.7.1)
28
+ net-imap
29
+ net-pop
30
+ net-smtp
31
+ actionmailer (7.0.4.2)
32
+ actionpack (= 7.0.4.2)
33
+ actionview (= 7.0.4.2)
34
+ activejob (= 7.0.4.2)
35
+ activesupport (= 7.0.4.2)
36
+ mail (~> 2.5, >= 2.5.4)
37
+ net-imap
38
+ net-pop
39
+ net-smtp
40
+ rails-dom-testing (~> 2.0)
41
+ actionpack (7.0.4.2)
42
+ actionview (= 7.0.4.2)
43
+ activesupport (= 7.0.4.2)
44
+ rack (~> 2.0, >= 2.2.0)
45
+ rack-test (>= 0.6.3)
46
+ rails-dom-testing (~> 2.0)
47
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
48
+ actiontext (7.0.4.2)
49
+ actionpack (= 7.0.4.2)
50
+ activerecord (= 7.0.4.2)
51
+ activestorage (= 7.0.4.2)
52
+ activesupport (= 7.0.4.2)
53
+ globalid (>= 0.6.0)
54
+ nokogiri (>= 1.8.5)
55
+ actionview (7.0.4.2)
56
+ activesupport (= 7.0.4.2)
57
+ builder (~> 3.1)
58
+ erubi (~> 1.4)
59
+ rails-dom-testing (~> 2.0)
60
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
61
+ activejob (7.0.4.2)
62
+ activesupport (= 7.0.4.2)
63
+ globalid (>= 0.3.6)
64
+ activemodel (7.0.4.2)
65
+ activesupport (= 7.0.4.2)
66
+ activerecord (7.0.4.2)
67
+ activemodel (= 7.0.4.2)
68
+ activesupport (= 7.0.4.2)
69
+ activestorage (7.0.4.2)
70
+ actionpack (= 7.0.4.2)
71
+ activejob (= 7.0.4.2)
72
+ activerecord (= 7.0.4.2)
73
+ activesupport (= 7.0.4.2)
74
+ marcel (~> 1.0)
75
+ mini_mime (>= 1.1.0)
76
+ activesupport (7.0.4.2)
77
+ concurrent-ruby (~> 1.0, >= 1.0.2)
78
+ i18n (>= 1.6, < 2)
79
+ minitest (>= 5.1)
80
+ tzinfo (~> 2.0)
81
+ anchormodel (0.1.2)
82
+ rails (~> 7.0)
83
+ ast (2.4.2)
84
+ builder (3.2.4)
85
+ cancancan (3.4.0)
86
+ concurrent-ruby (1.2.2)
87
+ crass (1.0.6)
88
+ date (3.3.3)
89
+ dslblend (0.0.3)
90
+ dyny (0.0.3)
91
+ rails
92
+ erubi (1.12.0)
93
+ globalid (1.1.0)
94
+ activesupport (>= 5.0)
95
+ i18n (1.12.0)
96
+ concurrent-ruby (~> 1.0)
97
+ json (2.6.3)
98
+ loofah (2.19.1)
99
+ crass (~> 1.0.2)
100
+ nokogiri (>= 1.5.9)
101
+ mail (2.8.1)
102
+ mini_mime (>= 0.1.1)
103
+ net-imap
104
+ net-pop
105
+ net-smtp
106
+ marcel (1.0.2)
107
+ method_source (1.0.0)
108
+ mini_mime (1.1.2)
109
+ minitest (5.18.0)
110
+ net-imap (0.3.4)
111
+ date
112
+ net-protocol
113
+ net-pop (0.1.2)
114
+ net-protocol
115
+ net-protocol (0.2.1)
116
+ timeout
117
+ net-smtp (0.3.3)
118
+ net-protocol
119
+ nio4r (2.5.8)
120
+ nokogiri (1.14.2-x86_64-linux)
121
+ racc (~> 1.4)
122
+ parallel (1.22.1)
123
+ parser (3.2.1.1)
124
+ ast (~> 2.4.1)
125
+ racc (1.6.2)
126
+ rack (2.2.6.3)
127
+ rack-test (2.0.2)
128
+ rack (>= 1.3)
129
+ rails (7.0.4.2)
130
+ actioncable (= 7.0.4.2)
131
+ actionmailbox (= 7.0.4.2)
132
+ actionmailer (= 7.0.4.2)
133
+ actionpack (= 7.0.4.2)
134
+ actiontext (= 7.0.4.2)
135
+ actionview (= 7.0.4.2)
136
+ activejob (= 7.0.4.2)
137
+ activemodel (= 7.0.4.2)
138
+ activerecord (= 7.0.4.2)
139
+ activestorage (= 7.0.4.2)
140
+ activesupport (= 7.0.4.2)
141
+ bundler (>= 1.15.0)
142
+ railties (= 7.0.4.2)
143
+ rails-dom-testing (2.0.3)
144
+ activesupport (>= 4.2.0)
145
+ nokogiri (>= 1.6)
146
+ rails-html-sanitizer (1.5.0)
147
+ loofah (~> 2.19, >= 2.19.1)
148
+ railties (7.0.4.2)
149
+ actionpack (= 7.0.4.2)
150
+ activesupport (= 7.0.4.2)
151
+ method_source
152
+ rake (>= 12.2)
153
+ thor (~> 1.0)
154
+ zeitwerk (~> 2.5)
155
+ rainbow (3.1.1)
156
+ rake (13.0.6)
157
+ regexp_parser (2.7.0)
158
+ request_store (1.5.1)
159
+ rack (>= 1.4)
160
+ rexml (3.2.5)
161
+ rubocop (1.48.0)
162
+ json (~> 2.3)
163
+ parallel (~> 1.10)
164
+ parser (>= 3.2.0.0)
165
+ rainbow (>= 2.2.2, < 4.0)
166
+ regexp_parser (>= 1.8, < 3.0)
167
+ rexml (>= 3.2.5, < 4.0)
168
+ rubocop-ast (>= 1.26.0, < 2.0)
169
+ ruby-progressbar (~> 1.7)
170
+ unicode-display_width (>= 2.4.0, < 3.0)
171
+ rubocop-ast (1.27.0)
172
+ parser (>= 3.2.1.0)
173
+ rubocop-rails (2.18.0)
174
+ activesupport (>= 4.2.0)
175
+ rack (>= 1.1)
176
+ rubocop (>= 1.33.0, < 2.0)
177
+ ruby-progressbar (1.13.0)
178
+ ruby2_keywords (0.0.4)
179
+ schemacop (3.0.22)
180
+ activesupport (>= 4.0)
181
+ ruby2_keywords (= 0.0.4)
182
+ simple_form (5.2.0)
183
+ actionpack (>= 5.2)
184
+ activemodel (>= 5.2)
185
+ thor (1.2.1)
186
+ timeout (0.3.2)
187
+ tzinfo (2.0.6)
188
+ concurrent-ruby (~> 1.0)
189
+ unicode-display_width (2.4.2)
190
+ webrick (1.7.0)
191
+ websocket-driver (0.7.5)
192
+ websocket-extensions (>= 0.1.0)
193
+ websocket-extensions (0.1.5)
194
+ yard (0.9.28)
195
+ webrick (~> 1.7.0)
196
+ zeitwerk (2.6.7)
197
+
198
+ PLATFORMS
199
+ x86_64-linux
200
+
201
+ DEPENDENCIES
202
+ compony!
203
+ rubocop (>= 1.48)
204
+ rubocop-rails (>= 2.18.0)
205
+ yard (>= 0.9.28)
206
+
207
+ BUNDLED WITH
208
+ 2.3.26
data/LICENSE ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ TODO: Write this
2
+
3
+ Notes:
4
+
5
+ - `model` is an ApplicationModel or similar (e.g. ActiveType, but not guarantted to work at this point), `.model_name` is important
6
+ - `data` can be model or models
7
+ - To redirect instead of rendering, use `before_render` if the redirect is conditional (e.g. if validation passes), or `respond` if always redirecting.
8
+ - As a rule of thumb, use `before_render` if there is a `content` block (even by inheritance) and `respond` otherwise.
9
+ - To protect a custom controller by compony authentication, use in the controller: `before_action Compony.authentication_before_action`
10
+
11
+ Feature sets:
12
+
13
+ - Base feature: Components
14
+ - replace routes, views and controllers
15
+ - actions
16
+ - params and nesting
17
+ - skipping authentication
18
+ - lifecycle
19
+ - standalone
20
+ - resourcefulness
21
+ - authorization
22
+ - Buttons and links
23
+ - labelling
24
+ - coloring
25
+ - Fields and field groups
26
+ - Feasibility
27
+ - Premade components
28
+ - button
29
+ - destroy
30
+ - form
31
+ - with_form
32
+ - new
33
+ - edit
data/Rakefile ADDED
@@ -0,0 +1,34 @@
1
+ require 'bundler/gem_tasks'
2
+ require_relative 'lib/compony/version'
3
+
4
+ task :gemspec do
5
+ specification = Gem::Specification.new do |s|
6
+ s.name = 'compony'
7
+ s.version = Compony::Version::LABEL
8
+ s.author = ['Sandro Kalbermatter', 'contributors']
9
+ s.summary = 'Needs summary'
10
+ s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
11
+ s.executables = []
12
+ s.require_paths = ['lib']
13
+ s.required_ruby_version = '>= 3.0.0'
14
+
15
+ # Dependencies
16
+ s.add_development_dependency 'yard', '>= 0.9.28'
17
+ s.add_development_dependency 'rubocop', '>= 1.48'
18
+ s.add_development_dependency 'rubocop-rails', '>= 2.18.0'
19
+
20
+ s.add_runtime_dependency 'request_store', '>= 1.5'
21
+ s.add_runtime_dependency 'dyny', '>= 0.0.3'
22
+ s.add_runtime_dependency 'schemacop', '>= 3.0.17'
23
+ s.add_runtime_dependency 'simple_form', '>= 5.1.0'
24
+ s.add_runtime_dependency 'dslblend', '>= 0.0.3'
25
+ s.add_runtime_dependency 'anchormodel', '~> 0.1.2'
26
+ s.add_runtime_dependency 'cancancan', '~> 3.4.0'
27
+ end
28
+
29
+ File.open('compony.gemspec', 'w') do |f|
30
+ f.puts('# DO NOT EDIT')
31
+ f.puts("# This file is auto-generated via: 'rake gemspec'.\n\n")
32
+ f.write(specification.to_ruby.strip)
33
+ end
34
+ end
@@ -0,0 +1,31 @@
1
+ class ComponyController < ApplicationController
2
+ # Init
3
+ actions_without_authentication = []
4
+
5
+ # Define a controller action for each route
6
+ Components.constants.each do |family_cst|
7
+ Components.const_get(family_cst).constants.each do |comp_cst|
8
+ # Instanciate the component for later information extraction
9
+ comp = Components.const_get(family_cst).const_get(comp_cst).new
10
+
11
+ # Standalone configs are already grouped in a hash, one entry per name/path
12
+ comp.standalone_configs.each_value do |standalone_config|
13
+ # Ignore incomplete standalone configs (these come from parent classes )
14
+ next if standalone_config[:path].blank?
15
+
16
+ # Define controller action for each standalone config
17
+ define_method(standalone_config.rails_action_name) do
18
+ verb_config = standalone_config.verbs[request.raw_request_method.downcase.to_sym]
19
+ Compony.comp_class_for!(comp_cst, family_cst).new.on_standalone_access(verb_config, self)
20
+ end
21
+
22
+ # Disable authentication for marked standalone configs
23
+ actions_without_authentication << standalone_config.rails_action_name.to_sym if standalone_config.skip_authentication
24
+ end
25
+ end
26
+ end
27
+
28
+ if Compony.authentication_before_action.present?
29
+ before_action Compony.authentication_before_action, except: actions_without_authentication
30
+ end
31
+ end
data/compony.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ # DO NOT EDIT
2
+ # This file is auto-generated via: 'rake gemspec'.
3
+
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: compony 0.0.1 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "compony".freeze
9
+ s.version = "0.0.1"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib".freeze]
13
+ s.authors = ["Sandro Kalbermatter".freeze, "contributors".freeze]
14
+ s.date = "2023-05-12"
15
+ s.files = [".gitignore".freeze, ".ruby-version".freeze, ".yardopts".freeze, "Gemfile".freeze, "Gemfile.lock".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "app/controllers/compony_controller.rb".freeze, "compony.gemspec".freeze, "config/locales/de.yml".freeze, "config/locales/en.yml".freeze, "config/routes.rb".freeze, "doc/resourceful_lifecycle.graphml".freeze, "doc/resourceful_lifecycle.pdf".freeze, "lib/compony.rb".freeze, "lib/compony/component.rb".freeze, "lib/compony/component_mixins/default/labelling.rb".freeze, "lib/compony/component_mixins/default/standalone.rb".freeze, "lib/compony/component_mixins/default/standalone/resourceful_verb_dsl.rb".freeze, "lib/compony/component_mixins/default/standalone/standalone_dsl.rb".freeze, "lib/compony/component_mixins/default/standalone/verb_dsl.rb".freeze, "lib/compony/component_mixins/resourceful.rb".freeze, "lib/compony/components/button.rb".freeze, "lib/compony/components/form.rb".freeze, "lib/compony/components/resourceful/destroy.rb".freeze, "lib/compony/components/resourceful/edit.rb".freeze, "lib/compony/components/resourceful/new.rb".freeze, "lib/compony/components/with_form.rb".freeze, "lib/compony/controller_mixin.rb".freeze, "lib/compony/engine.rb".freeze, "lib/compony/method_accessible_hash.rb".freeze, "lib/compony/model_fields/anchormodel.rb".freeze, "lib/compony/model_fields/association.rb".freeze, "lib/compony/model_fields/base.rb".freeze, "lib/compony/model_fields/boolean.rb".freeze, "lib/compony/model_fields/currency.rb".freeze, "lib/compony/model_fields/date.rb".freeze, "lib/compony/model_fields/datetime.rb".freeze, "lib/compony/model_fields/decimal.rb".freeze, "lib/compony/model_fields/float.rb".freeze, "lib/compony/model_fields/integer.rb".freeze, "lib/compony/model_fields/phone.rb".freeze, "lib/compony/model_fields/rich_text.rb".freeze, "lib/compony/model_fields/string.rb".freeze, "lib/compony/model_fields/text.rb".freeze, "lib/compony/model_fields/time.rb".freeze, "lib/compony/model_mixin.rb".freeze, "lib/compony/request_context.rb".freeze, "lib/compony/version.rb".freeze, "lib/compony/view_helpers.rb".freeze, "lib/generators/component/USAGE".freeze, "lib/generators/component/component_generator.rb".freeze, "lib/generators/component/templates/component.rb.erb".freeze]
16
+ s.required_ruby_version = Gem::Requirement.new(">= 3.0.0".freeze)
17
+ s.rubygems_version = "3.4.10".freeze
18
+ s.summary = "Needs summary".freeze
19
+
20
+ s.specification_version = 4
21
+
22
+ s.add_development_dependency(%q<yard>.freeze, [">= 0.9.28"])
23
+ s.add_development_dependency(%q<rubocop>.freeze, [">= 1.48"])
24
+ s.add_development_dependency(%q<rubocop-rails>.freeze, [">= 2.18.0"])
25
+ s.add_runtime_dependency(%q<request_store>.freeze, [">= 1.5"])
26
+ s.add_runtime_dependency(%q<dyny>.freeze, [">= 0.0.3"])
27
+ s.add_runtime_dependency(%q<schemacop>.freeze, [">= 3.0.17"])
28
+ s.add_runtime_dependency(%q<simple_form>.freeze, [">= 5.1.0"])
29
+ s.add_runtime_dependency(%q<dslblend>.freeze, [">= 0.0.3"])
30
+ s.add_runtime_dependency(%q<anchormodel>.freeze, ["~> 0.1.2"])
31
+ s.add_runtime_dependency(%q<cancancan>.freeze, ["~> 3.4.0"])
32
+ end
@@ -0,0 +1,29 @@
1
+ de:
2
+ compony:
3
+ filtered: '[Filtered]' # Not translated as this appears in log
4
+ boolean:
5
+ true: 'Ja'
6
+ false: 'Nein'
7
+ feasibility:
8
+ has_dependent_models: 'es gibt abhängige %{dependent_class}'
9
+ components:
10
+ form:
11
+ submit: 'Senden'
12
+ cancel: 'Abbrechen'
13
+ edit:
14
+ label:
15
+ long: '%{data_label} bearbeiten'
16
+ short: 'Bearbeiten'
17
+ data_was_updated: '%{data_label} wurde gespeichert.'
18
+ new:
19
+ label:
20
+ long: '%{data_class} erstellen'
21
+ short: 'Neu'
22
+ data_was_created: '%{data_label} wurde erstellt.'
23
+ destroy:
24
+ label:
25
+ long: '%{data_label} löschen'
26
+ short: 'Löschen'
27
+ confirm_question: 'Möchten Sie %{data_label} wirklich löschen?'
28
+ confirm_button: 'Ja, löschen'
29
+ data_was_destroyed: '%{data_label} wurde gelöscht.'
@@ -0,0 +1,29 @@
1
+ en:
2
+ compony:
3
+ filtered: '[Filtered]'
4
+ boolean:
5
+ yes: 'Yes'
6
+ no: 'No'
7
+ feasibility:
8
+ has_dependent_models: 'there are dependent %{dependent_class}'
9
+ components:
10
+ form:
11
+ submit: 'Submit'
12
+ cancel: 'Cancel'
13
+ edit:
14
+ label:
15
+ long: 'Edit %{data_label}'
16
+ short: 'Edit'
17
+ data_was_updated: '%{data_label} was updated.'
18
+ new:
19
+ label:
20
+ long: 'New %{data_class}'
21
+ short: 'New'
22
+ data_was_created: '%{data_label} was created.'
23
+ destroy:
24
+ label:
25
+ long: 'Delete %{data_label}'
26
+ short: 'Delete'
27
+ confirm_question: 'Do you really want to delete %{data_label}?'
28
+ confirm_button: 'Yes, delete'
29
+ data_was_destroyed: '%{data_label} was deleted.'
data/config/routes.rb ADDED
@@ -0,0 +1,18 @@
1
+ Rails.application.routes.draw do
2
+ # For every standalone and verb registered by every component, add a route comp#family_component
3
+ Components.constants.each do |family_cst|
4
+ Components.const_get(family_cst).constants.each do |comp_cst|
5
+ comp = Components.const_get(family_cst).const_get(comp_cst).new
6
+ # Standalone configs are already grouped in a hash, one entry per name/path
7
+ comp.standalone_configs.each_value do |standalone_config|
8
+ next if standalone_config[:path].blank? # Ignore incomplete standalone configs (these come from parent classes )
9
+ match(
10
+ standalone_config.path,
11
+ to: "compony##{standalone_config.rails_action_name}",
12
+ as: standalone_config.path_helper_name,
13
+ via: standalone_config.verbs.keys
14
+ )
15
+ end
16
+ end
17
+ end
18
+ end