Skip to content

Commit

Permalink
release prep
Browse files Browse the repository at this point in the history
  • Loading branch information
ttscoff committed Jul 6, 2021
1 parent 739bf91 commit 3fcbeb4
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 16 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### 1.0.58

#### IMPROVED

- Finish previous task if `doing again` and not already completed

### 1.0.57

#### IMPROVED
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ _Side note:_ I actually use the library behind this utility as part of another s

## Installation

The current version of `doing` is <!--VER-->1.0.56<!--END VER-->.
The current version of `doing` is <!--VER-->1.0.57<!--END VER-->.

$ [sudo] gem install doing

Expand Down
2 changes: 1 addition & 1 deletion lib/doing/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Doing
VERSION = '1.0.57'
VERSION = '1.0.58'
end
47 changes: 41 additions & 6 deletions lib/doing/wwid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,11 @@ def restart_last(opt = {})
@results.push(%(No previous entry found))
return
end
unless last.has_tags?(['done'], 'ALL')
new_item = last.dup
new_item['title'] += " @done(#{Time.now.strftime('%F %R')})"
update_item(last, new_item)
end
# Remove @done tag
title = last['title'].sub(/\s*@done(\(.*?\))?/, '').chomp
section = opt[:in].nil? ? last['section'] : guess_section(opt[:in])
Expand Down Expand Up @@ -736,8 +741,6 @@ def last_entry(opt = {})
end
items = combined['items'].dup.sort_by { |item| item['date'] }.reverse
sec_arr.push(items[0]['section'])

sec_arr = sections
else
sec_arr = [guess_section(opt[:section])]
end
Expand Down Expand Up @@ -800,12 +803,12 @@ def tag_last(opt = {})
if @content.key?(section)

items = @content[section]['items'].dup.sort_by { |item| item['date'] }.reverse
index = 0
idx = 0
done_date = Time.now
next_start = Time.now
count = (opt[:count]).zero? ? items.length : opt[:count]
items.map! do |item|
break if index == count
break if idx == count

tag_match = opt[:tag].nil? || opt[:tag].empty? ? true : item.has_tags?(opt[:tag], opt[:tag_bool])
search_match = opt[:search].nil? || opt[:search].empty? ? true : item.matches_search?(opt[:search])
Expand Down Expand Up @@ -854,7 +857,7 @@ def tag_last(opt = {})
item['title'] = title
end

index += 1
idx += 1
end

item
Expand Down Expand Up @@ -886,6 +889,37 @@ def tag_last(opt = {})
write(@doing_file)
end

def update_item(old_item, new_item)
items = []
@content.each do |_k, v|
items.concat(v['items'])
end

idx = nil

items.each_with_index do |item, i|
if old_item == item
idx = i
break
end
end

if idx.nil?
@results.push('No entries found')
return
end

section = items[idx]['section']

section_items = @content[section]['items']
s_idx = section_items.index(old_item)

section_items[s_idx] = new_item
@results.push("Entry updated: #{section_items[s_idx]['title']}")
@content[section]['items'] = section_items
write(@doing_file)
end

##
## @brief Edit the last entry
##
Expand Down Expand Up @@ -1014,7 +1048,8 @@ def note_last(section, note, replace: false)
# @param tag (String) Tag to replace
# @param opt (Hash) Additional Options
#
def stop_start(tag, opt = {})
def stop_start(target_tag, opt = {})
tag = target_tag.dup
opt[:section] ||= @current_section
opt[:archive] ||= false
opt[:back] ||= Time.now
Expand Down
18 changes: 10 additions & 8 deletions test/doing_task_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ def test_finish_task
'Finished time should be equal to the nearest minute')
end

def test_finish_tag
doing('now', 'Test new task @tag1')
doing('now', 'Another new task @tag2')
doing('finish', '--tag', 'tag1')
t1 = doing('show', '@tag1').uncolor.strip
assert_match(ENTRY_DONE_REGEX, t1, "@tag1 task should have @done timestamp")
t2 = doing('show', '@tag2').uncolor.strip
assert_no_match(ENTRY_DONE_REGEX, t2, "@tag2 task should not have @done timestamp")
end

def test_later_task
subject = 'Test later task'
result = doing('--stdout', 'later', subject)
Expand All @@ -76,14 +86,6 @@ def test_cancel_task
assert_match(/@done$/, result, 'should have @done tag with no timestamp')
end

def test_resume_task
subject = 'Test task'
doing('done', subject)
result = doing('--stdout', 'again')

assert_match(/Added "#{subject}" to Currently/, result, 'Task should be added again')
end

def test_archive_task
subject = 'Test task'
doing('done', subject)
Expand Down

0 comments on commit 3fcbeb4

Please sign in to comment.