doing 1.0.57 → 1.0.58

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: 749d71c6201256bf524d3ba0f543e11b7bcc421ee97bf951bd003242edba3847
4
- data.tar.gz: 2ec5d4cade4b81614bf336fe6ddf63b35b9bbe0064c5c910b9f275e7f8e0945f
3
+ metadata.gz: 27d29fb84f196b9219119d876aad52a8d4569b12324ece7617b74636d4245885
4
+ data.tar.gz: 40ed7d9d336b757d777dfa7014e754f115d732835a0a62c4e6a72ce9102c4a7f
5
5
  SHA512:
6
- metadata.gz: 2b7d5d7f24ff24701ce94d61311cd4b37ae547258a26193e28d16847d49743b5334e1e4c79145be43819fee1ee67f30d75979d7d26447bbd192a8211c2f63d80
7
- data.tar.gz: 2b0f4326f8b53a6c0da004a323881bbfff3dad10701a19fd7dc10e5f852e22a541644ac13d6a7c860ab0bac5118520df4366272dd7d93376c1adecbe96e2a152
6
+ metadata.gz: de8702acf70b5ea8382cf848b65b5164c2230e7f19b893032d4216fc225d596290146a8f461aae4d215a5021f1a0a4129b12750b119f324032f4e206819bfd3d
7
+ data.tar.gz: a52d1d2f07988441a14f5451206bfb9add306a9cf3b7bd0908b493c5076b5c720d8d26285bc5634f6e23db9ff81e670cd56c20e514bd5163ce82cab950a659dd
data/README.md CHANGED
@@ -29,7 +29,7 @@ _Side note:_ I actually use the library behind this utility as part of another s
29
29
 
30
30
  ## Installation
31
31
 
32
- The current version of `doing` is <!--VER-->1.0.56<!--END VER-->.
32
+ The current version of `doing` is <!--VER-->1.0.57<!--END VER-->.
33
33
 
34
34
  $ [sudo] gem install doing
35
35
 
data/lib/doing/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Doing
2
- VERSION = '1.0.57'
2
+ VERSION = '1.0.58'
3
3
  end
data/lib/doing/wwid.rb CHANGED
@@ -707,6 +707,11 @@ class WWID
707
707
  @results.push(%(No previous entry found))
708
708
  return
709
709
  end
710
+ unless last.has_tags?(['done'], 'ALL')
711
+ new_item = last.dup
712
+ new_item['title'] += " @done(#{Time.now.strftime('%F %R')})"
713
+ update_item(last, new_item)
714
+ end
710
715
  # Remove @done tag
711
716
  title = last['title'].sub(/\s*@done(\(.*?\))?/, '').chomp
712
717
  section = opt[:in].nil? ? last['section'] : guess_section(opt[:in])
@@ -736,8 +741,6 @@ class WWID
736
741
  end
737
742
  items = combined['items'].dup.sort_by { |item| item['date'] }.reverse
738
743
  sec_arr.push(items[0]['section'])
739
-
740
- sec_arr = sections
741
744
  else
742
745
  sec_arr = [guess_section(opt[:section])]
743
746
  end
@@ -800,12 +803,12 @@ class WWID
800
803
  if @content.key?(section)
801
804
 
802
805
  items = @content[section]['items'].dup.sort_by { |item| item['date'] }.reverse
803
- index = 0
806
+ idx = 0
804
807
  done_date = Time.now
805
808
  next_start = Time.now
806
809
  count = (opt[:count]).zero? ? items.length : opt[:count]
807
810
  items.map! do |item|
808
- break if index == count
811
+ break if idx == count
809
812
 
810
813
  tag_match = opt[:tag].nil? || opt[:tag].empty? ? true : item.has_tags?(opt[:tag], opt[:tag_bool])
811
814
  search_match = opt[:search].nil? || opt[:search].empty? ? true : item.matches_search?(opt[:search])
@@ -854,7 +857,7 @@ class WWID
854
857
  item['title'] = title
855
858
  end
856
859
 
857
- index += 1
860
+ idx += 1
858
861
  end
859
862
 
860
863
  item
@@ -886,6 +889,37 @@ class WWID
886
889
  write(@doing_file)
887
890
  end
888
891
 
892
+ def update_item(old_item, new_item)
893
+ items = []
894
+ @content.each do |_k, v|
895
+ items.concat(v['items'])
896
+ end
897
+
898
+ idx = nil
899
+
900
+ items.each_with_index do |item, i|
901
+ if old_item == item
902
+ idx = i
903
+ break
904
+ end
905
+ end
906
+
907
+ if idx.nil?
908
+ @results.push('No entries found')
909
+ return
910
+ end
911
+
912
+ section = items[idx]['section']
913
+
914
+ section_items = @content[section]['items']
915
+ s_idx = section_items.index(old_item)
916
+
917
+ section_items[s_idx] = new_item
918
+ @results.push("Entry updated: #{section_items[s_idx]['title']}")
919
+ @content[section]['items'] = section_items
920
+ write(@doing_file)
921
+ end
922
+
889
923
  ##
890
924
  ## @brief Edit the last entry
891
925
  ##
@@ -1014,7 +1048,8 @@ class WWID
1014
1048
  # @param tag (String) Tag to replace
1015
1049
  # @param opt (Hash) Additional Options
1016
1050
  #
1017
- def stop_start(tag, opt = {})
1051
+ def stop_start(target_tag, opt = {})
1052
+ tag = target_tag.dup
1018
1053
  opt[:section] ||= @current_section
1019
1054
  opt[:archive] ||= false
1020
1055
  opt[:back] ||= Time.now
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doing
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.57
4
+ version: 1.0.58
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra