termodoro 0.2.5 → 0.2.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e28ec45a4d531ae0799b06ce31cd75ec88edf3b7
4
- data.tar.gz: a85d9385d4e7aaad04cfb9948c338066be54b27b
3
+ metadata.gz: 7682de14275ca02cf30abbe59667d3da687c0efe
4
+ data.tar.gz: a70da49bae67f5e40bbf256d7037b47350e5d85e
5
5
  SHA512:
6
- metadata.gz: 39845df2b62a2d2d28cd113e228b0d6dc2a9f08e9a4028265e2974fd32dcaafde1bf9b74996e66fd4f589400791be2e0532b14a37e77a81ddd51425da7e19096
7
- data.tar.gz: 00966d8256cb2d33359e3aa8eb2be226da9884717327f6476f54b315072483dad8e4d077d5b2c21d394e33a139d95c04c70cbdf502cdc9f882ca0ea97cc20450
6
+ metadata.gz: c4008f442898bffc655229d1f949d148ea4dcf0ccce288925c89925e0413d27fe4e30a4b4c115bd38dc40445f93028d77b36fcb7e4a5c171b88ed492dbc6d199
7
+ data.tar.gz: d83df704e3cd2fc09b335c16d69afbae37734392c96dbe91a7472298e0f39dae87defd28d878db263ea61e282b093ab5db2c649e3f5fbef313ca58c3eda9191d
data/CHANGELOG.md CHANGED
@@ -1,11 +1,15 @@
1
+ ### 0.2.6 (10/29/2013)
2
+
3
+ - Fully-document using YARD. Updated variable names (`time_part` --> `time_unit`, `number_part` --> `number_of_units`). Minor readme updates.
4
+
1
5
  ### 0.2.5 (10/29/2013)
2
6
 
3
7
  * Integrate Travis CI. Add Bundler and Rake. Add License. Minor changes to gemspec file. Add this changelog file.
4
8
 
5
9
  ### 0.2.0 (10/29/2013)
6
10
 
