termodoro 0.0.3 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/bin/termodoro +6 -0
  3. data/lib/run.rb +7 -0
  4. data/lib/termodoro.rb +63 -37
  5. metadata +23 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a57560be8cfe5f63fba72b449505c77c94805643
4
- data.tar.gz: 26d2b776bc37641e39a46246ebe4ec71d9a3ba27
3
+ metadata.gz: bedddd976063c2aff3aa487dc6040c547c062a9b
4
+ data.tar.gz: 8e8f652f79d584c05cf98ffabd374b159cb6f80f
5
5
  SHA512:
6
- metadata.gz: 2da529ee87d605d7806aab8c3d859fdd4218ee935cf62cb15a7a8ee0f20e4584010e869ffe898dd9841db0e386d405524c4b2e0197aa58e7d71eea09b8c6721a
7
- data.tar.gz: 0ed3d1e0f6d2974cc0b440214cb497f0ab895921ed8e8e267426140ef75c829ca7d66edddfe963a9010ab2846f785ae3229a7c504fce99da09ec8f27a47391f8
6
+ metadata.gz: a809c70f16150e9fb6abaffa20bfd56eef33973c104d2157ce3f88858eda9f3e827a62a9f21c80b8d48c3289e514f481d5230e39d598d911812b1edad2fccf3c
7
+ data.tar.gz: ab177bd909c3a0f467fe099db214934d7a0f4a1489daabe450608b0d92e2191c578ee0d63722c94a443613666b1d6dbc80be9b6c9942e668e27f7c4d20e3ad0c
data/bin/termodoro CHANGED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'termodoro'
4
+
5
+ a = Termodoro.new(ARGV.join(" "))
6
+ exec(a.command)
data/lib/run.rb ADDED
@@ -0,0 +1,7 @@
1
+ require_relative './lib/termodoro'
2
+
3
+ class Run
4
+ def self.execute(input)
5
+ a = Termodoro.new(input)
6
+ exec(a.command)
7
+ end
data/lib/termodoro.rb CHANGED
@@ -1,51 +1,77 @@
1
- require 'pry'
2
1
 
3
2
  class Termodoro
3
+ attr_accessor :time_part, :number_part, :message
4
+
5
+ SECS_IN_MIN = 60
6
+ SECS_IN_HOUR = 3600
7
+
8
+ def initialize(arguments)
9
+ @arguments = arguments
4
10
 
5
- def initialize
6
- @desired_length
7
11
  # message
8
- # title on/off
12
+ # title on/off -- probably going to drop this
9
13
  end
10
14
 
11
- def parse_time
12
- @desired_length.seconds?
13
- @desired_length.minutes?
14
- @desired_length.hours?
15
- # take duration and make into seconds
16
- # return total seconds
17
- duration
15
+ def parse_time_part
16
+ segment = @arguments.scan(/[\D]+[^\w]/).first.split(" ").first
17
+ self.time_part = segment
18
+ #=> hours/minutes/seconds, etc.
18
19
  end
19
20
 
20
- def run
21
- # system call
22
- # if title on/off call one or the other
21
+ def parse_number_part
22
+ number = @arguments.scan(/[\d]+/).first.strip.to_i
23
+ self.number_part = number
24
+ #=> the number of time_parts given
23
25
  end
24
26
 
25
- end
27
+ def parse_message
28
+ # .split(/[\d]+.[\w]+/).last
29
+ parsed_message = @arguments.split(/^\s*[\d]+\s*[\w]+/).last.strip
30
+ self.message = parsed_message
31
+ end
26
32
 
27
- puts "how long? (write only a number for minutes)"
28
- length_response = gets.chomp
29
- number = length_response.split(" ").first.to_i
30
- segment = length_response.split(" ").last
31
- duration = 5
32
-
33
- if segment == "seconds" || segment == "sec" || segment == "secs" || segment == "s"
34
- duration = number
35
- elsif segment == "m" || segment == "min" || segment == "mins" || segment == "minutes" || segment == ""
36
- duration = number * 60
37
- elsif segment == "h" || segment == "hour" || segment == "hours"
38
- duration = number * 3600
39
- end
33
+ def calculate_time
34
+ if minutes?
35
+ seconds = parse_number_part * SECS_IN_MIN
36
+ elsif hours?
37
+ seconds = parse_number_part * SECS_IN_HOUR
38
+ elsif seconds?
39
+ seconds = parse_number_part
40
+ end
41
+
42
+ seconds #=> returns seconds
43
+ end
44
+
45
+ def seconds?
46
+ seconds = %w[s sec secs second seconds]
47
+ true if seconds.include?(parse_time_part)
48
+ #=> true/false
49
+ end
40
50
 
41
- puts "what message?"
42
- message = gets.chomp
43
- puts "enter a title here if you want one,"
44
- puts "otherwise, just hit enter"
45
- title = gets.chomp
51
+ def minutes?
52
+ minutes = %w[m min mins minute minutes]
53
+ true if minutes.include?(parse_time_part)
54
+ #=> true/false
55
+ end
56
+
57
+ def hours?
58
+ hours = %w[h hr hrs hour hours]
59
+ true if hours.include?(parse_time_part)
60
+ #=> true/false
61
+ end
62
+
63
+ def clean_message
64
+ parse_message
65
+ # will need something to sanitize apostrophes and stuff
66
+ #=> return sanitized message to insert into terminal
67
+ end
68
+
69
+ def command
70
+ # title = "title" -- leaving off title for now.
71
+ # if title on/off call one or the other
72
+
73
+ "sleep #{calculate_time} && terminal-notifier -message '#{parse_message}' -title 'Termodoro' & disown"
74
+ #=> return the fully-formed command string for Bash
75
+ end
46
76
 
47
- if title == ""
48
- system("sleep #{duration} && terminal-notifier -message '#{message}' & disown && exit")
49
- else
50
- system("sleep #{duration} && terminal-notifier -message '#{message}' -title '#{title}' & disown && exit")
51
77
  end
metadata CHANGED
@@ -1,22 +1,39 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: termodoro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vinney Cavallo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-22 00:00:00.000000000 Z
12
- dependencies: []
13
- description: This is a work-in-progress. Description coming...
11
+ date: 2013-10-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: terminal-notifier
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Use this little utility to set simple reminders from the command line.
28
+ See the github page below for more information
14
29
  email: vcavallo@gmail.com
15
- executables: []
30
+ executables:
31
+ - termodoro
16
32
  extensions: []
17
33
  extra_rdoc_files: []
18
34
  files:
19
35
  - lib/termodoro.rb
36
+ - lib/run.rb
20
37
  - bin/termodoro
21
38
  homepage: https://github.com/vcavallo/termodoro
22
39
  licenses:
@@ -41,5 +58,5 @@ rubyforge_project:
41
58
  rubygems_version: 2.0.6
42
59
  signing_key:
43
60
  specification_version: 4
44
- summary: (this will be a) Lightweight CL reminder/timer app
61
+ summary: A lightweight CL reminder app
45
62
  test_files: []