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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MzA4MGIwZmUxODA0MWY3ZDI1ZjdkYWVjOThlOTFiZDhlODZlYzY1OQ==
4
+ NmZiMDg3YWJkN2E2ZDk2NGNmNjIyOGNlNjYwMjFjYTFkOWIyN2NmNw==
5
5
  data.tar.gz: !binary |-
6
- ZmRjYWNlY2FlOGVhMTJlNjE5Y2NjODI1NjMyNDI1M2I4YzJkNTgyMQ==
6
+ ZjUzNmNhNTMxZjA0YjMwMjFjZjBmNmRmMDkzNjQ1ZjY4NGMyNzc1Mg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YmMxMzQwZDJiYjRhNjBlNWI5M2NlNmJiMmQ0NjA3MjNhMWFiOGYwZDcwNzEw
10
- OGMxMTMxYzZhNzAwMjI3ZTEzMTMzZWJiYzg2ZDc2MzA0ZWFmZWVmYmQxYTA5
11
- MWY0Mjk5ODQwZmJiNjMyY2JkMjQwZWRhNzI3ODQ2MmFhYzNmMGI=
9
+ MWUxODVmZmQ0MWM0ZDI5NmE0MTlmMjIzZjdiMGY4OWNlZmZiMDc5YjkzMjBk
10
+ ZjRkZDJiMzJlZTY1NWE4ODExMTVjZmJkZjkxMWE2ZWUyOGJiYTE3NDA2NjJi
11
+ OGNjYmY3N2Y4ZTBiNGE1MjA5ZDFiMzZmNGU5YjZjZmRkMjk2MGM=
12
12
  data.tar.gz: !binary |-
13
- YzQ2NzJkMjdkOTI1ZWY3OTM2ZjcxMTg4YzJhMTE5Y2U4MDNkYjk2YWJlY2E5
14
- MzU2ZTE2ZmQwODhkOWMyNThlNzkzYzAxMThlMzI1NGE3MzViZDY4Mjc4MDU0
15
- NzYwYzRkYzM4OGFjOWNhODc3NjBlYzIwZTEyZGU4ZGZkMmI5ZmQ=
13
+ MjViOGQ0ZWNmODhhZDAyMDhkNTc0YjFhM2FkYzM4MjNmMDkyZGZjNjE0ZDUz
14
+ OGE1ZjljNjhlMGY0NzBiYzYxNTU4YWI4YmEwMGUyYjY4YzIxMGRjMzdiODY2
15
+ NjUwNGU0ZTY0NGQyNWU2NDE5NzUyOWQ1YmM1NmIzNjUyYmMzYTE=
@@ -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
- check = [options.message, options.mark]
80
- (check.any?{ |z| !z.nil? } && !check.all?{ |z| !z.nil? }) and Base.log_and_raise(options.ui.logger, BenchmarkError, "You must supply both a message and a mark!")
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 (options.message && options.mark)
85
- if options.use_spinner
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.message && options.mark) and options.ui.stdout.print("#{options.mark}\n" % benchmark)
98
- options.ui.logger.info { "#{options.message} #{options.mark}" % benchmark }
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
@@ -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))
@@ -1,6 +1,6 @@
1
1
  module ZTK
2
2
 
3
3
  # ZTK Version String
4
- VERSION = "1.15.3"
4
+ VERSION = "1.16.1"
5
5
 
6
6
  end
@@ -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
- lambda {
60
- ZTK::Benchmark.bench(:ui => @ui, :message => "Hello World")
61
- }.should raise_error ZTK::BenchmarkError
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
- lambda {
66
- ZTK::Benchmark.bench(:ui => @ui, :mark => "%0.4f")
67
- }.should raise_error ZTK::BenchmarkError
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.15.3
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.2.1
348
+ rubygems_version: 2.1.11
349
349
  signing_key:
350
350
  specification_version: 4
351
351
  summary: Zachary's Tool Kit