doing 1.0.84 → 1.0.85
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/README.md +1 -1
- data/bin/doing +19 -12
- data/lib/doing/version.rb +1 -1
- data/lib/doing/wwid.rb +47 -13
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f11196376a7860f14164c80a107ce4151b18399f785cd607ba4f3a27205828fb
|
4
|
+
data.tar.gz: 1033e528416e1e3660db44ae55973009aa9b766f2566c0ff6e4bb942fdce4c05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db7dc195eedf329ec7aad7e29830cf0d42c57178570a4675ce607e29761f733d2371b390f8c8ea73425a86240a28a91f7e05842ad9b49dd89257affbca12e5e6
|
7
|
+
data.tar.gz: 2b992ffea5a41c6f81ab7b5b1fb9b244197cca7eb1d7bbbae1eb6f9911db6ee16293b19e32c8c0b31cd03a3e181c4df9f8e1de893cc37c479fa2bdfd4accf6c4
|
data/README.md
CHANGED
@@ -27,7 +27,7 @@ If there's something I want to look at later but doesn't need to be added to a t
|
|
27
27
|
|
28
28
|
## Installation
|
29
29
|
|
30
|
-
The current version of `doing` is <!--VER-->1.0.
|
30
|
+
The current version of `doing` is <!--VER-->1.0.84<!--END VER-->.
|
31
31
|
|
32
32
|
$ [sudo] gem install doing
|
33
33
|
|
data/bin/doing
CHANGED
@@ -333,10 +333,6 @@ command :later do |c|
|
|
333
333
|
c.desc "Edit entry with #{ENV['EDITOR']}"
|
334
334
|
c.switch %i[e editor], negatable: false, default_value: false
|
335
335
|
|
336
|
-
c.desc 'Edit entry with specified app'
|
337
|
-
c.arg_name 'APP'
|
338
|
-
c.flag %i[a app]
|
339
|
-
|
340
336
|
c.desc 'Backdate start time to date string [4pm|20m|2h|yesterday noon]'
|
341
337
|
c.arg_name 'DATE_STRING'
|
342
338
|
c.flag %i[b back]
|
@@ -353,7 +349,7 @@ command :later do |c|
|
|
353
349
|
date = Time.now
|
354
350
|
end
|
355
351
|
|
356
|
-
if options[:
|
352
|
+
if options[:editor] || (args.empty? && $stdin.stat.size.zero?)
|
357
353
|
exit_now! 'No EDITOR variable defined in environment' if ENV['EDITOR'].nil?
|
358
354
|
|
359
355
|
input = args.empty? ? '' : args.join(' ')
|
@@ -456,7 +452,7 @@ command %i[done did] do |c|
|
|
456
452
|
section = wwid.config['current_section']
|
457
453
|
end
|
458
454
|
|
459
|
-
if options[:
|
455
|
+
if options[:editor]
|
460
456
|
exit_now! 'No EDITOR variable defined in environment' if ENV['EDITOR'].nil?
|
461
457
|
|
462
458
|
input = ''
|
@@ -1321,7 +1317,7 @@ command :last do |c|
|
|
1321
1317
|
|
1322
1318
|
end
|
1323
1319
|
|
1324
|
-
if options[:
|
1320
|
+
if options[:editor]
|
1325
1321
|
wwid.edit_last(section: options[:s], options: { search: options[:search], tag: tags, tag_bool: options[:bool] })
|
1326
1322
|
else
|
1327
1323
|
puts wwid.last(times: true, section: options[:s],
|
@@ -1554,6 +1550,11 @@ command :archive do |c|
|
|
1554
1550
|
c.arg_name 'QUERY'
|
1555
1551
|
c.flag [:search]
|
1556
1552
|
|
1553
|
+
c.desc 'Archive entries older than date
|
1554
|
+
(Flexible date format, e.g. 1/27/2021, 2020-07-19, or Monday 3pm)'
|
1555
|
+
c.arg_name 'DATE_STRING'
|
1556
|
+
c.flag [:before]
|
1557
|
+
|
1557
1558
|
c.action do |_global_options, options, args|
|
1558
1559
|
if args.empty?
|
1559
1560
|
section = wwid.current_section
|
@@ -1583,6 +1584,7 @@ command :archive do |c|
|
|
1583
1584
|
'AND'
|
1584
1585
|
end
|
1585
1586
|
opts = {
|
1587
|
+
before: options[:before],
|
1586
1588
|
bool: options[:bool],
|
1587
1589
|
destination: options[:to],
|
1588
1590
|
keep: options[:keep],
|
@@ -1615,6 +1617,11 @@ command :rotate do |c|
|
|
1615
1617
|
c.arg_name 'QUERY'
|
1616
1618
|
c.flag [:search]
|
1617
1619
|
|
1620
|
+
c.desc 'Rotate entries older than date
|
1621
|
+
(Flexible date format, e.g. 1/27/2021, 2020-07-19, or Monday 3pm)'
|
1622
|
+
c.arg_name 'DATE_STRING'
|
1623
|
+
c.flag [:before]
|
1624
|
+
|
1618
1625
|
c.action do |_global_options, options, args|
|
1619
1626
|
if options[:section] && options[:section] !~ /^all$/i
|
1620
1627
|
options[:section] = wwid.guess_section(options[:section])
|
@@ -1641,11 +1648,11 @@ command :open do |c|
|
|
1641
1648
|
if `uname` =~ /Darwin/
|
1642
1649
|
c.desc 'Open with app name'
|
1643
1650
|
c.arg_name 'APP_NAME'
|
1644
|
-
c.flag [
|
1651
|
+
c.flag %i[a app]
|
1645
1652
|
|
1646
1653
|
c.desc 'Open with app bundle id'
|
1647
1654
|
c.arg_name 'BUNDLE_ID'
|
1648
|
-
c.flag [
|
1655
|
+
c.flag %i[b bundle_id]
|
1649
1656
|
end
|
1650
1657
|
c.desc "Open with $EDITOR (#{ENV['EDITOR']})"
|
1651
1658
|
c.switch %i[e editor], negatable: false, default_value: false
|
@@ -1656,11 +1663,11 @@ command :open do |c|
|
|
1656
1663
|
k.instance_of?(String) || v.nil? || v == false
|
1657
1664
|
end
|
1658
1665
|
if `uname` =~ /Darwin/
|
1659
|
-
if options[:
|
1666
|
+
if options[:app]
|
1660
1667
|
system %(open -a "#{options[:a]}" "#{File.expand_path(wwid.doing_file)}")
|
1661
|
-
elsif options[:
|
1668
|
+
elsif options[:bundle_id]
|
1662
1669
|
system %(open -b "#{options[:b]}" "#{File.expand_path(wwid.doing_file)}")
|
1663
|
-
elsif options[:
|
1670
|
+
elsif options[:editor]
|
1664
1671
|
exit_now! 'No EDITOR variable defined in environment' if ENV['EDITOR'].nil?
|
1665
1672
|
|
1666
1673
|
system %($EDITOR "#{File.expand_path(wwid.doing_file)}")
|
data/lib/doing/version.rb
CHANGED
data/lib/doing/wwid.rb
CHANGED
@@ -1100,7 +1100,6 @@ class WWID
|
|
1100
1100
|
items = @content[section]['items'].dup.sort_by { |item| item['date'] }.reverse
|
1101
1101
|
idx = 0
|
1102
1102
|
done_date = Time.now
|
1103
|
-
next_start = Time.now
|
1104
1103
|
count = (opt[:count]).zero? ? items.length : opt[:count]
|
1105
1104
|
items.map! do |item|
|
1106
1105
|
break if idx == count
|
@@ -1119,8 +1118,8 @@ class WWID
|
|
1119
1118
|
end
|
1120
1119
|
else
|
1121
1120
|
if opt[:sequential]
|
1122
|
-
|
1123
|
-
|
1121
|
+
next_entry = next_item(item)
|
1122
|
+
done_date = next_entry['date'] - 60 if next_entry
|
1124
1123
|
elsif opt[:took]
|
1125
1124
|
if item['date'] + opt[:took] > Time.now
|
1126
1125
|
item['date'] = Time.now - opt[:took]
|
@@ -1209,6 +1208,24 @@ class WWID
|
|
1209
1208
|
return new_item
|
1210
1209
|
end
|
1211
1210
|
|
1211
|
+
##
|
1212
|
+
## @brief Get next item in the index
|
1213
|
+
##
|
1214
|
+
## @param old_item
|
1215
|
+
##
|
1216
|
+
def next_item(old_item)
|
1217
|
+
section = old_item['section']
|
1218
|
+
|
1219
|
+
section_items = @content[section]['items'].sort_by { |entry| entry['date'] }
|
1220
|
+
idx = section_items.index(old_item)
|
1221
|
+
|
1222
|
+
if section_items.size > idx
|
1223
|
+
section_items[idx + 1]
|
1224
|
+
else
|
1225
|
+
nil
|
1226
|
+
end
|
1227
|
+
end
|
1228
|
+
|
1212
1229
|
##
|
1213
1230
|
## @brief Delete an item from the index
|
1214
1231
|
##
|
@@ -1478,7 +1495,7 @@ class WWID
|
|
1478
1495
|
##
|
1479
1496
|
## @param file (String) The filepath to write to
|
1480
1497
|
##
|
1481
|
-
def write(file = nil)
|
1498
|
+
def write(file = nil, backup: true)
|
1482
1499
|
output = @other_content_top ? "#{@other_content_top.join("\n")}\n" : ''
|
1483
1500
|
|
1484
1501
|
@content.each do |title, section|
|
@@ -1490,7 +1507,7 @@ class WWID
|
|
1490
1507
|
$stdout.puts output
|
1491
1508
|
else
|
1492
1509
|
file = File.expand_path(file)
|
1493
|
-
if File.exist?(file)
|
1510
|
+
if File.exist?(file) && backup
|
1494
1511
|
# Create a backup copy for the undo command
|
1495
1512
|
FileUtils.cp(file, "#{file}~")
|
1496
1513
|
end
|
@@ -1549,9 +1566,15 @@ class WWID
|
|
1549
1566
|
new_content[section]['items'] = []
|
1550
1567
|
|
1551
1568
|
moved_items = []
|
1552
|
-
if !tags.empty? || opt[:search]
|
1569
|
+
if !tags.empty? || opt[:search] || opt[:before]
|
1570
|
+
if opt[:before]
|
1571
|
+
time_string = opt[:before]
|
1572
|
+
time_string += ' 12am' if time_string !~ /(\d+:\d+|\d+[ap])/
|
1573
|
+
cutoff = chronify(time_string)
|
1574
|
+
end
|
1575
|
+
|
1553
1576
|
items.delete_if do |item|
|
1554
|
-
if ((!tags.empty? && item.has_tags?(tags, bool)) || (opt[:search] && item.matches_search?(opt[:search].to_s)))
|
1577
|
+
if ((!tags.empty? && item.has_tags?(tags, bool)) || (opt[:search] && item.matches_search?(opt[:search].to_s)) || (opt[:before] && item['date'] < cutoff))
|
1555
1578
|
moved_items.push(item)
|
1556
1579
|
counter += 1
|
1557
1580
|
true
|
@@ -1587,10 +1610,15 @@ class WWID
|
|
1587
1610
|
|
1588
1611
|
write(@doing_file)
|
1589
1612
|
|
1590
|
-
file = @doing_file.sub(/(\.\w+)$/, "_#{Time.now.strftime('%Y-%m-%d
|
1591
|
-
|
1613
|
+
file = @doing_file.sub(/(\.\w+)$/, "_#{Time.now.strftime('%Y-%m-%d')}\\1")
|
1614
|
+
if File.exist?(file)
|
1615
|
+
init_doing_file(file)
|
1616
|
+
@content.deep_merge(new_content)
|
1617
|
+
else
|
1618
|
+
@content = new_content
|
1619
|
+
end
|
1592
1620
|
|
1593
|
-
write(file)
|
1621
|
+
write(file, backup: false)
|
1594
1622
|
end
|
1595
1623
|
|
1596
1624
|
##
|
@@ -2012,7 +2040,7 @@ class WWID
|
|
2012
2040
|
destination = guess_section(destination)
|
2013
2041
|
|
2014
2042
|
if sections.include?(destination) && (sections.include?(section) || archive_all)
|
2015
|
-
do_archive(section, destination, { count: count, tags: tags, bool: bool, search: options[:search], label: options[:label] })
|
2043
|
+
do_archive(section, destination, { count: count, tags: tags, bool: bool, search: options[:search], label: options[:label], before: options[:before] })
|
2016
2044
|
write(doing_file)
|
2017
2045
|
else
|
2018
2046
|
exit_now! 'Either source or destination does not exist'
|
@@ -2045,9 +2073,15 @@ class WWID
|
|
2045
2073
|
items = @content[section]['items'].dup
|
2046
2074
|
|
2047
2075
|
moved_items = []
|
2048
|
-
if !tags.empty? || opt[:search]
|
2076
|
+
if !tags.empty? || opt[:search] || opt[:before]
|
2077
|
+
if opt[:before]
|
2078
|
+
time_string = opt[:before]
|
2079
|
+
time_string += ' 12am' if time_string !~ /(\d+:\d+|\d+[ap])/
|
2080
|
+
cutoff = chronify(time_string)
|
2081
|
+
end
|
2082
|
+
|
2049
2083
|
items.delete_if do |item|
|
2050
|
-
if (!tags.empty? && item.has_tags?(tags, bool) || (opt[:search] && item.matches_search?(opt[:search].to_s)))
|
2084
|
+
if ((!tags.empty? && item.has_tags?(tags, bool)) || (opt[:search] && item.matches_search?(opt[:search].to_s)) || (opt[:before] && item['date'] < cutoff))
|
2051
2085
|
moved_items.push(item)
|
2052
2086
|
counter += 1
|
2053
2087
|
true
|