tictoc 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/Gemfile +3 -0
- data/Rakefile +6 -0
- data/bin/tictoc +61 -0
- data/lib/tictoc.rb +1 -0
- data/lib/tictoc/version.rb +3 -0
- data/tictoc.gemspec +23 -0
- metadata +114 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
data/bin/tictoc
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift(File.join(File.dirname(__FILE__), "/../lib"))
|
4
|
+
require 'tictoc'
|
5
|
+
|
6
|
+
require 'active_support/core_ext'
|
7
|
+
require 'appscript'
|
8
|
+
require 'ostruct'
|
9
|
+
|
10
|
+
class ModelBase < OpenStruct
|
11
|
+
def <=>(other)
|
12
|
+
self.sort_key <=> other.sort_key
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Task < ModelBase
|
17
|
+
end
|
18
|
+
|
19
|
+
class Session < ModelBase
|
20
|
+
def sort_key
|
21
|
+
[self.date, self.task.name.downcase]
|
22
|
+
end
|
23
|
+
|
24
|
+
def date
|
25
|
+
start_date.to_date
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
sessions = []
|
30
|
+
app = Appscript.app('Tictoc')
|
31
|
+
app.tasks.properties_.get.each do |task_data|
|
32
|
+
task_ref = app.tasks.ID(task_data[:id_])
|
33
|
+
task = Task.new(task_data)
|
34
|
+
task_ref.sessions.properties_.get.each do |session_data|
|
35
|
+
session = Session.new(session_data.merge(:task => task))
|
36
|
+
sessions << session
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
footer_text = "Total:"
|
41
|
+
max_name_len = footer_text.size
|
42
|
+
|
43
|
+
days = {}
|
44
|
+
sessions.sort.each do |session|
|
45
|
+
day = days[session.date] ||= Hash.new(0)
|
46
|
+
day[session.task.name] += session.duration / 3600.0
|
47
|
+
max_name_len = [max_name_len, session.task.name.size].max
|
48
|
+
end
|
49
|
+
|
50
|
+
def format_hours(hours)
|
51
|
+
"#{hours.floor.to_s.rjust 2}:#{(hours*60%60).round(0).to_s.rjust(2,'0')} (#{hours.round(2)} hours)"
|
52
|
+
end
|
53
|
+
|
54
|
+
days.each do |date,tasks|
|
55
|
+
puts date.strftime '%Y-%m-%d %A'
|
56
|
+
tasks.each do |name, hours|
|
57
|
+
puts " #{name.ljust max_name_len} #{format_hours hours}"
|
58
|
+
end
|
59
|
+
puts " #{footer_text.rjust max_name_len} #{format_hours tasks.values.sum}"
|
60
|
+
puts
|
61
|
+
end
|
data/lib/tictoc.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'tictoc/version'
|
data/tictoc.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/tictoc/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ['Jason Weathered']
|
6
|
+
gem.email = ['jason@jasoncodes.com']
|
7
|
+
gem.summary = %q{Report Tictoc timesheet summary by day}
|
8
|
+
gem.homepage = 'https://github.com/jasoncodes/tictoc'
|
9
|
+
|
10
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
11
|
+
gem.files = `git ls-files`.split("\n")
|
12
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
13
|
+
gem.name = 'tictoc'
|
14
|
+
gem.require_paths = ['lib']
|
15
|
+
gem.version = Tictoc::VERSION
|
16
|
+
|
17
|
+
gem.add_dependency 'rb-appscript'
|
18
|
+
gem.add_dependency 'i18n'
|
19
|
+
gem.add_dependency 'activerecord', '~> 3.0'
|
20
|
+
|
21
|
+
gem.add_development_dependency 'rake'
|
22
|
+
gem.add_development_dependency 'gem-release'
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tictoc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jason Weathered
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-12-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rb-appscript
|
16
|
+
requirement: &70232952930360 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70232952930360
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: i18n
|
27
|
+
requirement: &70232952929740 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70232952929740
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: activerecord
|
38
|
+
requirement: &70232952944620 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '3.0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70232952944620
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: &70232952942420 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70232952942420
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: gem-release
|
60
|
+
requirement: &70232952938940 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70232952938940
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- jason@jasoncodes.com
|
72
|
+
executables:
|
73
|
+
- tictoc
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- .gitignore
|
78
|
+
- Gemfile
|
79
|
+
- Rakefile
|
80
|
+
- bin/tictoc
|
81
|
+
- lib/tictoc.rb
|
82
|
+
- lib/tictoc/version.rb
|
83
|
+
- tictoc.gemspec
|
84
|
+
homepage: https://github.com/jasoncodes/tictoc
|
85
|
+
licenses: []
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ! '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
segments:
|
97
|
+
- 0
|
98
|
+
hash: -610537785577650725
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
101
|
+
requirements:
|
102
|
+
- - ! '>='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
segments:
|
106
|
+
- 0
|
107
|
+
hash: -610537785577650725
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 1.8.11
|
111
|
+
signing_key:
|
112
|
+
specification_version: 3
|
113
|
+
summary: Report Tictoc timesheet summary by day
|
114
|
+
test_files: []
|