trick_bag 0.40.0 → 0.41.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/RELEASE_NOTES.md +5 -0
- data/lib/trick_bag/timing/timing.rb +22 -0
- data/lib/trick_bag/version.rb +1 -1
- data/spec/trick_bag/timing/timing_spec.rb +21 -5
- metadata +5 -19
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MDVjMzY3ZGQ2ODZhM2MxOTZkMGQ2NmYyMWQ4NGIzMzQzYTFjZmQ2Mw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YzNiNzBkMWVjMjVlZjI5NWFhZTRkMDQ4ODY0OTY1YjdhMGFhZGU5OQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MjEyNzc0NjBiNGJlODYzY2ZkZGJhMjRiNGU2OWNkMzI0YjBhNjE3NjdjYTIy
|
10
|
+
ZjQwMjBlYTQwN2FjZDg4NTAyMzVmNWEyODJkOTY0OWZjYmZhYmMyYWJjYjc0
|
11
|
+
YjIxMzliZTczZjA5NDZlMTNkYjk3YjlkMDU4MTBlM2IzN2M1ZmM=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MmI0NWNiMjM4MDkxMmI3MzBmMTdhODYwYTM4OGM5ZTJmYTBkOGVmMDczMDVi
|
14
|
+
YzJjNjBlYTM3NTViNjBmODFhNzg3NTY0ODg1MWUyYmQ5NTkxYjA5MWE2MzE3
|
15
|
+
Mjk5ZTVhYzU2MjY3YjUyNGFiMmU2MDlhMTNmNTRhOWIwNjRiZmM=
|
data/RELEASE_NOTES.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'trick_bag/io/text_mode_status_updater'
|
2
|
+
require 'benchmark'
|
2
3
|
|
3
4
|
module TrickBag
|
4
5
|
module Timing
|
@@ -45,5 +46,26 @@ module Timing
|
|
45
46
|
success
|
46
47
|
end
|
47
48
|
|
49
|
+
|
50
|
+
# Executes the passed block with the Ruby Benchmark standard library.
|
51
|
+
# Prints the benchmark string to the specified output stream.
|
52
|
+
# Returns the passed block's return value.
|
53
|
+
#
|
54
|
+
# e.g. benchmark('time to loop 1,000,000 times') { 1_000_000.times { 42 }; 'hi' }
|
55
|
+
# outputs to the specified output stream the following string:
|
56
|
+
# 0.050000 0.000000 0.050000 ( 0.042376): time to loop 1,000,000 times
|
57
|
+
# and returns: 42
|
58
|
+
#
|
59
|
+
# @param caption the text fragment to print after the timing data
|
60
|
+
# @param out_stream object responding to << that will get the output string
|
61
|
+
# @default $stdout
|
62
|
+
# @block the block to execute and benchmark
|
63
|
+
def benchmark(caption, out_stream = $stdout, &block)
|
64
|
+
return_value = nil
|
65
|
+
bm = Benchmark.measure { return_value = block.call }
|
66
|
+
out_stream << bm.to_s.chomp << ": #{caption}\n"
|
67
|
+
return_value
|
68
|
+
end
|
69
|
+
|
48
70
|
end
|
49
71
|
end
|
data/lib/trick_bag/version.rb
CHANGED
@@ -6,11 +6,27 @@ module TrickBag
|
|
6
6
|
|
7
7
|
describe Timing do
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
context '.retry_until_true_or_timeout' do
|
10
|
+
it 'returns when the predicate returns true' do
|
11
|
+
count = 0
|
12
|
+
predicate = ->{ count += 1; count == 3 }
|
13
|
+
Timing.retry_until_true_or_timeout(predicate, 0, 1, StringIO.new)
|
14
|
+
expect(count).to eq(3)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
context '.benchmark' do
|
20
|
+
it "returns the passed expression's return value" do
|
21
|
+
expect(Timing.benchmark('', '') { 123 }).to eq(123)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'includes the label in the output string' do
|
25
|
+
label = 'foo'
|
26
|
+
output_string = ''
|
27
|
+
Timing.benchmark(label, output_string) {}
|
28
|
+
expect(output_string).to include(label)
|
29
|
+
end
|
14
30
|
end
|
15
31
|
end
|
16
32
|
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trick_bag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.41.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Keith Bennett
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-12 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: os
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ! '>='
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ! '>='
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: bundler
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ~>
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,7 +41,6 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rake
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ! '>='
|
52
46
|
- !ruby/object:Gem::Version
|
@@ -54,7 +48,6 @@ dependencies:
|
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ! '>='
|
60
53
|
- !ruby/object:Gem::Version
|
@@ -62,7 +55,6 @@ dependencies:
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rspec
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
59
|
- - ! '>='
|
68
60
|
- !ruby/object:Gem::Version
|
@@ -70,7 +62,6 @@ dependencies:
|
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
66
|
- - ! '>='
|
76
67
|
- !ruby/object:Gem::Version
|
@@ -78,7 +69,6 @@ dependencies:
|
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: guard
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
73
|
- - ! '>='
|
84
74
|
- !ruby/object:Gem::Version
|
@@ -86,7 +76,6 @@ dependencies:
|
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
80
|
- - ! '>='
|
92
81
|
- !ruby/object:Gem::Version
|
@@ -94,7 +83,6 @@ dependencies:
|
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: guard-rspec
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
87
|
- - ! '>='
|
100
88
|
- !ruby/object:Gem::Version
|
@@ -102,7 +90,6 @@ dependencies:
|
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
94
|
- - ! '>='
|
108
95
|
- !ruby/object:Gem::Version
|
@@ -168,27 +155,26 @@ files:
|
|
168
155
|
homepage: https://github.com/keithrbennett/trick_bag
|
169
156
|
licenses:
|
170
157
|
- MIT
|
158
|
+
metadata: {}
|
171
159
|
post_install_message:
|
172
160
|
rdoc_options: []
|
173
161
|
require_paths:
|
174
162
|
- lib
|
175
163
|
required_ruby_version: !ruby/object:Gem::Requirement
|
176
|
-
none: false
|
177
164
|
requirements:
|
178
165
|
- - ! '>='
|
179
166
|
- !ruby/object:Gem::Version
|
180
167
|
version: '0'
|
181
168
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
|
-
none: false
|
183
169
|
requirements:
|
184
170
|
- - ! '>='
|
185
171
|
- !ruby/object:Gem::Version
|
186
172
|
version: '0'
|
187
173
|
requirements: []
|
188
174
|
rubyforge_project:
|
189
|
-
rubygems_version:
|
175
|
+
rubygems_version: 2.2.2
|
190
176
|
signing_key:
|
191
|
-
specification_version:
|
177
|
+
specification_version: 4
|
192
178
|
summary: Miscellaneous general useful tools.
|
193
179
|
test_files:
|
194
180
|
- spec/spec_helper.rb
|