timetrap 1.8.3.beta1 → 1.8.3.beta2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -364,8 +364,7 @@ See ``t configure`` for details. Currently supported options are:
364
364
 
365
365
  **default_command**: The default command to invoke when you call `t`
366
366
 
367
- **sheets_are_exclusive**: Only allow one running entry at a time. Defaults to
368
- false which allows one running entry per sheet.
367
+ **auto_checkout**: Automatically check out of running entries when you check in
369
368
 
370
369
  Special Thanks
371
370
  --------------
data/VERSION.yml CHANGED
@@ -2,4 +2,4 @@
2
2
  :major: 1
3
3
  :minor: 8
4
4
  :patch: 3
5
- :build: beta1
5
+ :build: beta2
data/lib/timetrap/cli.rb CHANGED
@@ -32,7 +32,13 @@ COMMAND is one of:
32
32
  database_file: The file path of the sqlite database
33
33
  append_notes_delimiter: delimiter used when appending notes via
34
34
  t edit --append
35
+ formatter_search_paths: an array of directories to search for user
36
+ defined fomatter classes
37
+ default_formatter: The format to use when display is invoked without a
38
+ `--format` option
35
39
  default_command: The default command to run when calling t.
40
+ auto_checkout: Automatically check out of running entries when
41
+ you check in
36
42
 
37
43
  * display - Display the current timesheet or a specific. Pass `all' as SHEET
38
44
  to display all unarchived sheets or `full' to display archived and
@@ -225,8 +231,8 @@ COMMAND is one of:
225
231
  end
226
232
 
227
233
  def in
228
- if Config['sheets_are_exclusive']
229
- Timer.stop_other_sheets(args['-a']).each do |checked_out_of|
234
+ if Config['auto_checkout']
235
+ Timer.stop_all(args['-a']).each do |checked_out_of|
230
236
  warn "Checked out of sheet #{checked_out_of.sheet.inspect}."
231
237
  end
232
238
  end
@@ -26,8 +26,8 @@ module Timetrap
26
26
  # the default command to when you run `t`. default to printing usage.
27
27
  'default_command' => nil,
28
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
29
+ # automatically check out of any running tasks when checking in.
30
+ 'auto_checkout' => false
31
31
  }
32
32
  end
33
33
 
@@ -87,8 +87,8 @@ module Timetrap
87
87
  Entry.filter(:end => nil)
88
88
  end
89
89
 
90
- def stop_other_sheets(time = nil)
91
- running_entries.all.select{ |e| stop(e, time) unless current_sheet == e.sheet }
90
+ def stop_all(time = nil)
91
+ running_entries.map{ |e| stop(e, time) }
92
92
  end
93
93
 
94
94
  def stop sheet_or_entry, time = nil
@@ -104,6 +104,7 @@ module Timetrap
104
104
  a.end = time
105
105
  a.save
106
106
  end
107
+ a
107
108
  end
108
109
 
109
110
  def start note, time = nil
@@ -520,9 +520,9 @@ END:VCALENDAR
520
520
  $stderr.string.should =~ /\w+/
521
521
  end
522
522
 
523
- describe "with sheets_are_exclusive config option set" do
523
+ describe "with auto_checkout config option set" do
524
524
  before do
525
- with_stubbed_config 'sheets_are_exclusive' => true
525
+ with_stubbed_config 'auto_checkout' => true
526
526
  end
527
527
 
528
528
  it "should check in normally if nothing else is running" do
@@ -537,10 +537,15 @@ END:VCALENDAR
537
537
  invoke 'in first task'
538
538
  end
539
539
 
540
- it "should tell you you're already checked in" do
540
+ it "should check out and back in" do
541
541
  entry = Timetrap::Timer.active_entry('sheet1')
542
542
  invoke 'in second task'
543
- Timetrap::Timer.active_entry('sheet1').should == entry
543
+ Timetrap::Timer.active_entry('sheet1').note.should == 'second task'
544
+ end
545
+
546
+ it "should tell me what it's doing" do
547
+ invoke 'in second task'
548
+ $stderr.string.should include "Checked out"
544
549
  end
545
550
  end
546
551
 
@@ -823,6 +828,53 @@ END:VCALENDAR
823
828
  Timetrap::Timer.active_entry.note.should ==("New Note")
824
829
  end
825
830
  end
831
+
832
+ describe "with auto_checkout config option set" do
833
+ before do
834
+ with_stubbed_config 'auto_checkout' => true
835
+ end
836
+
837
+ it "should check in normally if nothing else is running" do
838
+ Timetrap::Timer.should_not be_running #precondition
839
+ invoke 'resume'
840
+ Timetrap::Timer.should be_running
841
+ end
842
+
843
+ describe "with a running entry on current sheet" do
844
+ before do
845
+ invoke 'sheet sheet1'
846
+ invoke 'in first task'
847
+ end
848
+
849
+ it "should check out and back in" do
850
+ entry = Timetrap::Timer.active_entry('sheet1')
851
+ invoke 'resume second task'
852
+ Timetrap::Timer.active_entry('sheet1').id.should_not == entry.id
853
+ end
854
+ end
855
+
856
+ describe "with a running entry on another sheet" do
857
+ before do
858
+ invoke 'sheet sheet1'
859
+ invoke 'in first task'
860
+ invoke 'sheet sheet2'
861
+ end
862
+
863
+ it "should check out of the running entry" do
864
+ Timetrap::Timer.active_entry('sheet1').should be_a(Timetrap::Entry)
865
+ invoke 'resume second task'
866
+ Timetrap::Timer.active_entry('sheet1').should be nil
867
+ end
868
+
869
+ it "should check out of the running entry at another time" do
870
+ now = Time.at(Time.now - 5 * 60) # 5 minutes ago
871
+ entry = Timetrap::Timer.active_entry('sheet1')
872
+ entry.should be_a(Timetrap::Entry)
873
+ invoke "resume -a '#{now}' second task"
874
+ entry.reload.end.to_s.should == now.to_s
875
+ end
876
+ end
877
+ end
826
878
  end
827
879
 
828
880
  describe "sheet" do
data/timetrap.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "timetrap"
8
- s.version = "1.8.3.beta1"
8
+ s.version = "1.8.3.beta2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Sam Goldstein"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timetrap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.3.beta1
4
+ version: 1.8.3.beta2
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors: