timetrap 1.8.11 → 1.8.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ce19a1337e4238314c4b8559d860e3b5fe060e35
4
+ data.tar.gz: e642ab919336be668b2e1a748aceccf954fda443
5
+ SHA512:
6
+ metadata.gz: dc45d1614cb7fc9c8e341bdb4d642c46f9ae9a2ff8b0323bf8bd7c13153d3830d47eb27e3d50cbfa468e10619893f32c065aee72f23264a0f2e012edf24d24ce
7
+ data.tar.gz: 6ce14e2dce4dd692c0422b1fc7772b9fbe7b07404fd65f073558d1ef28b961d3e2d96884ba06e3c59fa5b3e3d72170644f801488214ae2f42716f00a63627e40
data/README.md CHANGED
@@ -16,6 +16,8 @@ This will place a ``t`` executable in your path.
16
16
  ### Basic Usage
17
17
 
18
18
  $ # get help
19
+ $ timetrap --help
20
+ $ # or
19
21
  $ t --help
20
22
 
21
23
  Timetrap maintains a list of *timesheets*.
@@ -199,8 +201,10 @@ formatter in a different place you can run `t configure` and edit the
199
201
  All timetrap formatters live under the namespace `Timetrap::Formatters` so
200
202
  define your class like this:
201
203
 
202
- class Timetrap::Formatters::Notes
203
- end
204
+ ```ruby
205
+ class Timetrap::Formatters::Notes
206
+ end
207
+ ```
204
208
 
205
209
  When `t display` is invoked, timetrap initializes a new instance of the
206
210
  formatter passing it an Array of entries. It then calls `#output` which should
@@ -209,15 +213,17 @@ return a string to be printed to the screen.
209
213
  This means we need to implement an `#initialize` method and an `#output`
210
214
  method for the class. Something like this:
211
215
 
212
- class Timetrap::Formatters::Notes
213
- def initialize(entries)
214
- @entries = entries
215
- end
216
+ ```ruby
217
+ class Timetrap::Formatters::Notes
218
+ def initialize(entries)
219
+ @entries = entries
220
+ end
216
221
 
217
- def output
218
- @entries.map{|entry| entry[:note]}.join("\n")
219
- end
220
- end
222
+ def output
223
+ @entries.map{|entry| entry[:note]}.join("\n")
224
+ end
225
+ end
226
+ ```
221
227
 
222
228
  Now when I invoke it:
223
229
 
@@ -301,7 +307,8 @@ Commands
301
307
  **out**
302
308
  Stop the timer for the current timesheet. Must be called after in. Accepts an
303
309
  optional --at flag. Accepts an optional TIMESHEET name to check out of a
304
- running, non-current sheet.
310
+ running, non-current sheet. Will check out of all running sheets if the
311
+ auto_checkout configuration option is enabled.
305
312
 
306
313
  usage: ``t out [--at TIME] [TIMESHEET]``
307
314
 
@@ -370,7 +377,10 @@ See ``t configure`` for details. Currently supported options are:
370
377
 
371
378
  **default_command**: The default command to invoke when you call `t`
372
379
 
373
- **auto_checkout**: Automatically check out of running entries when you check in
380
+ **auto_checkout**: Automatically check out of running entries when you check
381
+ in or out
382
+
383
+ **require_note**: Prompt for a note if one isn't provided when checking in
374
384
 
375
385
  Autocomplete
376
386
  ------------
data/bin/timetrap ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ begin
3
+ require 'timetrap'
4
+ rescue LoadError
5
+ if File.symlink? __FILE__
6
+ require File.dirname(File.readlink(__FILE__)) + '/../lib/timetrap'
7
+ else
8
+ require File.dirname(__FILE__) + '/../lib/timetrap'
9
+ end
10
+ end
11
+ Timetrap::CLI.invoke
@@ -1294,8 +1294,8 @@ EOS
1294
1294
  end
