Skip to content

Commit

Permalink
release prep
Browse files Browse the repository at this point in the history
  • Loading branch information
ttscoff committed Jul 7, 2021
1 parent 3fcbeb4 commit 5bb6229
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 132 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.59

#### IMPROVED

- Improvements to `doing again --tag=` functionality

### 1.0.58

#### 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.57<!--END VER-->.
The current version of `doing` is <!--VER-->1.0.58<!--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.58'
VERSION = '1.0.59'
end
23 changes: 2 additions & 21 deletions lib/doing/wwid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require 'deep_merge'
require 'open3'
require 'pp'

##
## @brief Hash helpers
Expand Down Expand Up @@ -890,34 +891,14 @@ def tag_last(opt = {})
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 = old_item['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

##
Expand Down
51 changes: 43 additions & 8 deletions test/doing_task_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,41 @@ def teardown
FileUtils.rm_rf(@tmpdirs)
end

def test_section_rejects_empty_args
assert_raises(RuntimeError) { doing('now', '--section') }
end

def test_new_task
# Add a task
subject = 'Test new task @tag1'
doing('now', subject)
assert_match(/#{subject}\s*$/, doing('show', '-c 1'), 'should have added task')
end

def test_new_task_finishing_last
subject = 'Test new task'
subject2 = 'Another task'
doing('now', subject)
doing('now', '--finish_last', subject2)
assert_matches([
[/#{subject} @done/, 'First task should be @done'],
[/#{subject2}\s*$/, 'Second task should be added']
], doing('show'))
end

def test_section_rejects_empty_args
assert_raises(RuntimeError) { doing('now', '--section') }
end

def test_add_section
doing('add_section', 'Test Section')
assert_match(/^Test Section$/, doing('sections', '-c'), 'should have added section')
end

def test_add_to_section
section = 'Test Section'
subject = 'Test task @testtag'
doing('add_section', section)
doing('now', '--section', section, subject)
assert_match(/#{subject}/, doing('show', section), 'Task should exist in new section')
end

def test_done_task
subject = 'Test finished task @tag1'
now = Time.now.round_time(1)
Expand Down Expand Up @@ -74,16 +98,17 @@ def test_finish_tag
def test_later_task
subject = 'Test later task'
result = doing('--stdout', 'later', subject)
assert_match(/Added section "Later"/, result, 'should have added Later section')
assert_match(/Added "#{subject}" to Later/, result, 'should have added task to Later section')
assert_matches([
[/Added section "Later"/, 'should have added Later section'],
[/Added "#{subject}" to Later/, 'should have added task to Later section']
], result)
assert_equal(1, doing('show', 'later').uncolor.strip.split("\n").count, 'Later section should have 1 entry')
end

def test_cancel_task
doing('now', 'Test task')
doing('cancel')
result = doing('show')
assert_match(/@done$/, result, 'should have @done tag with no timestamp')
assert_match(/@done$/, doing('show'), 'should have @done tag with no timestamp')
end

def test_archive_task
Expand All @@ -97,6 +122,16 @@ def test_archive_task

private

def assert_matches(matches, shown)
matches.each do |regexp, msg, opt_refute|
if opt_refute
assert_no_match(regexp, shown, msg)
else
assert_match(regexp, shown, msg)
end
end
end

def mktmpdir
tmpdir = Dir.mktmpdir
@tmpdirs.push(tmpdir)
Expand Down
101 changes: 0 additions & 101 deletions test/note_editor_test.rb

This file was deleted.

0 comments on commit 5bb6229

Please sign in to comment.