tins 1.42.0 → 1.43.0

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: 4c39c23e05afb35543b49c007605bac9ce2f254d272424afcc2e79baf116adea
4
- data.tar.gz: ea9ac39af506ae7cf12de6ad45ce48041fb6613dd90c9e66ece61b499f26a751
3
+ metadata.gz: fb6123d834dff1c32f3797c66fe9caf261b6f8463d29bf388f1d180da05e7157
4
+ data.tar.gz: 05b4687013b1842153c9dc96974bd000e59523cc2fefb26ed31e09d855971235
5
5
  SHA512:
6
- metadata.gz: 46cc25fbb33d0958aa149f687635af0ada89aa720312355b9f33a0f0a3a30b30c7a85188e2071e92115826a72fc99c44032a1746dc5b0750292fc2710f1b3d76
7
- data.tar.gz: 2da0195875a75ed63b0126599193a9bb8c4cce877a0bbd2328d1bb630c9eff9c6ae18c8e855d2a25f6e528cc9febea9154c94fd3a0347e7e133a7cac001e6a62
6
+ metadata.gz: 0eac79c5130dd92ddb9de65604b447eb6a271d0d94aecdebea60a78f163a073fc88161e0f43b0971c8e0e12f704e58ceae924c6b623e5eca714089a27de51041
7
+ data.tar.gz: 6c951446395225c9b03785f8aa8e44f5bfc6cf20cadd01346b02cfbc1c8e88a44aae997245c992df8867878f3d9ed8962d4109bb74479b227ce656f958eea840
data/.contexts/yard.md CHANGED
@@ -67,7 +67,6 @@ want to document using YARD.
67
67
  #
68
68
  # @return [optional, types, ...] description
69
69
  # @return [true] always returns true
70
- # @return [void]
71
70
  # @return [String, nil] the contents of our object or nil
72
71
  # if the object has not been filled with data.
73
72
  #
data/CHANGES.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changes
2
2
 
3
+ ## 2025-09-05 v1.43.0
4
+
5
+ - Added new `dsl_lazy_accessor` method that creates lazy-loaded accessors with
6
+ support for default blocks and dynamic block assignment
7
+ - Removed support for Ruby versions **3.1** and **3.0** from image definitions
8
+
3
9
  ## 2025-08-19 v1.42.0
4
10
 
5
11
  - Improved core class extension safety by using `respond_to?` checks to avoid
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ GemHadar do
12
12
  test_dir 'tests'
13
13
  test_files.concat Dir["#{test_dir}/*_test.rb"]
14
14
  ignore '.*.sw[pon]', 'pkg', 'Gemfile.lock', '.rvmrc', 'coverage', '.rbx',
15
- '.AppleDouble', '.DS_Store', 'tags', '.bundle', '.byebug_history'
15
+ '.AppleDouble', '.DS_Store', 'tags', '.bundle', '.byebug_history', '.yardoc'
16
16
  package_ignore '.all_images.yml', '.tool-versions', '.gitignore', 'VERSION',
17
17
  '.utilsrc', 'TODO', '.github', '.contexts'
18
18
 
data/lib/tins/dslkit.rb CHANGED
@@ -12,8 +12,6 @@ module Tins
12
12
  # The module can be included into other modules/classes to make the methods available.
13
13
  module Eigenclass
14
14
  # Returns the eigenclass of this object.
15
- def eigenclass
16
- end
17
15
  alias eigenclass singleton_class
18
16
 
19
17
  # Evaluates the _block_ in context of the eigenclass of this object.
@@ -241,6 +239,36 @@ module Tins
241
239
  end
242
240
  end
243
241
 
242
+ # The dsl_lazy_accessor method defines a lazy-loaded accessor method with
243
+ # a default block.
244
+ #
245
+ # This method creates a dynamic accessor that initializes its value
246
+ # lazily when first accessed. It stores the default value as a block in
247
+ # an instance variable and evaluates it on first access. If a block is
248
+ # passed to the accessor, it sets the instance variable to that block for
249
+ # future use.
250
+ #
251
+ # @param name [ Object ] the name of the accessor method to define
252
+ # @yield [ default ] optional block that provides the default value for initialization
253
+ #
254
+ # @return [ Symbol ] returns name of the defined method.
255
+ def dsl_lazy_accessor(name, &default)
256
+ variable = "@#{name}"
257
+ define_method(name) do |*args, &block|
258
+ if !block && args.empty?
259
+ if instance_variable_defined?(variable)
260
+ instance_eval(&instance_variable_get(variable))
261
+ elsif default
262
+ instance_eval(&default)
263
+ end
264
+ elsif block
265
+ instance_variable_set(variable, block)
266
+ else
267
+ raise ArgumentError, '&block argument is required'
268
+ end
269
+ end
270
+ end
271
+
244
272
  # This method creates a dsl reader accessor, that behaves exactly like a
245
273
  # #dsl_accessor but can only be read not set.
246
274
  def dsl_reader(name, *default, &block)
data/lib/tins/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Tins
2
2
  # Tins version
3
- VERSION = '1.42.0'
3
+ VERSION = '1.43.0'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
data/tests/dslkit_test.rb CHANGED
@@ -65,6 +65,12 @@ class DA
65
65
  end
66
66
 
67
67
  dsl_reader :abc, *%w[a b c]
68
+
69
+ dsl_lazy_accessor :lazy do
70
+ :foo
71
+ end
72
+
73
+ dsl_lazy_accessor :lazy_no_default
68
74
  end
69
75
 
70
76
  class I
@@ -220,6 +226,15 @@ class PoliteTest < Test::Unit::TestCase
220
226
  assert_equal %w[a b c], @da.abc
221
227
  end
222
228
 
229
+ def test_lazy_accessor
230
+ assert_equal :foo, @da.lazy
231
+ @da.lazy { :bar }
232
+ assert_equal :bar, @da.lazy
233
+ assert_equal nil, @da.lazy_no_default
234
+ @da.lazy_no_default { :bar }
235
+ assert_equal :bar, @da.lazy_no_default
236
+ end
237
+
223
238
  def test_dsl_accessor_multiple
224
239
  assert_nil @da.foo
225
240
  assert_equal :bar, @da.bar
data/tins.gemspec CHANGED
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: tins 1.42.0 ruby lib
2
+ # stub: tins 1.43.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "tins".freeze
6
- s.version = "1.42.0".freeze
6
+ s.version = "1.43.0".freeze
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
23
23
 
24
24
  s.specification_version = 4
25
25
 
26
- s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 2.0".freeze])
26
+ s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 2.2".freeze])
27
27
  s.add_development_dependency(%q<all_images>.freeze, [">= 0".freeze])
28
28
  s.add_development_dependency(%q<context_spook>.freeze, ["~> 0.2".freeze])
29
29
  s.add_development_dependency(%q<debug>.freeze, [">= 0".freeze])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tins
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.42.0
4
+ version: 1.43.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: '2.0'
18
+ version: '2.2'
19
19
  type: :development
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
- version: '2.0'
25
+ version: '2.2'
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: all_images
28
28
  requirement: !ruby/object:Gem::Requirement