timed_report 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/timed_report.rb +44 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7089d003634204fbde2f5ac98dd7b479521f78cc
4
+ data.tar.gz: 78416f520523de40d3ac41dca5692019fec2f94d
5
+ SHA512:
6
+ metadata.gz: dd96da59a002ec573de153650db7103d6a6d8556844d7abee78bd968b23cfc684922d075d02568d56da9f6cb722318d964278de32459748d9b162d8c05b5fecf
7
+ data.tar.gz: 80f901cbe5fd68e9dcc69c7eb6fa014698e0e20220ee456bd0b945b4a806f4698d5f43357b2e3d8876afb7802799785bed297c2552084bd9e5d6c9db070b76fc
@@ -0,0 +1,44 @@
1
+ class TimedReport
2
+
3
+ def initialize named = nil
4
+ @start_time = Time.now
5
+ @step_time = Time.now
6
+ @output = "\n=========================="
7
+
8
+ if named != nil
9
+ @output += "\nReport: #{named}"
10
+ @output += "\n--------------------------"
11
+ end
12
+
13
+ @output_methods = [lambda{|m| puts(m)}]
14
+ end
15
+
16
+ def add_output_method method
17
+ @output_methods.push method
18
+ end
19
+
20
+ def time_step
21
+ @step_time = Time.now
22
+ end
23
+
24
+ def add txt, with_time = true
25
+ if with_time
26
+ timing_info = "%.5f: " % (Time.now - @step_time)
27
+ time_step()
28
+ else
29
+ timing_info = ""
30
+ end
31
+
32
+ @output += "\n#{timing_info}#{txt}"
33
+ end
34
+
35
+ def finish
36
+ @output += "\n--------------------------"
37
+ @output += "\nTotal time: %.5f" % (Time.now-@start_time)
38
+ @output += "\n=========================="
39
+ @output_methods.each do |om|
40
+ om.call(@output)
41
+ end
42
+ end
43
+
44
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: timed_report
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Tom Aizenberg
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-14 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Create reports in your script with timing information.
14
+ email: tom.aizenberg@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/timed_report.rb
20
+ homepage: https://github.com/Tomtomgo/timed_report
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.0.0.rc.2
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Puts with timing info.
44
+ test_files: []