kirei 0.8.1 → 0.8.2
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/lib/cli/commands/new_app/files/app.rb +5 -5
- data/lib/cli/commands/new_app/files/db_rake.rb +4 -4
- data/lib/kirei/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: 0e16807cffd59ce38ba7cb3e8a0474e26fff5c4d6598ee63ac745382d0c4d30f
|
4
|
+
data.tar.gz: 180c00ecc9ad0668cffcf3f1448779acbe2e5fb35c8f7632159358d8637734c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 780e826760bd7ff48e1decf31446c7f9d5b3fc9504c5b3674af04b746cda67f1bba61fe27658fdec5993e1c2c0bba3030a45557f32d8cc0465342a85da1fd6db
|
7
|
+
data.tar.gz: 7e32df47ece711cc97471801bad3085e2f1008abca7f0be1af8acf402c8569199018284bbeb6ece672a6745cd06957f30e29802218372ef1816c64e431813b36
|
@@ -29,8 +29,8 @@ module Cli
|
|
29
29
|
Dir[File.join(__dir__, "config/initializers", "*.rb")].each { require(_1) }
|
30
30
|
|
31
31
|
# Fourth: load all application code
|
32
|
-
|
33
|
-
|
32
|
+
APP_LOADER = Zeitwerk::Loader.new
|
33
|
+
APP_LOADER.tag = File.basename(__FILE__, ".rb")
|
34
34
|
[
|
35
35
|
"/app",
|
36
36
|
"/app/models",
|
@@ -38,9 +38,9 @@ module Cli
|
|
38
38
|
].each do |root_namespace|
|
39
39
|
# a root namespace skips the auto-infered module for this folder
|
40
40
|
# so we don't have to write e.g. `Models::` or `Services::`
|
41
|
-
|
41
|
+
APP_LOADER.push_dir("\#{File.dirname(__FILE__)}\#{root_namespace}")
|
42
42
|
end
|
43
|
-
|
43
|
+
APP_LOADER.setup
|
44
44
|
|
45
45
|
# Fifth: load configs
|
46
46
|
Dir[File.join(__dir__, "config", "**", "*.rb")].each do |cnf|
|
@@ -52,7 +52,7 @@ module Cli
|
|
52
52
|
config.app_name = "#{snake_case_app_name}"
|
53
53
|
end
|
54
54
|
|
55
|
-
|
55
|
+
APP_LOADER.eager_load
|
56
56
|
RUBY
|
57
57
|
end
|
58
58
|
end
|
@@ -173,24 +173,23 @@ module Cli
|
|
173
173
|
next if !model_file_name.nil? && model_file == model_file_name
|
174
174
|
|
175
175
|
model_path = File.expand_path(model_file, app_root_dir)
|
176
|
-
loader = Zeitwerk::Registry.loaders.find { |l| l.tag == "app" }
|
177
176
|
|
178
177
|
full_path = File.expand_path(model_file, app_root_dir)
|
179
|
-
klass_constant_name =
|
178
|
+
klass_constant_name = APP_LOADER.inflector.camelize(File.basename(model_file, ".rb"), full_path)
|
180
179
|
|
181
180
|
#
|
182
181
|
# root namespaces in Zeitwerk are flattend, e.g. if "app/models" is a root namespace
|
183
182
|
# then a file "app/models/airport.rb" is loaded as "::Airport".
|
184
183
|
# if it weren't a root namespace, it would be "::Models::Airport".
|
185
184
|
#
|
186
|
-
root_dir_namespaces =
|
185
|
+
root_dir_namespaces = APP_LOADER.dirs.filter_map { |dir| dir == app_dir ? nil : Pathname.new(dir).relative_path_from(Pathname.new(app_dir)).to_s }
|
187
186
|
relative_path = Pathname.new(full_path).relative_path_from(Pathname.new(app_dir)).to_s
|
188
187
|
root_dir_of_model = root_dir_namespaces.find { |root_dir| relative_path.start_with?(root_dir) }
|
189
188
|
relative_path.sub!("\#{root_dir_of_model}/", "") unless root_dir_of_model.nil? || root_dir_of_model.empty?
|
190
189
|
|
191
190
|
namespace_parts = relative_path.split("/")
|
192
191
|
namespace_parts.pop
|
193
|
-
namespace_parts.map! { |part|
|
192
|
+
namespace_parts.map! { |part| APP_LOADER.inflector.camelize(part, full_path) }
|
194
193
|
|
195
194
|
constant_name = "\#{namespace_parts.join('::')}::\#{klass_constant_name}"
|
196
195
|
|
@@ -231,6 +230,7 @@ module Cli
|
|
231
230
|
name, info = column
|
232
231
|
type = "\#{info[:db_type]}(\#{info[:max_length]})" if info[:max_length]
|
233
232
|
type ||= info[:db_type]
|
233
|
+
type = "\#{type}, " if type.size >= 20 \# e.g. "timestamp without time zone" exceeds 20 characters
|
234
234
|
null = info[:allow_null] ? 'null' : 'not null'
|
235
235
|
primary_key = info[:primary_key] ? ', primary key' : ''
|
236
236
|
lines << "# \#{name.to_s.ljust(20)}:\#{type.to_s.ljust(20)}\#{null}\#{primary_key}"
|
data/lib/kirei/version.rb
CHANGED