1295
1295
  prog.sub!(%r#.*/#,'')
1296
1296
  r = ''
1297
- if defined?($VERSION)
1298
- r << "\n#{prog}: version #{$VERSION} (#{filedate})\n\n"
1297
+ if defined?(::Timetrap::VERSION)
1298
+ r << "\n#{prog}: version #{::Timetrap::VERSION} (#{filedate})\n\n"
1299
1299
  else
1300
1300
  r << "\n#{prog}: version dated #{filedate}\n\n"
1301
1301
  end
data/lib/timetrap.rb CHANGED
@@ -5,6 +5,7 @@ require 'sequel'
5
5
  require 'yaml'
6
6
  require 'erb'
7
7
  require 'sequel/extensions/inflector'
8
+ require File.join(File.dirname(__FILE__), 'timetrap', 'version')
8
9
  require File.join(File.dirname(__FILE__), 'Getopt/Declare')
9
10
  require File.join(File.dirname(__FILE__), 'timetrap', 'config')
10
11
  require File.join(File.dirname(__FILE__), 'timetrap', 'helpers')
data/lib/timetrap/cli.rb CHANGED
@@ -38,7 +38,9 @@ COMMAND is one of:
38
38
  `--format` option
39
39
  default_command: The default command to run when calling t.
40
40
  auto_checkout: Automatically check out of running entries when
41
- you check in
41
+ you check in or out
42
+ require_note: Prompt for a note if one isn't provided when
43
+ checking in
42
44
 
43
45
  * display - Display the current timesheet or a specific. Pass `all' as SHEET
44
46
  to display all unarchived sheets or `full' to display archived and
@@ -78,7 +80,7 @@ COMMAND is one of:
78
80
  * now - Show all running entries.
79
81
  usage: t now
80
82
 
81
- * out - Stop the timer for the a timesheet.
83
+ * out - Stop the timer for a timesheet.
82
84
  usage: t out [--at TIME] [TIMESHEET]
83
85
  -a, --at <time:qs> Use this time instead of now
84
86
 
@@ -253,6 +255,12 @@ COMMAND is one of:
253
255
  warn "Checked out of sheet #{checked_out_of.sheet.inspect}."
254
256
  end
255
257
  end
258
+
259
+ if Config['require_note'] && !Timer.running? && unused_args.empty?
260
+ $stderr.print("Please enter a note for this entry:\n> ")
261
+ self.unused_args = $stdin.gets
262
+ end
263
+
256
264
  Timer.start unused_args, args['-a']
257
265
  warn "Checked into sheet #{Timer.current_sheet.inspect}."
258
266
  end
@@ -270,11 +278,20 @@ COMMAND is one of:
270
278
  end
271
279
 
272
280
  def out
273
- sheet = sheet_name_from_string(unused_args)
274
- if Timer.stop sheet, args['-a']
275
- warn "Checked out of sheet #{sheet.inspect}."
281
+ if Config['auto_checkout']
282
+ stopped = Timer.stop_all(args['-a']).each do |checked_out_of|
283
+ warn "Checked out of sheet #{checked_out_of.sheet.inspect}."
284
+ end
285
+ if stopped.empty?
286
+ warn "No running entries to stop."
287
+ end
276
288
  else
277
- warn "No running entry on sheet #{sheet.inspect}."
289
+ sheet = sheet_name_from_string(unused_args)
290
+ if Timer.stop sheet, args['-a']
291
+ warn "Checked out of sheet #{sheet.inspect}."
292
+ else
293
+ warn "No running entry on sheet #{sheet.inspect}."
294
+ end
278
295
  end
279
296
  end
280
297
 
@@ -27,7 +27,9 @@ module Timetrap
27
27
  'default_command' => nil,
28
28
  # only allow one running entry at a time.
29
29
  # automatically check out of any running tasks when checking in.
30
- 'auto_checkout' => false
30
+ 'auto_checkout' => false,
31
+ # interactively prompt for a note if one isn't passed when checking in.
32
+ 'require_note' => false
31
33
  }
32
34
  end
33
35
 
@@ -1,3 +1,3 @@
1
1
  module Timetrap
2
- VERSION = '1.8.11'
2
+ VERSION = '1.8.12'
3
3
  end
@@ -555,6 +555,32 @@ END:VCALENDAR
555
555
  $stderr.string.should =~ /\w+/
556
556
  end
557
557
 
558
+ describe "with require_note config option set" do
559
+ before do
560
+ with_stubbed_config 'require_note' => true
561
+ end
562
+
563
+ it "should prompt for a note if one isn't passed" do
564
+ $stdin.string = "an interactive note\n"
565
+ invoke "in"
566
+ $stderr.string.should include('enter a note')
567
+ Timetrap::Timer.active_entry.note.should == "an interactive note"
568
+ end
569
+
570
+ it "should not prompt for a note if one is passed" do
571
+ $stdin.string = "an interactive note\n"
572
+ invoke "in a normal note"
573
+ Timetrap::Timer.active_entry.note.should == "a normal note"
574
+ end
575
+
576
+ it "should not stop the running entry or prompt" do
577
+ invoke "in a normal note"
578
+ $stdin.string = "an interactive note\n"
579
+ invoke "in"
580
+ Timetrap::Timer.active_entry.note.should == "a normal note"
581
+ end
582
+ end
583
+
558
584
  describe "with auto_checkout config option set" do
