timetrap 1.8.2 → 1.8.3.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +10 -4
- data/Rakefile +1 -1
- data/VERSION.yml +2 -1
- data/lib/timetrap/cli.rb +5 -0
- data/lib/timetrap/config.rb +4 -1
- data/lib/timetrap/timer.rb +13 -2
- data/spec/timetrap_spec.rb +54 -3
- data/timetrap.gemspec +3 -3
- metadata +5 -8
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Timetrap
|
1
|
+
Timetrap [![Build Status](https://secure.travis-ci.org/samg/timetrap.png)](http://travis-ci.org/samg/timetrap)
|
2
2
|
========
|
3
3
|
|
4
4
|
Timetrap is a simple command line time tracker written in ruby. It provides an
|
@@ -353,14 +353,20 @@ See ``t configure`` for details. Currently supported options are:
|
|
353
353
|
|
354
354
|
**database_file**: The file path of the sqlite database
|
355
355
|
|
356
|
-
**append_notes_delimiter**: delimiter used when appending notes via
|
356
|
+
**append_notes_delimiter**: delimiter used when appending notes via
|
357
|
+
`t edit --append`
|
357
358
|
|
358
|
-
**formatter_search_paths**: an array of directories to search for user
|
359
|
+
**formatter_search_paths**: an array of directories to search for user
|
360
|
+
defined fomatter classes
|
359
361
|
|
360
|
-
**default_formatter**: The format to use when display is invoked without a
|
362
|
+
**default_formatter**: The format to use when display is invoked without a
|
363
|
+
`--format` option
|
361
364
|
|
362
365
|
**default_command**: The default command to invoke when you call `t`
|
363
366
|
|
367
|
+
**sheets_are_exclusive**: Only allow one running entry at a time. Defaults to
|
368
|
+
false which allows one running entry per sheet.
|
369
|
+
|
364
370
|
Special Thanks
|
365
371
|
--------------
|
366
372
|
|
data/Rakefile
CHANGED
data/VERSION.yml
CHANGED
data/lib/timetrap/cli.rb
CHANGED
@@ -225,6 +225,11 @@ COMMAND is one of:
|
|
225
225
|
end
|
226
226
|
|
227
227
|
def in
|
228
|
+
if Config['sheets_are_exclusive']
|
229
|
+
Timer.stop_other_sheets(args['-a']).each do |checked_out_of|
|
230
|
+
warn "Checked out of sheet #{checked_out_of.sheet.inspect}."
|
231
|
+
end
|
232
|
+
end
|
228
233
|
Timer.start unused_args, args['-a']
|
229
234
|
warn "Checked into sheet #{Timer.current_sheet.inspect}."
|
230
235
|
end
|
data/lib/timetrap/config.rb
CHANGED
@@ -24,7 +24,10 @@ module Timetrap
|
|
24
24
|
# formatter to use when display is invoked without a --format option
|
25
25
|
'default_formatter' => 'text',
|
26
26
|
# the default command to when you run `t`. default to printing usage.
|
27
|
-
'default_command' => nil
|
27
|
+
'default_command' => nil,
|
28
|
+
# only allow one running entry at a time.
|
29
|
+
# when set to false it is possible to have one running entry per sheet.
|
30
|
+
'sheets_are_exclusive' => false
|
28
31
|
}
|
29
32
|
end
|
30
33
|
|
data/lib/timetrap/timer.rb
CHANGED
@@ -87,8 +87,19 @@ module Timetrap
|
|
87
87
|
Entry.filter(:end => nil)
|
88
88
|
end
|
89
89
|
|
90
|
-
def
|
91
|
-
|
90
|
+
def stop_other_sheets(time = nil)
|
91
|
+
running_entries.all.select{ |e| stop(e, time) unless current_sheet == e.sheet }
|
92
|
+
end
|
93
|
+
|
94
|
+
def stop sheet_or_entry, time = nil
|
95
|
+
a = case sheet_or_entry
|
96
|
+
when Entry
|
97
|
+
sheet_or_entry
|
98
|
+
when String
|
99
|
+
active_entry(sheet_or_entry)
|
100
|
+
end
|
101
|
+
|
102
|
+
if a
|
92
103
|
time ||= Time.now
|
93
104
|
a.end = time
|
94
105
|
a.save
|
data/spec/timetrap_spec.rb
CHANGED
@@ -12,9 +12,10 @@ def local_time_cli(str)
|
|
12
12
|
end
|
13
13
|
|
14
14
|
module Timetrap::StubConfig
|
15
|
-
def with_stubbed_config options
|
16
|
-
|
17
|
-
|
15
|
+
def with_stubbed_config options = {}
|
16
|
+
defaults = Timetrap::Config.defaults.dup
|
17
|
+
Timetrap::Config.stub(:[]).and_return do |k|
|
18
|
+
defaults.merge(options)[k]
|
18
19
|
end
|
19
20
|
yield if block_given?
|
20
21
|
end
|
@@ -22,6 +23,9 @@ end
|
|
22
23
|
|
23
24
|
describe Timetrap do
|
24
25
|
include Timetrap::StubConfig
|
26
|
+
before do
|
27
|
+
with_stubbed_config
|
28
|
+
end
|
25
29
|
def create_entry atts = {}
|
26
30
|
Timetrap::Entry.create({
|
27
31
|
:sheet => 'default',
|
@@ -515,6 +519,53 @@ END:VCALENDAR
|
|
515
519
|
Timetrap::Entry.order_by(:id).last.should be_nil
|
516
520
|
$stderr.string.should =~ /\w+/
|
517
521
|
end
|
522
|
+
|
523
|
+
describe "with sheets_are_exclusive config option set" do
|
524
|
+
before do
|
525
|
+
with_stubbed_config 'sheets_are_exclusive' => true
|
526
|
+
end
|
527
|
+
|
528
|
+
it "should check in normally if nothing else is running" do
|
529
|
+
Timetrap::Timer.should_not be_running #precondition
|
530
|
+
invoke 'in'
|
531
|
+
Timetrap::Timer.should be_running
|
532
|
+
end
|
533
|
+
|
534
|
+
describe "with a running entry on current sheet" do
|
535
|
+
before do
|
536
|
+
invoke 'sheet sheet1'
|
537
|
+
invoke 'in first task'
|
538
|
+
end
|
539
|
+
|
540
|
+
it "should tell you you're already checked in" do
|
541
|
+
entry = Timetrap::Timer.active_entry('sheet1')
|
542
|
+
invoke 'in second task'
|
543
|
+
Timetrap::Timer.active_entry('sheet1').should == entry
|
544
|
+
end
|
545
|
+
end
|
546
|
+
|
547
|
+
describe "with a running entry on another sheet" do
|
548
|
+
before do
|
549
|
+
invoke 'sheet sheet1'
|
550
|
+
invoke 'in first task'
|
551
|
+
invoke 'sheet sheet2'
|
552
|
+
end
|
553
|
+
|
554
|
+
it "should check out of the running entry" do
|
555
|
+
Timetrap::Timer.active_entry('sheet1').should be_a(Timetrap::Entry)
|
556
|
+
invoke 'in second task'
|
557
|
+
Timetrap::Timer.active_entry('sheet1').should be nil
|
558
|
+
end
|
559
|
+
|
560
|
+
it "should check out of the running entry at another time" do
|
561
|
+
now = Time.at(Time.now - 5 * 60) # 5 minutes ago
|
562
|
+
entry = Timetrap::Timer.active_entry('sheet1')
|
563
|
+
entry.should be_a(Timetrap::Entry)
|
564
|
+
invoke "in -a '#{now}' second task"
|
565
|
+
entry.reload.end.to_s.should == now.to_s
|
566
|
+
end
|
567
|
+
end
|
568
|
+
end
|
518
569
|
end
|
519
570
|
|
520
571
|
describe "kill" do
|
data/timetrap.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "timetrap"
|
8
|
-
s.version = "1.8.
|
8
|
+
s.version = "1.8.3.beta1"
|
9
9
|
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new("
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Sam Goldstein"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-11-06"
|
13
13
|
s.description = "Command line time tracker"
|
14
14
|
s.email = "sgrock@gmail.com"
|
15
15
|
s.executables = ["t"]
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timetrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
5
|
-
prerelease:
|
4
|
+
version: 1.8.3.beta1
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Sam Goldstein
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sequel
|
@@ -251,15 +251,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
251
251
|
- - ! '>='
|
252
252
|
- !ruby/object:Gem::Version
|
253
253
|
version: '0'
|
254
|
-
segments:
|
255
|
-
- 0
|
256
|
-
hash: 799045396901513239
|
257
254
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
258
255
|
none: false
|
259
256
|
requirements:
|
260
|
-
- - ! '
|
257
|
+
- - ! '>'
|
261
258
|
- !ruby/object:Gem::Version
|
262
|
-
version:
|
259
|
+
version: 1.3.1
|
263
260
|
requirements: []
|
264
261
|
rubyforge_project:
|
265
262
|
rubygems_version: 1.8.24
|