field_struct 0.15.0 → 1.0.0.pre1
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 +4 -4
- data/.claude-plugin/marketplace.json +13 -0
- data/.claude-plugin/plugin.json +9 -0
- data/AGENTS.md +47 -54
- data/CHANGELOG.md +53 -640
- data/LICENSE.txt +21 -0
- data/README.md +33 -628
- data/USAGE.md +771 -715
- data/docs/getting_started.md +139 -325
- data/lib/field_struct/base.rb +241 -1149
- data/lib/field_struct/class_macros.rb +163 -0
- data/lib/field_struct/describer.rb +167 -0
- data/lib/field_struct/errors.rb +182 -62
- data/lib/field_struct/exceptions.rb +40 -0
- data/lib/field_struct/field.rb +69 -135
- data/lib/field_struct/field_builder.rb +110 -0
- data/lib/field_struct/field_checks.rb +50 -0
- data/lib/field_struct/introspection.rb +199 -0
- data/lib/field_struct/json_codec.rb +240 -0
- data/lib/field_struct/metadata.rb +65 -260
- data/lib/field_struct/model_name.rb +27 -27
- data/lib/field_struct/option_checker.rb +121 -0
- data/lib/field_struct/partial.rb +49 -0
- data/lib/field_struct/presence.rb +45 -0
- data/lib/field_struct/rbs.rb +151 -271
- data/lib/field_struct/registered_option.rb +113 -0
- data/lib/field_struct/registry.rb +40 -50
- data/lib/field_struct/restrictions.rb +90 -0
- data/lib/field_struct/scaffold.rb +274 -301
- data/lib/field_struct/suggestion.rb +33 -0
- data/lib/field_struct/types/array.rb +147 -126
- data/lib/field_struct/types/base.rb +113 -124
- data/lib/field_struct/types/big_decimal.rb +59 -55
- data/lib/field_struct/types/binary.rb +18 -25
- data/lib/field_struct/types/boolean.rb +74 -97
- data/lib/field_struct/types/builtin.rb +32 -0
- data/lib/field_struct/types/date.rb +23 -137
- data/lib/field_struct/types/datetime.rb +30 -139
- data/lib/field_struct/types/element_options.rb +51 -0
- data/lib/field_struct/types/email.rb +27 -38
- data/lib/field_struct/types/float.rb +58 -56
- data/lib/field_struct/types/format_presets.rb +30 -0
- data/lib/field_struct/types/hash.rb +144 -0
- data/lib/field_struct/types/immutable_string.rb +16 -9
- data/lib/field_struct/types/integer.rb +74 -102
- data/lib/field_struct/types/nested.rb +57 -58
- data/lib/field_struct/types/preset_resolver.rb +9 -24
- data/lib/field_struct/types/rfc3339_format.rb +70 -153
- data/lib/field_struct/types/string.rb +48 -46
- data/lib/field_struct/types/symbol.rb +23 -20
- data/lib/field_struct/types/temporal.rb +232 -0
- data/lib/field_struct/types/time.rb +32 -145
- data/lib/field_struct/types/union.rb +111 -65
- data/lib/field_struct/types/union_pick.rb +139 -0
- data/lib/field_struct/types/url.rb +24 -35
- data/lib/field_struct/types/uuid.rb +24 -35
- data/lib/field_struct/types/value.rb +14 -9
- data/lib/field_struct/types/zone.rb +118 -0
- data/lib/field_struct/version.rb +3 -3
- data/lib/field_struct.rb +102 -122
- data/sig/field_struct.rbs +1180 -2300
- data/sig/manifest.yaml +6 -0
- data/skills/field-struct/SKILL.md +73 -159
- metadata +37 -28
- data/CODE_OF_CONDUCT.md +0 -132
- data/UPGRADING.md +0 -743
- data/lib/field_struct/error.rb +0 -48
- data/lib/field_struct/types/temporal_parser.rb +0 -93
- data/lib/field_struct/types/time_format_resolver.rb +0 -54
- data/lib/field_struct/types/zone_option.rb +0 -267
data/sig/manifest.yaml
ADDED
|
@@ -1,183 +1,97 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: field-struct
|
|
3
|
-
description:
|
|
4
|
-
when_to_use:
|
|
3
|
+
description: Define, debug and type Ruby models built with the field_struct gem (typed plain objects with coerced, validated fields). Use when writing or changing a class that inherits FieldStruct::Base, reading its errors, or generating RBS for it.
|
|
4
|
+
when_to_use: The code requires 'field_struct', a class inherits FieldStruct::Base, or the user asks for typed Ruby value objects with declared fields, coercion and validation errors.
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
#
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
7
|
+
# field_struct
|
|
8
|
+
|
|
9
|
+
A model is a class that inherits `FieldStruct::Base` and declares fields. Every assignment coerces the value and records
|
|
10
|
+
errors; nothing raises unless the class says so.
|
|
11
|
+
|
|
12
|
+
The full reference ships with the gem. Read `USAGE.md` once before writing a model (`bundle exec gem contents field_struct | grep USAGE.md`,
|
|
13
|
+
or `bundle info field_struct` for the path). `docs/getting_started.md` has the task map and the error table.
|
|
14
|
+
|
|
15
|
+
## Define a model
|
|
16
|
+
|
|
17
|
+
1. List the fields and decide which are `required` (must be present) and which are `optional`.
|
|
18
|
+
2. Pick a type for each: `:string`, `:immutable_string`, `:integer`, `:float`, `:decimal` (or `:big_decimal`),
|
|
19
|
+
`:boolean`, `:symbol`, `:date`, `:time`, `:datetime`, `:uuid`, `:url`, `:email`, `:binary`, `:value` (anything),
|
|
20
|
+
`:array` (needs `of:`), `:hash` (String keys; needs `of:` for the values), `:union` (needs `of: [...]`;
|
|
21
|
+
`discriminator:` picks struct members by a tag), or another struct class for a nested field.
|
|
22
|
+
3. Add the options the type takes: `format:`, `enum:`, `in:`, `length:`, `round:`, `base:`, `strict:`, `values:`,
|
|
23
|
+
`zone:`, `element:`, `discriminator:`, `max_items:`. Universal ones: `default:`, `nullable:` (a required field that
|
|
24
|
+
may be sent as null), `coercion_policy:`, `description:` (or `desc:`), `rbs_type:`, `sensitive:`. An unknown option
|
|
25
|
+
key raises at declaration; adapter keys (`avro:`, `proto:`, `json_schema:`) work once that adapter is required.
|
|
26
|
+
For an option key your app reads itself, call `FieldStruct.register_option(:catalog, type: Hash, owner: 'my_app')`
|
|
27
|
+
before the classes that use it.
|
|
28
|
+
4. Add class settings if needed: `unknown_attributes :raise`, `coercion_policy :raise`, `json_omit :unset` (leave out
|
|
29
|
+
fields the caller didn't send), `immutable!`, `frozen!`, `mirror!` (a field of this class reads any object
|
|
30
|
+
through its public readers).
|
|
31
|
+
5. Add cross-field rules with `validate :method` (add messages to `errors[:base]`).
|
|
32
|
+
6. Add `serialize :json, field: 'externalName'` if the JSON names differ.
|
|
33
|
+
7. Check it: `Model.describe`, then build one from sample input and read `valid?` and `errors.to_h`.
|
|
25
34
|
|
|
26
35
|
```ruby
|
|
27
|
-
class
|
|
28
|
-
required :
|
|
29
|
-
optional :
|
|
30
|
-
optional :
|
|
31
|
-
optional :tags, :array, of: :string # arrays need `of:`
|
|
36
|
+
class Plant < FieldStruct::Base
|
|
37
|
+
required :species, :string
|
|
38
|
+
optional :leaves, :integer, in: 1..5000
|
|
39
|
+
optional :tags, :array, of: :string
|
|
32
40
|
end
|
|
33
|
-
|
|
34
|
-
u = User.new(name: 'Alice', age: '30') # Hash arg; Symbol or String keys both work
|
|
35
|
-
u.age # => 30 (coerced from "30")
|
|
36
|
-
u.valid? # => true
|
|
37
|
-
u.attributes # => { name: "Alice", age: 30, email: nil, tags: nil }
|
|
38
41
|
```
|
|
39
42
|
|
|
40
|
-
|
|
41
|
-
1. Subclass `FieldStruct::Base`.
|
|
42
|
-
2. Use `required` for presence-checked fields, `optional` (or bare `field`) otherwise.
|
|
43
|
-
3. Pick a **registered type symbol** — `:string :integer :float :big_decimal`
|
|
44
|
-
(`:decimal`) `:boolean :date :time :datetime :symbol :uuid :url :email :binary
|
|
45
|
-
:value :array :union` — or pass another `FieldStruct::Base` subclass for a nested
|
|
46
|
-
struct.
|
|
47
|
-
4. Add options (see scoping below). Common: `default:` (literal or a callable like
|
|
48
|
-
`-> { Time.now }`), `desc:`.
|
|
49
|
-
5. For composites: `:array` requires `of: <type>`; `:union` requires `of: [a, b, …]`
|
|
50
|
-
with ≥2 members; nested = pass the class.
|
|
51
|
-
|
|
52
|
-
## Mistakes to avoid (these are the ones that bite)
|
|
53
|
-
|
|
54
|
-
1. **Setters are permissive — don't "fix" them.** `user.age = "30"` is *valid*; the
|
|
55
|
-
type coerces. Readers are typed; writers accept anything coercible. `nil` passes
|
|
56
|
-
through as `nil` for nearly every type.
|
|
57
|
-
2. **`required` does NOT guarantee non-nil at runtime.** A required field can hold
|
|
58
|
-
`nil` (coercion failed, or `:replace` policy, or never assigned). Validity is
|
|
59
|
-
separate from construction — gate on `valid?`, never assume a required reader is
|
|
60
|
-
present.
|
|
61
|
-
3. **Whitespace-only strings count as "missing"** for `:string` and its subtypes
|
|
62
|
-
(`:uuid :url :email :immutable_string`). So `required :name, :string` with
|
|
63
|
-
`name: " "` is **invalid**. `:binary` is the exception (its whitespace bytes are
|
|
64
|
-
real data — only nil/empty are missing).
|
|
65
|
-
4. **`:array` needs `of:`; `:union` needs `of: [...]` (≥2).** Omitting raises
|
|
66
|
-
`ArgumentError` at class-definition time.
|
|
67
|
-
5. **Option scoping is enforced at declaration** (misuse raises `ArgumentError`):
|
|
68
|
-
- `format:` → string-shaped + `:date`/`:time`/`:datetime` (regex, strftime string, or preset Symbol)
|
|
69
|
-
- `enum:` → `:string`/`:symbol` (and subtypes) only — an `Array` of allowed values
|
|
70
|
-
- `in:` → `:integer`/`:float`/`:decimal`/`:date`/`:time`/`:datetime` — an `Array` or `Range`
|
|
71
|
-
- `round:` → `:float`/`:decimal` (Integer places, half up; keeps the field's type)
|
|
72
|
-
- `base:` → `:integer` (radix 2..36 for strings; default 10, so `"010"` is 10)
|
|
73
|
-
- `values:` → `:boolean` (a `{truthy:, falsy:}` Hash or a preset Symbol)
|
|
74
|
-
- `strict:` → `:string` (and subtypes) / `:integer` (Boolean — refuse loose input instead of `to_s` / truncating)
|
|
75
|
-
- `zone:` → `:time`/`:datetime` (`"UTC"`, `"±HH:MM"` or an IANA name like `"America/Denver"` for zone-less strings; no Rails names or abbreviations)
|
|
76
|
-
- `sensitive:` → any type (mask the value in `inspect`)
|
|
77
|
-
- `element:` → `:array` (a Hash of the element type's own options, e.g.
|
|
78
|
-
`of: :integer, element: {strict: true}`; bad elements are reported by index — every one, the first five listed)
|
|
79
|
-
6. **Cross-field rules use `validate` + `errors.add(:base, …)`**, run at `valid?`.
|
|
80
|
-
`errors[:base]` is cleared each `valid?`; per-field errors are owned by the setter.
|
|
81
|
-
```ruby
|
|
82
|
-
validate :ends_after_start
|
|
83
|
-
def ends_after_start
|
|
84
|
-
errors.add(:base, 'end before start') if start && finish && finish < start
|
|
85
|
-
end
|
|
86
|
-
```
|
|
87
|
-
7. **JSON**: `serialize :json, internal: 'externalKey'` maps keys; `as_json`/`to_json`
|
|
88
|
-
apply it forward, `Klass.from_json(str)` reverse-maps. Everything round-trips
|
|
89
|
-
**except `:value`** (no type info to restore). Uses **Oj**, not stdlib JSON.
|
|
90
|
-
8. **Unknown input keys are dropped by default** (`unknown_attributes :ignore`); set
|
|
91
|
-
`unknown_attributes :raise` on the class to reject them. Do this at payment/API
|
|
92
|
-
boundaries, on **every** struct that reads input: nested classes don't inherit it
|
|
93
|
-
from the struct that holds them.
|
|
94
|
-
9. **Messages never echo values** (payments data stays out of logs): errors and raised
|
|
95
|
-
errors name the field, expected type and input *class*. `sensitive: true` (any
|
|
96
|
-
type) shows `[FILTERED]` in `inspect`/`pp`; readers, `to_h`, `as_json`/`to_json`
|
|
97
|
-
still return the real value.
|
|
98
|
-
10. **Validity is computed on assignment.** Mutating a nested struct or array element
|
|
99
|
-
in place (`rec.address.city = nil`, `rec.tags << 5`) doesn't refresh the parent's
|
|
100
|
-
errors, and an in-place push isn't coerced. Assign the field again (or use
|
|
101
|
-
`rec.with(address: ...)`) to re-validate.
|
|
102
|
-
11. **Immutable/frozen instances change by copy**: `rec.with(field: value)` returns a
|
|
103
|
-
new instance; changed fields run the setter pipeline. Shallow, like `dup`.
|
|
104
|
-
|
|
105
|
-
## Upgrading field_struct
|
|
106
|
-
|
|
107
|
-
When bumping the gem, follow `UPGRADING.md` (shipped with the gem, next to
|
|
108
|
-
`USAGE.md`; or https://github.com/Paymentbox-com/field_struct/blob/main/UPGRADING.md).
|
|
109
|
-
It lists every visible change since 0.10 as **Symptom / Find / Fix / Why**; don't
|
|
110
|
-
guess from memory.
|
|
111
|
-
|
|
112
|
-
1. Read your old version from `Gemfile.lock` (`field_struct (x.y.z)`) and the target
|
|
113
|
-
tag. Open `UPGRADING.md` (repo root, or `bundle show field_struct` after bumping)
|
|
114
|
-
and read every section from the one after your old version to the target.
|
|
115
|
-
2. Bump the Gemfile tag. If the project uses **actionable** >= 1.6, field_struct
|
|
116
|
-
must be >= 0.12 (its gemspec says so); if `oj` is pinned below 3.11.2, loosen it.
|
|
117
|
-
`bundle update field_struct`.
|
|
118
|
-
3. Check `rg --pcre2-version` works in your shell. Run the Find of every entry
|
|
119
|
-
the TL;DR lists as **silent**, from the project root, and read each hit using the
|
|
120
|
-
entry's narrowing rule. Run the other entries' Finds only for code the suite
|
|
121
|
-
doesn't reach; those changes raise or fail a spec.
|
|
122
|
-
4. Apply the matching **Fix** to each real hit. Don't change behaviour you weren't
|
|
123
|
-
asked to — e.g. keep a renamed reserved field's wire name with `serialize :json`.
|
|
124
|
-
5. Run the full suite. Match each failure against UPGRADING.md's symptom index and
|
|
125
|
-
fix it; if nothing matches, follow its "If something else breaks" section.
|
|
126
|
-
6. If the project generates RBS with `FieldStruct::RBS.generate`, or with a task that
|
|
127
|
-
wraps it (`rg -n 'FieldStruct::RBS' lib Rakefile`), regenerate it and run Steep if
|
|
128
|
-
the project does.
|
|
129
|
-
7. Report: old → new version, each entry that applied (file:line, fix), each Find
|
|
130
|
-
with no hits, and anything left unexplained.
|
|
131
|
-
|
|
132
|
-
## Debugging an invalid instance
|
|
43
|
+
## Common mistakes
|
|
133
44
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
45
|
+
- Expecting setters to raise. They store the raw value and record an error. Check `valid?`.
|
|
46
|
+
- Treating `required` as "never nil". An unset required field reads as `nil`; `valid?` is what fails.
|
|
47
|
+
- Whitespace-only strings, empty arrays and empty hashes are missing.
|
|
48
|
+
- Leaving out `of:` on `:array`, `:hash` or `:union`.
|
|
49
|
+
- Putting an option on a type that doesn't take it (`round:` on a string). The error lists the types that do.
|
|
50
|
+
- Putting element options on the field instead of in `element: {...}`.
|
|
51
|
+
- Putting cross-field rules anywhere but `errors[:base]` via `validate`.
|
|
52
|
+
- Using stdlib JSON on a struct. Use `to_json`, `as_json`, `from_json` (Oj).
|
|
53
|
+
- Forgetting unknown keys are ignored unless `unknown_attributes :raise`.
|
|
54
|
+
- Mutating a nested object in place and expecting the parent's validity to update. Re-assign it or use `with`.
|
|
55
|
+
- Calling `with(hash)`. It takes keywords: `with(**hash)`.
|
|
56
|
+
|
|
57
|
+
## Debug an invalid instance
|
|
58
|
+
|
|
59
|
+
Read `obj.errors.to_h` (Symbol field to Array of Strings). Messages never contain the value, only its class.
|
|
60
|
+
`obj.errors.paths` gives the same messages keyed by full path (`"name"`, `"trays[1].label"`).
|
|
61
|
+
`obj.given_fields` says which fields the input actually carried. Frozen errors (`errors.freeze`, as on an actionable
|
|
62
|
+
result) refuse `add` and `clear`, and `valid?` then reads them as they are instead of re-running the validators.
|
|
139
63
|
|
|
140
|
-
- `"is required"
|
|
141
|
-
|
|
142
|
-
- `"
|
|
143
|
-
|
|
144
|
-
- `"could not be coerced: …"` → coercion raised; under the default `:keep_raw` the raw
|
|
145
|
-
value is kept, under `:replace` it's nilled. Check the field's/class's
|
|
146
|
-
`coercion_policy`.
|
|
64
|
+
- `"is required"`: the field is nil, blank or empty. Send a value or make it `optional`.
|
|
65
|
+
- `"is invalid"`: the value was read but broke `format:`, `enum:` or `in:`, or a nested struct inside it is invalid.
|
|
66
|
+
- `"could not be coerced: ..."`: the type couldn't read the value; the text after the colon says why.
|
|
67
|
+
- `"element at index N ..."`: an array element is the problem; the index is 0-based.
|
|
147
68
|
|
|
148
|
-
|
|
69
|
+
The raw input stays in the reader, so `obj.field` shows what was sent. Under `coercion_policy :replace` it is `nil`.
|
|
149
70
|
|
|
150
|
-
|
|
151
|
-
|
|
71
|
+
## Extend with a custom type
|
|
72
|
+
|
|
73
|
+
Subclass `FieldStruct::Types::Base`; implement `coerce(value, **options)` (raise `ArgumentError`, `TypeError` or
|
|
74
|
+
`RangeError` for unreadable input) and `ruby_type`. Register it in a registry:
|
|
152
75
|
|
|
153
76
|
```ruby
|
|
154
|
-
module
|
|
77
|
+
module Nursery
|
|
155
78
|
def self.field_types
|
|
156
|
-
@field_types ||= FieldStruct.new_registry
|
|
157
|
-
register :money, Acme::Types::Money # a FieldStruct::Types::Base subclass
|
|
158
|
-
register :dec, :big_decimal # alias to an existing name
|
|
159
|
-
end
|
|
79
|
+
@field_types ||= FieldStruct.new_registry { register :cents, Cents }
|
|
160
80
|
end
|
|
161
81
|
end
|
|
162
82
|
```
|
|
163
83
|
|
|
164
|
-
|
|
165
|
-
`#ruby_type` (override `#missing?` for a broader-than-nil notion).
|
|
84
|
+
Structs inside `Nursery` can then say `required :yield_kg, :cents`. Add `rbs_type` to the type to control its RBS.
|
|
166
85
|
|
|
167
|
-
##
|
|
86
|
+
## Type models with RBS
|
|
168
87
|
|
|
169
|
-
`FieldStruct::RBS.generate(
|
|
170
|
-
|
|
88
|
+
`FieldStruct::RBS.generate(Model)` returns RBS for a model: readers of required fields have no `?`, writers accept
|
|
89
|
+
`nil`, scalar array elements are nullable. The types describe a valid instance, so check `valid?`. Override a field with
|
|
90
|
+
`rbs_type: '::Pathname'`. The gem's own signatures are in `sig/field_struct.rbs`.
|
|
171
91
|
|
|
172
|
-
|
|
173
|
-
puts FieldStruct::RBS.generate(User)
|
|
174
|
-
# class User < ::FieldStruct::Base
|
|
175
|
-
# attr_reader name: ::String
|
|
176
|
-
# def name=: (::String? value) -> ::String?
|
|
177
|
-
# ...
|
|
178
|
-
```
|
|
92
|
+
## Upgrade
|
|
179
93
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
94
|
+
1. Read `CHANGELOG.md` from your version to the new one.
|
|
95
|
+
2. Update the gem and run your suite.
|
|
96
|
+
3. Regenerate model signatures with `FieldStruct::RBS.generate` and review the diff.
|
|
97
|
+
4. If a model fails a declaration check (`ArgumentError` at class definition), the message names the field and the fix.
|
metadata
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: field_struct
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0.pre1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Adrian Madrid
|
|
8
|
-
bindir:
|
|
8
|
+
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
@@ -51,48 +51,57 @@ dependencies:
|
|
|
51
51
|
- - "~>"
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
53
|
version: '2.0'
|
|
54
|
-
description:
|
|
55
|
-
|
|
56
|
-
declared attributes that have enforced types, presence checks, and
|
|
57
|
-
per-field validation. Each class collects its declarations into an
|
|
58
|
-
inspectable Metadata object; types are pluggable via a registry that
|
|
59
|
-
namespaces can extend or replace.
|
|
60
|
-
|
|
61
|
-
Not a database layer, not a form object, not an ActiveModel replacement.
|
|
62
|
-
Mirrors the AM interface shape where it helps adoption, but reuses no AM
|
|
63
|
-
code.
|
|
54
|
+
description: Declare fields with a name, a type and options. Every assignment coerces
|
|
55
|
+
the value, records validation errors for that field, and keeps the object usable.
|
|
64
56
|
email:
|
|
65
|
-
-
|
|
57
|
+
- adrian.madrid@timeworxs.com
|
|
66
58
|
executables: []
|
|
67
59
|
extensions: []
|
|
68
60
|
extra_rdoc_files: []
|
|
69
61
|
files:
|
|
62
|
+
- ".claude-plugin/marketplace.json"
|
|
63
|
+
- ".claude-plugin/plugin.json"
|
|
70
64
|
- AGENTS.md
|
|
71
65
|
- CHANGELOG.md
|
|
72
|
-
-
|
|
66
|
+
- LICENSE.txt
|
|
73
67
|
- README.md
|
|
74
|
-
- UPGRADING.md
|
|
75
68
|
- USAGE.md
|
|
76
69
|
- docs/getting_started.md
|
|
77
70
|
- lib/field_struct.rb
|
|
78
71
|
- lib/field_struct/base.rb
|
|
79
|
-
- lib/field_struct/
|
|
72
|
+
- lib/field_struct/class_macros.rb
|
|
73
|
+
- lib/field_struct/describer.rb
|
|
80
74
|
- lib/field_struct/errors.rb
|
|
75
|
+
- lib/field_struct/exceptions.rb
|
|
81
76
|
- lib/field_struct/field.rb
|
|
77
|
+
- lib/field_struct/field_builder.rb
|
|
78
|
+
- lib/field_struct/field_checks.rb
|
|
79
|
+
- lib/field_struct/introspection.rb
|
|
80
|
+
- lib/field_struct/json_codec.rb
|
|
82
81
|
- lib/field_struct/metadata.rb
|
|
83
82
|
- lib/field_struct/model_name.rb
|
|
83
|
+
- lib/field_struct/option_checker.rb
|
|
84
|
+
- lib/field_struct/partial.rb
|
|
85
|
+
- lib/field_struct/presence.rb
|
|
84
86
|
- lib/field_struct/rbs.rb
|
|
87
|
+
- lib/field_struct/registered_option.rb
|
|
85
88
|
- lib/field_struct/registry.rb
|
|
89
|
+
- lib/field_struct/restrictions.rb
|
|
86
90
|
- lib/field_struct/scaffold.rb
|
|
91
|
+
- lib/field_struct/suggestion.rb
|
|
87
92
|
- lib/field_struct/types/array.rb
|
|
88
93
|
- lib/field_struct/types/base.rb
|
|
89
94
|
- lib/field_struct/types/big_decimal.rb
|
|
90
95
|
- lib/field_struct/types/binary.rb
|
|
91
96
|
- lib/field_struct/types/boolean.rb
|
|
97
|
+
- lib/field_struct/types/builtin.rb
|
|
92
98
|
- lib/field_struct/types/date.rb
|
|
93
99
|
- lib/field_struct/types/datetime.rb
|
|
100
|
+
- lib/field_struct/types/element_options.rb
|
|
94
101
|
- lib/field_struct/types/email.rb
|
|
95
102
|
- lib/field_struct/types/float.rb
|
|
103
|
+
- lib/field_struct/types/format_presets.rb
|
|
104
|
+
- lib/field_struct/types/hash.rb
|
|
96
105
|
- lib/field_struct/types/immutable_string.rb
|
|
97
106
|
- lib/field_struct/types/integer.rb
|
|
98
107
|
- lib/field_struct/types/nested.rb
|
|
@@ -100,24 +109,24 @@ files:
|
|
|
100
109
|
- lib/field_struct/types/rfc3339_format.rb
|
|
101
110
|
- lib/field_struct/types/string.rb
|
|
102
111
|
- lib/field_struct/types/symbol.rb
|
|
103
|
-
- lib/field_struct/types/
|
|
112
|
+
- lib/field_struct/types/temporal.rb
|
|
104
113
|
- lib/field_struct/types/time.rb
|
|
105
|
-
- lib/field_struct/types/time_format_resolver.rb
|
|
106
114
|
- lib/field_struct/types/union.rb
|
|
115
|
+
- lib/field_struct/types/union_pick.rb
|
|
107
116
|
- lib/field_struct/types/url.rb
|
|
108
117
|
- lib/field_struct/types/uuid.rb
|
|
109
118
|
- lib/field_struct/types/value.rb
|
|
110
|
-
- lib/field_struct/types/
|
|
119
|
+
- lib/field_struct/types/zone.rb
|
|
111
120
|
- lib/field_struct/version.rb
|
|
112
121
|
- sig/field_struct.rbs
|
|
122
|
+
- sig/manifest.yaml
|
|
113
123
|
- skills/field-struct/SKILL.md
|
|
114
|
-
homepage: https://github.com/
|
|
115
|
-
licenses:
|
|
124
|
+
homepage: https://github.com/gliders-rb/gems
|
|
125
|
+
licenses:
|
|
126
|
+
- MIT
|
|
116
127
|
metadata:
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
source_code_uri: https://github.com/Paymentbox-com/field_struct
|
|
120
|
-
changelog_uri: https://github.com/Paymentbox-com/field_struct/blob/main/CHANGELOG.md
|
|
128
|
+
source_code_uri: https://github.com/gliders-rb/gems/tree/main/gems/field_struct
|
|
129
|
+
changelog_uri: https://github.com/gliders-rb/gems/blob/main/gems/field_struct/CHANGELOG.md
|
|
121
130
|
rubygems_mfa_required: 'true'
|
|
122
131
|
rdoc_options: []
|
|
123
132
|
require_paths:
|
|
@@ -126,14 +135,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
126
135
|
requirements:
|
|
127
136
|
- - ">="
|
|
128
137
|
- !ruby/object:Gem::Version
|
|
129
|
-
version: 3.
|
|
138
|
+
version: '3.3'
|
|
130
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
140
|
requirements:
|
|
132
141
|
- - ">="
|
|
133
142
|
- !ruby/object:Gem::Version
|
|
134
143
|
version: '0'
|
|
135
144
|
requirements: []
|
|
136
|
-
rubygems_version:
|
|
145
|
+
rubygems_version: 3.6.9
|
|
137
146
|
specification_version: 4
|
|
138
|
-
summary: Typed
|
|
147
|
+
summary: Typed plain Ruby objects with declared, coerced, validated fields.
|
|
139
148
|
test_files: []
|
data/CODE_OF_CONDUCT.md
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
|
2
|
-
|
|
3
|
-
## Our Pledge
|
|
4
|
-
|
|
5
|
-
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
-
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
-
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
-
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
-
nationality, personal appearance, race, caste, color, religion, or sexual
|
|
10
|
-
identity and orientation.
|
|
11
|
-
|
|
12
|
-
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
-
diverse, inclusive, and healthy community.
|
|
14
|
-
|
|
15
|
-
## Our Standards
|
|
16
|
-
|
|
17
|
-
Examples of behavior that contributes to a positive environment for our
|
|
18
|
-
community include:
|
|
19
|
-
|
|
20
|
-
* Demonstrating empathy and kindness toward other people
|
|
21
|
-
* Being respectful of differing opinions, viewpoints, and experiences
|
|
22
|
-
* Giving and gracefully accepting constructive feedback
|
|
23
|
-
* Accepting responsibility and apologizing to those affected by our mistakes,
|
|
24
|
-
and learning from the experience
|
|
25
|
-
* Focusing on what is best not just for us as individuals, but for the overall
|
|
26
|
-
community
|
|
27
|
-
|
|
28
|
-
Examples of unacceptable behavior include:
|
|
29
|
-
|
|
30
|
-
* The use of sexualized language or imagery, and sexual attention or advances of
|
|
31
|
-
any kind
|
|
32
|
-
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
33
|
-
* Public or private harassment
|
|
34
|
-
* Publishing others' private information, such as a physical or email address,
|
|
35
|
-
without their explicit permission
|
|
36
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
|
37
|
-
professional setting
|
|
38
|
-
|
|
39
|
-
## Enforcement Responsibilities
|
|
40
|
-
|
|
41
|
-
Community leaders are responsible for clarifying and enforcing our standards of
|
|
42
|
-
acceptable behavior and will take appropriate and fair corrective action in
|
|
43
|
-
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
44
|
-
or harmful.
|
|
45
|
-
|
|
46
|
-
Community leaders have the right and responsibility to remove, edit, or reject
|
|
47
|
-
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
48
|
-
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
49
|
-
decisions when appropriate.
|
|
50
|
-
|
|
51
|
-
## Scope
|
|
52
|
-
|
|
53
|
-
This Code of Conduct applies within all community spaces, and also applies when
|
|
54
|
-
an individual is officially representing the community in public spaces.
|
|
55
|
-
Examples of representing our community include using an official email address,
|
|
56
|
-
posting via an official social media account, or acting as an appointed
|
|
57
|
-
representative at an online or offline event.
|
|
58
|
-
|
|
59
|
-
## Enforcement
|
|
60
|
-
|
|
61
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
62
|
-
reported to the community leaders responsible for enforcement at
|
|
63
|
-
[INSERT CONTACT METHOD].
|
|
64
|
-
All complaints will be reviewed and investigated promptly and fairly.
|
|
65
|
-
|
|
66
|
-
All community leaders are obligated to respect the privacy and security of the
|
|
67
|
-
reporter of any incident.
|
|
68
|
-
|
|
69
|
-
## Enforcement Guidelines
|
|
70
|
-
|
|
71
|
-
Community leaders will follow these Community Impact Guidelines in determining
|
|
72
|
-
the consequences for any action they deem in violation of this Code of Conduct:
|
|
73
|
-
|
|
74
|
-
### 1. Correction
|
|
75
|
-
|
|
76
|
-
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
77
|
-
unprofessional or unwelcome in the community.
|
|
78
|
-
|
|
79
|
-
**Consequence**: A private, written warning from community leaders, providing
|
|
80
|
-
clarity around the nature of the violation and an explanation of why the
|
|
81
|
-
behavior was inappropriate. A public apology may be requested.
|
|
82
|
-
|
|
83
|
-
### 2. Warning
|
|
84
|
-
|
|
85
|
-
**Community Impact**: A violation through a single incident or series of
|
|
86
|
-
actions.
|
|
87
|
-
|
|
88
|
-
**Consequence**: A warning with consequences for continued behavior. No
|
|
89
|
-
interaction with the people involved, including unsolicited interaction with
|
|
90
|
-
those enforcing the Code of Conduct, for a specified period of time. This
|
|
91
|
-
includes avoiding interactions in community spaces as well as external channels
|
|
92
|
-
like social media. Violating these terms may lead to a temporary or permanent
|
|
93
|
-
ban.
|
|
94
|
-
|
|
95
|
-
### 3. Temporary Ban
|
|
96
|
-
|
|
97
|
-
**Community Impact**: A serious violation of community standards, including
|
|
98
|
-
sustained inappropriate behavior.
|
|
99
|
-
|
|
100
|
-
**Consequence**: A temporary ban from any sort of interaction or public
|
|
101
|
-
communication with the community for a specified period of time. No public or
|
|
102
|
-
private interaction with the people involved, including unsolicited interaction
|
|
103
|
-
with those enforcing the Code of Conduct, is allowed during this period.
|
|
104
|
-
Violating these terms may lead to a permanent ban.
|
|
105
|
-
|
|
106
|
-
### 4. Permanent Ban
|
|
107
|
-
|
|
108
|
-
**Community Impact**: Demonstrating a pattern of violation of community
|
|
109
|
-
standards, including sustained inappropriate behavior, harassment of an
|
|
110
|
-
individual, or aggression toward or disparagement of classes of individuals.
|
|
111
|
-
|
|
112
|
-
**Consequence**: A permanent ban from any sort of public interaction within the
|
|
113
|
-
community.
|
|
114
|
-
|
|
115
|
-
## Attribution
|
|
116
|
-
|
|
117
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
118
|
-
version 2.1, available at
|
|
119
|
-
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
|
120
|
-
|
|
121
|
-
Community Impact Guidelines were inspired by
|
|
122
|
-
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
|
123
|
-
|
|
124
|
-
For answers to common questions about this code of conduct, see the FAQ at
|
|
125
|
-
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
|
126
|
-
[https://www.contributor-covenant.org/translations][translations].
|
|
127
|
-
|
|
128
|
-
[homepage]: https://www.contributor-covenant.org
|
|
129
|
-
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
|
130
|
-
[Mozilla CoC]: https://github.com/mozilla/diversity
|
|
131
|
-
[FAQ]: https://www.contributor-covenant.org/faq
|
|
132
|
-
[translations]: https://www.contributor-covenant.org/translations
|