timetrap 1.9.0 → 1.10.0
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 +4 -4
- data/.travis.yml +2 -5
- data/lib/timetrap/auto_sheets/nested_dotfiles.rb +25 -0
- data/lib/timetrap/cli.rb +5 -3
- data/lib/timetrap/helpers.rb +5 -0
- data/lib/timetrap/version.rb +1 -1
- data/spec/dotfile/nested/.timetrap-sheet +1 -0
- data/spec/dotfile/nested/no-sheet/.gitkeep +0 -0
- data/spec/timetrap_spec.rb +58 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f0cfbd1ca2273c6fbcaa8a48af329f8bb02e29b
|
4
|
+
data.tar.gz: 55d18f5690cfcfbf6f5379f244e323d5f2da4d80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 099d87442198a0dd457bf1ea35c6a2a7dd390b0b6c3935f63edfd6d5bb76d0adb605e82c46a454f1b5ff8e3bc36933c230267838050d2d311fac9a28ea776bfa
|
7
|
+
data.tar.gz: 4e18a20f8a8cdff882cf3a2b72f4e31f5adb8af5b5f2aed738f649e2a5190c0028cbff9a40649bedd6cfa15587524633fc7763d7e292a71fbdc85575a0226654
|
data/.travis.yml
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Timetrap
|
2
|
+
module AutoSheets
|
3
|
+
#
|
4
|
+
# Check the current dir and all parent dirs for .timetrap-sheet
|
5
|
+
#
|
6
|
+
class NestedDotfiles
|
7
|
+
def check_sheet(dir)
|
8
|
+
dotfile = File.join(dir, '.timetrap-sheet')
|
9
|
+
File.read(dotfile).chomp if File.exist?(dotfile)
|
10
|
+
end
|
11
|
+
|
12
|
+
def sheet
|
13
|
+
dir = Dir.pwd
|
14
|
+
while true do
|
15
|
+
sheet = check_sheet dir
|
16
|
+
break if nil != sheet
|
17
|
+
new_dir = File.expand_path("..", dir)
|
18
|
+
break if new_dir == dir
|
19
|
+
dir = new_dir
|
20
|
+
end
|
21
|
+
return sheet
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/timetrap/cli.rb
CHANGED
@@ -19,6 +19,7 @@ COMMAND is one of:
|
|
19
19
|
usage: t archive [--start DATE] [--end DATE] [SHEET]
|
20
20
|
-s, --start <date:qs> Include entries that start on this date or later
|
21
21
|
-e, --end <date:qs> Include entries that start on this date or earlier
|
22
|
+
-g, --grep <regexp> Include entries where the note matches this regexp.
|
22
23
|
|
23
24
|
* backend - Open an sqlite shell to the database.
|
24
25
|
usage: t backend
|
@@ -54,6 +55,7 @@ COMMAND is one of:
|
|
54
55
|
Documentation on defining custom formats can be
|
55
56
|
found in the README included in this
|
56
57
|
distribution.
|
58
|
+
-g, --grep <regexp> Include entries where the note matches this regexp.
|
57
59
|
|
58
60
|
* edit - Alter an entry's note, start, or end time. Defaults to the active
|
59
61
|
entry. Defaults to the last entry to be checked out of if no entry is active.
|
@@ -193,7 +195,7 @@ COMMAND is one of:
|
|
193
195
|
def archive
|
194
196
|
ee = selected_entries
|
195
197
|
if ask_user "Archive #{ee.count} entries? "
|
196
|
-
ee.
|
198
|
+
ee.each do |e|
|
197
199
|
next unless e.end
|
198
200
|
e.update :sheet => "_#{e.sheet}"
|
199
201
|
end
|
@@ -277,7 +279,7 @@ COMMAND is one of:
|
|
277
279
|
entry
|
278
280
|
when Timer.last_checkout
|
279
281
|
last = Timer.last_checkout
|
280
|
-
warn "Resuming last
|
282
|
+
warn "Resuming last entry you checked out of (#{last.note})"
|
281
283
|
last
|
282
284
|
end
|
283
285
|
|
@@ -334,7 +336,7 @@ COMMAND is one of:
|
|
334
336
|
end
|
335
337
|
|
336
338
|
def display
|
337
|
-
entries = selected_entries
|
339
|
+
entries = selected_entries
|
338
340
|
if entries == []
|
339
341
|
warn "No entries were selected to display."
|
340
342
|
else
|
data/lib/timetrap/helpers.rb
CHANGED
@@ -50,6 +50,11 @@ module Timetrap
|
|
50
50
|
end
|
51
51
|
ee = ee.filter('start >= ?', Date.parse(Timer.process_time(args['-s']).to_s)) if args['-s']
|
52
52
|
ee = ee.filter('start <= ?', Date.parse(Timer.process_time(args['-e']).to_s) + 1) if args['-e']
|
53
|
+
ee = ee.order(:start)
|
54
|
+
if args['-g']
|
55
|
+
re = Regexp::new(args['-g'])
|
56
|
+
ee = ee.find_all{|e| re.match(e.note)}
|
57
|
+
end
|
53
58
|
ee
|
54
59
|
end
|
55
60
|
|
data/lib/timetrap/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
nested-sheet
|
File without changes
|
data/spec/timetrap_spec.rb
CHANGED
@@ -87,11 +87,26 @@ describe Timetrap do
|
|
87
87
|
|
88
88
|
describe 'archive' do
|
89
89
|
before do
|
90
|
+
3.times do |i|
|
91
|
+
create_entry({:note => 'grep'})
|
92
|
+
end
|
90
93
|
3.times do |i|
|
91
94
|
create_entry
|
92
95
|
end
|
93
96
|
end
|
94
97
|
|
98
|
+
it "should only archive entries matched by the provided regex" do
|
99
|
+
$stdin.string = "yes\n"
|
100
|
+
invoke 'archive --grep [g][r][e][p]'
|
101
|
+
Timetrap::Entry.each do |e|
|
102
|
+
if e.note == 'grep'
|
103
|
+
e.sheet.should == '_default'
|
104
|
+
else
|
105
|
+
e.sheet.should == 'default'
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
95
110
|
it "should put the entries in a hidden sheet" do
|
96
111
|
$stdin.string = "yes\n"
|
97
112
|
invoke 'archive'
|
@@ -277,6 +292,32 @@ describe Timetrap do
|
|
277
292
|
end
|
278
293
|
end
|
279
294
|
end
|
295
|
+
|
296
|
+
describe "using nested_dotfiles auto_sheet" do
|
297
|
+
describe 'with a .timetrap-sheet in cwd' do
|
298
|
+
it 'should use sheet defined in dotfile' do
|
299
|
+
Dir.chdir('spec/dotfile') do
|
300
|
+
with_stubbed_config('auto_sheet' => 'nested_dotfiles')
|
301
|
+
Timetrap::Timer.current_sheet.should == 'dotfile-sheet'
|
302
|
+
end
|
303
|
+
end
|
304
|
+
it 'should use top-most sheet found in dir heirarchy' do
|
305
|
+
Dir.chdir('spec/dotfile/nested') do
|
306
|
+
with_stubbed_config('auto_sheet' => 'nested_dotfiles')
|
307
|
+
Timetrap::Timer.current_sheet.should == 'nested-sheet'
|
308
|
+
end
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
describe 'with no .timetrap-sheet in cwd' do
|
313
|
+
it 'should use sheet defined in ancestor\'s dotfile' do
|
314
|
+
Dir.chdir('spec/dotfile/nested/no-sheet') do
|
315
|
+
with_stubbed_config('auto_sheet' => 'nested_dotfiles')
|
316
|
+
Timetrap::Timer.current_sheet.should == 'nested-sheet'
|
317
|
+
end
|
318
|
+
end
|
319
|
+
end
|
320
|
+
end
|
280
321
|
end
|
281
322
|
|
282
323
|
describe "backend" do
|
@@ -332,6 +373,17 @@ Timesheet: SpecSheet
|
|
332
373
|
Total 8:00:00
|
333
374
|
OUTPUT
|
334
375
|
|
376
|
+
@desired_output_grepped = <<-OUTPUT
|
377
|
+
Timesheet: SpecSheet
|
378
|
+
Day Start End Duration Notes
|
379
|
+
Fri Oct 03, 2008 12:00:00 - 14:00:00 2:00:00 entry 1
|
380
|
+
2:00:00
|
381
|
+
Sun Oct 05, 2008 16:00:00 - 18:00:00 2:00:00 entry 3
|
382
|
+
2:00:00
|
383
|
+
-----------------------------------------------------------
|
384
|
+
Total 4:00:00
|
385
|
+
OUTPUT
|
386
|
+
|
335
387
|
@desired_output_with_ids = <<-OUTPUT
|
336
388
|
Timesheet: SpecSheet
|
337
389
|
Id Day Start End Duration Notes
|
@@ -408,6 +460,12 @@ Grand Total 10:00:00
|
|
408
460
|
$stdout.string.should include("entry 5")
|
409
461
|
end
|
410
462
|
|
463
|
+
it "should only display entries that are matched by the provided regex" do
|
464
|
+
Timetrap::Timer.current_sheet = 'SpecSheet'
|
465
|
+
invoke 'display --grep [13]'
|
466
|
+
$stdout.string.should == @desired_output_grepped
|
467
|
+
end
|
468
|
+
|
411
469
|
it "should display a timesheet with ids" do
|
412
470
|
invoke 'display S --ids'
|
413
471
|
$stdout.string.should == @desired_output_with_ids
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timetrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Goldstein
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -164,6 +164,7 @@ files:
|
|
164
164
|
- lib/timetrap.rb
|
165
165
|
- lib/timetrap/auto_sheets.rb
|
166
166
|
- lib/timetrap/auto_sheets/dotfiles.rb
|
167
|
+
- lib/timetrap/auto_sheets/nested_dotfiles.rb
|
167
168
|
- lib/timetrap/auto_sheets/yaml_cwd.rb
|
168
169
|
- lib/timetrap/cli.rb
|
169
170
|
- lib/timetrap/config.rb
|
@@ -179,6 +180,8 @@ files:
|
|
179
180
|
- lib/timetrap/timer.rb
|
180
181
|
- lib/timetrap/version.rb
|
181
182
|
- spec/dotfile/.timetrap-sheet
|
183
|
+
- spec/dotfile/nested/.timetrap-sheet
|
184
|
+
- spec/dotfile/nested/no-sheet/.gitkeep
|
182
185
|
- spec/timetrap_spec.rb
|
183
186
|
- timetrap.gemspec
|
184
187
|
homepage: https://github.com/samg/timetrap
|
@@ -207,4 +210,6 @@ specification_version: 4
|
|
207
210
|
summary: Command line time tracker
|
208
211
|
test_files:
|
209
212
|
- spec/dotfile/.timetrap-sheet
|
213
|
+
- spec/dotfile/nested/.timetrap-sheet
|
214
|
+
- spec/dotfile/nested/no-sheet/.gitkeep
|
210
215
|
- spec/timetrap_spec.rb
|