doing 1.0.40 → 1.0.45

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
  SHA256:
3
- metadata.gz: e9647740f610a441d3740aa8233e20cfa2b95cce65d047bf046233f7685b1936
4
- data.tar.gz: 99a6dc7fcb96ca1e3a54cedc3e41be3f3d9bdd71f8c6d50c0d2aa4efc5c95ce4
3
+ metadata.gz: 8449bbc0f6d6a8d059856d77abd2f4648544c3bda9e69c75a93a69fd8dffe851
4
+ data.tar.gz: 90c223b97441535bd6cda1563fcbc2dd97197901b9972ceb51989b1f4ad9599c
5
5
  SHA512:
6
- metadata.gz: 53d0c3b2162eaf701b4b7df557446fdf12af0834e6083c7d59b4059f73f098c0339d5a2f72249981227c13f7b3f4f21b3f3cd6286260195a44e989b5899f5f66
7
- data.tar.gz: 9249e276bfd117e47e10a4832ca5ccf376b425fe39ebd34574d0c66e1503483d02655a944dc8cd231106cbbecd39b0ad47ff357713fcbce1a50bf3ce04e555bb
6
+ metadata.gz: a42c67cf02151718f867e98d2a6571c88a7360b2a83c5e529378730364f4b812a4811c8bc03e990b08193fc4503b6f0e3f16b572a21cac1f45d15cb562333755
7
+ data.tar.gz: e0bac7d7dbd30808b9d438be3e4f887ddab05db294dff84467e55b3d3846e246e769b211dd37ff66f8e28c84c97262d23daca5af0445dd25ded03a7446707fef
data/bin/doing CHANGED
@@ -488,6 +488,21 @@ command :finish do |c|
488
488
  end
489
489
  end
490
490
 
491
+ desc 'Repeat last entry as new entry'
492
+ arg_name 'section'
493
+ command [:again,:resume] do |c|
494
+ c.desc 'Section'
495
+ c.flag [:s, :section], :default_value => "All"
496
+
497
+ c.desc 'Note'
498
+ c.arg_name 'note_text'
499
+ c.flag [:n,:note]
500
+
501
+ c.action do |global_options, options, args|
502
+ wwid.restart_last({ section: options[:s], note: options[:n] })
503
+ end
504
+ end
505
+
491
506
  desc 'Tag last entry'
492
507
  arg_name 'tag1 [tag2...]'
493
508
  command :tag do |c|
@@ -555,7 +570,7 @@ command :tag do |c|
555
570
  end
556
571
 
557
572
  desc 'Mark last entry as highlighted'
558
- command :mark do |c|
573
+ command [:mark,:flag] do |c|
559
574
  c.desc 'Section'
560
575
  c.default_value wwid.current_section
561
576
  c.flag [:s,:section], :default_value => wwid.current_section
@@ -1212,7 +1227,7 @@ post do |global,command,options,args|
1212
1227
  if global[:stdout]
1213
1228
  $stdout.print wwid.results.join("\n")
1214
1229
  else
1215
- $stderr.puts wwid.results.join("\n")
1230
+ warn wwid.results.join("\n")
1216
1231
  end
1217
1232
  end
1218
1233
 
data/lib/doing/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Doing
2
- VERSION = '1.0.40'
2
+ VERSION = '1.0.45'
3
3
  end
data/lib/doing/wwid.rb CHANGED
@@ -654,6 +654,62 @@ class WWID
654
654
  end
655
655
  end
656
656
 
657
+ ##
658
+ ## @brief Restart the last entry
659
+ ##
660
+ ## @param opt (Hash) Additional Options
661
+ ##
662
+ def restart_last(opt = {})
663
+ opt[:section] ||= 'all'
664
+ opt[:note] ||= []
665
+
666
+ last = last_entry(opt)
667
+ if last.nil?
668
+ @results.push(%Q{No previous entry found})
669
+ return
670
+ end
671
+ # Remove @done tag
672
+ title = last['title'].sub(/\s*@done(\(.*?\))?/, '').chomp
673
+ add_item(title, last['section'], {:note => opt[:note], :back => opt[:date], :timed => true})
674
+ write(@doing_file)
675
+ end
676
+
677
+ ##
678
+ ## @brief Get the last entry
679
+ ##
680
+ ## @param opt (Hash) Additional Options
681
+ ##
682
+ def last_entry(opt={})
683
+ opt[:section] ||= @current_section
684
+
685
+ sec_arr = []
686
+
687
+ if opt[:section].nil?
688
+ sec_arr = [@current_section]
689
+ elsif opt[:section].class == String
690
+ if opt[:section] =~ /^all$/i
691
+ combined = {'items' => []}
692
+ @content.each {|k,v|
693
+ combined['items'] += v['items']
694
+ }
695
+ items = combined['items'].dup.sort_by{|item| item['date'] }.reverse
696
+ sec_arr.push(items[0]['section'])
697
+
698
+ sec_arr = sections
699
+ else
700
+ sec_arr = [guess_section(opt[:section])]
701
+ end
702
+ end
703
+
704
+
705
+ all_items = []
706
+ sec_arr.each do |section|
707
+ all_items.concat(@content[section]['items'].dup) if @content.has_key?(section)
708
+ end
709
+
710
+ all_items.sort_by { |item| item['date'] }.last
711
+ end
712
+
657
713
  ##
658
714
  ## @brief Tag the last entry or X entries
659
715
  ##
@@ -903,14 +959,23 @@ class WWID
903
959
  if file.nil?
904
960
  $stdout.puts output
905
961
  else
906
- if File.exists?(File.expand_path(file))
962
+ file = File.expand_path(file)
963
+ if File.exists?(file)
907
964
  # Create a backup copy for the undo command
908
965
  FileUtils.cp(file,file+"~")
909
966
 
910
- File.open(File.expand_path(file),'w+') do |f|
967
+ File.open(file,'w+') do |f|
911
968
  f.puts output
912
969
  end
913
970
  end
971
+
972
+ if @config.key?('run_after')
973
+ script = File.expand_path(@config['run_after'])
974
+ if File.exist?(script)
975
+ # warn "Running #{script}"
976
+ `#{script}`
977
+ end
978
+ end
914
979
  end
915
980
  end
916
981
 
@@ -1125,7 +1190,6 @@ class WWID
1125
1190
  }
1126
1191
  out = output.join("")
1127
1192
  elsif opt[:output] == "json" || opt[:output] == "timeline"
1128
-
1129
1193
  items_out = []
1130
1194
  max = items[-1]['date'].strftime('%F')
1131
1195
  min = items[0]['date'].strftime('%F')
@@ -1137,7 +1201,6 @@ class WWID
1137
1201
  title = i['title']
1138
1202
  note = i['note'].map { |line| line.strip } if i['note']
1139
1203
  end
1140
-
1141
1204
  if i['title'] =~ /@done\((\d{4}-\d\d-\d\d \d\d:\d\d.*?)\)/ && opt[:times]
1142
1205
  end_date = Time.parse($1)
1143
1206
  interval = get_interval(i,false)
@@ -1152,14 +1215,16 @@ class WWID
1152
1215
  tags.push(tag[0]) unless skip_tags.include?(tag[0])
1153
1216
  }
1154
1217
  if opt[:output] == "json"
1218
+
1155
1219
  items_out << {
1156
1220
  :date => i['date'],
1157
1221
  :end_date => end_date,
1158
1222
  :title => title.strip, #+ " #{note}"
1159
- :note => note.class == Array ? note.join("\n") : note,
1223
+ :note => note.class == Array ? note.map(&:strip).join("\n") : note,
1160
1224
  :time => "%02d:%02d:%02d" % fmt_time(interval),
1161
1225
  :tags => tags
1162
1226
  }
1227
+
1163
1228
  elsif opt[:output] == "timeline"
1164
1229
  new_item = {
1165
1230
  'id' => index + 1,
@@ -1280,7 +1345,7 @@ EOTEMPLATE
1280
1345
  end
1281
1346
 
1282
1347
  if (item.has_key?('note') && !item['note'].empty?) && @config[:include_notes]
1283
- note_lines = item['note'].delete_if{|line| line =~ /^\s*$/ }.map{|line| "\t" + line.sub(/^\t*/,'') + " " }
1348
+ note_lines = item['note'].delete_if{|line| line =~ /^\s*$/ }.map{|line| "\t\t" + line.sub(/^\t*/,'').sub(/^-/, '—') + " " }
1284
1349
  if opt[:wrap_width] && opt[:wrap_width] > 0
1285
1350
  width = opt[:wrap_width]
1286
1351
  note_lines.map! {|line|
@@ -1607,7 +1672,6 @@ EOTEMPLATE
1607
1672
  ## @param format (String) return format (html, json, or text)
1608
1673
  ##
1609
1674
  def tag_times(format="text", sort_by_name = false)
1610
-
1611
1675
  return "" if @timers.empty?
1612
1676
 
1613
1677
  max = @timers.keys.sort_by {|k| k.length }.reverse[0].length + 1
@@ -1722,7 +1786,7 @@ EOS
1722
1786
  if m.kind_of?(Array)
1723
1787
  index = 1
1724
1788
  m.each {|v|
1725
- new_tag = new_tag.sub('\\' + index.to_s, v)
1789
+ new_tag = new_tag.gsub('\\' + index.to_s, v)
1726
1790
  index = index + 1
1727
1791
  }
1728
1792
  end
@@ -1799,6 +1863,10 @@ EOS
1799
1863
  if seconds.nil?
1800
1864
  return [0, 0, 0]
1801
1865
  end
1866
+ if seconds =~ /(\d+):(\d+):(\d+)/
1867
+ h, m, s = [$1, $2, $3]
1868
+ seconds = (h.to_i * 60 * 60) + (m.to_i * 60) + s.to_i
1869
+ end
1802
1870
  minutes = (seconds / 60).to_i
1803
1871
  hours = (minutes / 60).to_i
1804
1872
  days = (hours / 24).to_i
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doing
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.40
4
+ version: 1.0.45
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-24 00:00:00.000000000 Z
11
+ date: 2021-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake