Skip to content

Commit

Permalink
Fix autotagging for doing done
Browse files Browse the repository at this point in the history
- FIXED: `doing done ...` wasn't autotagging the new entry
  • Loading branch information
ttscoff committed Jun 29, 2022
1 parent e43ccc0 commit f836faa
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
doing (2.1.58)
doing (2.1.59)
chronic (~> 0.10, >= 0.10.2)
deep_merge (~> 1.2, >= 1.2.1)
gli (~> 2.20, >= 2.20.1)
Expand Down Expand Up @@ -40,7 +40,7 @@ GEM
rdoc (6.3.3)
redcarpet (3.5.1)
rexml (3.2.5)
rouge (3.28.0)
rouge (3.29.0)
safe_yaml (1.0.5)
strings (0.2.1)
strings-ansi (~> 0.2)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ _If you're one of the rare people like me who find this useful, feel free to

<!--README-->

The current version of `doing` is <!--VER-->2.1.57<!--END VER-->.
The current version of `doing` is <!--VER-->2.1.58<!--END VER-->.

Find all of the documentation in the [doing wiki][wiki].

Expand Down
17 changes: 13 additions & 4 deletions bin/commands/done.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,14 @@
section = Doing.setting('current_section')
end


note = Doing::Note.new
note.add(options[:note]) if options[:note]

if options[:ask] && !options[:editor]
note.add(Doing::Prompt.read_lines(prompt: 'Add a note'))
end
note.add(Doing::Prompt.read_lines(prompt: 'Add a note')) if options[:ask] && !options[:editor]

if options[:editor]
raise MissingEditor, 'No EDITOR variable defined in environment' if Doing::Util.default_editor.nil?

is_new = false

if args.empty?
Expand Down Expand Up @@ -122,6 +120,11 @@
note.add(ask_note) if ask_note.good?
end

if Doing.auto_tag
title = @wwid.autotag(title)
title.add_tags!(Doing.setting('default_tags')) if Doing.setting('default_tags').good?
end

date = d.nil? ? date : d
new_entry = Doing::Item.new(date, title, section, note)
if new_entry.should_finish?
Expand Down Expand Up @@ -171,6 +174,12 @@
new_note.add(options[:note])
title.chomp!
section = 'Archive' if options[:archive]

if Doing.auto_tag
title = @wwid.autotag(title)
title.add_tags!(Doing.setting('default_tags')) if Doing.setting('default_tags').good?
end

new_entry = Doing::Item.new(date, title, section, new_note)

if new_entry.should_finish?
Expand Down
11 changes: 11 additions & 0 deletions lib/doing/completion/completion_string.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
module Doing
module Completion
module StringUtils

##
## Get short description for command completion
##
## @return [String] Short description
##
def short_desc
split(/[,.]/)[0].sub(/ \(.*?\)?$/, '').strip
end

##
## Truncate string from left
##
## @param max The maximum number of characters
##
def ltrunc(max)
if length > max
sub(/^.*?(.{#{max - 3}})$/, '...\1')
Expand Down
10 changes: 10 additions & 0 deletions lib/doing/string/query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,23 @@ def to_rx(distance: nil, case_type: nil)
Regexp.new(pattern, !case_sensitive)
end

##
## Returns a phrase query (elastic search) representation of the object as a phrase parser.
##
## @return Phrase query representation of the object.
##
def to_phrase_query
parser = PhraseParser::QueryParser.new
transformer = PhraseParser::QueryTransformer.new
parse_tree = parser.parse(self)
transformer.apply(parse_tree).to_elasticsearch
end

##
## Returns a query (elastic search) representation of the object as a boolean term parser.
##
## @return Query representation of the object.
##
def to_query
parser = BooleanTermParser::QueryParser.new
transformer = BooleanTermParser::QueryTransformer.new
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 = '2.1.58'
VERSION = '2.1.59'
end
1 change: 0 additions & 1 deletion lib/doing/wwid/modify.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ def repeat_last(opt)
write(@doing_file)
end


##
## Tag the last entry or X entries
##
Expand Down

0 comments on commit f836faa

Please sign in to comment.