tapioca 0.2.7 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +27 -1
  3. data/README.md +21 -2
  4. data/Rakefile +15 -4
  5. data/lib/tapioca.rb +15 -9
  6. data/lib/tapioca/cli.rb +41 -12
  7. data/lib/tapioca/compilers/dsl/action_controller_helpers.rb +129 -0
  8. data/lib/tapioca/compilers/dsl/action_mailer.rb +65 -0
  9. data/lib/tapioca/compilers/dsl/active_record_associations.rb +285 -0
  10. data/lib/tapioca/compilers/dsl/active_record_columns.rb +379 -0
  11. data/lib/tapioca/compilers/dsl/active_record_enum.rb +112 -0
  12. data/lib/tapioca/compilers/dsl/active_record_identity_cache.rb +213 -0
  13. data/lib/tapioca/compilers/dsl/active_record_scope.rb +100 -0
  14. data/lib/tapioca/compilers/dsl/active_record_typed_store.rb +170 -0
  15. data/lib/tapioca/compilers/dsl/active_resource.rb +140 -0
  16. data/lib/tapioca/compilers/dsl/active_support_current_attributes.rb +126 -0
  17. data/lib/tapioca/compilers/dsl/base.rb +163 -0
  18. data/lib/tapioca/compilers/dsl/frozen_record.rb +96 -0
  19. data/lib/tapioca/compilers/dsl/protobuf.rb +144 -0
  20. data/lib/tapioca/compilers/dsl/smart_properties.rb +173 -0
  21. data/lib/tapioca/compilers/dsl/state_machines.rb +378 -0
  22. data/lib/tapioca/compilers/dsl/url_helpers.rb +83 -0
  23. data/lib/tapioca/compilers/dsl_compiler.rb +121 -0
  24. data/lib/tapioca/compilers/requires_compiler.rb +67 -0
  25. data/lib/tapioca/compilers/sorbet.rb +34 -0
  26. data/lib/tapioca/compilers/symbol_table/symbol_generator.rb +209 -49
  27. data/lib/tapioca/compilers/symbol_table/symbol_loader.rb +3 -17
  28. data/lib/tapioca/compilers/todos_compiler.rb +32 -0
  29. data/lib/tapioca/config.rb +42 -0
  30. data/lib/tapioca/config_builder.rb +75 -0
  31. data/lib/tapioca/constant_locator.rb +1 -0
  32. data/lib/tapioca/core_ext/class.rb +23 -0
  33. data/lib/tapioca/gemfile.rb +14 -1
  34. data/lib/tapioca/generator.rb +235 -67
  35. data/lib/tapioca/loader.rb +20 -9
  36. data/lib/tapioca/sorbet_config_parser.rb +77 -0
  37. data/lib/tapioca/version.rb +1 -1
  38. metadata +35 -66
@@ -24,6 +24,24 @@ module Tapioca
24
24
  load_rails_engines
25
25
  end
26
26
 
27
+ sig { params(environment_load: T::Boolean, eager_load: T::Boolean).void }
28
+ def load_rails(environment_load: false, eager_load: false)
29
+ return unless File.exist?("config/application.rb")
30
+
31
+ safe_require("rails")
32
+
33
+ silence_deprecations
34
+
35
+ safe_require("rails/generators/test_case")
36
+ if environment_load
37
+ safe_require("./config/environment")
38
+ else
39
+ safe_require("./config/application")
40
+ end
41
+
42
+ eager_load_rails_app if eager_load
43
+ end
44
+
27
45
  private
28
46
 
29
47
  sig { returns(Tapioca::Gemfile) }
@@ -80,15 +98,8 @@ module Tapioca
80
98
  end
81
99
 
82
100
  sig { void }
83
- def load_rails
84
- return unless File.exist?("config/application.rb")
85
-
86
- safe_require("rails")
87
-
88
- silence_deprecations
89
-
90
- safe_require("rails/generators/test_case")
91
- safe_require("./config/application")
101
+ def eager_load_rails_app
102
+ Object.const_get("Rails").autoloaders.each(&:eager_load)
92
103
  end
93
104
 
94
105
  sig { void }
