francois-tt 0.0.1 → 0.0.2

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.
Files changed (6) hide show
  1. data/Rakefile +1 -1
  2. data/bin/pi +6 -0
  3. data/bin/po +6 -0
  4. data/bin/tt +24 -0
  5. data/lib/tt.rb +10 -16
  6. metadata +8 -3
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ Rake::GemPackageTask.new($spec) do |pkg|
6
6
  pkg.gem_spec = $spec
7
7
  end
8
8
 
9
- task :install => [:package] do
9
+ task :install => [:repackage] do
10
10
  sh %{sudo gem install --no-rdoc --no-ri pkg/#{GEM}-#{VERSION}}
11
11
  end
12
12
 
data/bin/pi ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ require "rubygems"
3
+ $: << File.dirname(__FILE__) + "/../lib"
4
+ require "tt"
5
+
6
+ Tt.punch_in(Dir.pwd, ARGV.empty? ? nil : ARGV.join(" "))
data/bin/po ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ require "rubygems"
3
+ $: << File.dirname(__FILE__) + "/../lib"
4
+ require "tt"
5
+
6
+ Tt.punch_out(Dir.pwd, ARGV.empty? ? nil : ARGV.join(" "))
data/bin/tt ADDED
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+ require "rubygems"
3
+ $: << File.dirname(__FILE__) + "/../lib"
4
+ require "tt"
5
+
6
+ case command = ARGV.shift
7
+ when "list", "ls"
8
+ Tt.report
9
+ when "clear"
10
+ Tt.clear
11
+ when "drop"
12
+ Tt.drop
13
+ else
14
+ puts <<EOF
15
+ WARNING: No command given
16
+
17
+ tt - Time Tracker
18
+
19
+ list: lists the time entries
20
+ clear: deletes all time entries
21
+ drop: drops the last time entry from the file
22
+ EOF
23
+ exit 1
24
+ end
data/lib/tt.rb CHANGED
@@ -30,22 +30,16 @@ module Tt
30
30
 
31
31
  def self.report_line(dir, intime, outtime, comment)
32
32
  ltime = Time.now
33
- intime = intime + ltime.utc_offset if intime
34
- outtime = outtime + ltime.utc_offset if outtime
35
-
36
- if outtime then
37
- duration_in_seconds = outtime - intime
38
- duration_in_minutes = duration_in_seconds / 60
39
- duration_as_human_string = "%02d:%02d" % [duration_in_minutes / 60, duration_in_minutes % 60]
40
-
41
- print "%-40s %16s %16s %5s" % [dir, intime.strftime(SCREEN_FORMAT), outtime.strftime(SCREEN_FORMAT), duration_as_human_string]
42
- print " - %s" % comment if comment && !comment.empty?
43
- puts
44
- else
45
- print "%-40s %16s %16s %5s" % [dir, intime.strftime(SCREEN_FORMAT), "", ""]
46
- print " - %s" % comment if comment && !comment.empty?
47
- puts
48
- end
33
+ intime = intime + ltime.utc_offset
34
+ endtime = (outtime.nil? ? Time.now.utc : outtime) + ltime.utc_offset
35
+
36
+ duration_in_seconds = endtime - intime
37
+ duration_in_minutes = duration_in_seconds / 60
38
+ duration_as_human_string = "%02d:%02d" % [duration_in_minutes / 60, duration_in_minutes % 60]
39
+
40
+ print "%-40s %16s %16s %5s" % [dir, intime.strftime(SCREEN_FORMAT), outtime ? outtime.strftime(SCREEN_FORMAT) : "", duration_as_human_string]
41
+ print " - %s" % comment if comment && !comment.empty?
42
+ puts
49
43
  end
50
44
 
51
45
  def self.report
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: francois-tt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Fran\xC3\xA7ois Beausoleil"
@@ -23,8 +23,10 @@ dependencies:
23
23
  version:
24
24
  description: Track your time locally, offline, using this simple tool.
25
25
  email: francois@teksol.info
26
- executables: []
27
-
26
+ executables:
27
+ - tt
28
+ - pi
29
+ - po
28
30
  extensions: []
29
31
 
30
32
  extra_rdoc_files:
@@ -37,6 +39,9 @@ files:
37
39
  - Rakefile
38
40
  - TODO
39
41
  - lib/tt.rb
42
+ - bin/tt
43
+ - bin/pi
44
+ - bin/po
40
45
  has_rdoc: true
41
46
  homepage: http://github.com/francois/tt
42
47
  post_install_message: