lazy_string 0.8.0 → 0.10.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.
Files changed (3) hide show
  1. data/LICENSE.txt +1 -1
  2. data/test/lazy_string_test.rb +19 -0
  3. metadata +2 -18
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012-2025 Aaron Beckerman
1
+ Copyright (c) 2012-2026 Aaron Beckerman
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of
4
4
  this software and associated documentation files (the "Software"), to deal in
@@ -103,6 +103,25 @@ class ::Object
103
103
  fail "" unless 1 == block_result.instance_variable_get(:@_test_calls)
104
104
  end
105
105
 
106
+ # LazyString#to_str should memoize a falsy conversion result. Even when the
107
+ # converted value is nil or false, it should not call the saved proc again in
108
+ # subsequent invocations. (This is why #to_str checks defined? @str rather than
109
+ # using @str ||= ..., which would re-run the proc whenever @str is falsy.)
110
+ class ::Object
111
+ calls = 0
112
+ block_result = Object.new
113
+ def block_result.to_str
114
+ nil
115
+ end
116
+ ls = LazyString.new do
117
+ calls += 1
118
+ block_result
119
+ end
120
+ fail "" unless nil.equal? ls.to_str
121
+ fail "" unless nil.equal? ls.to_str
122
+ fail "" unless 1 == calls
123
+ end
124
+
106
125
  # LazyString#to_str should not save any result if converting to a string raised
107
126
  # an exception.
108
127
  class ::Object
metadata CHANGED
@@ -1,13 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lazy_string
3
3
  version: !ruby/object:Gem::Version
4
- hash: 63
5
- prerelease:
6
- segments:
7
- - 0
8
- - 8
9
- - 0
10
- version: 0.8.0
4
+ version: 0.10.0
11
5
  platform: ruby
12
6
  authors:
13
7
  - Aaron Beckerman
@@ -15,7 +9,7 @@ autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
11
 
18
- date: 2025-05-16 00:00:00 -07:00
12
+ date: 2026-06-05 00:00:00 -07:00
19
13
  default_executable:
20
14
  dependencies: []
21
15
 
@@ -42,24 +36,14 @@ rdoc_options: []
42
36
  require_paths:
43
37
  - lib
44
38
  required_ruby_version: !ruby/object:Gem::Requirement
45
- none: false
46
39
  requirements:
47
40
  - - ">="
48
41
  - !ruby/object:Gem::Version
49
- hash: 57
50
- segments:
51
- - 1
52
- - 8
53
- - 7
54
42
  version: 1.8.7
55
43
  required_rubygems_version: !ruby/object:Gem::Requirement
56
- none: false
57
44
  requirements:
58
45
  - - ">="
59
46
  - !ruby/object:Gem::Version
60
- hash: 3
61
- segments:
62
- - 0
63
47
  version: "0"
64
48
  requirements: []
65
49