interval_timer 0.0.1 → 0.0.2

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/interval_timer.rb +2 -67
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 68db778f7dea16c6f7b4d8cb24e2012613710174
4
- data.tar.gz: 64024c733a6e3da4d634fef795376f937790736b
3
+ metadata.gz: d88dbd392209a5d3a494277feefb8ca47b5cf140
4
+ data.tar.gz: ac43d289695a9a9102549376e7dc51b3ffdab16e
5
5
  SHA512:
6
- metadata.gz: 8462f61e949b2fc11eb22c18651ae81892ced45a57e052887ad5576ef261d59e28a56627fca7c19662b3f6aa3240c6a2b124d1058dda22109671b445b44ae866
7
- data.tar.gz: 66f029b9cbfdcdbe62398703c464733652f566a5717d79e53f5b8ab8aac3627c360125034bc34159745273de07eac529d93d6eee1b425c9ae08709f3cd565904
6
+ metadata.gz: 61098145ee1587303eed5b234586735517b305989c797aac81fac5a892cfa5bda152702475159119117fcb562d073f86842a0cee7eb607030fcd6ca437e2470e
7
+ data.tar.gz: 3a47159c815c6ff21eaad8a8abdc24f8e435f9f98c77e3bd4d25d76869c4eae254286b0a808d5c405da74374d58aabe2c2a4e6c798f608a7e98a49348c953bee
@@ -1,67 +1,2 @@
1
- class IntervalTimer
2
- def self.started
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.1
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: '0'
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: '0'
26
+ version: '3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: pry
29
29
  requirement: !ruby/object:Gem::Requirement