na 1.2.7 → 1.2.8

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: 77270e07e7c7d4332a5fb8ec87f4e9ad5496bd220d188e75adfb71026aff1180
4
- data.tar.gz: a3521feaefc9573bd78344b6a16ae57719284bde611e8f9f6e664238fcc1b5c3
3
+ metadata.gz: a5d95b5e069cbe51ad597f9af95744a84590e9513d28dd53c5710c477c59e19e
4
+ data.tar.gz: bbaefe5d4151348443260a940f143e83d5514967886caa8d4a0e5848f01860a1
5
5
  SHA512:
6
- metadata.gz: 2a714a764879036b9ad51626445e9ef920909da333e3fc6ecb18b8b3755cf8afad811c7baf1e3aea622a5d74b1ca41e1cf64c43541f772db9ae50cfc03c1de90
7
- data.tar.gz: 06b865817db9731ded06c415f5c71a10a2f8b928b0f6da5ee9cca083f951e35ee716eaf6e2558daf89ec5378910286be4304fbdbe67e17756eae2be553fee0ea
6
+ metadata.gz: 9747348a856378659ab51925aace1eb7f0e056003e6f3a06bc53cb23c3f954f3b2cbd60b4c598db4e2e537052be665eda10871718f2aa517b19d9ef28a2ab82a
7
+ data.tar.gz: 7d2dff9e215a1e05a70aa31a0abb10d98d8a2937936192c74a6f952c195e292b8f24bffd5968a0d2190b7f0548ffaaeb699c10066781566f68950ca62a0314d7
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ### 1.2.8
2
+
3
+ 2022-10-28 11:52
4
+
5
+ #### IMPROVED
6
+
7
+ - Empty lines in notes end a task in the parser
8
+ - Moving a task to the end of a project respects line breaks
9
+
10
+ #### FIXED
11
+
12
+ - Moving action within same project to end not parsing correctly
13
+
1
14
  ### 1.2.7
2
15
 
3
16
  2022-10-28 07:29
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- na (1.2.7)
4
+ na (1.2.8)
5
5
  chronic (~> 0.10, >= 0.10.2)
6
6
  gli (~> 2.21.0)
7
7
  mdless (~> 1.0, >= 1.0.32)
data/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  _If you're one of the rare people like me who find this useful, feel free to
10
10
  [buy me some coffee][donate]._
11
11
 
12
- The current version of `na` is 1.2.7
12
+ The current version of `na` is 1.2.8
13
13
  .
14
14
 
15
15
  `na` ("next action") is a command line tool designed to make it easy to see what your next actions are for any project, right from the command line. It works with TaskPaper-formatted files (but any plain text format will do), looking for `@na` tags (or whatever you specify) in todo files in your current folder.
@@ -77,11 +77,11 @@ SYNOPSIS
77
77
  na [global options] command [command options] [arguments...]
78
78
 
79
79
  VERSION
80
- 1.2.7
80
+ 1.2.8
81
81
 
82
82
  GLOBAL OPTIONS
83
83
  -a, --[no-]add - Add a next action (deprecated, for backwards compatibility)
84
- --add_at=POSITION - Add all new/moved entries at [s]tart or [e]nd of target project (default: end)
84
+ --add_at=POSITION - Add all new/moved entries at [s]tart or [e]nd of target project (default: start)
85
85
  --cwd_as=TYPE - Use current working directory as [p]roject, [t]ag, or [n]one (default: none)
86
86
  -d, --depth=DEPTH - Recurse to depth (default: 3)
87
87
  --[no-]debug - Display verbose output
@@ -127,7 +127,9 @@ module NA
127
127
 
128
128
  def shift_index_after(projects, idx, length = 1)
129
129
  projects.map do |proj|
130
- proj.line = proj.line > idx ? proj.line - length : proj.line
130
+ proj.line = proj.line - length if proj.line > idx
131
+ proj.last_line = proj.last_line - length if proj.last_line > idx
132
+
131
133
  proj
132
134
  end
133
135
  end
@@ -196,7 +198,7 @@ module NA
196
198
  content = "#{input.join("\n")}\n#{content}"
197
199
  end
198
200
 
199
- new_project = NA::Project.new(path.map(&:cap_first).join(':'), indent - 1, input.count - 1)
201
+ new_project = NA::Project.new(path.map(&:cap_first).join(':'), indent - 1, input.count - 1, input.count - 1)
200
202
  else
201
203
  line = final_match.line + 1
202
204
  indent = final_match.indent + 1
@@ -206,7 +208,7 @@ module NA
206
208
  indent += 1
207
209
  end
208
210
  content = content.split("\n").insert(line, input.join("\n")).join("\n")
209
- new_project = NA::Project.new(path.map(&:cap_first).join(':'), indent - 1, line + input.count - 1)
211
+ new_project = NA::Project.new(path.map(&:cap_first).join(':'), indent - 1, line + input.count - 1, line + input.count - 1)
210
212
  end
211
213
 
212
214
  File.open(target, 'w') do |f|
@@ -307,19 +309,18 @@ module NA
307
309
  break
308
310
  end
309
311
  end
310
-
311
312
  target_line = if this_idx == projects.length - 1
312
313
  contents.count
313
314
  else
314
- projects[this_idx + 1].line - 1
315
+ projects[this_idx].last_line + 1
315
316
  end
316
317
  else
317
- target_line = target_proj.line
318
+ target_line = target_proj.line + 1
318
319
  end
319
320
 
320
321
  contents.insert(target_line, "#{indent}\t- #{action.action}#{note}")
321
322
  else
322
- projects, actions = find_actions(target, search, tagged, done: done, all: all)
323
+ _, actions = find_actions(target, search, tagged, done: done, all: all)
323
324
 