559
585
  before do
560
586
  with_stubbed_config 'auto_checkout' => true
@@ -604,6 +630,14 @@ END:VCALENDAR
604
630
  invoke "in -a '#{now}' second task"
605
631
  entry.reload.end.to_s.should == now.to_s
606
632
  end
633
+
634
+ it "should check out of the running entry without having to start a new entry" do
635
+ entry = Timetrap::Timer.active_entry('sheet1')
636
+ entry.should be_a(Timetrap::Entry)
637
+ entry.end.should be_nil
638
+ invoke "out"
639
+ entry.reload.end.should_not be_nil
640
+ end
607
641
  end
608
642
  end
609
643
  end
@@ -1279,4 +1313,13 @@ END:VCALENDAR
1279
1313
  end
1280
1314
 
1281
1315
  end
1316
+ describe 'bins' do
1317
+ # https://github.com/samg/timetrap/pull/80
1318
+ it 'should include a t bin and an equivalent timetrap bin' do
1319
+ timetrap = File.open(File.expand_path(File.join(File.dirname(__FILE__), '..', 'bin', 'timetrap')))
1320
+ t = File.open(File.expand_path(File.join(File.dirname(__FILE__), '..', 'bin', 't')))
1321
+ t.read.should == timetrap.read
1322
+ t.stat.mode.should == timetrap.stat.mode
1323
+ end
1324
+ end
1282
1325
  end
metadata CHANGED
@@ -1,169 +1,151 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: timetrap
3
- version: !ruby/object:Gem::Version
4
- hash: 33
5
- prerelease:
6
- segments:
7
- - 1
8
- - 8
9
- - 11
10
- version: 1.8.11
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.8.12
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Sam Goldstein
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2013-12-07 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
11
+ date: 2013-12-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
21
14
  name: bundler
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
26
17
  - - ~>
27
- - !ruby/object:Gem::Version
28
- hash: 9
29
- segments:
30
- - 1
31
- - 3
32
- version: "1.3"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
33
20
  type: :development
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: rake
37
21
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 0
46
- version: "0"
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
47
34
  type: :development
48
- version_requirements: *id002
49
- - !ruby/object:Gem::Dependency
50
- name: rspec
51
35
  prerelease: false
52
- requirement: &id003 !ruby/object:Gem::Requirement
53
- none: false
54
- requirements:
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
55
45
  - - ~>
56
- - !ruby/object:Gem::Version
57
- hash: 25
58
- segments:
59
- - 2
60
- - 13
61
- version: "2.13"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.13'
62
48
  type: :development
63
- version_requirements: *id003
64
- - !ruby/object:Gem::Dependency
65
- name: fakefs
66
49
  prerelease: false
67
- requirement: &id004 !ruby/object:Gem::Requirement
68
- none: false
69
- requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- hash: 3
73
- segments:
74
- - 0
75
- version: "0"
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '2.13'
55
+ - !ruby/object:Gem::Dependency
56
+ name: fakefs
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
76
62
  type: :development
77
- version_requirements: *id004
78
- - !ruby/object:Gem::Dependency
79
- name: icalendar
80
63
  prerelease: false
81
- requirement: &id005 !ruby/object:Gem::Requirement
82
- none: false
83
- requirements:
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: icalendar
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
84
73
  - - ~>
85
- - !ruby/object:Gem::Version
86
- hash: 27
87
- segments:
88
- - 1
89
- - 3
90
- - 0
74
+ - !ruby/object:Gem::Version
91
75
  version: 1.3.0
92
76
  type: :development
93
- version_requirements: *id005
94
- - !ruby/object:Gem::Dependency
95
- name: json
96
77
  prerelease: false
97
- requirement: &id006 !ruby/object:Gem::Requirement
98
- none: false
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- hash: 3
103
- segments:
104
- - 0
105
- version: "0"
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 1.3.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: json
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
106
90
  type: :development
107
- version_requirements: *id006
108
- - !ruby/object:Gem::Dependency
109
- name: sequel
110
91
  prerelease: false