@@ -0,0 +1,77 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Tapioca
5
+ class SorbetConfig
6
+ extend T::Sig
7
+
8
+ sig { returns(T::Array[String]) }
9
+ attr_reader :paths, :ignore
10
+
11
+ sig { void }
12
+ def initialize
13
+ @paths = T.let([], T::Array[String])
14
+ @ignore = T.let([], T::Array[String])
15
+ end
16
+
17
+ class << self
18
+ extend T::Sig
19
+
20
+ sig { params(sorbet_config_path: String).returns(SorbetConfig) }
21
+ def parse_file(sorbet_config_path)
22
+ parse_string(File.read(sorbet_config_path))
23
+ end
24
+
25
+ sig { params(sorbet_config: String).returns(SorbetConfig) }
26
+ def parse_string(sorbet_config)
27
+ config = SorbetConfig.new
28
+ ignore = T.let(false, T::Boolean)
29
+ skip = T.let(false, T::Boolean)
30
+ sorbet_config.each_line do |line|
31
+ line = line.strip
32
+ case line
33
+ when /^--ignore$/
34
+ ignore = true
35
+ next
36
+ when /^--ignore=/
37
+ config.ignore << parse_option(line)
38
+ next
39
+ when /^--file$/
40
+ next
41
+ when /^--file=/
42
+ config.paths << parse_option(line)
43
+ next
44
+ when /^--dir$/
45
+ next
46
+ when /^--dir=/
47
+ config.paths << parse_option(line)
48
+ next
49
+ when /^--.*=/
50
+ next
51
+ when /^--/
52
+ skip = true
53
+ when /^-.*=?/
54
+ next
55
+ else
56
+ if ignore
57
+ config.ignore << line
58
+ ignore = false
59
+ elsif skip
60
+ skip = false
61
+ else
62
+ config.paths << line
63
+ end
64
+ end
65
+ end
66
+ config
67
+ end
68
+
69
+ private
70
+
71
+ sig { params(line: String).returns(String) }
72
+ def parse_option(line)
73
+ T.must(line.split("=").last).strip
74
+ end
75
+ end
76
+ end
77
+ end
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Tapioca
5
- VERSION = "0.2.7"
5
+ VERSION = "0.4.1"
6
6
  end
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.2.7
4
+ version: 0.4.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: 2020-02-13 00:00:00.000000000 Z
14
+ date: 2020-07-27 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: pry
@@ -56,89 +56,33 @@ dependencies:
56
56
  - !ruby/object:Gem::Version
57
57
  version: '0'
58
58
  - !ruby/object:Gem::Dependency
59
- name: thor
59
+ name: parlour
60
60
  requirement: !ruby/object:Gem::Requirement
61
61
  requirements:
62
62
  - - ">="
63
63
  - !ruby/object:Gem::Version
64
- version: '0'
64
+ version: 2.1.0
65
65
  type: :runtime
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
69
  - - ">="
70
70
  - !ruby/object:Gem::Version
71
- version: '0'
72
- - !ruby/object:Gem::Dependency
73
- name: bundler
74
- requirement: !ruby/object:Gem::Requirement
75
- requirements:
76
- - - "~>"
77
- - !ruby/object:Gem::Version
78
- version: '1.17'
79
- type: :development
80
- prerelease: false
81
- version_requirements: !ruby/object:Gem::Requirement
82
- requirements:
83
- - - "~>"
84
- - !ruby/object:Gem::Version
85
- version: '1.17'
86
- - !ruby/object:Gem::Dependency
87
- name: pry-byebug
88
- requirement: !ruby/object:Gem::Requirement
89
- requirements:
90
- - - ">="
91
- - !ruby/object:Gem::Version
92
- version: '0'
93
- type: :development
94
- prerelease: false
95
- version_requirements: !ruby/object:Gem::Requirement
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- version: '0'
71
+ version: 2.1.0
100
72
  - !ruby/object:Gem::Dependency
