interval_timer 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/interval_timer.rb +2 -67
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d88dbd392209a5d3a494277feefb8ca47b5cf140
|
4
|
+
data.tar.gz: ac43d289695a9a9102549376e7dc51b3ffdab16e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61098145ee1587303eed5b234586735517b305989c797aac81fac5a892cfa5bda152702475159119117fcb562d073f86842a0cee7eb607030fcd6ca437e2470e
|
7
|
+
data.tar.gz: 3a47159c815c6ff21eaad8a8abdc24f8e435f9f98c77e3bd4d25d76869c4eae254286b0a808d5c405da74374d58aabe2c2a4e6c798f608a7e98a49348c953bee
|
data/lib/interval_timer.rb
CHANGED
@@ -1,67 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
timer = new
|
4
|
-
timer.start
|
5
|
-
timer
|
6
|
-
end
|
7
|
-
|
8
|
-
def start
|
9
|
-
raise "Already started" if @start_time
|
10
|
-
|
11
|
-
@start_time = Time.now
|
12
|
-
end
|
13
|
-
|
14
|
-
def check_in(message = nil)
|
15
|
-
check_in = build_check_in(message)
|
16
|
-
check_ins.push(check_in)
|
17
|
-
check_in
|
18
|
-
end
|
19
|
-
alias_method :mark, :check_in
|
20
|
-
|
21
|
-
def report
|
22
|
-
[
|
23
|
-
report_header.join("\n"),
|
24
|
-
report_body.join("\n")
|
25
|
-
].join("\n")
|
26
|
-
end
|
27
|
-
|
28
|
-
def check_ins
|
29
|
-
@check_ins ||= []
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def build_check_in(message)
|
35
|
-
{ created_at: Time.now, message: message }
|
36
|
-
end
|
37
|
-
|
38
|
-
def report_header
|
39
|
-
output = []
|
40
|
-
|
41
|
-
output << "start_time: #{@start_time}"
|
42
|
-
|
43
|
-
output
|
44
|
-
end
|
45
|
-
|
46
|
-
def report_body
|
47
|
-
output = []
|
48
|
-
|
49
|
-
check_ins.each_with_index do |x, i|
|
50
|
-
last = i == 0 ? nil : check_ins[i - 1]
|
51
|
-
|
52
|
-
output.push report_line(x, last)
|
53
|
-
end
|
54
|
-
|
55
|
-
output
|
56
|
-
end
|
57
|
-
|
58
|
-
def report_line(x, last)
|
59
|
-
if last
|
60
|
-
since_last = x[:created_at] - last[:created_at]
|
61
|
-
else
|
62
|
-
since_last = x[:created_at] - @start_time
|
63
|
-
end
|
64
|
-
|
65
|
-
"#{x[:created_at]} -- #{ since_last.round(3) } -- #{x[:message]}"
|
66
|
-
end
|
67
|
-
end
|
1
|
+
require_relative './interval_timer/interval_timer.rb'
|
2
|
+
require_relative './interval_timer/version.rb'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: interval_timer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luke Griffiths
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pry
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|