7
- * Adds [@scottcreynold](https://github.com/scottcreynolds)'s feature which allows for omitting the message. Also includes the first tests. - [@vcavallo](http://github.com/vcavallo)
11
+ - Adds [@scottcreynold](https://github.com/scottcreynolds)'s feature which allows for omitting the message. Also includes the first tests. - [@vcavallo](http://github.com/vcavallo)
8
12
 
9
13
  ### 0.1.9 (10/24/2013)
10
14
 
11
- * First working public release. - [@vcavallo](http://github.com/vcavallo)
15
+ - First working public release. - [@vcavallo](http://github.com/vcavallo)
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Termodoro
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/termodoro.png)](http://badge.fury.io/rb/termodoro)
4
+ [![Build Status](https://travis-ci.org/vcavallo/termodoro.png)](https://travis-ci.org/vcavallo/termodoro)
5
+
3
6
  ## What is this?
4
7
 
5
8
  ***Termodoro*** is an ultra-simple, frictionless BASH reminder / pomodoro timer ( in fact it's portmanteau of *terminal* and *[pomodoro](http://en.wikipedia.org/wiki/Pomodoro_Technique)* )
@@ -47,12 +50,11 @@ This is the first gem I've built. I do not claim that it is perfect, nor that it
47
50
  - set defaults to something agreeable (like maybe 20 minutes and some generic 'do that thing you wanted to do' message) such that you could just do `termodoro` and it'll do that default.
48
51
  - Make it useable in other shells and without the terminal-notifier gem.
49
52
  - Sanitize the message so as to not cause bash issues
50
- - Write good tests!
51
- - Make sure to follow gem best-practices
53
+ - Write good tests! *(getting there)*
54
+ - Make sure to follow gem best-practices *(Might be done with this one...)*
52
55
  - A bunch of other stuff I'll add here
53
56
  - Make sure it persists through computer sleep
54
57
  - Make sure I'm using ARGV properly and issuing the system command properly
55
- - Generally revise to adhere to best practices.
56
58
 
57
59
  ## Upcoming features:
58
60
 
@@ -1,84 +1,120 @@
1
1
 
2
- class Termodoro
3
- attr_accessor :time_part, :number_part, :message
4
2
 
3
+ # A new instance of this class takes user-input as command line arguments and
4
+ # prepares a string to be execute as a Bash system command. The user specifies an
5
+ # amount of time and an optional message to display. After the amount of time elapses
6
+ # a terminal-notifier message appears with the message - if the message was omitted,
7
+ # the word "Termodoro" appears instead.
8
+ class Termodoro
9
+ attr_accessor :time_unit, :number_of_units, :message
10
+ # @!attribute time_unit
11
+ # @return [String] the unit of time specified by the user.
12
+ # @!attribute number_of_units
13
+ # @return [Integer] the number of units of time specified by the user.
14
+ # @!attribute message
15
+ # @return [String] the message specified by the user.
16
+
17
+ # Used in multiplication to arrive at the number of seconds in a minute.
5
18
  SECS_IN_MIN = 60
19
+ # Used in multiplication to arrive at the number of seconds in an hour.
6
20
  SECS_IN_HOUR = 3600
7
21
 
22
+ # @param arguments [String] The arguments passed in by the user at the command
23
+ # line. this includes the time after which the reminder will appear and an
24
+ # optional message to appear in the body of the reminder.
8
25
  def initialize(arguments)
9
26
  @arguments = arguments
10
-
11
- # message
12
- # title on/off -- probably going to drop this
13
27
  end
14
28
 
15
- # parse class
16
- # Parse.new(input)
17
- #
18
- # calculate class
19
- # run clean_message
20
-
21
- def parse_time_part
29
+ # Looks into the user-supplied arguments and retreives the unit of time.
30
+ # @return [String] a version of hours, minutes or seconds, depending on
31
+ # how the user inputs it ("s", "Sec", "seconds", etc.)
32
+ def parse_time_unit
22
33
  segment = @arguments.match(/\D+/)[0].split(' ').first
23
- self.time_part = segment
24
- #=> hours/minutes/seconds, etc.
34
+ self.time_unit = segment
25
35
  end
26
36
 
27
- def parse_number_part
37
+ # Looks into the user-supplied arguments and parses out the number of units of
38
+ # time.
39
+ # @return [Integer] the number of units of time given by the user.
40
+ def parse_number_of_units
28
41
  number = @arguments.scan(/[\d]+/).first.strip.to_i
29
- self.number_part = number
30
- #=> the number of time_parts given
42
+ self.number_of_units = number
31
43
  end
32
44
 
45
+ # Looks into the user-supplied arguments and returns the message, if one is present.
46
+ # If not, sets the message to "Termodoro".
47
+ # @return [String] the optional message given by the user.
33
48
  def parse_message
34
49
  # .split(/[\d]+.[\w]+/).last
35
50
  parsed_message = @arguments.split(/^\s*[\d]+\s*[\w]+/).last || 'Termodoro'
36
51
  self.message = parsed_message.strip
37
52
  end
38
53
 
54
+ # Depending on what unit of time is being used, determines the number of seconds
55
+ # using multiplication by {Termodoro::SECS_IN_MIN SECS_IN_MIN} and
56
+ # {Termodoro::SECS_IN_HOUR SECS_IN_HOUR} constants. The check to #seconds? is
57
+ # not necessary, but feels nice.
58
+ # @see #parse_number_of_units
59
+ # @see #seconds?
60
+ # @see #minutes?
61
+ # @see #hours?
62
+ # @return [Integer] total number of seconds for which to wait until the reminder
63
+ # is displayed.
39
64
  def calculate_time
40
65
  if minutes?
41
- seconds = parse_number_part * SECS_IN_MIN
66
+ seconds = parse_number_of_units * SECS_IN_MIN
42
67
  elsif hours?
43
- seconds = parse_number_part * SECS_IN_HOUR
68
+ seconds = parse_number_of_units * SECS_IN_HOUR
44
69
  elsif seconds?
45
- seconds = parse_number_part
70
+ seconds = parse_number_of_units
46
71
  end
47
72
 
48
- seconds #=> returns seconds
73
+ seconds
49
74
  end
50
75
 
76
+
77
+ # Truthy if user has input a number of seconds.
78
+ # @return [Boolean]
79
+ # @see #parse_time_unit
51
80
  def seconds?
52
81
  seconds = %w[s sec secs second seconds]
53
- true if seconds.include?(parse_time_part)
54
- #=> true/false
82
+ true if seconds.include?(parse_time_unit)
55
83
  end
56
84
 
85
+ # Truthy if user has input a number of minutes.
86
+ # @return [Boolean]
87
+ # @see #parse_time_unit
57
88
  def minutes?
58
89
  minutes = %w[m min mins minute minutes]
59
- true if minutes.include?(parse_time_part)
60
- #=> true/false
90
+ true if minutes.include?(parse_time_unit)
61
91
  end
62
92
 
93
+ # Truthy if user has input a number of hours.
94
+ # @see #parse_time_unit
95
+ # @return [Boolean]
63
96
  def hours?
64
97
  hours = %w[h hr hrs hour hours]
65
- true if hours.include?(parse_time_part)
66
- #=> true/false
98
+ true if hours.include?(parse_time_unit)
67
99
  end
68
100
 
101
+ # PENDING - will eventually be used to ensure user input is safe to run as terminal
102
+ # command. (i.e. remove special punctuation and the like).
103
+ # @return [String] sanitized message.
69
104
  def clean_message
70
105
  parse_message
71
- # will need something to sanitize apostrophes and stuff
72
- #=> return sanitized message to insert into terminal
73
106
  end
74
107
 
108
+ # Workhorse method: Runs #calculate_time and #parse_message, taking the results
109
+ # of those methods and creating the string to execute.
110
+ # @see #calculate_time
111
+ # @see #parse_message
112
+ # @return [String] the fully-formed command string ready to be run by bash as
113
+ # a system command.
75
114
  def command
76
- # title = "title" -- leaving off title for now.
77
- # if title on/off call one or the other
78
- time_part = calculate_time
115
+ time_unit = calculate_time
79
116
  msg_part = parse_message
80
- "sleep #{time_part} && terminal-notifier -message '#{msg_part}' -title 'Termodoro' & disown"
81
- #=> return the fully-formed command string for Bash
117
+ "sleep #{time_unit} && terminal-notifier -message '#{msg_part}' -title 'Termodoro' & disown"
82
118
  end
83
119
 
84
120
  end
data/termodoro.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'termodoro'
3
- s.version = '0.2.5'
3
+ s.version = '0.2.6'
4
4
  s.date = '2013-10-24'
5
5
  s.summary = "A lightweight CL reminder app"
6
6
  s.description = "Use this little utility to set simple reminders from the command line. See the github page below for more information"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: termodoro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vinney Cavallo