111
- requirement: &id007 !ruby/object:Gem::Requirement
112
- none: false
113
- requirements:
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: sequel
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
114
101
  - - ~>
115
- - !ruby/object:Gem::Version
116
- hash: 63
117
- segments:
118
- - 4
119
- - 0
120
- - 0
102
+ - !ruby/object:Gem::Version
121
103
  version: 4.0.0
122
104
  type: :runtime
123
- version_requirements: *id007
124
- - !ruby/object:Gem::Dependency
125
- name: sqlite3
126
105
  prerelease: false
127
- requirement: &id008 !ruby/object:Gem::Requirement
128
- none: false
129
- requirements:
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: 4.0.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: sqlite3
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
130
115
  - - ~>
131
- - !ruby/object:Gem::Version
132
- hash: 29
133
- segments:
134
- - 1
135
- - 3
136
- - 3
116
+ - !ruby/object:Gem::Version
137
117
  version: 1.3.3
138
118
  type: :runtime
139
- version_requirements: *id008
140
- - !ruby/object:Gem::Dependency
141
- name: chronic
142
119
  prerelease: false
143
- requirement: &id009 !ruby/object:Gem::Requirement
144
- none: false
145
- requirements:
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ version: 1.3.3
125
+ - !ruby/object:Gem::Dependency
126
+ name: chronic
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
146
129
  - - ~>
147
- - !ruby/object:Gem::Version
148
- hash: 51
149
- segments:
150
- - 0
151
- - 10
152
- - 2
130
+ - !ruby/object:Gem::Version
153
131
  version: 0.10.2
154
132
  type: :runtime
155
- version_requirements: *id009
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ~>
137
+ - !ruby/object:Gem::Version
138
+ version: 0.10.2
156
139
  description: Command line time tracker
157
- email:
140
+ email:
158
141
  - sgrock@gmail.org
159
- executables:
142
+ executables:
160
143
  - dev_t
161
144
  - t
145
+ - timetrap
162
146
  extensions: []
163
-
164
147
  extra_rdoc_files: []
165
-
166
- files:
148
+ files:
167
149
  - .gitignore
168
150
  - .rspec
169
151
  - .travis.yml
@@ -172,9 +154,9 @@ files:
172
154
  - LICENSE.txt
173
155
  - README.md
174
156
  - Rakefile
175
- - VERSION.yml
176
157
  - bin/dev_t
177
158
  - bin/t
159
+ - bin/timetrap
178
160
  - completions/bash/timetrap-autocomplete.bash
179
161
  - completions/zsh/_t
180
162
  - lib/Getopt/Declare.rb
@@ -196,37 +178,28 @@ files:
196
178
  - spec/timetrap_spec.rb
197
179
  - timetrap.gemspec
198
180
  homepage: https://github.com/samg/timetrap
199
- licenses:
181
+ licenses:
200
182
  - MIT
183
+ metadata: {}
201
184
  post_install_message:
202
185
  rdoc_options: []
203
-
204
- require_paths:
186
+ require_paths:
205
187
  - lib
206
- required_ruby_version: !ruby/object:Gem::Requirement
207
- none: false
208
- requirements:
209
- - - ">="
210
- - !ruby/object:Gem::Version
211
- hash: 3
212
- segments:
213
- - 0
214
- version: "0"
215
- required_rubygems_version: !ruby/object:Gem::Requirement
216
- none: false
217
- requirements:
218
- - - ">="
219
- - !ruby/object:Gem::Version
220
- hash: 3
221
- segments:
222
- - 0
223
- version: "0"
188
+ required_ruby_version: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - '>='
191
+ - !ruby/object:Gem::Version
192
+ version: '0'
193
+ required_rubygems_version: !ruby/object:Gem::Requirement
194
+ requirements:
195
+ - - '>='
196
+ - !ruby/object:Gem::Version
197
+ version: '0'
224
198
  requirements: []
225
-
226
199
  rubyforge_project:
227
- rubygems_version: 1.8.15
200
+ rubygems_version: 2.0.2
228
201
  signing_key:
229
- specification_version: 3
202
+ specification_version: 4
230
203
  summary: Command line time tracker
231
- test_files:
204
+ test_files:
232
205
  - spec/timetrap_spec.rb
data/VERSION.yml DELETED
@@ -1,4 +0,0 @@
1
- ---
2
- :major: 1
3
- :minor: 8
4
- :patch: 7