low_type 1.1.3 → 1.1.4

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: 31fd9fee4aba001196fa20d6aaf51428121c4512ec85093bd3c68a1103b0ba83
4
- data.tar.gz: 6ddc9528e3f5b0b6ac3fb841bf620874ab3ef08f0cd7acb0d6e0f6aebe3d20d7
3
+ metadata.gz: 2ed9039d493d3be677095a358691d03a7edf2dfd6416b48dfa352d03fec7cef7
4
+ data.tar.gz: 832ac8f63eec8a4e03d616286bea41f9945e0c30fbe55afe41f88857a82e01e9
5
5
  SHA512:
6
- metadata.gz: 6eb3e48691817f849f922e5f59af5157eb107b9cf960cdd7e147eb49561a0617ad6e6669d8f7a8319f8b39ea46e98f66cb4ac91e4c4a35fe269b2db115811a2f
7
- data.tar.gz: 4ad23e5c8e4c5be264713f4dc6ea6deff8e66019db967ff09bbe92d4b0e7d3d46796bc123fa188a17d3b6904e76268e29a9def75b2c34304d0712c785cfee4ee
6
+ metadata.gz: b3eb8482d26eed780072944c51a00afb5e0d6cb360d754f37208453728102a07ed227ed13d17735e096ff107709b06e61d215ee6b0d89b3b9cdf5099048a643e
7
+ data.tar.gz: 3710dfca9e28556e2d8a781585adc809992b6469e0f3cd4f7c26fcd82e54d149a303f020522531b1350adaf954e09ffc8f02813c88c83f5718f5b334c59d4939
@@ -25,13 +25,15 @@ module LowType
25
25
  def param_proxies(method_node:, file:)
26
26
  return [] if method_node.parameters.nil?
27
27
 
28
+ params_without_block = method_node.parameters.slice.delete_suffix(', &block')
29
+
28
30
  # Not a security risk because the code comes from a trusted source; the file that did the include. Does the file trust itself?
29
- ruby_method = eval("-> (#{method_node.parameters.slice}) {}", binding, __FILE__, __LINE__) # rubocop:disable Security/Eval
31
+ ruby_method = eval("-> (#{params_without_block}) {}", binding, __FILE__, __LINE__) # rubocop:disable Security/Eval
30
32
 
31
33
  # Not a security risk because the code comes from a trusted source; the file that did the include. Does the file trust itself?
32
34
  # Local variable names are prefixed with __lt or __rb where necessary to avoid being overridden by method parameters.
33
35
  typed_method = <<~RUBY
34
- -> (#{method_node.parameters.slice}, __rb_method:, __lt_file:) {
36
+ -> (#{params_without_block}, __rb_method:, __lt_file:) {
35
37
  param_proxies_for_type_expressions(ruby_method: __rb_method, file: __lt_file, method_binding: binding)
36
38
  }
37
39
  RUBY
data/lib/low_type.rb CHANGED
@@ -11,7 +11,7 @@ require_relative 'types/complex_types'
11
11
 
12
12
  module LowType
13
13
  # We do as much as possible on class load rather than on instantiation to be thread-safe and efficient.
14
- def self.included(klass)
14
+ def self.included(klass) # rubocop:disable Metrics/AbcSize
15
15
  require_relative 'syntax/union_types' if LowType.config.union_type_expressions
16
16
 
17
17
  class << klass
@@ -21,6 +21,8 @@ module LowType
21
21
  end
22
22
 
23
23
  file_path = FileQuery.file_path(klass:)
24
+ return unless File.exist?(file_path)
25
+
24
26
  parser = FileParser.new(klass:, file_path:)
25
27
 
26
28
  klass.extend TypeAccessors
data/lib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LowType
4
- VERSION = '1.1.3'
4
+ VERSION = '1.1.4'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: low_type
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - maedi