todo_lint 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/lib/todo_lint/cli.rb +8 -4
- data/lib/todo_lint/reporter.rb +2 -3
- data/lib/todo_lint/todo.rb +27 -2
- data/lib/todo_lint/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9468fdec36cf8fd3dd9af14c1969c31181fed8ff
|
4
|
+
data.tar.gz: 665b4a107a8dc3202edfe9125ca7f7787446da10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62036c3c37d81615f93f88699de46fbf31bad91f831ff7d961f8527c3fea201fef25a45f21c5a39bf52aadd17e9bf7eb8691bb5faeda3ae00908506f676ceb86
|
7
|
+
data.tar.gz: e5683ed19b617972f455b36562feec1297eb9c5f7250f66b1951bf8c6cbaa5ffd9b48ce0162880ac134aea2203b08596ac97e796ddb6531ca99915be13fa3898
|
data/README.md
CHANGED
@@ -47,6 +47,14 @@ to:
|
|
47
47
|
|
48
48
|
Now your build will pass. Until November, 2043.
|
49
49
|
|
50
|
+
### Alternative usage as todo_list generator
|
51
|
+
|
52
|
+
If you'd like a summary of all of the todos, instead run:
|
53
|
+
|
54
|
+
```
|
55
|
+
bundle exec todo_lint --report
|
56
|
+
```
|
57
|
+
|
50
58
|
## Configuration
|
51
59
|
|
52
60
|
Create a .todo_lint.yml file in your main repo
|
@@ -71,6 +79,7 @@ Command flag | Description
|
|
71
79
|
`-c/--config [FILE]` | Load the specified config file
|
72
80
|
`-e/--exclude [FILES]` | Exclude the specified files
|
73
81
|
`-i/--include [EXTS]` | Only look at specified extensions
|
82
|
+
`-r/--report` | Print a sorted todo list instead of linting
|
74
83
|
|
75
84
|
## Development
|
76
85
|
|
data/lib/todo_lint/cli.rb
CHANGED
@@ -66,7 +66,6 @@ module TodoLint
|
|
66
66
|
reports = files.map do |file|
|
67
67
|
Todo.within(File.open(file)).map do |todo|
|
68
68
|
reporter = Reporter.new(todo,
|
69
|
-
:path => file,
|
70
69
|
:judge => Judge.new(todo))
|
71
70
|
reporter.report.tap do |report|
|
72
71
|
print Rainbow(".").public_send(report.nil? ? :green : :red)
|
@@ -101,11 +100,16 @@ module TodoLint
|
|
101
100
|
end
|
102
101
|
todos.sort.each.with_index do |todo, num|
|
103
102
|
due_date = if todo.due_date
|
104
|
-
Rainbow(" (due #{todo.due_date.to_date})")
|
103
|
+
Rainbow(" (due #{todo.due_date.to_date})")
|
104
|
+
.public_send(todo.due_date.overdue? ? :red : :blue)
|
105
105
|
else
|
106
|
-
Rainbow(" (
|
106
|
+
Rainbow(" (no due date)").red
|
107
107
|
end
|
108
|
-
puts "#{num + 1}. #{todo.task}#{due_date}"
|
108
|
+
puts "#{num + 1}. #{todo.task}#{due_date} " +
|
109
|
+
Rainbow(
|
110
|
+
"(#{todo.relative_path}:#{todo.line_number}:" \
|
111
|
+
"#{todo.character_number})"
|
112
|
+
).yellow
|
109
113
|
end
|
110
114
|
|
111
115
|
exit 0
|
data/lib/todo_lint/reporter.rb
CHANGED
@@ -5,12 +5,11 @@ module TodoLint
|
|
5
5
|
# Accept a todo and a path to check for problems
|
6
6
|
# @example
|
7
7
|
# Reporter.new(todo,
|
8
|
-
# path: "/Users/max/src/required_arg/README.md",
|
9
8
|
# judge: Judge.new(todo))
|
10
9
|
# @api public
|
11
|
-
def initialize(todo,
|
10
|
+
def initialize(todo, judge: RequiredArg.new)
|
12
11
|
@todo = todo
|
13
|
-
@path = path
|
12
|
+
@path = todo.path
|
14
13
|
@judge = judge
|
15
14
|
end
|
16
15
|
|
data/lib/todo_lint/todo.rb
CHANGED
@@ -16,7 +16,9 @@ module TodoLint
|
|
16
16
|
# @return [Array<Todo>]
|
17
17
|
def self.within(file)
|
18
18
|
file.each_line.with_index.map do |line, line_number|
|
19
|
-
|
19
|
+
if present_in?(line)
|
20
|
+
new(line, :line_number => line_number + 1, :path => file.path)
|
21
|
+
end
|
20
22
|
end.compact
|
21
23
|
end
|
22
24
|
|
@@ -44,14 +46,25 @@ module TodoLint
|
|
44
46
|
# @return [Fixnum]
|
45
47
|
attr_reader :line_number
|
46
48
|
|
49
|
+
# The absolute path to the file where we found this todo
|
50
|
+
# @example
|
51
|
+
# todo.path #=> "/Users/max/src/layabout/Gemfile"
|
52
|
+
#
|
53
|
+
# @api public
|
54
|
+
# @return [String]
|
55
|
+
attr_reader :path
|
56
|
+
|
47
57
|
# A new Todo must know a few things
|
48
58
|
# @example
|
49
59
|
# Todo.new("#TODO: get a boat", line_number: 4)
|
50
60
|
# @api public
|
51
|
-
def initialize(line,
|
61
|
+
def initialize(line,
|
62
|
+
line_number: RequiredArg.new(:line_number),
|
63
|
+
path: RequiredArg.new(:path))
|
52
64
|
absent_todo!(line) unless self.class.present_in?(line)
|
53
65
|
@line = line
|
54
66
|
@line_number = line_number
|
67
|
+
@path = path
|
55
68
|
end
|
56
69
|
|
57
70
|
# Was this todo annotated with a due date?
|
@@ -120,6 +133,18 @@ module TodoLint
|
|
120
133
|
due_date_for_sorting <=> other.due_date_for_sorting
|
121
134
|
end
|
122
135
|
|
136
|
+
# The relative path to the file where this todo was found
|
137
|
+
#
|
138
|
+
# @example
|
139
|
+
# todo.relative #=> "spec/spec_helper.rb"
|
140
|
+
#
|
141
|
+
# @return [String]
|
142
|
+
# @api public
|
143
|
+
def relative_path
|
144
|
+
current_dir = Pathname.new(File.expand_path("./"))
|
145
|
+
Pathname.new(path).relative_path_from(current_dir).to_s
|
146
|
+
end
|
147
|
+
|
123
148
|
protected
|
124
149
|
|
125
150
|
# Helper for sorting todos
|
data/lib/todo_lint/version.rb
CHANGED