tapioca 0.3.0 → 0.4.3

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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +25 -1
  3. data/README.md +23 -2
  4. data/Rakefile +15 -4
  5. data/lib/tapioca.rb +8 -2
  6. data/lib/tapioca/cli.rb +31 -2
  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 +387 -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 +165 -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 +92 -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 +223 -35
  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 +14 -6
  30. data/lib/tapioca/config_builder.rb +22 -9
  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 +32 -9
  34. data/lib/tapioca/generator.rb +231 -23
  35. data/lib/tapioca/loader.rb +30 -9
  36. data/lib/tapioca/sorbet_config_parser.rb +77 -0
  37. data/lib/tapioca/version.rb +1 -1
  38. metadata +31 -51
@@ -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,18 @@ 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
+ if Object.const_defined?("ActiveSupport")
103
+ Object.const_get("ActiveSupport").run_load_hooks(
104
+ :before_eager_load,
105
+ Object.const_get("Rails").application
106
+ )
107
+ end
108
+ if Object.const_defined?("Zeitwerk::Loader")
109
+ zeitwerk_loader = Object.const_get("Zeitwerk::Loader")
110
+ zeitwerk_loader.eager_load_all
111
+ end
112
+ Object.const_get("Rails").autoloaders.each(&:eager_load)
92
113
  end
93
114
 
94
115
  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.3.0"
5
+ VERSION = "0.4.3"
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.3.0
4
+ version: 0.4.3
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-03-26 00:00:00.000000000 Z
14
+ date: 2020-08-19 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: pry
@@ -56,75 +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.19.2
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.19.2
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'
71
+ version: 2.1.0
86
72
  - !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'
100
- - !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: sorbet
73
+ name: thor
116
74
  requirement: !ruby/object:Gem::Requirement
117
75
  requirements:
118
76
  - - ">="
119
77
  - !ruby/object:Gem::Version
120
- version: '0'
121
- type: :development
78
+ version: 0.19.2
79
+ type: :runtime
122
80
  prerelease: false
123
81
  version_requirements: !ruby/object:Gem::Requirement
124
82
  requirements:
125
83
  - - ">="
126
84
  - !ruby/object:Gem::Version
127
- version: '0'
85
+ version: 0.19.2
128
86
  description:
129
87
  email:
130
88
  - ruby@shopify.com
@@ -139,15 +97,37 @@ files:
139
97
  - exe/tapioca
140
98
  - lib/tapioca.rb
141
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
142
119
  - lib/tapioca/compilers/symbol_table/symbol_generator.rb
143
120
  - lib/tapioca/compilers/symbol_table/symbol_loader.rb
144
121
  - lib/tapioca/compilers/symbol_table_compiler.rb
122
+ - lib/tapioca/compilers/todos_compiler.rb
145
123
  - lib/tapioca/config.rb
146
124
  - lib/tapioca/config_builder.rb
147
125
  - lib/tapioca/constant_locator.rb
126
+ - lib/tapioca/core_ext/class.rb
148
127
  - lib/tapioca/gemfile.rb
149
128
  - lib/tapioca/generator.rb
150
129
  - lib/tapioca/loader.rb
130
+ - lib/tapioca/sorbet_config_parser.rb
151
131
  - lib/tapioca/version.rb
152
132
  homepage: https://github.com/Shopify/tapioca
153
133
  licenses: