ztk 1.15.3 → 1.16.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 +8 -8
- data/lib/ztk/benchmark.rb +10 -11
- data/lib/ztk/logger.rb +1 -1
- data/lib/ztk/version.rb +1 -1
- data/spec/ztk/benchmark_spec.rb +11 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NmZiMDg3YWJkN2E2ZDk2NGNmNjIyOGNlNjYwMjFjYTFkOWIyN2NmNw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZjUzNmNhNTMxZjA0YjMwMjFjZjBmNmRmMDkzNjQ1ZjY4NGMyNzc1Mg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MWUxODVmZmQ0MWM0ZDI5NmE0MTlmMjIzZjdiMGY4OWNlZmZiMDc5YjkzMjBk
|
10
|
+
ZjRkZDJiMzJlZTY1NWE4ODExMTVjZmJkZjkxMWE2ZWUyOGJiYTE3NDA2NjJi
|
11
|
+
OGNjYmY3N2Y4ZTBiNGE1MjA5ZDFiMzZmNGU5YjZjZmRkMjk2MGM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MjViOGQ0ZWNmODhhZDAyMDhkNTc0YjFhM2FkYzM4MjNmMDkyZGZjNjE0ZDUz
|
14
|
+
OGE1ZjljNjhlMGY0NzBiYzYxNTU4YWI4YmEwMGUyYjY4YzIxMGRjMzdiODY2
|
15
|
+
NjUwNGU0ZTY0NGQyNWU2NDE5NzUyOWQ1YmM1NmIzNjUyYmMzYTE=
|
data/lib/ztk/benchmark.rb
CHANGED
@@ -76,17 +76,14 @@ module ZTK
|
|
76
76
|
|
77
77
|
!block_given? and Base.log_and_raise(options.ui.logger, BenchmarkError, "You must supply a block!")
|
78
78
|
|
79
|
-
|
80
|
-
|
79
|
+
if (!options.message.nil? && !options.message.empty?)
|
80
|
+
options.ui.stdout.print(options.message)
|
81
|
+
options.ui.logger.info { options.message }
|
82
|
+
end
|
81
83
|
|
82
|
-
(options.message && options.mark) and options.ui.stdout.print("#{options.message} ")
|
83
84
|
benchmark = ::Benchmark.realtime do
|
84
|
-
if
|
85
|
-
|
86
|
-
ZTK::Spinner.spin(options) do
|
87
|
-
yield
|
88
|
-
end
|
89
|
-
else
|
85
|
+
if options.use_spinner
|
86
|
+
ZTK::Spinner.spin(options) do
|
90
87
|
yield
|
91
88
|
end
|
92
89
|
else
|
@@ -94,8 +91,10 @@ module ZTK
|
|
94
91
|
end
|
95
92
|
end
|
96
93
|
|
97
|
-
(options.
|
98
|
-
|
94
|
+
if (!options.mark.nil? && !options.mark.empty?)
|
95
|
+
options.ui.stdout.print(options.mark % benchmark)
|
96
|
+
options.ui.logger.info { options.mark % benchmark }
|
97
|
+
end
|
99
98
|
|
100
99
|
benchmark
|
101
100
|
end
|
data/lib/ztk/logger.rb
CHANGED
@@ -150,7 +150,7 @@ module ZTK
|
|
150
150
|
|
151
151
|
called_by = parse_caller(caller[1+shift])
|
152
152
|
|
153
|
-
message = [message, progname].flatten.compact.join(": ")
|
153
|
+
message = [message.chomp, progname].flatten.compact.join(": ")
|
154
154
|
message = "%19s.%06d|%05d|%5s|%s%s\n" % [Time.now.utc.strftime("%Y-%m-%d|%H:%M:%S"), Time.now.utc.usec, Process.pid, SEVERITIES[severity], called_by, message]
|
155
155
|
|
156
156
|
@logdev.write(ZTK::ANSI.uncolor(message))
|
data/lib/ztk/version.rb
CHANGED
data/spec/ztk/benchmark_spec.rb
CHANGED
@@ -55,20 +55,22 @@ describe ZTK::Benchmark do
|
|
55
55
|
mark.should be_an_instance_of Float
|
56
56
|
end
|
57
57
|
|
58
|
-
it "should throw an exception if executed with a message but without a mark" do
|
59
|
-
|
60
|
-
ZTK::Benchmark.bench(:ui => @ui, :message => "Hello World")
|
61
|
-
|
58
|
+
it "should not throw an exception if executed with a message but without a mark" do
|
59
|
+
expect {
|
60
|
+
ZTK::Benchmark.bench(:ui => @ui, :message => "Hello World") do
|
61
|
+
end
|
62
|
+
}.not_to raise_error
|
62
63
|
end
|
63
64
|
|
64
|
-
it "should throw an exception if executed without a message but with a mark" do
|
65
|
-
|
66
|
-
ZTK::Benchmark.bench(:ui => @ui, :mark => "%0.4f")
|
67
|
-
|
65
|
+
it "should not throw an exception if executed without a message but with a mark" do
|
66
|
+
expect {
|
67
|
+
ZTK::Benchmark.bench(:ui => @ui, :mark => "%0.4f") do
|
68
|
+
end
|
69
|
+
}.not_to raise_error
|
68
70
|
end
|
69
71
|
|
70
72
|
it "should not write to STDOUT if not given a message or mark" do
|
71
|
-
ZTK::Benchmark.bench(:ui => @ui) do
|
73
|
+
ZTK::Benchmark.bench(:ui => @ui, :use_spinner => false) do
|
72
74
|
sleep(0.1)
|
73
75
|
end
|
74
76
|
@ui.stdout.size.should == 0
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ztk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.16.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zachary Patten
|
@@ -345,7 +345,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
345
345
|
version: '0'
|
346
346
|
requirements: []
|
347
347
|
rubyforge_project:
|
348
|
-
rubygems_version: 2.
|
348
|
+
rubygems_version: 2.1.11
|
349
349
|
signing_key:
|
350
350
|
specification_version: 4
|
351
351
|
summary: Zachary's Tool Kit
|