kube-dsl 0.8.0 → 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: de8bd85a855059eb721225535bf9116a71a724fa6200204f68fde813131536a8
4
- data.tar.gz: 9086677e1ccdd62fcea750c39b57d6dac113cbb5bba4033db0893c861c843f44
3
+ metadata.gz: 999f2bf83f428a8df758af2b435fb0aa64b8e69a722ff8eeb7ffc9837573a1ba
4
+ data.tar.gz: 735868e4588d34645f9cc7164ddb21f363b2b3af1b7a9b8b1ad6c4e5cb506a02
5
5
  SHA512:
6
- metadata.gz: 1c4222594087e664ceb1f35d2f22382f42c5a3b78fcee23fd7fcf2d43c4f2d1e426f3e3cebbd42ca8f6d12b02a6c5c0bb465b4f6772b1d411d2130f818da9683
7
- data.tar.gz: 91bad2ac1bb76b7e5c1b906f34e49a6e9cbfba755bf6f80ab6483b1a3fe0ef7f27a6b73c05cb9d0d9fd733683eb8f5053d519d79a1422a65c3101f597dbf7aee
6
+ metadata.gz: bb4a68116b5fefcf99bddd0857e43907f4dead424e51a5b6e76d1845c5264b193cefb871502a351aa172445ff47ad7fcdb39cc02eaec4050fb3e8bcb1f86930d
7
+ data.tar.gz: 5b4065446416e170515e3138d42805c1a2c0c8ab128b505f565c7135a2e587d87808811ef3be70a1726aece93d709b35eb1db882ac766b20e5d3009a3303d1d5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 0.8.2
2
+ * Fix entrypoint type signatures to make the block optional (#8, @Bo98)
3
+ * Tighten arity of value and object fields (#9, @Bo98)
4
+
5
+ ## 0.8.1
6
+ * Fix Sorbet types for blocks passed to DSL methods (#6, @Bo98)
7
+ * Fix handling of number types (#5, @Bo98)
8
+
1
9
  ## 0.8.0
2
10
 
3
11
  * Update Kubernetes to v1.23.17 to match kuby.
@@ -7,7 +7,7 @@ module KubeDSL
7
7
  extend ::KubeDSL::ValueFields
8
8
  extend ::KubeDSL::Validations
9
9
 
10
- # T::Sig::WithoutRuntime.sig { params(block: T.nilable(T.proc.void)).void }
10
+ # T::Sig::WithoutRuntime.sig { params(block: T.nilable(T.proc.bind(::KubeDSL::DSLObject).void)).void }
11
11
  def initialize(&block)
12
12
  instance_eval(&block) if block
13
13
  end
@@ -42,8 +42,9 @@ module KubeDSL
42
42
  next if block && !block.call(resource, ns)
43
43
 
44
44
  method_name = method_name_for(resource)
45
+ resource_type = "::#{ns}::#{resource.ref.kind}"
45
46
 
46
- rbi_code << "#{indent}T::Sig::WithoutRuntime.sig { params(block: T.proc.void).returns(::#{ns}::#{resource.ref.kind}) }\n"
47
+ rbi_code << "#{indent}T::Sig::WithoutRuntime.sig { params(block: T.nilable(T.proc.bind(#{resource_type}).void)).returns(#{resource_type}) }\n"
47
48
  rbi_code << "#{indent}def #{method_name}(&block); end\n\n"
48
49
  end
49
50
 
@@ -22,7 +22,7 @@ module KubeDSL
22
22
 
23
23
  def fields_to_rbi(_inflector)
24
24
  [
25
- "T::Sig::WithoutRuntime.sig { params(block: T.nilable(T.proc.void)).returns(::KubeDSL::KeyValueFields) }",
25
+ "T::Sig::WithoutRuntime.sig { params(block: T.nilable(T.proc.bind(::KubeDSL::KeyValueFields).void)).returns(::KubeDSL::KeyValueFields) }",
26
26
  "def #{underscore(name)}(&block); end"
27
27
  ]
28
28
  end
@@ -18,8 +18,8 @@ module KubeDSL
18
18
 
19
19
  def fields_to_rbi(_inflector)
20
20
  [
21
- "T::Sig::WithoutRuntime.sig { returns(#{ruby_type}) }",
22
- "def #{ruby_safe_name}; end",
21
+ "T::Sig::WithoutRuntime.sig { params(block: T.nilable(T.proc.bind(#{ruby_type}).void)).returns(#{ruby_type}) }",
22
+ "def #{ruby_safe_name}(&block); end",
23
23
  "",
24
24
  "T::Sig::WithoutRuntime.sig { returns(T::Boolean) }",
25
25
  "def #{ruby_safe_name}_present?; end"
@@ -5,7 +5,7 @@ module KubeDSL
5
5
 
6
6
  TYPE_MAP = {
7
7
  'boolean' => 'T::Boolean',
8
- 'number' => 'Integer'
8
+ 'number' => 'T.any(Integer, Float)'
9
9
  }
10
10
 
11
11
  TYPE_MAP.freeze
@@ -88,6 +88,8 @@ module KubeDSL
88
88
  [String]
89
89
  when :integer
90
90
  [Integer]
91
+ when :number
92
+ [Integer, Float]
91
93
  when :boolean
92
94
  [TrueClass, FalseClass]
93
95
  else
@@ -14,13 +14,13 @@ module KubeDSL
14
14
  def value_field(field, default: nil)
15
15
  __fields__[:value] << field
16
16
 
17
- define_method(field) do |*args|
18
- if args.empty?
17
+ define_method(field) do |value = (value_set = true; nil)|
18
+ if value_set
19
+ instance_variable_set(:"@#{field}", value)
20
+ else
19
21
  instance_variable_get(:"@#{field}") || (
20
22
  default.respond_to?(:call) ? default.call(self) : default
21
23
  )
22
- else
23
- instance_variable_set(:"@#{field}", args.first)
24
24
  end
25
25
  end
26
26
  end
@@ -29,11 +29,11 @@ module KubeDSL
29
29
  __fields__[:object] << field
30
30
  ivar = :"@#{field}"
31
31
 
32
- define_method(field) do |*args, &block|
32
+ define_method(field) do |&block|
33
33
  val = instance_variable_get(ivar)
34
34
 
35
35
  unless val
36
- val = field_block.call(*args)
36
+ val = field_block.call
37
37
  instance_variable_set(ivar, val)
38
38
  end
39
39
 
@@ -1,5 +1,5 @@
1
1
  # typed: strict
2
2
 
3
3
  module KubeDSL
4
- VERSION = '0.8.0'
4
+ VERSION = '0.8.2'
5
5
  end