tapioca 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/lib/tapioca/compilers/dsl/active_record_relations.rb +9 -1
- data/lib/tapioca/compilers/dsl/rails_generators.rb +2 -2
- data/lib/tapioca/compilers/dsl/smart_properties.rb +11 -15
- data/lib/tapioca/compilers/dsl/url_helpers.rb +8 -3
- data/lib/tapioca/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4eea2d365ede4ba5398d65a2042c7dc86270ec7309cb0bc9747357f44ea1c675
|
4
|
+
data.tar.gz: 7f7252a0619b138664fe5d30acf0858fb09eb9403d513a06266cc58c464dd3b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ac4530bd50af56e2acee0a630571dbc7452cf10e55ec89088ddb5ed8f9a350fae0b4031602fa13b5b319390172e55bdebe6a3d3b6a722e88fe7902aceb5bb61
|
7
|
+
data.tar.gz: 26a6365606966861c36ffcea2b247a7dfc5395925d04a9d89f35273ce6ae9c3f29ee3d94002c3dd49c46f05acda9e202025a79cf9e4dd0fbebe49ff542d575ae
|
data/Gemfile
CHANGED
@@ -532,7 +532,7 @@ module Tapioca
|
|
532
532
|
],
|
533
533
|
return_type: "T::Boolean"
|
534
534
|
)
|
535
|
-
when :find
|
535
|
+
when :find
|
536
536
|
create_common_method(
|
537
537
|
"find",
|
538
538
|
parameters: [
|
@@ -548,6 +548,14 @@ module Tapioca
|
|
548
548
|
],
|
549
549
|
return_type: "T.nilable(#{constant_name})"
|
550
550
|
)
|
551
|
+
when :find_by!
|
552
|
+
create_common_method(
|
553
|
+
"find_by!",
|
554
|
+
parameters: [
|
555
|
+
create_rest_param("args", type: "T.untyped"),
|
556
|
+
],
|
557
|
+
return_type: constant_name
|
558
|
+
)
|
551
559
|
when :first, :last, :take
|
552
560
|
create_common_method(
|
553
561
|
method_name,
|
@@ -64,12 +64,12 @@ module Tapioca
|
|
64
64
|
|
65
65
|
sig { override.returns(T::Enumerable[Module]) }
|
66
66
|
def gather_constants
|
67
|
-
|
67
|
+
all_classes.select do |const|
|
68
68
|
name = qualified_name_of(const)
|
69
69
|
|
70
70
|
name &&
|
71
71
|
!name.match?(BUILT_IN_MATCHER) &&
|
72
|
-
|
72
|
+
::Rails::Generators::Base > const
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
@@ -71,14 +71,15 @@ module Tapioca
|
|
71
71
|
)
|
72
72
|
return if properties.keys.empty?
|
73
73
|
|
74
|
-
instance_methods = constant.instance_methods(false).map(&:to_s).to_set
|
75
|
-
|
76
74
|
root.create_path(constant) do |k|
|
77
|
-
|
78
|
-
|
79
|
-
|
75
|
+
smart_properties_methods_name = "SmartPropertiesGeneratedMethods"
|
76
|
+
k.create_module(smart_properties_methods_name) do |mod|
|
77
|
+
properties.values.each do |property|
|
78
|
+
generate_methods_for_property(mod, property)
|
80
79
|
end
|
81
80
|
end
|
81
|
+
|
82
|
+
k.create_include(smart_properties_methods_name)
|
82
83
|
end
|
83
84
|
end
|
84
85
|
|
@@ -95,26 +96,21 @@ module Tapioca
|
|
95
96
|
|
96
97
|
sig do
|
97
98
|
params(
|
98
|
-
|
99
|
-
property: ::SmartProperties::Property
|
100
|
-
block: T.proc.params(arg: String).returns(T::Boolean)
|
99
|
+
mod: RBI::Scope,
|
100
|
+
property: ::SmartProperties::Property
|
101
101
|
).void
|
102
102
|
end
|
103
|
-
def generate_methods_for_property(
|
103
|
+
def generate_methods_for_property(mod, property)
|
104
104
|
type = type_for(property)
|
105
105
|
|
106
106
|
if property.writable?
|
107
107
|
name = property.name.to_s
|
108
108
|
method_name = "#{name}="
|
109
109
|
|
110
|
-
|
111
|
-
method_name,
|
112
|
-
parameters: [create_param(name, type: type)],
|
113
|
-
return_type: type
|
114
|
-
) if block.call(method_name)
|
110
|
+
mod.create_method(method_name, parameters: [create_param(name, type: type)], return_type: type)
|
115
111
|
end
|
116
112
|
|
117
|
-
|
113
|
+
mod.create_method(property.reader.to_s, return_type: type)
|
118
114
|
end
|
119
115
|
|
120
116
|
BOOLEANS = T.let([
|
@@ -151,9 +151,14 @@ module Tapioca
|
|
151
151
|
|
152
152
|
sig { params(mod: Module, helper: Module).returns(T::Boolean) }
|
153
153
|
def includes_helper?(mod, helper)
|
154
|
-
superclass_ancestors =
|
155
|
-
|
156
|
-
|
154
|
+
superclass_ancestors = []
|
155
|
+
|
156
|
+
if Class === mod
|
157
|
+
superclass = superclass_of(mod)
|
158
|
+
superclass_ancestors = ancestors_of(superclass) if superclass
|
159
|
+
end
|
160
|
+
|
161
|
+
(ancestors_of(mod) - superclass_ancestors).any? { |ancestor| helper == ancestor }
|
157
162
|
end
|
158
163
|
end
|
159
164
|
end
|
data/lib/tapioca/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tapioca
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ufuk Kayserilioglu
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date: 2021-12-
|
14
|
+
date: 2021-12-26 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|