thread_local_var_accessors 1.3.0 → 1.3.1

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: 4537e0db3960367d75a6ab4d731026c6a425e315816bf0523d078b563b90a09a
4
- data.tar.gz: d270efc557c3b04f41ae9adf7850157d98c793a7d57cd025e8c88a40d2aaa154
3
+ metadata.gz: 6ed08c93f6e727f6ba7dc57984a05669fbf06bfe99f4fd46b3a6e81f72727128
4
+ data.tar.gz: b8223cf233fa40fc0749849117c0b6773b2a9723fd98dd80aed9017275f9882f
5
5
  SHA512:
6
- metadata.gz: b1ad3ff8ce74641cdb6956fe084d8bd69e2712b002805302c2ca3550d82591e2874e94322dbf3ba4123f70f8185318fb05c6ef51e8527ce6145361f72347fb64
7
- data.tar.gz: 16ad94b606dfc4249bf344fcd859c1db7929bd026680fc8ef885e6768097c20cfbbc4753543c4989fea1095ce2876fbd525b5ba9090570fd117d79936446838b
6
+ metadata.gz: d2387dc90dd67a904b4757a5461ecff8ca4c6b5cbd4ae515f3be15241df0a7e956583b6760ba6b7f6398fdcbdfcd64852f06c62579ea01edba2d3ae0763c670a
7
+ data.tar.gz: 1942812b37021fdeb8f4f4cf1acf782591e400c229247815f1308553ab37872caca9131aca67b304b1f5fcc3c43238699794ffae431ab19d236827913b6271c1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ 2024-05-09: Version 1.3.1
2
+ - DRYed up the `tlv_default` method
3
+ - Changed CI to support "release" task on the main branch
4
+ - Added more tasks to the Rakefile
5
+ - Added RELEASES to the version file.
6
+ - Updated the ruby version to 3.1
7
+
1
8
  2023-05-04: Version 1.0.0
2
9
  - added support for default values:
3
10
  - renamed `tlv_new` to `tlv_init` (leaving `tlv_new` as an alias)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- thread_local_var_accessors (1.3.0)
4
+ thread_local_var_accessors (1.3.1)
5
5
  concurrent-ruby
6
6
 
7
7
  GEM
@@ -79,6 +79,7 @@ GEM
79
79
 
80
80
  PLATFORMS
81
81
  x86_64-darwin-21
82
+ x86_64-linux
82
83
 
83
84
  DEPENDENCIES
84
85
  bundler
data/Rakefile CHANGED
@@ -1,19 +1,37 @@
1
1
  # Rakefile for thread_local_var_accessors
2
- require "bundler/gem_tasks"
3
- require "rspec/core/rake_task"
2
+ require 'bundler/gem_tasks'
3
+ require 'rspec/core/rake_task'
4
4
  require 'yard'
5
5
 
6
+ namespace :spec do
7
+ desc 'run tests with code coverage'
8
+ task :coverage do
9
+ sh 'COVERAGE=1 bundle exec rake spec'
10
+ end
11
+ end
12
+
13
+ task build: %i[bundle:add_linux]
14
+ task install: %i[build spec]
15
+ task release: %i[build spec]
16
+
6
17
  # Local CI testing
7
18
 
8
19
  namespace :ci do
9
- desc "Check CIRCLECI config"
20
+ desc 'Check CIRCLECI config'
10
21
  task :check do
11
- sh "circleci config validate", verbose: true
22
+ sh 'circleci config validate', verbose: true
12
23
  end
13
24
 
14
- desc "Run CIRCLECI config locally"
25
+ desc 'Run CIRCLECI config locally'
15
26
  task :local do
16
- sh "circleci local execute", verbose: true
27
+ sh 'circleci local execute', verbose: true
28
+ end
29
+ end
30
+
31
+ namespace :bundle do
32
+ desc 'add linux platform to Gemfile.lock'
33
+ task :add_linux do
34
+ sh "grep -s 'x86_64-linux' Gemfile.lock >/dev/null || bundle lock --add-platform x86_64-linux"
17
35
  end