101
- name: rspec
102
- requirement: !ruby/object:Gem::Requirement
103
- requirements:
104
- - - ">="
105
- - !ruby/object:Gem::Version
106
- version: '0'
107
- type: :development
108
- prerelease: false
109
- version_requirements: !ruby/object:Gem::Requirement
110
- requirements:
111
- - - ">="
112
- - !ruby/object:Gem::Version
113
- version: '0'
114
- - !ruby/object:Gem::Dependency
115
- name: rubocop
116
- requirement: !ruby/object:Gem::Requirement
117
- requirements:
118
- - - "~>"
119
- - !ruby/object:Gem::Version
120
- version: 0.78.0
121
- type: :development
122
- prerelease: false
123
- version_requirements: !ruby/object:Gem::Requirement
124
- requirements:
125
- - - "~>"
126
- - !ruby/object:Gem::Version
127
- version: 0.78.0
128
- - !ruby/object:Gem::Dependency
129
- name: sorbet
73
+ name: thor
130
74
  requirement: !ruby/object:Gem::Requirement
131
75
  requirements:
132
76
  - - ">="
133
77
  - !ruby/object:Gem::Version
134
- version: '0'
135
- type: :development
78
+ version: 0.19.2
79
+ type: :runtime
136
80
  prerelease: false
137
81
  version_requirements: !ruby/object:Gem::Requirement
138
82
  requirements:
139
83
  - - ">="
140
84
  - !ruby/object:Gem::Version
141
- version: '0'
85
+ version: 0.19.2
142
86
  description:
143
87
  email:
144
88
  - ruby@shopify.com
@@ -153,18 +97,43 @@ files:
153
97
  - exe/tapioca
154
98
  - lib/tapioca.rb
155
99
  - lib/tapioca/cli.rb
100
+ - lib/tapioca/compilers/dsl/action_controller_helpers.rb
101
+ - lib/tapioca/compilers/dsl/action_mailer.rb
102
+ - lib/tapioca/compilers/dsl/active_record_associations.rb
103
+ - lib/tapioca/compilers/dsl/active_record_columns.rb
104
+ - lib/tapioca/compilers/dsl/active_record_enum.rb
105
+ - lib/tapioca/compilers/dsl/active_record_identity_cache.rb
106
+ - lib/tapioca/compilers/dsl/active_record_scope.rb
107
+ - lib/tapioca/compilers/dsl/active_record_typed_store.rb
108
+ - lib/tapioca/compilers/dsl/active_resource.rb
109
+ - lib/tapioca/compilers/dsl/active_support_current_attributes.rb
110
+ - lib/tapioca/compilers/dsl/base.rb
111
+ - lib/tapioca/compilers/dsl/frozen_record.rb
112
+ - lib/tapioca/compilers/dsl/protobuf.rb
113
+ - lib/tapioca/compilers/dsl/smart_properties.rb
114
+ - lib/tapioca/compilers/dsl/state_machines.rb
115
+ - lib/tapioca/compilers/dsl/url_helpers.rb
116
+ - lib/tapioca/compilers/dsl_compiler.rb
117
+ - lib/tapioca/compilers/requires_compiler.rb
118
+ - lib/tapioca/compilers/sorbet.rb
156
119
  - lib/tapioca/compilers/symbol_table/symbol_generator.rb
157
120
  - lib/tapioca/compilers/symbol_table/symbol_loader.rb
158
121
  - lib/tapioca/compilers/symbol_table_compiler.rb
122
+ - lib/tapioca/compilers/todos_compiler.rb
123
+ - lib/tapioca/config.rb
124
+ - lib/tapioca/config_builder.rb
159
125
  - lib/tapioca/constant_locator.rb
126
+ - lib/tapioca/core_ext/class.rb
160
127
  - lib/tapioca/gemfile.rb
161
128
  - lib/tapioca/generator.rb
162
129
  - lib/tapioca/loader.rb
130
+ - lib/tapioca/sorbet_config_parser.rb
163
131
  - lib/tapioca/version.rb
164
132
  homepage: https://github.com/Shopify/tapioca
165
133
  licenses:
166
134
  - MIT
167
- metadata: {}
135
+ metadata:
136
+ allowed_push_host: https://rubygems.org
168
137
  post_install_message:
169
138
  rdoc_options: []
170
139
  require_paths: