lazy_string 0.7.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.
- data/LICENSE.txt +1 -1
- data/test/lazy_string_test.rb +19 -0
- metadata +4 -21
- data/lazy_string.gemspec +0 -14
data/LICENSE.txt
CHANGED
data/test/lazy_string_test.rb
CHANGED
|
@@ -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
|
-
|
|
5
|
-
prerelease:
|
|
6
|
-
segments:
|
|
7
|
-
- 0
|
|
8
|
-
- 7
|
|
9
|
-
- 0
|
|
10
|
-
version: 0.7.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:
|
|
12
|
+
date: 2026-06-05 00:00:00 -07:00
|
|
19
13
|
default_executable:
|
|
20
14
|
dependencies: []
|
|
21
15
|
|
|
@@ -30,7 +24,6 @@ extra_rdoc_files: []
|
|
|
30
24
|
files:
|
|
31
25
|
- LICENSE.txt
|
|
32
26
|
- README.txt
|
|
33
|
-
- lazy_string.gemspec
|
|
34
27
|
- lib/lazy_string.rb
|
|
35
28
|
- test/lazy_string_test.rb
|
|
36
29
|
has_rdoc: true
|
|
@@ -43,24 +36,14 @@ rdoc_options: []
|
|
|
43
36
|
require_paths:
|
|
44
37
|
- lib
|
|
45
38
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
46
|
-
none: false
|
|
47
39
|
requirements:
|
|
48
40
|
- - ">="
|
|
49
41
|
- !ruby/object:Gem::Version
|
|
50
|
-
hash: 57
|
|
51
|
-
segments:
|
|
52
|
-
- 1
|
|
53
|
-
- 8
|
|
54
|
-
- 7
|
|
55
42
|
version: 1.8.7
|
|
56
43
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
|
-
none: false
|
|
58
44
|
requirements:
|
|
59
45
|
- - ">="
|
|
60
46
|
- !ruby/object:Gem::Version
|
|
61
|
-
hash: 3
|
|
62
|
-
segments:
|
|
63
|
-
- 0
|
|
64
47
|
version: "0"
|
|
65
48
|
requirements: []
|
|
66
49
|
|
|
@@ -69,5 +52,5 @@ rubygems_version: 1.6.2
|
|
|
69
52
|
signing_key:
|
|
70
53
|
specification_version: 3
|
|
71
54
|
summary: A class for computing strings only when necessary.
|
|
72
|
-
test_files:
|
|
73
|
-
|
|
55
|
+
test_files: []
|
|
56
|
+
|
data/lazy_string.gemspec
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
Gem::Specification.new do |s|
|
|
2
|
-
s.name = "lazy_string"
|
|
3
|
-
s.version = "0.7.0"
|
|
4
|
-
s.authors = ["Aaron Beckerman"]
|
|
5
|
-
s.summary = "A class for computing strings only when necessary."
|
|
6
|
-
s.description = "This library provides LazyString, a class for computing" \
|
|
7
|
-
" strings only when necessary. This is useful when computing the string" \
|
|
8
|
-
" is expensive but the string might never be used."
|
|
9
|
-
s.licenses = ["MIT"]
|
|
10
|
-
s.files = ["LICENSE.txt", "README.txt", "lazy_string.gemspec",
|
|
11
|
-
"lib/lazy_string.rb", "test/lazy_string_test.rb"]
|
|
12
|
-
s.test_files = ["test/lazy_string_test.rb"]
|
|
13
|
-
s.required_ruby_version = ">= 1.8.7"
|
|
14
|
-
end
|