timetrap 1.12.0 → 1.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 932d2f57b36aa208733e8f99532073b97c224c2e
4
- data.tar.gz: c7664fc5641cbcb202d9d368a97ec48e46fa20de
3
+ metadata.gz: bbc0d7f0e44a53e45a15d6aa657371644c9c12e0
4
+ data.tar.gz: ed4fee1b239512ff12507f976b822b5a8f3a64b7
5
5
  SHA512:
6
- metadata.gz: e7e215bbf435d29824abae93dd2d33bdab1e98ea8fba91400a3f34e3d9b6a04f12749fa426b7e12d3db863edf648a527077d364aa074798d2e9ef2863a970fab
7
- data.tar.gz: 8ca27f988fa422d5044964cae9dff471acd34e4d8f6fd0dbdfd5ef40c6dee1160ffb3fee2d563497a3213724bd9b1eb61d3a181707a0d66ff344747ad157f779
6
+ metadata.gz: bb06b383210f57f21129a7881b632a3e80eafa966470cd38df94d2d742e619a8e4937ea4e981ea6e3a7c454e9f5f4c379ca128685abf40a62988861095be15ed
7
+ data.tar.gz: ff020f3440853d565980b0209807045f48111ad61a18ef21e47228f111007e916d70aa85a9865190828b8772af96228484d16d3a51e07c2a87fd120ec7017613
data/lib/timetrap/cli.rb CHANGED
@@ -246,7 +246,7 @@ COMMAND is one of:
246
246
  if args['-z']
247
247
  note = [entry.note, get_note_from_external_editor].join(Config['append_notes_delimiter'])
248
248
  entry.update :note => note
249
- elsif args.size == 0 # no arguments supplied
249
+ elsif editing_a_note?
250
250
  entry.update :note => get_note_from_external_editor(entry.note)
251
251
  end
252
252
  else
@@ -492,6 +492,15 @@ COMMAND is one of:
492
492
  file.unlink
493
493
  end
494
494
 
495
+ def editing_a_note?
496
+ return true if args.size == 0
497
+
498
+ args.each do |(k,_v)|
499
+ return false unless ["--id", "-i"].include?(k)
500
+ end
501
+ true
502
+ end
503
+
495
504
  extend Helpers::AutoLoad
496
505
  def format_entries(entries)
497
506
  load_formatter(args['-f'] || Config['default_formatter']).new(Array(entries)).output
@@ -1,3 +1,3 @@
1
1
  module Timetrap
2
- VERSION = '1.12.0'
2
+ VERSION = '1.13.0'
3
3
  end
@@ -273,6 +273,39 @@ describe Timetrap do
273
273
  expect(capture).to eq("running entry")
274
274
  end
275
275
 
276
+
277
+ it "should edit a non running entry with an external editor" do |example|
278
+ not_running = Timetrap::Timer.active_entry
279
+ Timetrap::Timer.stop(Timetrap::Timer.current_sheet)
280
+ Timetrap::Timer.start "another entry", nil
281
+
282
+ # create a few more entries to ensure we're not falling back on "last
283
+ # checked out of" feature.
284
+ Timetrap::Timer.stop(Timetrap::Timer.current_sheet)
285
+ Timetrap::Timer.start "another entry", nil
286
+
287
+ Timetrap::Timer.stop(Timetrap::Timer.current_sheet)
288
+
289
+ Timetrap::CLI.stub(:system) do |editor_command|
290
+ path = editor_command.match(/#{note_editor_command} (?<path>.*)/)
291
+ File.write(path[:path], "id passed note")
292
+ end
293
+
294
+ invoke "edit --id #{not_running.id}"
295
+
296
+ not_running.refresh.note.should == "id passed note"
297
+ end
298
+
299
+ it "should not call the editor if there are arguments other than --id" do
300
+ not_running = Timetrap::Timer.active_entry
301
+ Timetrap::Timer.stop(Timetrap::Timer.current_sheet)
302
+ Timetrap::Timer.start "another entry", nil
303
+
304
+ Timetrap::Timer.stop(Timetrap::Timer.current_sheet)
305
+ expect(Timetrap::CLI).not_to receive(:system)
306
+ invoke "edit --id #{not_running.id} --start \"yesterday 10am\""
307
+ end
308
+
276
309
  context "appending" do
277
310
  it "should open an editor for editing the note with -z" do |example|
278
311
  Timetrap::CLI.stub(:system) do |editor_command|
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.12.0
4
+ version: 1.13.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: 2016-08-19 00:00:00.000000000 Z
11
+ date: 2016-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler