well_formed 0.1.0

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.
Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/.rubocop.yml +12 -0
  4. data/.standard.yml +3 -0
  5. data/CHANGELOG.md +5 -0
  6. data/CODE_OF_CONDUCT.md +132 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +869 -0
  9. data/Rakefile +36 -0
  10. data/Steepfile +17 -0
  11. data/gems/well_formed-pundit/.rspec +3 -0
  12. data/gems/well_formed-pundit/Gemfile +13 -0
  13. data/gems/well_formed-pundit/README.md +73 -0
  14. data/gems/well_formed-pundit/Rakefile +12 -0
  15. data/gems/well_formed-pundit/lib/well_formed/pundit/version.rb +7 -0
  16. data/gems/well_formed-pundit/lib/well_formed/pundit.rb +25 -0
  17. data/gems/well_formed-pundit/lib/well_formed-pundit.rb +8 -0
  18. data/gems/well_formed-pundit/spec/spec_helper.rb +13 -0
  19. data/gems/well_formed-pundit/spec/well_formed/pundit_integration_spec.rb +101 -0
  20. data/gems/well_formed-pundit/spec/well_formed/pundit_spec.rb +80 -0
  21. data/gems/well_formed-pundit/well_formed-pundit.gemspec +28 -0
  22. data/lib/generators/resource_form_generator.rb +26 -0
  23. data/lib/generators/templates/form.rb.tt +28 -0
  24. data/lib/well_formed/action_form.rb +7 -0
  25. data/lib/well_formed/attribute_assignment.rb +42 -0
  26. data/lib/well_formed/collections.rb +114 -0
  27. data/lib/well_formed/errors.rb +16 -0
  28. data/lib/well_formed/initializer.rb +31 -0
  29. data/lib/well_formed/nested_attributes.rb +194 -0
  30. data/lib/well_formed/nested_form.rb +14 -0
  31. data/lib/well_formed/performer.rb +57 -0
  32. data/lib/well_formed/persistence.rb +61 -0
  33. data/lib/well_formed/railtie.rb +9 -0
  34. data/lib/well_formed/record_identity.rb +32 -0
  35. data/lib/well_formed/resource_form.rb +7 -0
  36. data/lib/well_formed/simple_action.rb +14 -0
  37. data/lib/well_formed/simple_nested_form.rb +12 -0
  38. data/lib/well_formed/simple_resource.rb +14 -0
  39. data/lib/well_formed/simple_struct.rb +29 -0
  40. data/lib/well_formed/struct.rb +7 -0
  41. data/lib/well_formed/transactional.rb +38 -0
  42. data/lib/well_formed/translations.rb +30 -0
  43. data/lib/well_formed/version.rb +5 -0
  44. data/lib/well_formed/with_user.rb +43 -0
  45. data/lib/well_formed.rb +38 -0
  46. data/rbs_collection.yaml +19 -0
  47. data/sig/well_formed.rbs +129 -0
  48. metadata +105 -0
