trakr 0.0.1
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/.document +5 -0
- data/.gitignore +18 -0
- data/.travis.yml +8 -0
- data/Gemfile +1 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/bin/trakr +10 -0
- data/lib/storage.yml +0 -0
- data/lib/trakr.rb +20 -0
- data/lib/trakr/numeric.rb +18 -0
- data/lib/trakr/parse.rb +68 -0
- data/lib/trakr/project.rb +35 -0
- data/lib/trakr/storage.rb +17 -0
- data/lib/trakr/version.rb +3 -0
- data/test/helper.rb +22 -0
- data/test/test_trakr.rb +7 -0
- data/trakr.gemspec +26 -0
- metadata +136 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 349615e87f78ba056c4ba8aca65fdce3f052ebcc
|
4
|
+
data.tar.gz: 1f55c46b2ef7876570041399058df33e0375cf9b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5dbece41fb3f9dbc0d485e192b768d81c4e0e8437408feb0fb86ae50cedc72192e172a33a4d77f6a7302a8e34fd0cb185379715d14f52f2865e0d7a588de522a
|
7
|
+
data.tar.gz: 59a57e78ebb1cba50c1ae4e944a5a35b170e53f525a0aab9e881ddd1fa5ce7722cadbaa94a02bebb3225e932805f778c54f5a3c8e45f3bcb7a81fa9e443a2f4c
|
data/.document
ADDED
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
source "http://rubygems.org"
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Katherine Whitlock
|
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,31 @@
|
|
1
|
+
# Trakr
|
2
|
+
[](https://travis-ci.org/toroidal-code/trakr)
|
3
|
+
[](https://gemnasium.com/toroidal-code/trakr)
|
4
|
+
|
5
|
+
TODO: Write a gem description
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'trakr'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install trakr
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/trakr
ADDED
data/lib/storage.yml
ADDED
File without changes
|
data/lib/trakr.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'commander/import'
|
4
|
+
|
5
|
+
require 'trakr/version'
|
6
|
+
program :version, Trakr::VERSION
|
7
|
+
program :description, 'Track your software exploits'
|
8
|
+
|
9
|
+
require 'rainbow'
|
10
|
+
require 'terminal-table'
|
11
|
+
require 'yaml'
|
12
|
+
|
13
|
+
#Require all the stuff
|
14
|
+
#lib_path = File.join(File.dirname(__FILE__), 'trakr', '*.rb')
|
15
|
+
#Dir[lib_path].each { |file| require file }
|
16
|
+
require 'trakr/numeric'
|
17
|
+
require 'trakr/project'
|
18
|
+
require 'trakr/storage'
|
19
|
+
require 'trakr/parse'
|
20
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Numeric
|
2
|
+
def duration
|
3
|
+
secs = self.to_int
|
4
|
+
mins = secs / 60
|
5
|
+
hours = mins / 60
|
6
|
+
days = hours / 24
|
7
|
+
|
8
|
+
if days > 0
|
9
|
+
"#{days} %02d:%02d:%02d" % [hours % 24, mins % 60, secs % 60]
|
10
|
+
elsif hours > 0
|
11
|
+
"%02d:%02d:%02d" % [hours, mins % 60, secs % 60]
|
12
|
+
elsif mins > 0
|
13
|
+
"%02d:%02d:%02d" % [hours, mins, secs % 60]
|
14
|
+
elsif secs >= 0
|
15
|
+
"%02d:%02d:%02d" % [hours, mins, secs]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/trakr/parse.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
storage = Storage.new()
|
4
|
+
storage.load
|
5
|
+
|
6
|
+
command :start do |c|
|
7
|
+
c.syntax = 'trakr start project'
|
8
|
+
c.summary = 'start the timer'
|
9
|
+
c.description = 'Starts the timer for a given project'
|
10
|
+
c.example 'An example', 'trakr start project'
|
11
|
+
c.action do |args|
|
12
|
+
storage.database[args.first].start_timer
|
13
|
+
storage.write!
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
command :stop do |c|
|
19
|
+
c.syntax = 'trakr stop project'
|
20
|
+
c.summary = 'stop the timer'
|
21
|
+
c.description = 'Stops the timer for a given project'
|
22
|
+
c.example 'description','trakr stop project'
|
23
|
+
c.action do |args|
|
24
|
+
storage.database[args.first].stop_timer
|
25
|
+
storage.write!
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
command :new do |c|
|
31
|
+
c.syntax = 'trakr new project, [options]'
|
32
|
+
c.summary = 'add a new project'
|
33
|
+
c.description = 'Add a new project to a database.'
|
34
|
+
c.example 'Create a project', 'trakr new project'
|
35
|
+
c.option '--estimate', 'State the estimated time for completion'
|
36
|
+
c.action do |args, options|
|
37
|
+
next if args.first == ""
|
38
|
+
puts "Name cannot be empty"
|
39
|
+
storage.database.merge!(args.first => Project.new(args.first, options.estimate))
|
40
|
+
storage.write!
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
command :remove do |c|
|
45
|
+
c.syntax = 'trakr remove project'
|
46
|
+
c.summary = 'remove a project'
|
47
|
+
c.description = 'Remove a project from the database'
|
48
|
+
c.example 'Remove project', 'trakr remove project'
|
49
|
+
c.action do |args|
|
50
|
+
storage.database.delete(args.first)
|
51
|
+
storage.write!
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
command :list do |c|
|
56
|
+
c.syntax = 'trakr list'
|
57
|
+
c.summary = 'show the list'
|
58
|
+
c.description = 'Display a table of projects'
|
59
|
+
c.example 'Show table', 'trakr list'
|
60
|
+
c.action do
|
61
|
+
rows = []
|
62
|
+
storage.database.each_value do |v|
|
63
|
+
rows << v.to_a
|
64
|
+
end
|
65
|
+
puts Terminal::Table.new :headings => Project.headings, :rows => rows
|
66
|
+
end
|
67
|
+
end
|
68
|
+
alias_command :'ls', :'list'
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class Project
|
2
|
+
attr_accessor :name, :time, :state,
|
3
|
+
:start_time, :expected
|
4
|
+
|
5
|
+
def initialize(name, expected=nil)
|
6
|
+
@name = name
|
7
|
+
@expected = expected
|
8
|
+
@state = false
|
9
|
+
@time = 0
|
10
|
+
end
|
11
|
+
|
12
|
+
def start_timer
|
13
|
+
@state = true
|
14
|
+
@start_time = Time.now
|
15
|
+
end
|
16
|
+
|
17
|
+
def stop_timer
|
18
|
+
@state = false
|
19
|
+
@time += Time.now - start_time
|
20
|
+
@start_time = nil
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_a
|
24
|
+
if @state
|
25
|
+
[@state.to_s.foreground(:green), @name, (Time.now - @start_time).duration, @expected]
|
26
|
+
else
|
27
|
+
[@state.to_s.foreground(:red), @name, @time.duration, @expected]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.headings
|
32
|
+
['Running', 'Name', 'Time', 'Estimate']
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Storage
|
2
|
+
attr_accessor :file, :database
|
3
|
+
def initialize(file=File.join(File.expand_path('../..', __FILE__), 'storage.yml'))
|
4
|
+
@file = file
|
5
|
+
end
|
6
|
+
|
7
|
+
def load
|
8
|
+
@database = YAML.load_file(@file)
|
9
|
+
if not @database
|
10
|
+
@database = {}
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def write!
|
15
|
+
File.open(@file,'w+') {|f| f.write(@database.to_yaml)}
|
16
|
+
end
|
17
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
|
16
|
+
require 'simplecov'
|
17
|
+
SimpleCov.start
|
18
|
+
|
19
|
+
require 'trakr'
|
20
|
+
|
21
|
+
class Test::Unit::TestCase
|
22
|
+
end
|
data/test/test_trakr.rb
ADDED
data/trakr.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'trakr/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "trakr"
|
8
|
+
spec.version = Trakr::VERSION
|
9
|
+
spec.authors = ["Katherine Whitlock"]
|
10
|
+
spec.email = ["toroidalcode@gmail.com"]
|
11
|
+
spec.description = "A tracking utility for time on software projects"
|
12
|
+
spec.summary = "Track your software exploits"
|
13
|
+
spec.homepage = "http://github.com/toroidal-code/trakr"
|
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
|
+
spec.add_dependency "commander"
|
24
|
+
spec.add_dependency "rainbow"
|
25
|
+
spec.add_dependency "terminal-table"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: trakr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Katherine Whitlock
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-07-26 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
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: commander
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rainbow
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: terminal-table
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: A tracking utility for time on software projects
|
84
|
+
email:
|
85
|
+
- toroidalcode@gmail.com
|
86
|
+
executables:
|
87
|
+
- trakr
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- .document
|
92
|
+
- .gitignore
|
93
|
+
- .travis.yml
|
94
|
+
- Gemfile
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- bin/trakr
|
99
|
+
- lib/storage.yml
|
100
|
+
- lib/trakr.rb
|
101
|
+
- lib/trakr/numeric.rb
|
102
|
+
- lib/trakr/parse.rb
|
103
|
+
- lib/trakr/project.rb
|
104
|
+
- lib/trakr/storage.rb
|
105
|
+
- lib/trakr/version.rb
|
106
|
+
- test/helper.rb
|
107
|
+
- test/test_trakr.rb
|
108
|
+
- trakr.gemspec
|
109
|
+
homepage: http://github.com/toroidal-code/trakr
|
110
|
+
licenses:
|
111
|
+
- MIT
|
112
|
+
metadata: {}
|
113
|
+
post_install_message:
|
114
|
+
rdoc_options: []
|
115
|
+
require_paths:
|
116
|
+
- lib
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - '>='
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - '>='
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
requirements: []
|
128
|
+
rubyforge_project:
|
129
|
+
rubygems_version: 2.0.3
|
130
|
+
signing_key:
|
131
|
+
specification_version: 4
|
132
|
+
summary: Track your software exploits
|
133
|
+
test_files:
|
134
|
+
- test/helper.rb
|
135
|
+
- test/test_trakr.rb
|
136
|
+
has_rdoc:
|