boba 0.1.6 → 0.1.8
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/README.md +9 -3
- data/lib/boba/active_record/attribute_service.rb +6 -14
- data/lib/boba/active_record/reflection_service.rb +3 -5
- data/lib/boba/options/association_type_option.rb +5 -12
- data/lib/boba/version.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_associations_persisted.rb +3 -15
- data/lib/tapioca/dsl/compilers/active_record_columns_persisted.rb +4 -18
- data/lib/tapioca/dsl/compilers/active_record_relation_types.rb +4 -6
- data/lib/tapioca/dsl/compilers/attr_json.rb +4 -6
- data/lib/tapioca/dsl/compilers/flag_shih_tzu.rb +4 -6
- data/lib/tapioca/dsl/compilers/kaminari.rb +5 -6
- data/lib/tapioca/dsl/compilers/money_rails.rb +5 -6
- data/lib/tapioca/dsl/compilers/noticed.rb +91 -0
- data/lib/tapioca/dsl/compilers/paperclip.rb +4 -5
- data/lib/tapioca/dsl/compilers/state_machines_extended.rb +15 -29
- metadata +13 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8f3bbf276bdafe4ad59d597cfa3d481db980d8a1cc0639066289ee72671bee01
|
|
4
|
+
data.tar.gz: ed16c9705abe9aaa2997124342b920d748aac6d131bc25b4930a4bdfd8c82e4b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3efa241e2373a7566a2f9a565366a750947854c2af1ac7d26e66b934f6b4c18835ca8c58b64ec22f107871b46a1bde563663b1d30a1fe3dea54ba9c7afe8d82c
|
|
7
|
+
data.tar.gz: 59a567e245ad5d424bfccc9c101584500235ef2a71282e65cdcba5cb6448267684bc9b6fe5e85309c56db96ec8d0e088fa3a3bc33500b12a81614e9c122ff95e
|
data/README.md
CHANGED
|
@@ -19,13 +19,19 @@ group :development do
|
|
|
19
19
|
end
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
We recommend you also use the `only` configuration option in your Tapioca config (typically `sorbet/tapioca/config.yml`) to specify only the Tapioca compilers you wish to use.
|
|
22
|
+
We recommend you also use the `only` configuration option in your Tapioca config (typically `sorbet/tapioca/config.yml`) to specify only the Tapioca compilers you wish to use. For instance, the following is an example `tapioca/config.yml` using the Boba `ActiveRecord` compilers with the `persisted` options:
|
|
23
|
+
|
|
23
24
|
```yml
|
|
25
|
+
gem:
|
|
24
26
|
dsl:
|
|
27
|
+
compiler_options:
|
|
28
|
+
ActiveRecordColumnTypes: persisted
|
|
29
|
+
ActiveRecordAssociationTypes: persisted
|
|
25
30
|
only:
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
- ActiveRecordAssociationsPersisted
|
|
32
|
+
- ActiveRecordColumnsPersisted
|
|
28
33
|
```
|
|
34
|
+
|
|
29
35
|
This makes it easy to selectively enable only the compilers you want to use in your project.
|
|
30
36
|
|
|
31
37
|
### Typing Relations
|
|
@@ -5,27 +5,19 @@ module Boba
|
|
|
5
5
|
module ActiveRecord
|
|
6
6
|
module AttributeService
|
|
7
7
|
class << self
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
sig do
|
|
11
|
-
params(
|
|
12
|
-
constant: T.class_of(::ActiveRecord::Base),
|
|
13
|
-
attribute: String,
|
|
14
|
-
column_name: String,
|
|
15
|
-
).returns(T::Boolean)
|
|
16
|
-
end
|
|
8
|
+
#: (singleton(::ActiveRecord::Base) constant, String attribute, ?column_name: String) -> bool
|
|
17
9
|
def nilable_attribute?(constant, attribute, column_name: attribute)
|
|
18
10
|
return false if has_non_null_database_constraint?(constant, column_name)
|
|
19
11
|
|
|
20
12
|
!has_unconditional_presence_validator?(constant, attribute)
|
|
21
13
|
end
|
|
22
14
|
|
|
23
|
-
|
|
15
|
+
#: (singleton(::ActiveRecord::Base) constant, String column_name) -> bool
|
|
24
16
|
def virtual_attribute?(constant, column_name)
|
|
25
17
|
constant.columns_hash[column_name].nil?
|
|
26
18
|
end
|
|
27
19
|
|
|
28
|
-
|
|
20
|
+
#: (singleton(::ActiveRecord::Base) constant, String column_name) -> bool
|
|
29
21
|
def has_non_null_database_constraint?(constant, column_name)
|
|
30
22
|
column = constant.columns_hash[column_name]
|
|
31
23
|
return false if column.nil?
|
|
@@ -35,7 +27,7 @@ module Boba
|
|
|
35
27
|
false
|
|
36
28
|
end
|
|
37
29
|
|
|
38
|
-
|
|
30
|
+
#: (singleton(::ActiveRecord::Base) constant, String attribute) -> bool
|
|
39
31
|
def has_unconditional_presence_validator?(constant, attribute)
|
|
40
32
|
return false unless constant.respond_to?(:validators_on)
|
|
41
33
|
|
|
@@ -46,14 +38,14 @@ module Boba
|
|
|
46
38
|
|
|
47
39
|
private
|
|
48
40
|
|
|
49
|
-
|
|
41
|
+
#: (ActiveModel::Validator validator) -> bool
|
|
50
42
|
def unconditional_presence_validator?(validator)
|
|
51
43
|
return false unless validator.is_a?(::ActiveRecord::Validations::PresenceValidator)
|
|
52
44
|
|
|
53
45
|
unconditional_validator?(validator)
|
|
54
46
|
end
|
|
55
47
|
|
|
56
|
-
|
|
48
|
+
#: (ActiveModel::Validator validator) -> bool
|
|
57
49
|
def unconditional_validator?(validator)
|
|
58
50
|
!validator.options.key?(:if) && !validator.options.key?(:unless) && !validator.options.key?(:on)
|
|
59
51
|
end
|
|
@@ -7,13 +7,11 @@ module Boba
|
|
|
7
7
|
module ActiveRecord
|
|
8
8
|
module ReflectionService
|
|
9
9
|
class << self
|
|
10
|
-
extend T::Sig
|
|
11
|
-
|
|
12
10
|
ReflectionType = T.type_alias do
|
|
13
11
|
T.any(::ActiveRecord::Reflection::ThroughReflection, ::ActiveRecord::Reflection::AssociationReflection)
|
|
14
12
|
end
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
#: (ReflectionType reflection) -> bool
|
|
17
15
|
def required_reflection?(reflection)
|
|
18
16
|
return true if has_one_and_required_reflection?(reflection)
|
|
19
17
|
|
|
@@ -22,7 +20,7 @@ module Boba
|
|
|
22
20
|
|
|
23
21
|
private
|
|
24
22
|
|
|
25
|
-
|
|
23
|
+
#: (ReflectionType reflection) -> bool
|
|
26
24
|
def has_one_and_required_reflection?(reflection)
|
|
27
25
|
return false unless reflection.has_one?
|
|
28
26
|
return true if !!reflection.options[:required]
|
|
@@ -33,7 +31,7 @@ module Boba
|
|
|
33
31
|
)
|
|
34
32
|
end
|
|
35
33
|
|
|
36
|
-
|
|
34
|
+
#: (ReflectionType reflection) -> bool
|
|
37
35
|
def belongs_to_and_non_optional_reflection?(reflection)
|
|
38
36
|
return false unless reflection.belongs_to?
|
|
39
37
|
|
|
@@ -4,22 +4,15 @@
|
|
|
4
4
|
module Boba
|
|
5
5
|
module Options
|
|
6
6
|
class AssociationTypeOption < T::Enum
|
|
7
|
-
extend T::Sig
|
|
8
|
-
|
|
9
7
|
enums do
|
|
10
8
|
Nilable = new("nilable")
|
|
11
9
|
Persisted = new("persisted")
|
|
12
10
|
end
|
|
13
11
|
|
|
14
12
|
class << self
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
params(
|
|
19
|
-
options: T::Hash[String, T.untyped],
|
|
20
|
-
block: T.proc.params(value: String, default_association_type_option: AssociationTypeOption).void,
|
|
21
|
-
).returns(AssociationTypeOption)
|
|
22
|
-
end
|
|
13
|
+
#: (
|
|
14
|
+
#| Hash[String, untyped] options
|
|
15
|
+
#| ) { (String value, AssociationTypeOption default_association_type_option) -> void } -> AssociationTypeOption
|
|
23
16
|
def from_options(options, &block)
|
|
24
17
|
association_type_option = Nilable
|
|
25
18
|
value = options["ActiveRecordAssociationTypes"]
|
|
@@ -36,12 +29,12 @@ module Boba
|
|
|
36
29
|
end
|
|
37
30
|
end
|
|
38
31
|
|
|
39
|
-
|
|
32
|
+
#: -> bool
|
|
40
33
|
def persisted?
|
|
41
34
|
self == AssociationTypeOption::Persisted
|
|
42
35
|
end
|
|
43
36
|
|
|
44
|
-
|
|
37
|
+
#: -> bool
|
|
45
38
|
def nilable?
|
|
46
39
|
self == AssociationTypeOption::Nilable
|
|
47
40
|
end
|
data/lib/boba/version.rb
CHANGED
|
@@ -52,13 +52,11 @@ module Tapioca
|
|
|
52
52
|
# def author; end
|
|
53
53
|
# ~~~
|
|
54
54
|
class ActiveRecordAssociationsPersisted < ::Tapioca::Dsl::Compilers::ActiveRecordAssociations
|
|
55
|
-
extend T::Sig
|
|
56
|
-
|
|
57
55
|
ConstantType = type_member { { fixed: T.class_of(ActiveRecord::Base) } }
|
|
58
56
|
|
|
59
57
|
private
|
|
60
58
|
|
|
61
|
-
|
|
59
|
+
#: -> Boba::Options::AssociationTypeOption
|
|
62
60
|
def association_type_option
|
|
63
61
|
@association_type_option ||= T.let(
|
|
64
62
|
Boba::Options::AssociationTypeOption.from_options(options) do |value, default_association_type_option|
|
|
@@ -71,13 +69,7 @@ module Tapioca
|
|
|
71
69
|
)
|
|
72
70
|
end
|
|
73
71
|
|
|
74
|
-
|
|
75
|
-
params(
|
|
76
|
-
klass: RBI::Scope,
|
|
77
|
-
association_name: T.any(String, Symbol),
|
|
78
|
-
reflection: ReflectionType,
|
|
79
|
-
).void
|
|
80
|
-
end
|
|
72
|
+
#: (RBI::Scope klass, (String | Symbol) association_name, ReflectionType reflection) -> void
|
|
81
73
|
def populate_single_assoc_getter_setter(klass, association_name, reflection)
|
|
82
74
|
association_class = type_for(reflection)
|
|
83
75
|
association_type = single_association_type_for(reflection)
|
|
@@ -140,11 +132,7 @@ module Tapioca
|
|
|
140
132
|
end
|
|
141
133
|
end
|
|
142
134
|
|
|
143
|
-
|
|
144
|
-
params(
|
|
145
|
-
reflection: ReflectionType,
|
|
146
|
-
).returns(String)
|
|
147
|
-
end
|
|
135
|
+
#: (ReflectionType reflection) -> String
|
|
148
136
|
def single_association_type_for(reflection)
|
|
149
137
|
association_class = type_for(reflection)
|
|
150
138
|
return as_nilable_type(association_class) unless association_type_option.persisted?
|
|
@@ -126,13 +126,11 @@ module Tapioca
|
|
|
126
126
|
# def title; end
|
|
127
127
|
# ~~~
|
|
128
128
|
class ActiveRecordColumnsPersisted < ::Tapioca::Dsl::Compilers::ActiveRecordColumns
|
|
129
|
-
extend T::Sig
|
|
130
|
-
|
|
131
129
|
ConstantType = type_member { { fixed: T.class_of(ActiveRecord::Base) } }
|
|
132
130
|
|
|
133
131
|
private
|
|
134
132
|
|
|
135
|
-
|
|
133
|
+
#: -> ::Tapioca::Dsl::Helpers::ActiveRecordColumnTypeHelper
|
|
136
134
|
def column_type_helper
|
|
137
135
|
::Tapioca::Dsl::Helpers::ActiveRecordColumnTypeHelper.new(
|
|
138
136
|
constant,
|
|
@@ -140,19 +138,14 @@ module Tapioca
|
|
|
140
138
|
)
|
|
141
139
|
end
|
|
142
140
|
|
|
143
|
-
|
|
144
|
-
params(
|
|
145
|
-
attribute_name: String,
|
|
146
|
-
column_name: String,
|
|
147
|
-
).returns([String, String])
|
|
148
|
-
end
|
|
141
|
+
#: (String attribute_name, ?String column_name) -> [String, String]
|
|
149
142
|
def type_for(attribute_name, column_name = attribute_name)
|
|
150
143
|
return column_type_helper.send(:id_type) if attribute_name == "id"
|
|
151
144
|
|
|
152
145
|
column_type_for(column_name)
|
|
153
146
|
end
|
|
154
147
|
|
|
155
|
-
|
|
148
|
+
#: (String column_name) -> [String, String]
|
|
156
149
|
def column_type_for(column_name)
|
|
157
150
|
return ["T.untyped", "T.untyped"] if column_type_option.untyped?
|
|
158
151
|
|
|
@@ -184,14 +177,7 @@ module Tapioca
|
|
|
184
177
|
end
|
|
185
178
|
end
|
|
186
179
|
|
|
187
|
-
|
|
188
|
-
params(
|
|
189
|
-
klass: RBI::Scope,
|
|
190
|
-
attribute_name: String,
|
|
191
|
-
column_name: String,
|
|
192
|
-
methods_to_add: T.nilable(T::Array[String]),
|
|
193
|
-
).void
|
|
194
|
-
end
|
|
180
|
+
#: (RBI::Scope klass, String attribute_name, ?String column_name, ?Array[String]? methods_to_add) -> void
|
|
195
181
|
def add_methods_for_attribute(klass, attribute_name, column_name = attribute_name, methods_to_add = nil)
|
|
196
182
|
getter_type, setter_type = type_for(attribute_name, column_name)
|
|
197
183
|
|
|
@@ -37,11 +37,10 @@ module Tapioca
|
|
|
37
37
|
# end
|
|
38
38
|
# ~~~
|
|
39
39
|
class ActiveRecordRelationTypes < Compiler
|
|
40
|
-
extend T::Sig
|
|
41
|
-
|
|
42
40
|
ConstantType = type_member { { fixed: T.class_of(::ActiveRecord::Base) } }
|
|
43
41
|
|
|
44
|
-
|
|
42
|
+
# @override
|
|
43
|
+
#: -> void
|
|
45
44
|
def decorate
|
|
46
45
|
root.create_path(constant) do |rbi_class|
|
|
47
46
|
relation_type_alias = "T.any(" \
|
|
@@ -54,9 +53,8 @@ module Tapioca
|
|
|
54
53
|
end
|
|
55
54
|
|
|
56
55
|
class << self
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
sig { override.returns(T::Enumerable[T::Module[T.anything]]) }
|
|
56
|
+
# @override
|
|
57
|
+
#: -> Enumerable[Module[top]]
|
|
60
58
|
def gather_constants
|
|
61
59
|
Tapioca::Dsl::Compilers::ActiveRecordRelations.gather_constants
|
|
62
60
|
end
|
|
@@ -34,23 +34,21 @@ module Tapioca
|
|
|
34
34
|
# end
|
|
35
35
|
# ~~~
|
|
36
36
|
class AttrJson < Tapioca::Dsl::Compiler
|
|
37
|
-
extend T::Sig
|
|
38
|
-
|
|
39
37
|
# Class methods module is already defined in the gem rbi, so just reference it here.
|
|
40
38
|
ClassMethodsModuleName = "AttrJson::Record::ClassMethods"
|
|
41
39
|
InstanceMethodModuleName = "AttrJsonGeneratedMethods"
|
|
42
40
|
ConstantType = type_member { { fixed: T.any(T.class_of(::AttrJson::Record), T.class_of(::AttrJson::Model)) } }
|
|
43
41
|
|
|
44
42
|
class << self
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
sig { override.returns(T::Enumerable[Module]) }
|
|
43
|
+
# @override
|
|
44
|
+
#: -> Enumerable[Module]
|
|
48
45
|
def gather_constants
|
|
49
46
|
all_classes.select { |constant| constant < ::AttrJson::Record || constant < ::AttrJson::Model }
|
|
50
47
|
end
|
|
51
48
|
end
|
|
52
49
|
|
|
53
|
-
|
|
50
|
+
# @override
|
|
51
|
+
#: -> void
|
|
54
52
|
def decorate
|
|
55
53
|
rbi_class = root.create_path(constant)
|
|
56
54
|
instance_module = RBI::Module.new(InstanceMethodModuleName)
|
|
@@ -47,23 +47,21 @@ module Tapioca
|
|
|
47
47
|
# end
|
|
48
48
|
# ~~~
|
|
49
49
|
class FlagShihTzu < Tapioca::Dsl::Compiler
|
|
50
|
-
extend T::Sig
|
|
51
|
-
|
|
52
50
|
ConstantType = type_member { { fixed: T.all(T.class_of(::FlagShihTzu), ::FlagShihTzu::GeneratedClassMethods) } }
|
|
53
51
|
|
|
54
52
|
InstanceMethodsModuleName = "FlagShihTzuGeneratedMethods"
|
|
55
53
|
ClassMethodsModuleName = "::FlagShihTzu"
|
|
56
54
|
|
|
57
55
|
class << self
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
sig { override.returns(T::Enumerable[T::Module[T.anything]]) }
|
|
56
|
+
# @override
|
|
57
|
+
#: -> Enumerable[Module[top]]
|
|
61
58
|
def gather_constants
|
|
62
59
|
all_classes.select { |c| c < ::FlagShihTzu }
|
|
63
60
|
end
|
|
64
61
|
end
|
|
65
62
|
|
|
66
|
-
|
|
63
|
+
# @override
|
|
64
|
+
#: -> void
|
|
67
65
|
def decorate
|
|
68
66
|
return if constant.flag_mapping.blank?
|
|
69
67
|
|
|
@@ -37,12 +37,12 @@ module Tapioca
|
|
|
37
37
|
# end
|
|
38
38
|
# ~~~
|
|
39
39
|
class Kaminari < Tapioca::Dsl::Compiler
|
|
40
|
-
extend T::Sig
|
|
41
40
|
include Helpers::ActiveRecordConstantsHelper
|
|
42
41
|
|
|
43
42
|
ConstantType = type_member { { fixed: T.class_of(::ActiveRecord::Base) } }
|
|
44
43
|
|
|
45
|
-
|
|
44
|
+
# @override
|
|
45
|
+
#: -> void
|
|
46
46
|
def decorate
|
|
47
47
|
root.create_path(constant) do |model|
|
|
48
48
|
target_modules.each do |module_name, return_type|
|
|
@@ -58,9 +58,8 @@ module Tapioca
|
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
class << self
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
sig { override.returns(T::Enumerable[T::Module[T.anything]]) }
|
|
61
|
+
# @override
|
|
62
|
+
#: -> Enumerable[Module[top]]
|
|
64
63
|
def gather_constants
|
|
65
64
|
descendants_of(::ActiveRecord::Base).reject(&:abstract_class?)
|
|
66
65
|
end
|
|
@@ -68,7 +67,7 @@ module Tapioca
|
|
|
68
67
|
|
|
69
68
|
private
|
|
70
69
|
|
|
71
|
-
|
|
70
|
+
#: -> Array[[String, String]]
|
|
72
71
|
def target_modules
|
|
73
72
|
if compiler_enabled?("ActiveRecordRelations")
|
|
74
73
|
[
|
|
@@ -42,7 +42,6 @@ module Tapioca
|
|
|
42
42
|
# end
|
|
43
43
|
# ~~~
|
|
44
44
|
class MoneyRails < Tapioca::Dsl::Compiler
|
|
45
|
-
extend T::Sig
|
|
46
45
|
include RBIHelper
|
|
47
46
|
|
|
48
47
|
ConstantType = type_member do
|
|
@@ -58,9 +57,8 @@ module Tapioca
|
|
|
58
57
|
InstanceModuleName = "MoneyRailsGeneratedMethods"
|
|
59
58
|
|
|
60
59
|
class << self
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
sig { override.returns(T::Enumerable[T::Module[T.anything]]) }
|
|
60
|
+
# @override
|
|
61
|
+
#: -> Enumerable[Module[top]]
|
|
64
62
|
def gather_constants
|
|
65
63
|
all_classes.select { |c| c < ::MoneyRails::ActiveRecord::Monetizable }
|
|
66
64
|
end
|
|
@@ -68,7 +66,7 @@ module Tapioca
|
|
|
68
66
|
|
|
69
67
|
ColumnTypeOption = Tapioca::Dsl::Helpers::ActiveRecordColumnTypeHelper::ColumnTypeOption
|
|
70
68
|
|
|
71
|
-
|
|
69
|
+
#: -> ColumnTypeOption
|
|
72
70
|
def column_type_option
|
|
73
71
|
@column_type_option ||= T.let(
|
|
74
72
|
ColumnTypeOption.from_options(options) do |value, default_column_type_option|
|
|
@@ -81,7 +79,8 @@ module Tapioca
|
|
|
81
79
|
)
|
|
82
80
|
end
|
|
83
81
|
|
|
84
|
-
|
|
82
|
+
# @override
|
|
83
|
+
#: -> void
|
|
85
84
|
def decorate
|
|
86
85
|
return if constant.monetized_attributes.empty?
|
|
87
86
|
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
return unless defined?(Noticed::Event) && defined?(Noticed::Ephemeral)
|
|
5
|
+
|
|
6
|
+
module Tapioca
|
|
7
|
+
module Dsl
|
|
8
|
+
module Compilers
|
|
9
|
+
# `Tapioca::Dsl::Compilers::Noticed` decorates RBI files for subclasses
|
|
10
|
+
# of `Noticed::Event` and `Noticed::Ephemeral`.
|
|
11
|
+
#
|
|
12
|
+
# For example, with the following notifier class:
|
|
13
|
+
#
|
|
14
|
+
# ~~~rb
|
|
15
|
+
# class NewCommentNotifier < Noticed::Event
|
|
16
|
+
# required_params :comment
|
|
17
|
+
# deliver_by :email
|
|
18
|
+
# end
|
|
19
|
+
# ~~~
|
|
20
|
+
#
|
|
21
|
+
# This compiler will produce the RBI file `new_comment_notifier.rbi` with the following content:
|
|
22
|
+
#
|
|
23
|
+
# ~~~rbi
|
|
24
|
+
# # new_comment_notifier.rbi
|
|
25
|
+
# # typed: true
|
|
26
|
+
# class NewCommentNotifier
|
|
27
|
+
# class << self
|
|
28
|
+
# sig { params(params: T::Hash[Symbol, T.untyped]).returns(NewCommentNotifier) }
|
|
29
|
+
# def with(params); end
|
|
30
|
+
#
|
|
31
|
+
# sig { params(recipients: T.untyped, enqueue_job: T.nilable(T::Boolean), options: T.untyped).returns(NewCommentNotifier) }
|
|
32
|
+
# def deliver(recipients = T.unsafe(nil), enqueue_job: T.unsafe(nil), **options); end
|
|
33
|
+
#
|
|
34
|
+
# sig { params(recipients: T.untyped, enqueue_job: T.nilable(T::Boolean), options: T.untyped).returns(NewCommentNotifier) }
|
|
35
|
+
# def deliver_later(recipients = T.unsafe(nil), enqueue_job: T.unsafe(nil), **options); end
|
|
36
|
+
# end
|
|
37
|
+
# end
|
|
38
|
+
# ~~~
|
|
39
|
+
class Noticed < Tapioca::Dsl::Compiler
|
|
40
|
+
ConstantType = type_member do
|
|
41
|
+
{ fixed: T.any(T.class_of(::Noticed::Event), T.class_of(::Noticed::Ephemeral)) }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
class << self
|
|
45
|
+
# @override
|
|
46
|
+
#: -> Enumerable[Module[top]]
|
|
47
|
+
def gather_constants
|
|
48
|
+
all_classes.select do |klass|
|
|
49
|
+
klass < ::Noticed::Event || klass < ::Noticed::Ephemeral
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# @override
|
|
55
|
+
#: -> void
|
|
56
|
+
def decorate
|
|
57
|
+
root.create_path(constant) do |klass|
|
|
58
|
+
singleton = RBI::SingletonClass.new
|
|
59
|
+
klass << singleton
|
|
60
|
+
|
|
61
|
+
singleton.create_method(
|
|
62
|
+
"with",
|
|
63
|
+
parameters: [create_param("params", type: "T::Hash[Symbol, T.untyped]")],
|
|
64
|
+
return_type: "::#{constant}",
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
singleton.create_method(
|
|
68
|
+
"deliver",
|
|
69
|
+
parameters: [
|
|
70
|
+
create_opt_param("recipients", type: "T.untyped", default: "T.unsafe(nil)"),
|
|
71
|
+
create_kw_opt_param("enqueue_job", type: "T.nilable(T::Boolean)", default: "T.unsafe(nil)"),
|
|
72
|
+
create_kw_rest_param("options", type: "T.untyped"),
|
|
73
|
+
],
|
|
74
|
+
return_type: "::#{constant}",
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
singleton.create_method(
|
|
78
|
+
"deliver_later",
|
|
79
|
+
parameters: [
|
|
80
|
+
create_opt_param("recipients", type: "T.untyped", default: "T.unsafe(nil)"),
|
|
81
|
+
create_kw_opt_param("enqueue_job", type: "T.nilable(T::Boolean)", default: "T.unsafe(nil)"),
|
|
82
|
+
create_kw_rest_param("options", type: "T.untyped"),
|
|
83
|
+
],
|
|
84
|
+
return_type: "::#{constant}",
|
|
85
|
+
)
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
@@ -32,7 +32,6 @@ module Tapioca
|
|
|
32
32
|
# end
|
|
33
33
|
# ~~~
|
|
34
34
|
class Paperclip < Tapioca::Dsl::Compiler
|
|
35
|
-
extend T::Sig
|
|
36
35
|
include RBIHelper
|
|
37
36
|
|
|
38
37
|
ClassMethodsModuleName = "::Paperclip::Glue"
|
|
@@ -41,15 +40,15 @@ module Tapioca
|
|
|
41
40
|
ConstantType = type_member { { fixed: T.class_of(::Paperclip::Glue) } }
|
|
42
41
|
|
|
43
42
|
class << self
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
sig { override.returns(T::Enumerable[T::Module[T.anything]]) }
|
|
43
|
+
# @override
|
|
44
|
+
#: -> Enumerable[Module[top]]
|
|
47
45
|
def gather_constants
|
|
48
46
|
all_classes.select { |c| c < ::Paperclip::Glue }
|
|
49
47
|
end
|
|
50
48
|
end
|
|
51
49
|
|
|
52
|
-
|
|
50
|
+
# @override
|
|
51
|
+
#: -> void
|
|
53
52
|
def decorate
|
|
54
53
|
# this is a bit awkward, but load order determines the return order here, so sort to ensure consistency across
|
|
55
54
|
# all environments.
|
|
@@ -112,8 +112,6 @@ module Tapioca
|
|
|
112
112
|
# end
|
|
113
113
|
# ~~~
|
|
114
114
|
class StateMachinesExtended < Compiler
|
|
115
|
-
extend T::Sig
|
|
116
|
-
|
|
117
115
|
ACTIVE_RECORD_RELATION_MODULE_NAMES = [
|
|
118
116
|
"GeneratedRelationMethods",
|
|
119
117
|
"GeneratedAssociationRelationMethods",
|
|
@@ -121,7 +119,8 @@ module Tapioca
|
|
|
121
119
|
|
|
122
120
|
ConstantType = type_member { { fixed: T.all(T::Module[T.anything], ::StateMachines::ClassMethods) } }
|
|
123
121
|
|
|
124
|
-
|
|
122
|
+
# @override
|
|
123
|
+
#: -> void
|
|
125
124
|
def decorate
|
|
126
125
|
return if constant.state_machines.empty?
|
|
127
126
|
|
|
@@ -166,9 +165,8 @@ module Tapioca
|
|
|
166
165
|
end
|
|
167
166
|
|
|
168
167
|
class << self
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
sig { override.returns(T::Enumerable[T::Module[T.anything]]) }
|
|
168
|
+
# @override
|
|
169
|
+
#: -> Enumerable[Module[top]]
|
|
172
170
|
def gather_constants
|
|
173
171
|
all_classes.select { |mod| ::StateMachines::InstanceMethods > mod }
|
|
174
172
|
end
|
|
@@ -176,12 +174,12 @@ module Tapioca
|
|
|
176
174
|
|
|
177
175
|
private
|
|
178
176
|
|
|
179
|
-
|
|
177
|
+
#: (Module[top] constant) -> bool
|
|
180
178
|
def uses_active_record_integration?(constant)
|
|
181
179
|
::StateMachines::Integrations.match(constant)&.integration_name == :active_record
|
|
182
180
|
end
|
|
183
181
|
|
|
184
|
-
|
|
182
|
+
#: (::StateMachines::Machine machine) -> String
|
|
185
183
|
def state_type_for(machine)
|
|
186
184
|
value_types = machine.states.map { |state| state.value.class.name }.uniq
|
|
187
185
|
|
|
@@ -192,7 +190,7 @@ module Tapioca
|
|
|
192
190
|
end
|
|
193
191
|
end
|
|
194
192
|
|
|
195
|
-
|
|
193
|
+
#: (RBI::Module instance_module) -> void
|
|
196
194
|
def define_activerecord_methods(instance_module)
|
|
197
195
|
instance_module.create_method(
|
|
198
196
|
"changed_for_autosave?",
|
|
@@ -200,7 +198,7 @@ module Tapioca
|
|
|
200
198
|
)
|
|
201
199
|
end
|
|
202
200
|
|
|
203
|
-
|
|
201
|
+
#: (RBI::Module instance_module, ::StateMachines::Machine machine) -> void
|
|
204
202
|
def define_state_methods(instance_module, machine)
|
|
205
203
|
machine.states.each do |state|
|
|
206
204
|
instance_module.create_method(
|
|
@@ -210,7 +208,7 @@ module Tapioca
|
|
|
210
208
|
end
|
|
211
209
|
end
|
|
212
210
|
|
|
213
|
-
|
|
211
|
+
#: (RBI::Module instance_module, ::StateMachines::Machine machine) -> void
|
|
214
212
|
def define_event_methods(instance_module, machine)
|
|
215
213
|
machine.events.each do |event|
|
|
216
214
|
instance_module.create_method(
|
|
@@ -235,13 +233,7 @@ module Tapioca
|
|
|
235
233
|
end
|
|
236
234
|
end
|
|
237
235
|
|
|
238
|
-
|
|
239
|
-
params(
|
|
240
|
-
instance_module: RBI::Module,
|
|
241
|
-
machine: ::StateMachines::Machine,
|
|
242
|
-
state_type: String,
|
|
243
|
-
).void
|
|
244
|
-
end
|
|
236
|
+
#: (RBI::Module instance_module, ::StateMachines::Machine machine, String state_type) -> void
|
|
245
237
|
def define_state_accessor(instance_module, machine, state_type)
|
|
246
238
|
owner_class = machine.owner_class
|
|
247
239
|
attribute = machine.attribute.to_sym
|
|
@@ -266,7 +258,7 @@ module Tapioca
|
|
|
266
258
|
end
|
|
267
259
|
end
|
|
268
260
|
|
|
269
|
-
|
|
261
|
+
#: (RBI::Module instance_module, ::StateMachines::Machine machine) -> void
|
|
270
262
|
def define_state_predicate(instance_module, machine)
|
|
271
263
|
instance_module.create_method(
|
|
272
264
|
"#{machine.name}?",
|
|
@@ -275,7 +267,7 @@ module Tapioca
|
|
|
275
267
|
)
|
|
276
268
|
end
|
|
277
269
|
|
|
278
|
-
|
|
270
|
+
#: (RBI::Module instance_module, ::StateMachines::Machine machine) -> void
|
|
279
271
|
def define_event_helpers(instance_module, machine)
|
|
280
272
|
events_attribute = machine.attribute(:events).to_s
|
|
281
273
|
transitions_attribute = machine.attribute(:transitions).to_s
|
|
@@ -322,7 +314,7 @@ module Tapioca
|
|
|
322
314
|
end
|
|
323
315
|
end
|
|
324
316
|
|
|
325
|
-
|
|
317
|
+
#: (RBI::Module instance_module, ::StateMachines::Machine machine) -> void
|
|
326
318
|
def define_path_helpers(instance_module, machine)
|
|
327
319
|
paths_attribute = machine.attribute(:paths).to_s
|
|
328
320
|
|
|
@@ -333,13 +325,7 @@ module Tapioca
|
|
|
333
325
|
)
|
|
334
326
|
end
|
|
335
327
|
|
|
336
|
-
|
|
337
|
-
params(
|
|
338
|
-
instance_module: RBI::Module,
|
|
339
|
-
class_module: RBI::Module,
|
|
340
|
-
machine: ::StateMachines::Machine,
|
|
341
|
-
).void
|
|
342
|
-
end
|
|
328
|
+
#: (RBI::Module instance_module, RBI::Module class_module, ::StateMachines::Machine machine) -> void
|
|
343
329
|
def define_name_helpers(instance_module, class_module, machine)
|
|
344
330
|
name_attribute = machine.attribute(:name).to_s
|
|
345
331
|
event_name_attribute = machine.attribute(:event_name).to_s
|
|
@@ -364,7 +350,7 @@ module Tapioca
|
|
|
364
350
|
)
|
|
365
351
|
end
|
|
366
352
|
|
|
367
|
-
|
|
353
|
+
#: (RBI::Module class_module, ::StateMachines::Machine machine) -> void
|
|
368
354
|
def define_scopes(class_module, machine)
|
|
369
355
|
helper_modules = machine.instance_variable_get(:@helper_modules)
|
|
370
356
|
class_methods = helper_modules[:class].instance_methods(false)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: boba
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Angellist
|
|
@@ -10,33 +10,33 @@ cert_chain: []
|
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
|
-
name: sorbet
|
|
13
|
+
name: sorbet
|
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
|
15
15
|
requirements:
|
|
16
|
-
- - "
|
|
16
|
+
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version:
|
|
19
|
-
type: :
|
|
18
|
+
version: 0.6.12698
|
|
19
|
+
type: :development
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
|
-
- - "
|
|
23
|
+
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version:
|
|
25
|
+
version: 0.6.12698
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: tapioca
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
30
30
|
- - "<="
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: 0.
|
|
32
|
+
version: 0.19.0
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - "<="
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: 0.
|
|
39
|
+
version: 0.19.0
|
|
40
40
|
email:
|
|
41
41
|
- alex.stathis@angellist.com
|
|
42
42
|
executables: []
|
|
@@ -58,6 +58,7 @@ files:
|
|
|
58
58
|
- lib/tapioca/dsl/compilers/flag_shih_tzu.rb
|
|
59
59
|
- lib/tapioca/dsl/compilers/kaminari.rb
|
|
60
60
|
- lib/tapioca/dsl/compilers/money_rails.rb
|
|
61
|
+
- lib/tapioca/dsl/compilers/noticed.rb
|
|
61
62
|
- lib/tapioca/dsl/compilers/paperclip.rb
|
|
62
63
|
- lib/tapioca/dsl/compilers/state_machines_extended.rb
|
|
63
64
|
homepage: https://github.com/angellist/boba
|
|
@@ -65,9 +66,9 @@ licenses:
|
|
|
65
66
|
- MIT
|
|
66
67
|
metadata:
|
|
67
68
|
bug_tracker_uri: https://github.com/angellist/boba/issues
|
|
68
|
-
changelog_uri: https://github.com/angellist/boba/blob/0.1.
|
|
69
|
+
changelog_uri: https://github.com/angellist/boba/blob/0.1.8/History.md
|
|
69
70
|
homepage_uri: https://github.com/angellist/boba
|
|
70
|
-
source_code_uri: https://github.com/angellist/boba/tree/0.1.
|
|
71
|
+
source_code_uri: https://github.com/angellist/boba/tree/0.1.8
|
|
71
72
|
rubygems_mfa_required: 'true'
|
|
72
73
|
rdoc_options: []
|
|
73
74
|
require_paths:
|
|
@@ -83,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
83
84
|
- !ruby/object:Gem::Version
|
|
84
85
|
version: '0'
|
|
85
86
|
requirements: []
|
|
86
|
-
rubygems_version:
|
|
87
|
+
rubygems_version: 4.0.6
|
|
87
88
|
specification_version: 4
|
|
88
89
|
summary: Custom Tapioca compilers
|
|
89
90
|
test_files: []
|