steep-kit 0.1.0 → 0.1.1
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/CHANGELOG.md +6 -0
- data/README.md +5 -5
- data/lib/steep_kit/conventions.rb +32 -17
- data/lib/steep_kit/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 633566495dee65d8947786f6d4b1b022707bacae16ea102e9983ac741921265a
|
|
4
|
+
data.tar.gz: cbe952871e90220ab0397ecc55ce58f5e2739cabec7d372d753a258341e84b96
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3d6d9ec5989ffbec5eb98ed91d545b96479bb916251c5ee61173bbd9de3d165acd0664d2a2a05ae91fb7f260ea0be7a5294a2287fd775ab7ddcb7f0cc31a0b8d
|
|
7
|
+
data.tar.gz: a4c9d19afdfa792e7afb4ca1e3879e30ef6e4fbd9ee892ee2a74455bb1eb18433cdeecbdaf59b25eaa7a82dfe756af0f470c6da3fecee50e4eade52631f85979
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.1 (2026-11-29)
|
|
4
|
+
|
|
5
|
+
- Replace the YAML-1.1-unsafe `on:` key in `mixins.aliases` and `mixins.nested_classes` with `for:` (Psych parses
|
|
6
|
+
unquoted `on:` as boolean `true`). Quoted `'on':` remains accepted for backwards compatibility, and unquoted `on:` now
|
|
7
|
+
reports a clear hint pointing to `for:`.
|
|
8
|
+
|
|
3
9
|
## 0.1.0 (2026-11-29)
|
|
4
10
|
|
|
5
11
|
Initial public release:
|
data/README.md
CHANGED
|
@@ -235,13 +235,13 @@ corresponding `extend` declaration.
|
|
|
235
235
|
```yaml
|
|
236
236
|
mixins:
|
|
237
237
|
aliases:
|
|
238
|
-
-
|
|
238
|
+
- for: Operations::Base
|
|
239
239
|
alias: call!
|
|
240
240
|
to: call
|
|
241
241
|
require_typed: true
|
|
242
242
|
```
|
|
243
243
|
|
|
244
|
-
- Matches any class or module that `include`s `
|
|
244
|
+
- Matches any class or module that `include`s `for`, or any class that inherits from `for` (relative names resolve
|
|
245
245
|
lexically in the enclosing namespace).
|
|
246
246
|
- Infers `alias call! call` in memory unless the class defines `call!` itself, so `call!` automatically inherits the
|
|
247
247
|
exact inline signature of `#call`.
|
|
@@ -253,18 +253,18 @@ mixins:
|
|
|
253
253
|
```yaml
|
|
254
254
|
mixins:
|
|
255
255
|
nested_classes:
|
|
256
|
-
-
|
|
256
|
+
- for: Operations::Async
|
|
257
257
|
name: Worker
|
|
258
258
|
include:
|
|
259
259
|
- Sidekiq::Job
|
|
260
260
|
extend:
|
|
261
261
|
- Sidekiq::Job::ClassMethods
|
|
262
|
-
-
|
|
262
|
+
- for: Custom::Async
|
|
263
263
|
name: Worker
|
|
264
264
|
superclass: Custom::Async::Job
|
|
265
265
|
```
|
|
266
266
|
|
|
267
|
-
- When a class includes (or inherits from) `
|
|
267
|
+
- When a class includes (or inherits from) `for`, Steep sees a nested `class Worker` with the configured superclass,
|
|
268
268
|
`include`s, and `extend`s.
|
|
269
269
|
- An explicit `class Worker` in the source merges cleanly with the inferred superclass/mixins; an explicit `Worker`
|
|
270
270
|
constant or class alias is left untouched.
|
|
@@ -6,10 +6,10 @@ module SteepKit
|
|
|
6
6
|
CONSTANT_NAME = /\A[A-Z]\w*\z/
|
|
7
7
|
METHOD_NAME = /\A[a-z_]\w*[!?=]?\z/
|
|
8
8
|
MIXIN_KEYS = %i[class_methods aliases nested_classes].freeze
|
|
9
|
-
ALIAS_ALLOWED_KEYS = %i[
|
|
10
|
-
ALIAS_REQUIRED_KEYS = %i[
|
|
11
|
-
NESTED_CLASS_ALLOWED_KEYS = %i[
|
|
12
|
-
NESTED_CLASS_REQUIRED_KEYS = %i[
|
|
9
|
+
ALIAS_ALLOWED_KEYS = %i[for alias to require_typed].freeze
|
|
10
|
+
ALIAS_REQUIRED_KEYS = %i[for alias to].freeze
|
|
11
|
+
NESTED_CLASS_ALLOWED_KEYS = %i[for name superclass include extend].freeze
|
|
12
|
+
NESTED_CLASS_REQUIRED_KEYS = %i[for name].freeze
|
|
13
13
|
|
|
14
14
|
ClassMethodRule = Data.define(:mixin, :extension) do
|
|
15
15
|
def self.parse(entry)
|
|
@@ -37,14 +37,15 @@ module SteepKit
|
|
|
37
37
|
|
|
38
38
|
AliasRule = Data.define(:on, :alias_name, :target_name, :require_typed) do
|
|
39
39
|
def self.parse(entry)
|
|
40
|
-
Conventions.
|
|
41
|
-
|
|
40
|
+
normalized = Conventions.normalize_target_key('mixins.aliases', entry)
|
|
41
|
+
Conventions.validate_entry_keys!('mixins.aliases', normalized, required: ALIAS_REQUIRED_KEYS, allowed: ALIAS_ALLOWED_KEYS)
|
|
42
|
+
require_typed = normalized.fetch(:require_typed, false)
|
|
42
43
|
raise Error, 'mixins.aliases require_typed must be a boolean' unless [true, false].include?(require_typed)
|
|
43
44
|
|
|
44
45
|
new(
|
|
45
|
-
on: Conventions.absolute_name('mixins.aliases
|
|
46
|
-
alias_name: Conventions.method_name('mixins.aliases alias',
|
|
47
|
-
target_name: Conventions.method_name('mixins.aliases to',
|
|
46
|
+
on: Conventions.absolute_name('mixins.aliases for', normalized[:for]),
|
|
47
|
+
alias_name: Conventions.method_name('mixins.aliases alias', normalized[:alias]),
|
|
48
|
+
target_name: Conventions.method_name('mixins.aliases to', normalized[:to]),
|
|
48
49
|
require_typed:
|
|
49
50
|
)
|
|
50
51
|
end
|
|
@@ -52,14 +53,15 @@ module SteepKit
|
|
|
52
53
|
|
|
53
54
|
NestedClassRule = Data.define(:on, :name, :superclass, :includes, :extends) do
|
|
54
55
|
def self.parse(entry)
|
|
55
|
-
Conventions.
|
|
56
|
+
normalized = Conventions.normalize_target_key('mixins.nested_classes', entry)
|
|
57
|
+
Conventions.validate_entry_keys!('mixins.nested_classes', normalized, required: NESTED_CLASS_REQUIRED_KEYS, allowed: NESTED_CLASS_ALLOWED_KEYS)
|
|
56
58
|
|
|
57
59
|
new(
|
|
58
|
-
on: Conventions.absolute_name('mixins.nested_classes
|
|
59
|
-
name: Conventions.constant_name('mixins.nested_classes name',
|
|
60
|
-
superclass: (Conventions.absolute_name('mixins.nested_classes superclass',
|
|
61
|
-
includes: parse_modules('include',
|
|
62
|
-
extends: parse_modules('extend',
|
|
60
|
+
on: Conventions.absolute_name('mixins.nested_classes for', normalized[:for]),
|
|
61
|
+
name: Conventions.constant_name('mixins.nested_classes name', normalized[:name]),
|
|
62
|
+
superclass: (Conventions.absolute_name('mixins.nested_classes superclass', normalized[:superclass]) if normalized[:superclass]),
|
|
63
|
+
includes: parse_modules('include', normalized[:include]),
|
|
64
|
+
extends: parse_modules('extend', normalized[:extend])
|
|
63
65
|
)
|
|
64
66
|
end
|
|
65
67
|
|
|
@@ -93,15 +95,28 @@ module SteepKit
|
|
|
93
95
|
)
|
|
94
96
|
end
|
|
95
97
|
|
|
98
|
+
def self.normalize_target_key(label, entry)
|
|
99
|
+
raise Error, "#{label} entries must be mappings" unless entry.is_a?(Hash)
|
|
100
|
+
raise Error, "#{label} entries cannot set both for and on" if entry.key?(:for) && entry.key?(:on)
|
|
101
|
+
return entry unless entry.key?(:on)
|
|
102
|
+
|
|
103
|
+
entry.merge(for: entry[:on]).tap { |normalized| normalized.delete(:on) }
|
|
104
|
+
end
|
|
105
|
+
|
|
96
106
|
def self.validate_entry_keys!(label, entry, required:, allowed:)
|
|
97
107
|
raise Error, "#{label} entries must be mappings" unless entry.is_a?(Hash)
|
|
98
108
|
|
|
99
109
|
unknown = entry.keys - allowed
|
|
100
110
|
missing = required - entry.keys
|
|
101
|
-
raise Error,
|
|
111
|
+
raise Error, unknown_keys_message(label, unknown) if unknown.any?
|
|
102
112
|
raise Error, "#{label} entries are missing: #{missing.join(', ')}" if missing.any?
|
|
103
113
|
end
|
|
104
114
|
|
|
115
|
+
def self.unknown_keys_message(label, unknown)
|
|
116
|
+
hint = unknown.include?(true) ? ' (YAML parses unquoted `on:` as boolean `true`; use `for:`)' : ''
|
|
117
|
+
"#{label} entries have unknown keys: #{unknown.join(', ')}#{hint}"
|
|
118
|
+
end
|
|
119
|
+
|
|
105
120
|
def self.absolute_name(key, value)
|
|
106
121
|
raise Error, "#{key} must be a constant path: #{value.inspect}" unless value.is_a?(String) && value.match?(CONSTANT_PATH)
|
|
107
122
|
|
|
@@ -154,7 +169,7 @@ module SteepKit
|
|
|
154
169
|
end
|
|
155
170
|
end
|
|
156
171
|
|
|
157
|
-
private_class_method :parse_mixins, :parse_list, :parse_superclasses
|
|
172
|
+
private_class_method :parse_mixins, :parse_list, :parse_superclasses, :unknown_keys_message
|
|
158
173
|
|
|
159
174
|
def initialize(class_methods: [], aliases: [], nested_classes: [], superclasses: {})
|
|
160
175
|
@class_methods = class_methods.freeze
|
data/lib/steep_kit/version.rb
CHANGED