pomato 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pomato.rb +7 -13
- data/lib/pomato/history.rb +13 -0
- data/lib/pomato/paths.rb +24 -5
- data/lib/pomato/report.rb +14 -4
- data/lib/pomato/start.rb +1 -2
- data/lib/pomato/stop.rb +17 -0
- data/lib/pomato/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1809867009864c93d7006f1e5a7824f7c47000b1
|
4
|
+
data.tar.gz: df303a5d703d86f3094fba112baa67de4b94ab6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bddd7124c363561fff104a68a1d2ae0c2090915146b8f0ca1ca1f95941579441833c840b75bd75d93505d5ee317979552f2190f3eecfb1f9dafe0d364338a94f
|
7
|
+
data.tar.gz: 9362cbc77726ab8c1acf348213a617b8ee2a21ff35fac464b89c3658d9c7d9fe0a02da57f01339197a93e99bfc4d6b530c9dc3d4acda2691aef768adf4e86d7b
|
data/lib/pomato.rb
CHANGED
@@ -1,24 +1,18 @@
|
|
1
|
-
require 'pomato/tick'
|
2
|
-
require 'pomato/start'
|
3
|
-
require 'pomato/report'
|
4
|
-
|
5
1
|
module Pomato
|
6
2
|
module Cli
|
7
3
|
def self.execute(*args)
|
8
4
|
method, *args = args
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
def self.report
|
13
|
-
Pomato::Report.new.execute
|
5
|
+
method ||= :report
|
6
|
+
page_class(method).new(*args).execute
|
14
7
|
end
|
15
8
|
|
16
|
-
def self.
|
17
|
-
|
9
|
+
def self.classify(string)
|
10
|
+
string.to_s.split('_').map(&:capitalize).join
|
18
11
|
end
|
19
12
|
|
20
|
-
def self.
|
21
|
-
|
13
|
+
def self.page_class(name)
|
14
|
+
require "pomato/#{name}"
|
15
|
+
Pomato.const_get classify name
|
22
16
|
end
|
23
17
|
end
|
24
18
|
end
|
data/lib/pomato/paths.rb
CHANGED
@@ -24,6 +24,10 @@ module Pomato
|
|
24
24
|
append_to history_path, "#{now} #{message}"
|
25
25
|
end
|
26
26
|
|
27
|
+
def history_items
|
28
|
+
File.exist?(history_path) ? File.readlines(history_path) : []
|
29
|
+
end
|
30
|
+
|
27
31
|
def history_path
|
28
32
|
File.join home, 'history'
|
29
33
|
end
|
@@ -33,16 +37,31 @@ module Pomato
|
|
33
37
|
end
|
34
38
|
|
35
39
|
def jobs
|
36
|
-
Dir["#{home('jobs')}/*"].map {|p| load_yaml(p)
|
40
|
+
Dir["#{home('jobs')}/*"].map {|p| load_yaml(p) }
|
41
|
+
end
|
42
|
+
|
43
|
+
def dump_job(job)
|
44
|
+
dump_yaml(File.join(home('jobs'), job[:id]), job)
|
37
45
|
end
|
38
46
|
|
39
|
-
def
|
40
|
-
|
47
|
+
def start_job(job)
|
48
|
+
job[:id] = SecureRandom.uuid
|
49
|
+
history "#{job[:id]} start #{job[:time]} #{job[:name]}"
|
50
|
+
dump_job job.merge(start: now)
|
51
|
+
end
|
52
|
+
|
53
|
+
def stop_job(job)
|
54
|
+
history "#{job[:id]} stop #{job[:time]} #{job[:name]}"
|
55
|
+
destroy_job job
|
41
56
|
end
|
42
57
|
|
43
58
|
def finish_job(job)
|
44
|
-
history "finish #{job[:time]} #{job[:name]}"
|
45
|
-
|
59
|
+
history "#{job[:id]} finish #{job[:time]} #{job[:name]}"
|
60
|
+
destroy_job job
|
61
|
+
end
|
62
|
+
|
63
|
+
def destroy_job(job)
|
64
|
+
File.delete File.join(home('jobs'), job[:id])
|
46
65
|
end
|
47
66
|
|
48
67
|
def home(*paths)
|
data/lib/pomato/report.rb
CHANGED
@@ -5,11 +5,21 @@ module Pomato
|
|
5
5
|
include Paths
|
6
6
|
|
7
7
|
def execute
|
8
|
-
jobs.each do |job|
|
9
|
-
|
10
|
-
remaining = job[:time] -
|
11
|
-
|
8
|
+
jobs.sort_by! {|j| now + j[:time]}.each do |job|
|
9
|
+
elapsed = now - job[:start]
|
10
|
+
remaining = job[:time] - elapsed
|
11
|
+
end_time = now + job[:time]
|
12
|
+
puts " #{time_format end_time} (#{min_sec elapsed} completed, #{min_sec remaining} of #{min_sec job[:time]} remaining): #{job[:name]}"
|
12
13
|
end
|
13
14
|
end
|
15
|
+
|
16
|
+
def time_format(seconds)
|
17
|
+
time = Time.at seconds
|
18
|
+
time.strftime '%I:%M%p'
|
19
|
+
end
|
20
|
+
|
21
|
+
def min_sec(seconds)
|
22
|
+
"%02d:%02d" % [seconds/60, seconds%60]
|
23
|
+
end
|
14
24
|
end
|
15
25
|
end
|
data/lib/pomato/start.rb
CHANGED
data/lib/pomato/stop.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'pomato/paths'
|
2
|
+
|
3
|
+
module Pomato
|
4
|
+
class Stop
|
5
|
+
include Paths
|
6
|
+
|
7
|
+
def execute
|
8
|
+
search_string = args.first
|
9
|
+
jobs.each do |job|
|
10
|
+
if job[:name].include? search_string
|
11
|
+
puts "stopping \"#{job[:name]}\""
|
12
|
+
stop_job job
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/pomato/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pomato
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Ryall
|
@@ -53,9 +53,11 @@ files:
|
|
53
53
|
- Rakefile
|
54
54
|
- bin/pomato
|
55
55
|
- lib/pomato.rb
|
56
|
+
- lib/pomato/history.rb
|
56
57
|
- lib/pomato/paths.rb
|
57
58
|
- lib/pomato/report.rb
|
58
59
|
- lib/pomato/start.rb
|
60
|
+
- lib/pomato/stop.rb
|
59
61
|
- lib/pomato/tick.rb
|
60
62
|
- lib/pomato/version.rb
|
61
63
|
- pomato.gemspec
|