tsk 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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +35 -0
- data/Rakefile +1 -0
- data/bin/tsk +5 -0
- data/lib/tsk.rb +139 -0
- data/lib/tsk/version.rb +3 -0
- data/storage/log +0 -0
- data/tsk.gemspec +23 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: af732fd595b355dde6fef0d9860fef396c1afbf8
|
4
|
+
data.tar.gz: 010d3f4c738fed03f95169250c9511f130748897
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 404cbd1ed6b0726e193495b6d38a3d4cd0e297e4b60131425499bb58ed5f610d68c90b929317504c7dd014869bfa514c92f414e22c65e2a8842266d1c0086d13
|
7
|
+
data.tar.gz: 069408eea69e75fa65f2c486f6c389e6ca51be3a88e79109804d00e5fc79783333ab59acbd70ce5e400d5b1e4b7fff6ebe93c3df4dc400666fb4b4d9adeb8c74
|
data/.gitignore
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
tsk
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.0.0-p0
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Mike Anderson
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Tsk
|
2
|
+
|
3
|
+
This is a simple task tracker that I wrote to work the way I needed it to. You
|
4
|
+
may like it, you may not.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
$ gem install tsk
|
9
|
+
|
10
|
+
## Usage
|
11
|
+
|
12
|
+
Run:
|
13
|
+
|
14
|
+
$ tsk help
|
15
|
+
|
16
|
+
Usage: tsk [start[=<name>]|stop|status|report|clear|help]
|
17
|
+
|
18
|
+
start: Start a task.
|
19
|
+
stop: Stop the currently running task.
|
20
|
+
status: Display the current task, if any.
|
21
|
+
report: Shows a list of all tasks and time taken for each.
|
22
|
+
clear: Clear out the log file. Use with caution.
|
23
|
+
help: Display this help text. Meta.
|
24
|
+
|
25
|
+
Example:
|
26
|
+
|
27
|
+
$ tsk start "Doing something"
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
1. Fork it
|
32
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
33
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
34
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
35
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/tsk
ADDED
data/lib/tsk.rb
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
require 'tsk/version'
|
2
|
+
require 'date'
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
module Tsk
|
6
|
+
class Main
|
7
|
+
def initialize
|
8
|
+
@start = "START"
|
9
|
+
@stop = "STOP"
|
10
|
+
@log_file = File.expand_path('../../storage/log', __FILE__)
|
11
|
+
@log = load_log
|
12
|
+
end
|
13
|
+
|
14
|
+
def run args
|
15
|
+
@args = args
|
16
|
+
case @args[0]
|
17
|
+
when "start", "sta"
|
18
|
+
start @args[1]
|
19
|
+
when "stop", "sto"
|
20
|
+
stop
|
21
|
+
when "status", "st"
|
22
|
+
status
|
23
|
+
when "report", "r"
|
24
|
+
do_pretty = @args[1] == "--pretty" || @args[1] == "-p"
|
25
|
+
report do_pretty
|
26
|
+
when "clear"
|
27
|
+
puts "This will remove all logged time."
|
28
|
+
print "Are you sure you want to do this? "
|
29
|
+
print "(anything but \"yes\" will cancel) "
|
30
|
+
yes_no = $stdin.gets.chomp
|
31
|
+
if yes_no == 'yes'
|
32
|
+
print "Wiping log... "
|
33
|
+
File.open(@log_file, 'w+') { |f| f.write('') }
|
34
|
+
print "Done.\n"
|
35
|
+
else
|
36
|
+
puts "Your log was not wiped."
|
37
|
+
end
|
38
|
+
else
|
39
|
+
help
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def start name
|
44
|
+
name ||= "Unnamed task"
|
45
|
+
stop true
|
46
|
+
puts "Starting task: #{name}"
|
47
|
+
write_to_log @start, name
|
48
|
+
end
|
49
|
+
|
50
|
+
def stop silent=false
|
51
|
+
if task_running?
|
52
|
+
puts "Stopping last task."
|
53
|
+
write_to_log @stop
|
54
|
+
else
|
55
|
+
puts "No task running. Nothing was done." unless silent
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def status
|
60
|
+
if task_running?
|
61
|
+
puts "Task that is running:\n\t#{get_last_task[:name]}"
|
62
|
+
else
|
63
|
+
puts "No running task."
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def get_last_task
|
68
|
+
if @log.length > 0
|
69
|
+
@log[@log.keys.last][-1]
|
70
|
+
else
|
71
|
+
false
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def task_running?
|
76
|
+
if get_last_task
|
77
|
+
get_last_task[:action] == @start
|
78
|
+
else
|
79
|
+
false
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def report pretty=false
|
84
|
+
@log.keys.each do |date|
|
85
|
+
puts date
|
86
|
+
last = {}
|
87
|
+
@log[date].each do |entry|
|
88
|
+
if entry[:action] == @start
|
89
|
+
last = entry
|
90
|
+
elsif entry[:action] == @stop
|
91
|
+
d = date.split('-')
|
92
|
+
t = last[:time].split(':')
|
93
|
+
start_t = Time.new(d[0], d[1], d[2], t[0], t[1], t[2]).to_i
|
94
|
+
t = entry[:time].split(':')
|
95
|
+
end_t = Time.new(d[0], d[1], d[2], t[0], t[1], t[2]).to_i
|
96
|
+
puts "\t" + last[:name]
|
97
|
+
puts "\t" + NumberHelper.duration(end_t - start_t)
|
98
|
+
puts
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def help
|
105
|
+
puts "Usage: tsk [start[=<name>]|stop|status|report|clear|help]"
|
106
|
+
puts
|
107
|
+
puts "\tstart:\tStart a task."
|
108
|
+
puts "\tstop:\tStop the currently running task."
|
109
|
+
puts "\tstatus:\tDisplay the current task, if any."
|
110
|
+
puts "\treport:\tShows a list of all tasks and time taken for each."
|
111
|
+
puts "\tclear:\tClear out the log file. Use with caution."
|
112
|
+
puts "\thelp:\tDisplay this help text. Meta."
|
113
|
+
puts
|
114
|
+
puts "Example:\n\ttsk start \"Doing something\""
|
115
|
+
end
|
116
|
+
|
117
|
+
def load_log
|
118
|
+
YAML::load_file(@log_file) || Hash.new
|
119
|
+
end
|
120
|
+
|
121
|
+
def write_to_log action, task=nil
|
122
|
+
time = Time.now
|
123
|
+
data = {:action => action, :time => time.strftime('%T'), :name => task}
|
124
|
+
date = time.strftime '%F'
|
125
|
+
@log[date] ||= []
|
126
|
+
@log[date] << data
|
127
|
+
File.open(@log_file, 'w+') { |f| f.write(YAML::dump(@log)) }
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
class NumberHelper
|
132
|
+
def self.duration time
|
133
|
+
rest, seconds = time.divmod(60)
|
134
|
+
rest, minutes = rest.divmod(60)
|
135
|
+
hours = rest
|
136
|
+
Time.new(2013, 3, 2, hours, minutes, seconds).strftime('%T')
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
data/lib/tsk/version.rb
ADDED
data/storage/log
ADDED
File without changes
|
data/tsk.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'tsk/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "tsk"
|
8
|
+
spec.version = Tsk::VERSION
|
9
|
+
spec.authors = ["Mike Anderson"]
|
10
|
+
spec.email = ["athaeryn@me.com"]
|
11
|
+
spec.description = "Tsk tsk tsk... track your time."
|
12
|
+
spec.summary = "A simple time tracker."
|
13
|
+
spec.homepage = "https://github.com/athaeryn/tsk"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tsk
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mike Anderson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-04-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Tsk tsk tsk... track your time.
|
42
|
+
email:
|
43
|
+
- athaeryn@me.com
|
44
|
+
executables:
|
45
|
+
- tsk
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- .gitignore
|
50
|
+
- .ruby-gemset
|
51
|
+
- .ruby-version
|
52
|
+
- Gemfile
|
53
|
+
- LICENSE.txt
|
54
|
+
- README.md
|
55
|
+
- Rakefile
|
56
|
+
- bin/tsk
|
57
|
+
- lib/tsk.rb
|
58
|
+
- lib/tsk/version.rb
|
59
|
+
- storage/log
|
60
|
+
- tsk.gemspec
|
61
|
+
homepage: https://github.com/athaeryn/tsk
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
metadata: {}
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 2.0.3
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: A simple time tracker.
|
85
|
+
test_files: []
|