lazy_init 0.1.0 → 0.1.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: c64fcdc54aff938649a72d27f052323186594ae0811c797af886a8f50592c885
4
- data.tar.gz: 0d63513a82a948a865275cd22de4baaaaa33c594fed332f8398fd5f05a856e41
3
+ metadata.gz: 4c3c12be25d5a45b0b5d70589b47c4335e8e610b809ee80647e0230c7778c6a5
4
+ data.tar.gz: 50dcdd14ca0228e4c202cd886cb17c622c2b677e0cb041f8f39f36eb14bc08cb
5
5
  SHA512:
6
- metadata.gz: 8c2db87b2eb8bfb3c30ef12be6c2967a7172f2de3e74818271d44767f0484bf68c493aab388aa84963bd14703a6a606a9e761fdd4831d55472e2ffae575c0401
7
- data.tar.gz: 456a5e3b90199ef2687ec2b27ceee6eee751a3d311c365ed5e8b1e5aca786c00b1f9199ece268a8d0368a82e02f11bc17a6035421b19528e8c0810386022751b
6
+ metadata.gz: e7cfa817d7c404168dd8237410edd85453d71334b16b31dba4d63b2fecf5374080595c4db983798bddca2883704b8dc07639a861d8113fff4f7a24875bfb5340
7
+ data.tar.gz: 4c8ff04962ac7b59f6ecb9749faa6993814749fa9d146fc2eb482ffb9059ab03facc84430ceef04c07afc3484c5c041e833b8429a0ab523c6c352eef86659148
data/.yardopts ADDED
@@ -0,0 +1,7 @@
1
+ --markup markdown
2
+ --readme README.md
3
+ --title "LazyInit - Thread-safe Lazy Initialization"
4
+ --output-dir doc
5
+ lib/**/*.rb
6
+ - CHANGELOG.md
7
+ - LICENSE
data/CHANGELOG.md CHANGED
@@ -0,0 +1,10 @@
1
+
2
+
3
+ ### 0.1.1 (2025/06/07)
4
+
5
+ * Added YARD configuration for automatic documentation generation
6
+ * Enhanced code comments for better API documentation
7
+
8
+ ### 0.1.0 (2025/06/07)
9
+
10
+ * Initial public release
data/README.md CHANGED
@@ -4,7 +4,7 @@ Thread-safe lazy initialization patterns for Ruby with automatic dependency reso
4
4
 
5
5
  [![Ruby](https://img.shields.io/badge/ruby-%3E%3D%202.6-red.svg)](https://www.ruby-lang.org/)
6
6
  [![Gem Version](https://badge.fury.io/rb/lazy_init.svg)](https://badge.fury.io/rb/lazy_init)
7
- [![Build Status](https://github.com/N3BCKN/lazy_init/workflows/CI/badge.svg)](https://github.com/N3BCKN/lazy_init/actions)
7
+ [![Downloads](https://img.shields.io/gem/dt/lazy_init.svg)](https://rubygems.org/gems/lazy_init)
8
8
 
9
9
  ## Table of Contents
10
10
 
@@ -164,20 +164,20 @@ lazy_attr_reader(name, **options, &block)
164
164
  Defines a thread-safe lazy-initialized attribute.
165
165
  #### Parameters:
166
166
 
167
- - name (Symbol/String): Attribute name
168
- - timeout (Numeric, optional): Timeout in seconds for computation
169
- - depends_on (Array<Symbol>/Symbol, optional): Dependencies to resolve first
170
- - block (Proc): Computation block
167
+ - `name` (Symbol/String): Attribute name
168
+ - `timeout` (Numeric, optional): Timeout in seconds for computation
169
+ - `depends_on` (Array<Symbol>/Symbol, optional): Dependencies to resolve first
170
+ - `block` (Proc): Computation block
171
171
 
172
172
  #### Generated Methods:
173
173
 
174
- - #{name}: Returns the computed value
175
- - #{name}_computed?: Returns true if value has been computed
176
- - reset_#{name}!: Resets to uncomputed state
174
+ - `#{name}`: Returns computed value
175
+ - `#{name}_computed?`: Returns true if value has been computed
176
+ - `reset_#{name}!`: Resets to uncomputed state
177
177
 
178
178
  #### Examples:
179
179
  ```ruby
180
- rubyclass ServiceManager
180
+ class ServiceManager
181
181
  extend LazyInit
182
182
 
183
183
  # Simple lazy attribute
@@ -210,12 +210,12 @@ lazy_class_variable(name, **options, &block)
210
210
  Defines a thread-safe lazy-initialized class variable shared across all instances.
211
211
  #### Parameters:
212
212
 
213
- - Same as lazy_attr_reader
213
+ - Same as `lazy_attr_reader`
214
214
 
215
215
  #### Generated Methods:
216
216
 
217
- - Class-level: ClassName.#{name}, ClassName.#{name}\_computed?, ClassName.reset\_#{name}!
218
- - Instance-level: #{name}, #{name}\_computed?, reset\_#{name}! (delegates to class)
217
+ - Class-level: `ClassName.#{name}`, `ClassName.#{name}\_computed?`, `ClassName.reset\_#{name}!`
218
+ - Instance-level: `#{name}`, `#{name}\_computed?`, `reset\_#{name}!` (delegates to class)
219
219
 
220
220
  #### Example:
221
221
  ```ruby
@@ -244,7 +244,7 @@ class DataProcessor
244
244
  include LazyInit # Note: include, not extend
245
245
  end
246
246
  ```
247
- **lazy(&block)**
247
+ `lazy(&block)`
248
248
 
249
249
  Creates a standalone lazy value container.
250
250
  ```ruby
@@ -255,13 +255,13 @@ end
255
255
  ```
256
256
 
257
257
 
258
- __lazy_once(**options, &block)__
258
+ `lazy_once(**options, &block)`
259
259
 
260
260
  Method-scoped lazy initialization with automatic cache key generation.
261
261
  #### Parameters:
262
262
 
263
- - max_entries (Integer): Maximum cache entries before LRU eviction
264
- - ttl (Numeric): Time-to-live in seconds for cache entries
263
+ - `max_entries` (Integer): Maximum cache entries before LRU eviction
264
+ - `ttl` (Numeric): Time-to-live in seconds for cache entries
265
265
 
266
266
  #### Example:
267
267
  ``` ruby
@@ -276,11 +276,11 @@ class DataAnalyzer
276
276
  end
277
277
  ```
278
278
 
279
- **clear_lazy_once_values!**
279
+ `clear_lazy_once_values!`
280
280
 
281
281
  Clears all cached lazy_once values for the instance.
282
282
 
283
- **lazy_once_statistics**
283
+ `lazy_once_statistics`
284
284
 
285
285
  Returns cache statistics for debugging and monitoring.
286
286
 
@@ -308,15 +308,15 @@ end
308
308
 
309
309
  #### Configuration Options:
310
310
 
311
- - **default_timeout**: Default timeout for all lazy attributes (default: nil)
312
- - **max_lazy_once_entries**: Maximum entries in lazy_once cache (default: 1000)
313
- - **lazy_once_ttl**: Default TTL for lazy_once entries (default: nil)
311
+ - `default_timeout`: Default timeout for all lazy attributes (default: nil)
312
+ - `max_lazy_once_entries`: Maximum entries in lazy_once cache (default: 1000)
313
+ - `lazy_once_ttl`: Default TTL for lazy_once entries (default: nil)
314
314
 
315
315
  ## Advanced Usage
316
316
  ### Dependency Resolution
317
317
  #### LazyInit automatically resolves dependencies in the correct order:
318
318
  ```ruby
319
- rubyclass ComplexService
319
+ class ComplexService
320
320
  extend LazyInit
321
321
 
322
322
  lazy_attr_reader :config do
@@ -534,7 +534,7 @@ Realistic benchmark results (x86_64-darwin19, Ruby 3.0.2):
534
534
  - Initial computation: ~identical (LazyInit setup overhead negligible)
535
535
  - Cached access: 3.5x slower than manual ||=
536
536
  -100,000 calls: Manual 13ms, LazyInit 45ms
537
- - In practice: For expensive operations (5-50ms), the 0.0004ms per call overhead is negligible.
537
+ - In practice: For expensive operations (5-50ms), 0.0004ms per call overhead is negligible.
538
538
  - Trade-off: 3.5x cached access cost for 100% thread safety
539
539
 
540
540
  [Full details can be found here](https://github.com/N3BCKN/lazy_init/blob/main/benchmarks/benchmark_performance.rb)
@@ -735,7 +735,7 @@ A: Minimal - about 1 mutex + 3 instance variables per lazy attribute.
735
735
 
736
736
  Q: Can I use lazy_attr_reader with private methods?
737
737
 
738
- A: Yes, the generated methods respect the same visibility as where they're defined.
738
+ A: Yes, generated methods respect the same visibility as where they're defined.
739
739
 
740
740
  Q: How do I debug dependency resolution issues?
741
741
 
@@ -746,7 +746,7 @@ Q: Does this work with inheritance?
746
746
  A: Yes, lazy attributes are inherited and can be overridden in subclasses.
747
747
  ## Contributing
748
748
 
749
- 1. Fork the repository
749
+ 1. Fork repository
750
750
  2. Create your feature branch (git checkout -b my-new-feature)
751
751
  3. Write tests for your changes
752
752
  4. Ensure all tests pass (bundle exec rspec)
@@ -762,4 +762,4 @@ bundle install
762
762
  bundle exec rspec # Run tests
763
763
  ```
764
764
  ## License
765
- The gem is available as open source under the terms of the MIT License.
765
+ Gem is available as open source under the terms of the MIT License.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LazyInit
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lazy_init
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstanty Koszewski
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-07-05 00:00:00.000000000 Z
11
+ date: 2025-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -90,6 +90,7 @@ extra_rdoc_files: []
90
90
  files:
91
91
  - ".gitignore"
92
92
  - ".rspec"
93
+ - ".yardopts"
93
94
  - CHANGELOG.md
94
95
  - GEMFILE
95
96
  - LICENSE