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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2bde9dc5680f9744ab2eb1d0fce8fce8019f2177ee263d1b8d6d82bb9c6fff73
4
- data.tar.gz: 48732a443adf3d134fcf0fcdabc5e191b794f31a7966e36c1f83e80a9fe9585f
3
+ metadata.gz: 0e16807cffd59ce38ba7cb3e8a0474e26fff5c4d6598ee63ac745382d0c4d30f
4
+ data.tar.gz: 180c00ecc9ad0668cffcf3f1448779acbe2e5fb35c8f7632159358d8637734c3
5
5
  SHA512:
6
- metadata.gz: f5a4a532eb8181cf02d7725bed41c8492eb11e0b879e4a51ad430674e220dbb5b26c1b5a44aa29790f6af8f7a1b9ccc132262bb239815f3c290c75c2e7edaaea
7
- data.tar.gz: 604c5d622a63e5817e39b99d3029d2e15caa1c90a370cb44e9b2a0a321db8317c8da1686543a7267beef957abb149501c200fd0c5d2a148513210c7ab03e9ae5
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
- loader = Zeitwerk::Loader.new
33
- loader.tag = File.basename(__FILE__, ".rb")
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
- loader.push_dir("\#{File.dirname(__FILE__)}\#{root_namespace}")
41
+ APP_LOADER.push_dir("\#{File.dirname(__FILE__)}\#{root_namespace}")
42
42
  end
43
- loader.setup
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
- loader.eager_load
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 = loader.inflector.camelize(File.basename(model_file, ".rb"), full_path)
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 = loader.dirs.filter_map { |dir| dir == app_dir ? nil : Pathname.new(dir).relative_path_from(Pathname.new(app_dir)).to_s }
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| loader.inflector.camelize(part, full_path) }
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
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Kirei
5
- VERSION = "0.8.1"
5
+ VERSION = "0.8.2"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kirei
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ludwig Reinmiedl