18
36
  end
19
37
 
@@ -22,7 +40,7 @@ end
22
40
  RSpec::Core::RakeTask.new(:spec)
23
41
 
24
42
  namespace :spec do
25
- desc "run Simplecov"
43
+ desc 'run Simplecov'
26
44
  task :coverage do
27
45
  sh 'CODE_COVERAGE=1 bundle exec rake spec'
28
46
  end
@@ -1,3 +1,8 @@
1
1
  module ThreadLocalVarAccessors
2
- VERSION = '1.3.0'
2
+ RELEASES = [
3
+ ['1.3.1', '2024-05-09'],
4
+ ['1.3.0', '2023-05-04']
5
+ ].freeze
6
+
7
+ VERSION = RELEASES[0][0]
3
8
  end
@@ -160,7 +160,7 @@ require 'concurrent-ruby'
160
160
  #
161
161
  # def timeout=(value)
162
162
  # var = instance_variable_get(:@timeout) ||
163
- # instance_variable_get(:@timeout, Concurrent::ThreadLocalVar.new)
163
+ # instance_variable_set(:@timeout, Concurrent::ThreadLocalVar.new)
164
164
  # var.value = block_given? ? yield(var.value) : value
165
165
  # end
166
166
  #
@@ -277,7 +277,7 @@ module ThreadLocalVarAccessors
277
277
  # Creates a new TLVar with the given default value or block.
278
278
  # Equivalent to:
279
279
  # @name = ThreadLocalVar.new(block_given? ? yield : default)
280
- def tlv_new(name, default=nil, &block)
280
+ def tlv_new(name, default = nil, &block)
281
281
  instance_variable_set(
282
282
  name.to_ivar,
283
283
  Concurrent::ThreadLocalVar.new(default, &block)
@@ -291,7 +291,7 @@ module ThreadLocalVarAccessors
291
291
  # @name ||= ThreadLocalVar.new
292
292
  # @name.instance_variable_set(:@default, block_given? ? yield : default)
293
293
  # @name.value
294
- def tlv_init(name, default=nil, &block)
294
+ def tlv_init(name, default = nil, &block)
295
295
  tlv_set_default(name, default, &block)
296
296
  tlv_get(name)
297
297
  end
@@ -310,18 +310,16 @@ module ThreadLocalVarAccessors
310
310
  # Sets the default value or block for the TLV _(which is applied across all threads)_.
311
311
  # Creates a new TLV if the instance variable is not initialized.
312
312
  # @return [Object] the effective default value of the TLV instance variable
313
- def tlv_set_default(name, default=nil, &block)1
313
+ def tlv_set_default(name, default = nil, &block)
314
+ 1
314
315
  tlv = instance_variable_get(name.to_ivar)
315
316
  if tlv
316
- raise ArgumentError, "tlv_set_default: can only use a default or a block, not both" if default && block
317
+ raise ArgumentError, 'tlv_set_default: can only use a default or a block, not both' if default && block
317
318
 
318
- if block
319
- tlv.instance_variable_set(:@default_block, block)
320
- tlv.instance_variable_set(:@default, nil)
321
- else
322
- tlv.instance_variable_set(:@default_block, nil)
323
- tlv.instance_variable_set(:@default, default)
324
- end
319
+ # in both cases, the default is set to the given value, only one of which
320
+ # can be given at a time.
321
+ tlv.instance_variable_set(:@default_block, block)
322
+ tlv.instance_variable_set(:@default, default)
325
323
  tlv
326
324
  else
327
325
  tlv = tlv_new(name, default, &block)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thread_local_var_accessors
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alan Stebbens
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-10 00:00:00.000000000 Z
11
+ date: 2024-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -242,7 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
242
242
  - !ruby/object:Gem::Version
243
243
  version: '0'
244
244
  requirements: []
245
- rubygems_version: 3.1.6
245
+ rubygems_version: 3.3.26
246
246
  signing_key:
247
247
  specification_version: 4
248
248
  summary: Ruby gem to make ThreadLocalVars easy to use