trak 0.0.0 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Change log
2
2
 
3
+ ## v0.0.2 (2012-04-26)
4
+
5
+ Changed (8854df7):
6
+
7
+ * Refactored currentTimeInMintues to Time#to_minutes
8
+
9
+ ## v0.0.1 (2012-04-26)
10
+
11
+ Fixed (94929f0):
12
+
13
+ * Exception when tracking first time for day. Removed an erroneous call
14
+ to sprintf instead of strftime. Also ensured use of integers when
15
+ calculating current time in minutes.
16
+
3
17
  ## v0.0.0 (2012-04-25)
4
18
 
5
19
  Tracker is now known as trak, and it's a RubyGem!
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Trak: track chunks of time from the command line
2
2
 
3
- Trak, v0.0.0 (Apr 25, 2012)
3
+ Trak, v0.0.2 (Apr 26, 2012)
4
4
  Written by Adam Sharp
5
5
 
6
6
  ## Notice
@@ -35,10 +35,9 @@ An example work log that trak will create:
35
35
 
36
36
  ## Installation
37
37
 
38
- Check out this repository and then create a symlink to bin/trak
39
- somewhere in your path:
38
+ Trak is available from [RubyGems](https://rubygems.org/gems/trak):
40
39
 
41
- $ ln -s <repo>/bin/trak /usr/bin/trak
40
+ $ gem install trak
42
41
 
43
42
  ## Usage
44
43
 
data/lib/trak.rb CHANGED
@@ -12,6 +12,7 @@ require 'trollop'
12
12
  require 'debugger'
13
13
 
14
14
  require "trak/tracker_util"
15
+ require 'trak/time'
15
16
 
16
17
  # place where data is stored
17
18
  datadir = "#{ENV['HOME']}/Documents/Tracker/"
@@ -107,7 +108,7 @@ if MODE == 'report'
107
108
  puts "Hours logged until #{newTimeString} (since #{TrackerUtil::to12HourTime(startTime)}). "
108
109
 
109
110
  # if we're reporting for today, print the current time
110
- puts "Currently #{TrackerUtil::to12HourTime(TrackerUtil::currentTimeFormatted())}." unless opts[:date]
111
+ puts "Currently #{TrackerUtil::to12HourTime(Time.now.strftime(TrackerUtil::TIME_FORMAT_24HOUR))}." unless opts[:date]
111
112
  else
112
113
  if opts[:date]
113
114
  STDERR.puts "No time log for #{fdate}. Track some time first."
@@ -151,7 +152,8 @@ elsif MODE == 'insert'
151
152
  begin
152
153
  File.open filename, 'a', :autoclose => true do |file|
153
154
  if first_time
154
- currentTimeInMinutes = TrackerUtil::timeToMinutes(TrackerUtil::currentTimeFormatted)
155
+ debug
156
+ currentTimeInMinutes = Time.now.to_minutes
155
157
  startTime = TrackerUtil::minutesToTime((currentTimeInMinutes - minutes).round_to_nearest 15)
156
158
  file.puts "#{fdate} #{startTime}"
157
159
  end
data/lib/trak/time.rb ADDED
@@ -0,0 +1,6 @@
1
+ class Time
2
+ def to_minutes
3
+ minute, hour = self.to_a[1..2]
4
+ hour*60 + minute
5
+ end
6
+ end
@@ -58,10 +58,6 @@ module TrackerUtil
58
58
  end
59
59
  end
60
60
 
61
- def self.currentTimeFormatted
62
- Time.now.strftime(TIME_FORMAT_24HOUR)
63
- end
64
-
65
61
  # expects a single argument - the time argument in the format ##m or ##h
66
62
  # if argument has no m/h qualifier, assume m
67
63
  # returns a number of minutes
@@ -84,20 +80,13 @@ module TrackerUtil
84
80
  end
85
81
  end
86
82
 
87
- # expects a time string formatted HH24:MM
88
- def self.timeToMinutes(time)
89
- hours, minutes = time.split(':')
90
- hours*60 + minutes
91
- end
92
-
93
83
  # expects an integer
94
84
  def self.minutesToTime(minutes)
95
- time_with_hours_minutes(minutes / 60, minutes % 60).sprintf TIME_FORMAT_24HOUR
85
+ time_with_hours_minutes(minutes / 60, minutes % 60).strftime(TIME_FORMAT_24HOUR).strip
96
86
  end
97
87
 
98
88
  # expects an integer which is the amount of minutes logged
99
89
  def self.startTimeInMinutes(minutes)
100
- currentTimeInMinutes = timeToMinutes(currentTimeFormatted).round_to_nearest 15
101
- currentTimeInMinutes - minutes
90
+ Time.now.to_minutes.round_to_nearest(15) - minutes
102
91
  end
103
92
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trak
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -51,6 +51,7 @@ extra_rdoc_files: []
51
51
  files:
52
52
  - lib/trak/blank.rb
53
53
  - lib/trak/round_to_nearest.rb
54
+ - lib/trak/time.rb
54
55
  - lib/trak/tracker_util.rb
55
56
  - lib/trak.rb
56
57
  - bin/trak