pomato 0.0.4 → 0.0.5
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 +2 -2
- data/lib/pomato/add.rb +27 -0
- data/lib/pomato/configure.rb +1 -1
- data/lib/pomato/options.rb +20 -0
- data/lib/pomato/paths.rb +5 -11
- data/lib/pomato/report.rb +10 -5
- data/lib/pomato/run.rb +1 -1
- data/lib/pomato/start.rb +12 -3
- data/lib/pomato/stop.rb +1 -1
- data/lib/pomato/version.rb +1 -1
- data/pomato.gemspec +1 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 809e5356b5a84d5dbd97ae74293b5e100e82273f
|
4
|
+
data.tar.gz: 9af2da1b28c8eb398f1608b63377a5c23592da26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77979d100fc1a7515e78b51dcde062141da7531f2e27a43cc65dece84d84dc4314e41d9e160f334cb73a26fe8118d54ff46a6978e0f70bc69f57dda486cbc88b
|
7
|
+
data.tar.gz: 3ae3cf5cb9a255cfe56fa81749f57af1c1cba82fbb2d9977182257f2f30862759aceac299bf83dc493ffcdbac8b94fce8497df9dd74be3a99a0bd840a69c2e04
|
data/lib/pomato.rb
CHANGED
data/lib/pomato/add.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'pomato/paths'
|
2
|
+
require 'pomato/options'
|
3
|
+
|
4
|
+
module Pomato
|
5
|
+
class Add
|
6
|
+
include Paths
|
7
|
+
include Options
|
8
|
+
|
9
|
+
def execute
|
10
|
+
start = now
|
11
|
+
jobs.each do |job|
|
12
|
+
job_end = job[:start] + job[:time]
|
13
|
+
start = job_end if job_end > start
|
14
|
+
end
|
15
|
+
time = (opts[:for] || 25).to_i * 60
|
16
|
+
name = opts.arguments.empty? ? 'pomato' : opts.arguments.join(' ')
|
17
|
+
add_job start: start, name: name, time: time
|
18
|
+
end
|
19
|
+
|
20
|
+
def options
|
21
|
+
Slop::Options.new.tap do |opts|
|
22
|
+
opts.banner = 'usage: add [options] ...'
|
23
|
+
opts.string '--for', 'duration (eg. 10)'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/pomato/configure.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'slop'
|
2
|
+
|
3
|
+
module Pomato
|
4
|
+
module Options
|
5
|
+
attr :opts
|
6
|
+
|
7
|
+
def usage
|
8
|
+
puts options
|
9
|
+
exit 0
|
10
|
+
end
|
11
|
+
|
12
|
+
def opts
|
13
|
+
begin
|
14
|
+
@opts ||= Slop::Parser.new(options).parse ARGV
|
15
|
+
rescue Slop::UnknownOption
|
16
|
+
usage
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/pomato/paths.rb
CHANGED
@@ -6,12 +6,6 @@ module Pomato
|
|
6
6
|
module Paths
|
7
7
|
include FileUtils
|
8
8
|
|
9
|
-
attr_reader :args
|
10
|
-
|
11
|
-
def initialize(*args)
|
12
|
-
@args = args
|
13
|
-
end
|
14
|
-
|
15
9
|
def now
|
16
10
|
@now ||= Time.now.to_i
|
17
11
|
end
|
@@ -48,19 +42,19 @@ module Pomato
|
|
48
42
|
dump_yaml(File.join(home('jobs'), job[:id]), job)
|
49
43
|
end
|
50
44
|
|
51
|
-
def
|
45
|
+
def add_job(job)
|
52
46
|
job[:id] = SecureRandom.uuid
|
53
|
-
history "#{job[:id]} start #{job[:time]} #{job[:name]}"
|
54
|
-
dump_job job
|
47
|
+
history "#{job[:id]} add #{job[:start]} #{job[:time]} #{job[:name]}"
|
48
|
+
dump_job job
|
55
49
|
end
|
56
50
|
|
57
51
|
def stop_job(job)
|
58
|
-
history "#{job[:id]} stop #{job[:time]} #{job[:name]}"
|
52
|
+
history "#{job[:id]} stop #{job[:start]} #{job[:time]} #{job[:name]}"
|
59
53
|
destroy_job job
|
60
54
|
end
|
61
55
|
|
62
56
|
def finish_job(job)
|
63
|
-
history "#{job[:id]} finish #{job[:time]} #{job[:name]}"
|
57
|
+
history "#{job[:id]} finish #{job[:start]} #{job[:time]} #{job[:name]}"
|
64
58
|
destroy_job job
|
65
59
|
end
|
66
60
|
|
data/lib/pomato/report.rb
CHANGED
@@ -5,11 +5,16 @@ module Pomato
|
|
5
5
|
include Paths
|
6
6
|
|
7
7
|
def execute
|
8
|
-
jobs.sort_by! {|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
jobs.sort_by! {|job| job[:start] + job[:time]}.each do |job|
|
9
|
+
end_time = job[:start] + job[:time]
|
10
|
+
if now > job[:start]
|
11
|
+
elapsed = now - job[:start]
|
12
|
+
remaining = job[:time] - elapsed
|
13
|
+
puts " #{time_format end_time} (#{min_sec elapsed} completed, #{min_sec remaining} of #{min_sec job[:time]} remaining): #{job[:name]}"
|
14
|
+
else
|
15
|
+
starting = job[:start] - now
|
16
|
+
puts " #{time_format end_time} (#{min_sec job[:time]} starting in #{min_sec starting}): #{job[:name]}"
|
17
|
+
end
|
13
18
|
end
|
14
19
|
end
|
15
20
|
|
data/lib/pomato/run.rb
CHANGED
data/lib/pomato/start.rb
CHANGED
@@ -1,13 +1,22 @@
|
|
1
1
|
require 'pomato/paths'
|
2
|
+
require 'pomato/options'
|
2
3
|
|
3
4
|
module Pomato
|
4
5
|
class Start
|
5
6
|
include Paths
|
7
|
+
include Options
|
6
8
|
|
7
9
|
def execute
|
8
|
-
time =
|
9
|
-
name =
|
10
|
-
|
10
|
+
time = (opts[:for] || 25).to_i * 60
|
11
|
+
name = opts.arguments.empty? ? 'pomato' : opts.arguments.join(' ')
|
12
|
+
add_job start: now, name: name, time: time
|
13
|
+
end
|
14
|
+
|
15
|
+
def options
|
16
|
+
Slop::Options.new.tap do |opts|
|
17
|
+
opts.banner = 'usage: start [options] ...'
|
18
|
+
opts.string '--for', 'duration (eg. 10)'
|
19
|
+
end
|
11
20
|
end
|
12
21
|
end
|
13
22
|
end
|
data/lib/pomato/stop.rb
CHANGED
data/lib/pomato/version.rb
CHANGED
data/pomato.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Ryall
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: daemons
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: slop
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4.0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -69,8 +83,10 @@ files:
|
|
69
83
|
- bin/pomato
|
70
84
|
- bin/pomato_daemon
|
71
85
|
- lib/pomato.rb
|
86
|
+
- lib/pomato/add.rb
|
72
87
|
- lib/pomato/configure.rb
|
73
88
|
- lib/pomato/history.rb
|
89
|
+
- lib/pomato/options.rb
|
74
90
|
- lib/pomato/paths.rb
|
75
91
|
- lib/pomato/report.rb
|
76
92
|
- lib/pomato/run.rb
|