@@ -0,0 +1,129 @@
1
+ module WellFormed
2
+ VERSION: String
3
+
4
+ # Interface for objects that can be used as the `resource` argument to a form.
5
+ # Matches the subset of ActiveModel/ActiveRecord that form modules depend on.
6
+ interface _ActiveModelLike
7
+ def id: () -> untyped
8
+ def persisted?: () -> bool
9
+ def save: () -> bool
10
+ def errors: () -> ::ActiveModel::Errors
11
+ def valid?: (?untyped context) -> bool
12
+ end
13
+
14
+ class Error < StandardError
15
+ end
16
+
17
+ class UnmatchedAttributesError < Error
18
+ end
19
+
20
+ class RecordInvalid < Error
21
+ attr_reader record: untyped
22
+
23
+ def initialize: (untyped record) -> void
24
+ end
25
+
26
+ # Resource form without a user argument.
27
+ # Inherit from this when no authentication context is needed.
28
+ class SimpleResource
29
+ include _ActiveModelLike
30
+
31
+ def self.resource_alias: (::Class | ::Symbol | ::String resource) -> void
32
+ def self.unmatched_attributes: (:ignore | :warn | :raise mode) -> void
33
+ def self.merge_model_errors: () -> void
34
+ def self.save_within_transaction: () -> void
35
+ def self.nested_attributes_for: (::Symbol name, ?::Class form_class) ?{ () -> void } -> void
36
+ def self.nested_attribute_for: (::Symbol name, ?::Class form_class) ?{ () -> void } -> void
37
+ def initialize: (::WellFormed::_ActiveModelLike resource, ?::Hash[::Symbol | ::String, untyped] params) -> void
38
+
39
+ attr_reader resource: ::WellFormed::_ActiveModelLike
40
+
41
+ def id: () -> untyped
42
+ def persisted?: () -> bool
43
+ def new_record?: () -> bool
44
+ def to_param: () -> ::String?
45
+
46
+ def save: () -> bool
47
+ def save!: () -> bool
48
+ def submit: () -> (::WellFormed::_ActiveModelLike | false)
49
+ def submit!: () -> ::WellFormed::_ActiveModelLike
50
+ end
51
+
52
+ # Resource form with a user argument.
53
+ # Inherit from this for standard create/update flows.
54
+ class ResourceForm < SimpleResource
55
+ def self.nested_attributes_for: (::Symbol name, ?::Class form_class) ?{ () -> void } -> void
56
+ def self.nested_attribute_for: (::Symbol name, ?::Class form_class) ?{ () -> void } -> void
57
+
58
+ def initialize: (::WellFormed::_ActiveModelLike resource, untyped user, ?::Hash[::Symbol | ::String, untyped] params) -> void
59
+
60
+ attr_reader user: untyped
61
+ end
62
+
63
+ # Action form without a user argument.
64
+ # Inherit from this when no authentication context is needed.
65
+ class SimpleAction
66
+ def self.resource_alias: (::Class | ::Symbol | ::String resource) -> void
67
+ def self.nested_attributes_for: (::Symbol name, ?::Class form_class) ?{ () -> void } -> void
68
+ def self.nested_attribute_for: (::Symbol name, ?::Class form_class) ?{ () -> void } -> void
69
+
70
+ def initialize: (::WellFormed::_ActiveModelLike resource, ?::Hash[::Symbol | ::String, untyped] params) -> void
71
+
72
+ attr_reader resource: ::WellFormed::_ActiveModelLike
73
+
74
+ def id: () -> untyped
75
+ def persisted?: () -> bool
76
+ def new_record?: () -> bool
77
+ def to_param: () -> ::String?
78
+
79
+ def perform: () -> void
80
+ def submit: () -> bool
81
+ def submit!: () -> bool
82
+ end
83
+
84
+ # Action form with a user argument.
85
+ # Define a `perform` method; call `submit` or `submit!` to run it.
86
+ class ActionForm < SimpleAction
87
+ def self.nested_attributes_for: (::Symbol name, ?::Class form_class) ?{ () -> void } -> void
88
+ def self.nested_attribute_for: (::Symbol name, ?::Class form_class) ?{ () -> void } -> void
89
+
90
+ def initialize: (::WellFormed::_ActiveModelLike resource, untyped user, ?::Hash[::Symbol | ::String, untyped] params) -> void
91
+
92
+ attr_reader user: untyped
93
+ end
94
+
95
+ # Resource form for plain Ruby objects that may not fully implement the ActiveRecord interface.
96
+ # id and persisted? delegate to the resource if it responds to them, otherwise return nil/false.
97
+ # Does not support save_within_transaction (no ActiveRecord transaction available).
98
+ class SimpleStruct
99
+ def self.resource_alias: (::Class | ::Symbol | ::String resource) -> void
100
+ def self.unmatched_attributes: (:ignore | :warn | :raise mode) -> void
101
+ def self.merge_model_errors: () -> void
102
+ def self.nested_attributes_for: (::Symbol name, ?::Class form_class) ?{ () -> void } -> void
103
+ def self.nested_attribute_for: (::Symbol name, ?::Class form_class) ?{ () -> void } -> void
104
+
105
+ def initialize: (::WellFormed::_ActiveModelLike resource, ?::Hash[::Symbol | ::String, untyped] params) -> void
106
+
107
+ attr_reader resource: ::WellFormed::_ActiveModelLike
108
+
109
+ def id: () -> untyped
110
+ def persisted?: () -> bool
111
+ def new_record?: () -> bool
112
+ def to_param: () -> ::String?
113
+
114
+ def save: () -> bool
115
+ def save!: () -> bool
116
+ def submit: () -> (::WellFormed::_ActiveModelLike | false)
117
+ def submit!: () -> ::WellFormed::_ActiveModelLike
118
+ end
119
+
120
+ # SimpleStruct with a user argument.
121
+ class Struct < SimpleStruct
122
+ def self.nested_attributes_for: (::Symbol name, ?::Class form_class) ?{ () -> void } -> void
123
+ def self.nested_attribute_for: (::Symbol name, ?::Class form_class) ?{ () -> void } -> void
124
+
125
+ def initialize: (::WellFormed::_ActiveModelLike resource, untyped user, ?::Hash[::Symbol | ::String, untyped] params) -> void
126
+
127
+ attr_reader user: untyped
128
+ end
129
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: well_formed
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ben Morrall
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: activemodel
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
26
+ description: WellFormed provides tools to create and manage form objects in Rails
27
+ applications, including support for nested resources, validations, callbacks, and
28
+ error handling.
29
+ email:
30
+ - bemo56@hotmail.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - ".rspec"
36
+ - ".rubocop.yml"
37
+ - ".standard.yml"
38
+ - CHANGELOG.md
39
+ - CODE_OF_CONDUCT.md
40
+ - LICENSE.txt
41
+ - README.md
42
+ - Rakefile
43
+ - Steepfile
44
+ - gems/well_formed-pundit/.rspec
45
+ - gems/well_formed-pundit/Gemfile
46
+ - gems/well_formed-pundit/README.md
47
+ - gems/well_formed-pundit/Rakefile
48
+ - gems/well_formed-pundit/lib/well_formed-pundit.rb
49
+ - gems/well_formed-pundit/lib/well_formed/pundit.rb
50
+ - gems/well_formed-pundit/lib/well_formed/pundit/version.rb
51
+ - gems/well_formed-pundit/spec/spec_helper.rb
52
+ - gems/well_formed-pundit/spec/well_formed/pundit_integration_spec.rb
53
+ - gems/well_formed-pundit/spec/well_formed/pundit_spec.rb
54
+ - gems/well_formed-pundit/well_formed-pundit.gemspec
55
+ - lib/generators/resource_form_generator.rb
56
+ - lib/generators/templates/form.rb.tt
57
+ - lib/well_formed.rb
58
+ - lib/well_formed/action_form.rb
59
+ - lib/well_formed/attribute_assignment.rb
60
+ - lib/well_formed/collections.rb
61
+ - lib/well_formed/errors.rb
62
+ - lib/well_formed/initializer.rb
63
+ - lib/well_formed/nested_attributes.rb
64
+ - lib/well_formed/nested_form.rb
65
+ - lib/well_formed/performer.rb
66
+ - lib/well_formed/persistence.rb
67
+ - lib/well_formed/railtie.rb
68
+ - lib/well_formed/record_identity.rb
69
+ - lib/well_formed/resource_form.rb
70
+ - lib/well_formed/simple_action.rb
71
+ - lib/well_formed/simple_nested_form.rb
72
+ - lib/well_formed/simple_resource.rb
73
+ - lib/well_formed/simple_struct.rb
74
+ - lib/well_formed/struct.rb
75
+ - lib/well_formed/transactional.rb
76
+ - lib/well_formed/translations.rb
77
+ - lib/well_formed/version.rb
78
+ - lib/well_formed/with_user.rb
79
+ - rbs_collection.yaml
80
+ - sig/well_formed.rbs
81
+ homepage: https://github.com/bmorrall/well_formed
82
+ licenses:
83
+ - MIT
84
+ metadata:
85
+ homepage_uri: https://github.com/bmorrall/well_formed
86
+ source_code_uri: https://github.com/bmorrall/well_formed
87
+ changelog_uri: https://github.com/bmorrall/well_formed/CHANGELOG.md
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: 3.1.0
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubygems_version: 3.6.9
103
+ specification_version: 4
104
+ summary: Form objects for Rails applications.
105
+ test_files: []