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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b9be8524db2da9247a63d00806f7ab672bbbdbea
4
- data.tar.gz: a8776fbdb2e6277b47942fca4049511bc50a8cad
3
+ metadata.gz: 809e5356b5a84d5dbd97ae74293b5e100e82273f
4
+ data.tar.gz: 9af2da1b28c8eb398f1608b63377a5c23592da26
5
5
  SHA512:
6
- metadata.gz: e4c2cf32956c744e23215b1360350749a982f7c71796294662abcae8d38a4af3fe28e82b8b0fb2a92f479ef9e03815cb69afcd20f12b4b8cf0519f86407fadcc
7
- data.tar.gz: 4c557678d524fba9f075f5ab73a76050daccca78ba38c990c0a24896335e49a10d48885f3ea028357fd29b757b183816a39dc9f2804271cc12d139ba6f51fa77
6
+ metadata.gz: 77979d100fc1a7515e78b51dcde062141da7531f2e27a43cc65dece84d84dc4314e41d9e160f334cb73a26fe8118d54ff46a6978e0f70bc69f57dda486cbc88b
7
+ data.tar.gz: 3ae3cf5cb9a255cfe56fa81749f57af1c1cba82fbb2d9977182257f2f30862759aceac299bf83dc493ffcdbac8b94fce8497df9dd74be3a99a0bd840a69c2e04
@@ -1,9 +1,9 @@
1
1
  module Pomato
2
2
  module Cli
3
3
  def self.execute(*args)
4
- method, *args = args
4
+ method = ARGV.shift
5
5
  method ||= :report
6
- page_class(method).new(*args).execute
6
+ page_class(method).new.execute
7
7
  end
8
8
 
9
9
  def self.classify(string)
@@ -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
@@ -4,7 +4,7 @@ module Pomato
4
4
  class Configure
5
5
  include Paths
6
6
 
7
- def execute(*args)
7
+ def execute
8
8
  puts 'which track would you like to play when the timer ends?'
9
9
  self.config = { track: $stdin.gets.chomp }
10
10
  end
@@ -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
@@ -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 start_job(job)
45
+ def add_job(job)
52
46
  job[:id] = SecureRandom.uuid
53
- history "#{job[:id]} start #{job[:time]} #{job[:name]}"
54
- dump_job job.merge(start: now)
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
 
@@ -5,11 +5,16 @@ module Pomato
5
5
  include Paths
6
6
 
7
7
  def execute
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]}"
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
 
@@ -4,7 +4,7 @@ module Pomato
4
4
  class Run
5
5
  include Paths
6
6
 
7
- def execute(*args)
7
+ def execute
8
8
  loop do
9
9
  Pomato::Tick.new.execute
10
10
  sleep 10
@@ -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 = args.shift.to_i * 60
9
- name = args.join(' ')
10
- start_job name: name, time: time
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
@@ -5,7 +5,7 @@ module Pomato
5
5
  include Paths
6
6
 
7
7
  def execute
8
- search_string = args.first
8
+ search_string = ARGV.join(' ')
9
9
  jobs.each do |job|
10
10
  if job[:name].include? search_string
11
11
  puts "stopping \"#{job[:name]}\""
@@ -1,3 +1,3 @@
1
1
  module Pomato
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ['lib']
19
19
 
20
20
  spec.add_dependency 'daemons', '~> 1.1'
21
+ spec.add_dependency 'slop', '~> 4.0'
21
22
 
22
23
  spec.add_development_dependency 'bundler', '~> 1.7'
23
24
  spec.add_development_dependency 'rake', '~> 10.0'
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
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-24 00:00:00.000000000 Z
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