324
325
  return if actions.nil?
325
326
 
@@ -329,6 +330,8 @@ module NA
329
330
 
330
331
  projects = shift_index_after(projects, action.line, action.note.count + 1)
331
332
 
333
+ target_proj = projects.select { |proj| proj.project =~ /^#{target_proj.project}$/ }.first
334
+
332
335
  action = process_action(action, priority: priority, finish: finish, add_tag: add_tag, remove_tag: remove_tag)
333
336
 
334
337
  target_proj = if target_proj
@@ -347,14 +350,21 @@ module NA
347
350
  note = note.empty? ? '' : "\n#{indent}\t\t#{note.join("\n#{indent}\t\t").strip}"
348
351
 
349
352
  if append
350
- this_idx = projects.index(target_proj)
351
- if this_idx == projects.length - 1
352
- target_line = contents.count
353
- else
354
- target_line = projects[this_idx + 1].line - 1
353
+ this_idx = 0
354
+ projects.each_with_index do |proj, idx|
355
+ if proj.line == target_proj.line
356
+ this_idx = idx
357
+ break
358
+ end
355
359
  end
360
+
361
+ target_line = if this_idx == projects.length - 1
362
+ contents.count
363
+ else
364
+ projects[this_idx].last_line + 1
365
+ end
356
366
  else
357
- target_line = target_proj.line
367
+ target_line = target_proj.line + 1
358
368
  end
359
369
 
360
370
  contents.insert(target_line, "#{indent}\t- #{action.action}#{note}")
@@ -497,6 +507,7 @@ module NA
497
507
  content = file.read_file
498
508
  indent_level = 0
499
509
  parent = []
510
+ last_line = 0
500
511
  in_action = false
501
512
  content.split("\n").each.with_index do |line, idx|
502
513
  if line =~ /^([ \t]*)([^\-][^@()]+?): *(@\S+ *)*$/
@@ -513,20 +524,23 @@ module NA
513
524
  parent.push(proj)
514
525
  end
515
526
 
516
- projects.push(NA::Project.new(parent.join(':'), indent, idx + 1))
527
+ projects.push(NA::Project.new(parent.join(':'), indent, idx, idx))
517
528
 
518
529
  indent_level = indent
530
+ elsif line.strip =~ /^$/
531
+ in_action = false
519
532
  elsif line =~ /^[ \t]*- /
520
533
  in_action = false
521
- # search_for_done = false
522
- # optional_tag.each { |t| search_for_done = true if t[:tag] =~ /done/ }
523
- next if line =~ /@done/ && !done
524
-
525
- next if require_na && line !~ /@#{NA.na_tag}\b/
526
534
 
527
535
  action = line.sub(/^[ \t]*- /, '')
528
536
  new_action = NA::Action.new(file, File.basename(file, ".#{NA.extension}"), parent.dup, action, idx)
529
537
 
538
+ projects[-1].last_line = idx if projects.count.positive?
539
+
540
+ next if line =~ /@done/ && !done
541
+
542
+ next if require_na && line !~ /@#{NA.na_tag}\b/
543
+
530
544
  has_search = !optional.empty? || !required.empty? || !negated.empty?
531
545
 
532
546
  next if has_search && !new_action.search_match?(any: optional,
@@ -545,10 +559,12 @@ module NA
545
559
 
546
560
  actions.push(new_action)
547
561
  in_action = true
548
- else
549
- actions[-1].note.push(line.strip) if actions.count.positive? && in_action
562
+ elsif in_action
563
+ actions[-1].note.push(line.strip) if actions.count.positive?
564
+ projects[-1].last_line = idx if projects.count.positive?
550
565
  end
551
566
  end
567
+ projects = projects.dup
552
568
  end
553
569
 
554
570
  [files, actions, projects]
data/lib/na/project.rb CHANGED
@@ -2,24 +2,26 @@
2
2
 
3
3
  module NA
4
4
  class Project < Hash
5
- attr_accessor :project, :indent, :line
5
+ attr_accessor :project, :indent, :line, :last_line
6
6
 
7
- def initialize(project, indent = 0, line = 0)
7
+ def initialize(project, indent = 0, line = 0, last_line = 0)
8
8
  super()
9
9
  @project = project
10
10
  @indent = indent
11
11
  @line = line
12
+ @last_line = last_line
12
13
  end
13
14
 
14
15
  def to_s
15
- { project: @project, indent: @indent, line: @line }.to_s
16
+ { project: @project, indent: @indent, line: @line, last_line: @last_line }.to_s
16
17
  end
17
18
 
18
19
  def inspect
19
20
  [
20
21
  "@project: #{@project}",
21
22
  "@indent: #{@indent}",
22
- "@line: #{@line}"
23
+ "@line: #{@line}",
24
+ "@last_line: #{@last_line}"
23
25
  ].join(" ")
24
26
  end
25
27
  end
data/lib/na/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Na
2
- VERSION = '1.2.7'
2
+ VERSION = '1.2.8'
3
3
  end
data/src/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  _If you're one of the rare people like me who find this useful, feel free to
10
10
  [buy me some coffee][donate]._
11
11
 
12
- The current version of `na` is <!--VER-->1.2.6<!--END VER-->.
12
+ The current version of `na` is <!--VER-->1.2.7<!--END VER-->.
13
13
 
14
14
  `na` ("next action") is a command line tool designed to make it easy to see what your next actions are for any project, right from the command line. It works with TaskPaper-formatted files (but any plain text format will do), looking for `@na` tags (or whatever you specify) in todo files in your current folder.
15
15
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: na
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.7
4
+ version: 1.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra