todoloo 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +14 -0
- data/Rakefile +4 -0
- data/lib/todoloo/cli.rb +19 -4
- data/lib/todoloo/helpers.rb +11 -3
- data/lib/todoloo/parser.rb +1 -1
- data/lib/todoloo/task.rb +4 -0
- data/lib/todoloo/task_list.rb +32 -0
- data/lib/todoloo/transformer.rb +1 -1
- data/lib/todoloo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30e603e6f88a2ac0a52654b71d81714936db242648786c9bd1b0ac602cff03e6
|
4
|
+
data.tar.gz: 609ee891b2a8d01817c63725a4a4b4197c63e86cabeb5f44b32a8b4a470c224a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6f09e526d68283bc2ce77bdf9a2439f4d4a03bcb6b9dc199cdcd41356625fd7968eba57e6f2dade51a61aee5b280041e0e9ec82a2db99a093ce279006135ffd
|
7
|
+
data.tar.gz: 7e37cf807c222e8320e0af0eebaab9bd390beb2bb523c6174237a5f40d6a699e8d905e239a0c2b6e0ba917468885fd685d718526bb485fffa29d96cba867f5b5
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
Unreleased
|
2
|
+
|
3
|
+
0.0.4 - 13 August 2024
|
4
|
+
- Add more extensive CLI tests to catch some corner cases
|
5
|
+
- Fix `--exclude` flag not being repeatable
|
6
|
+
- Add `--pattern` flag for repeatable file matching pattern specification
|
7
|
+
- Add `--verbose` switch to opt-in for printing out scanned files
|
8
|
+
- Add `--output [FILENAME]` flag for specifying where to write the todos/tasks
|
9
|
+
- Fix remove file repeatitions when using `--pattern` that matches repeatedly
|
10
|
+
|
11
|
+
0.0.3 - 8 August 2024
|
12
|
+
- Add sorting support to `TaskList` and now sort CLI output by default
|
13
|
+
- Fix parsing for multiple tags, as in `TODO(a,b,c)`
|
14
|
+
|
1
15
|
0.0.2 - 19 July 2024
|
2
16
|
- Add regression for `Todoloo::TaskList` on writing tasks with blank topics
|
3
17
|
|
data/Rakefile
CHANGED
data/lib/todoloo/cli.rb
CHANGED
@@ -3,13 +3,28 @@ require "thor"
|
|
3
3
|
class Todoloo::CLI < Thor
|
4
4
|
package_name "Todoloo"
|
5
5
|
|
6
|
+
DEFAULT_PATTERN = [
|
7
|
+
"**/*.rb",
|
8
|
+
"*.rb"
|
9
|
+
].freeze
|
10
|
+
|
6
11
|
desc "scan", "Scans all files that match the given globs and outputs a tasks.yml"
|
7
|
-
method_option :
|
12
|
+
method_option :pattern, type: :string, repeatable: true, aliases: "-p", desc: "Path globs to match; can be repeated"
|
13
|
+
method_option :exclude, type: :string, repeatable: true, aliases: "-e", desc: "List of path globs to exclude"
|
14
|
+
method_option :output, type: :string, aliases: "-o", default: "tasks.yml", desc: "Name of the output file"
|
15
|
+
method_option :verbose, type: :boolean, default: false
|
8
16
|
def scan
|
17
|
+
patterns = options.fetch(:pattern, DEFAULT_PATTERN)
|
18
|
+
|
9
19
|
Todoloo::FileScanner
|
10
|
-
.new(
|
20
|
+
.new(
|
21
|
+
patterns,
|
22
|
+
excludes: options.fetch(:exclude, []),
|
23
|
+
trace: options.fetch(:verbose)
|
24
|
+
)
|
11
25
|
.scan
|
12
|
-
.
|
26
|
+
.sort
|
27
|
+
.write(options.fetch(:output))
|
13
28
|
end
|
14
29
|
|
15
30
|
desc "io", "Reads input from stdio and writes to stdout"
|
@@ -18,7 +33,7 @@ class Todoloo::CLI < Thor
|
|
18
33
|
Todoloo::Parser
|
19
34
|
.new
|
20
35
|
.parse_and_transform($stdin.read)
|
21
|
-
).write($stdout)
|
36
|
+
).sort.write($stdout)
|
22
37
|
end
|
23
38
|
|
24
39
|
def self.exit_on_failure?
|
data/lib/todoloo/helpers.rb
CHANGED
@@ -6,7 +6,9 @@ module Todoloo
|
|
6
6
|
# TODO We need to optimize how we traverse the file-system so that we can short-circuit the excludes instead
|
7
7
|
# of only filtering after finding them.
|
8
8
|
#
|
9
|
-
#
|
9
|
+
# TODO Optimize the seen_path handling
|
10
|
+
#
|
11
|
+
# @pattern [String, Array<String>]
|
10
12
|
# The file paths to glob
|
11
13
|
#
|
12
14
|
# @excludes [Array<String>]
|
@@ -14,9 +16,15 @@ module Todoloo
|
|
14
16
|
#
|
15
17
|
# @return [Enumerator<String>]
|
16
18
|
def glob_paths(pattern, excludes: [])
|
19
|
+
seen_paths = Set.new
|
20
|
+
|
17
21
|
Enumerator.new do |y|
|
18
|
-
Dir[pattern].lazy.each do |path|
|
19
|
-
|
22
|
+
Dir[*Array(pattern)].lazy.each do |path|
|
23
|
+
if !(seen_paths.include?(path) || excludes.any? { |e| File.fnmatch(e, path) })
|
24
|
+
y << path
|
25
|
+
end
|
26
|
+
|
27
|
+
seen_paths << path
|
20
28
|
end
|
21
29
|
end
|
22
30
|
end
|
data/lib/todoloo/parser.rb
CHANGED
@@ -148,7 +148,7 @@ module Todoloo
|
|
148
148
|
|
149
149
|
rule(:topic) { match(/[^),]/).repeat(1).as(:topic) }
|
150
150
|
|
151
|
-
rule(:topic_rest) { (str(",") >> spacing.maybe >> topic).repeat(0
|
151
|
+
rule(:topic_rest) { (str(",") >> spacing.maybe >> topic).repeat(0) }
|
152
152
|
|
153
153
|
# (topic1, topic2)
|
154
154
|
rule(:topics) { lparen >> topic >> topic_rest >> rparen }
|
data/lib/todoloo/task.rb
CHANGED
data/lib/todoloo/task_list.rb
CHANGED
@@ -2,6 +2,20 @@ require "yaml"
|
|
2
2
|
|
3
3
|
module Todoloo
|
4
4
|
class TaskList
|
5
|
+
include Enumerable
|
6
|
+
|
7
|
+
# Lower means higher priority
|
8
|
+
SEVERITY_INDEX = {
|
9
|
+
"FIXME" => 100,
|
10
|
+
"HACK" => 200,
|
11
|
+
"TODO" => 300,
|
12
|
+
"XXX" => 400,
|
13
|
+
"NOTE" => 500,
|
14
|
+
"HBD" => 600
|
15
|
+
}.freeze
|
16
|
+
|
17
|
+
UNKNOWN_INDEX = 1_000_000
|
18
|
+
|
5
19
|
def initialize
|
6
20
|
@tasks = []
|
7
21
|
end
|
@@ -17,6 +31,20 @@ module Todoloo
|
|
17
31
|
self
|
18
32
|
end
|
19
33
|
|
34
|
+
def each
|
35
|
+
to_enum(:each) unless block_given?
|
36
|
+
|
37
|
+
@tasks.each { |task| yield task }
|
38
|
+
end
|
39
|
+
|
40
|
+
def sort
|
41
|
+
@tasks.sort_by! do |t|
|
42
|
+
[t.topics, task_severity(t), t.path, t.line, t.column]
|
43
|
+
end
|
44
|
+
|
45
|
+
self
|
46
|
+
end
|
47
|
+
|
20
48
|
# Structure:
|
21
49
|
# TOPIC:
|
22
50
|
# TYPE:
|
@@ -38,6 +66,10 @@ module Todoloo
|
|
38
66
|
|
39
67
|
private
|
40
68
|
|
69
|
+
def task_severity(task)
|
70
|
+
SEVERITY_INDEX.fetch(task.type, UNKNOWN_INDEX)
|
71
|
+
end
|
72
|
+
|
41
73
|
def topics_for_task(task)
|
42
74
|
if task.topics.empty?
|
43
75
|
[""]
|
data/lib/todoloo/transformer.rb
CHANGED
data/lib/todoloo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: todoloo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Coetzee
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|