Permalink
Browse files

Whitespace

  • Loading branch information...
1 parent fe3a56c commit 4030a67ccf49330a0be9fc110ba77f171d1e1e51 @elia committed Nov 24, 2012
Showing with 39 additions and 39 deletions.
  1. +13 −13 README.md
  2. +6 −6 bin/timetap
  3. +20 −20 lib/time_tap/project.rb
View
26 README.md
@@ -2,15 +2,15 @@
TimeTap helps you track the time you spend coding on each project while in TextMate.
-Once it's launched you don't have to bother anymore starting/stopping timers or
+Once it's launched you don't have to bother anymore starting/stopping timers or
inventing some arbitrary amount of time to fill your fancy time tracker.
## Installation
gem install time_tap
-
+
timetap --install
-
+
… and visit [localhost:1111](http://localhost:1111/)
<img src="http://f.cl.ly/items/17025fecf7189518cf07/timetap-project-list.png"/>
@@ -20,13 +20,13 @@ inventing some arbitrary amount of time to fill your fancy time tracker.
## How it works
TimeTap keeps an eye on the modification time of the frontmost file in TextMate
-and tells you how much time you spent on each project.
+and tells you how much time you spent on each project.
-If you stop coding for a while while squeezing your brains TimeTap understands.
-TimeTap will consider "coding time" pauses to up to 30 minutes between to saves
+If you stop coding for a while while squeezing your brains TimeTap understands.
+TimeTap will consider "coding time" pauses to up to 30 minutes between to saves
in the same project.
-Technically it saves a timestamp+path of the frontmost file in TextMate every
+Technically it saves a timestamp+path of the frontmost file in TextMate every
30 seconds, then it digests all this information in a nice Sinatra webapp.
The server will respond on http://0.0.0.0:1111/.
@@ -48,19 +48,19 @@ TimeTap uses a config file to control where projects are kept, etc. the path is:
~/.tap_config
Which can look like this:
-
+
root: "~"
# root is where the logs will be saved
-
+
code: Code
# code is where all your projects live
-
+
nested_project_layers: 1
# see below about nested projects
-
+
port: 1111
# the port on localhost for the web interface
-
+
ruby: /usr/bin/ruby
# the ruby you want to use
@@ -81,7 +81,7 @@ TimeTap assumes you keep your projects inside a specific folder, like this:
AcmeCorp/
website/
intranet/
-
+
But if you keep your projects grouped in subfolders like this:
~/Code/
View
12 bin/timetap
@@ -16,19 +16,19 @@ OptionParser.new do |opts|
opts.on("-f", "--foreground", "Run in foreground (default).") do
TimeTap.config[:background] = false
end
-
+
opts.on("-b", "--background", "Run in background.") do
TimeTap.config[:background] = true
end
-
+
opts.on("-p", "--port PORT", "Use specified port for server. (default #{TimeTap.config['port']})") do |value|
TimeTap.config[:port] = value
end
-
+
opts.on("-l", "--log-level LEVEL", "Use specified port for server. (default #{TimeTap.config['port']})") do |value|
TimeTap.config[:log_level] = value
end
-
+
opts.on("-i", "--install", "Sets TimeTap to be launched automatically at login, and boots it.") do
puts 'Installing launcher...'
TimeTap.install_launcher!
@@ -49,11 +49,11 @@ end.parse!
TimeTap.config[:foreground] = !TimeTap.config[:background]
if TimeTap.config[:background]
require 'time_tap/daemon'
-
+
pid = fork {
# Try to replace "ruby" with "TimeTap" in the command string (for "ps -A" & co.)
$0 = 'TimeTap'
-
+
Process.daemon(true)
TimeTap.start
}
View
40 lib/time_tap/project.rb
@@ -2,9 +2,9 @@
require 'active_support/core_ext/numeric/time'
class TimeTap::Project
-
+
# CONFIG
-
+
class << self
attr_accessor :pause_limit
def load_projects
@@ -14,13 +14,13 @@ def load_projects
end
end
end
-
+
def projects
load_projects
@projects
end
attr_reader :backend
-
+
def reload!
@pause_limit = 30.minutes
@projects = {}.with_indifferent_access
@@ -40,11 +40,11 @@ class << self
def logger
TimeTap.logger
end
-
+
def all
projects.values
end
-
+
def register time, path
project = self[path]
if project
@@ -54,7 +54,7 @@ def register time, path
logger.info "[TimeTap::Project] skipping #{time}, no project"
end
end
-
+
def find name
projects[name.underscore.downcase]
end
@@ -65,20 +65,20 @@ def [] path
how_nested = 1
regex_suffix = "([^/]+)"
-
+
folders = TimeTap.config[:code_folders].map do |folder|
folder = File.expand_path(folder)
folder = Dir[folder]
end.flatten
-
+
folders_regex = folders.map{|f| Regexp.escape f}.join('|')
res = path.scan(%r{(#{folders_regex})/#{regex_suffix}}).flatten
-
+
# res = path.scan(%r{(#{TimeTap.config[:code] || "Code"})/#{regex_suffix}}).flatten
mid_path = res[0] # not in a MatchObj group any more, so it's 0 based
name = res[how_nested]
mid_path, name = path.scan(%r{#{File.expand_path("~")}/([^/]+)/([^/]+)}).flatten if name.nil?
-
+
if name
name.chomp!
key = name.underscore.downcase
@@ -102,14 +102,14 @@ def initialize mid_path, name
@path = File.expand_path("~/#{mid_path}/#{name}/")
@pinches = []
end
-
-
-
-
+
+
+
+
# ATTRIBUTES
-
+
attr_reader :name, :path, :pinches
-
+
def work_time
pinches.sum(&:duration)
end
@@ -136,12 +136,12 @@ def humanized_duration
seconds = duration
hours = mins = 0
- if seconds >= 60 then
- mins = (seconds / 60).to_i
+ if seconds >= 60 then
+ mins = (seconds / 60).to_i
seconds = (seconds % 60 ).to_i
if mins >= 60 then
- hours = (mins / 60).to_i
+ hours = (mins / 60).to_i
mins = (mins % 60).to_i
end
end

0 comments on commit 4030a67

Please sign in to comment.