todo_lint 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3d925d1749e411f4de9fc8c753060ab43ef53937
4
- data.tar.gz: b8c5e5db3ca4f210b752ede2a47c43e451e72fab
3
+ metadata.gz: 9468fdec36cf8fd3dd9af14c1969c31181fed8ff
4
+ data.tar.gz: 665b4a107a8dc3202edfe9125ca7f7787446da10
5
5
  SHA512:
6
- metadata.gz: 99c1e602b9ef8577c0cd984b772a1417b4c1b658a026d6183d2420d1bf4f2a3e63b80c625d525f46221cd9ab61a29a853e9af6598a6c9cd7c6e9b3984af087e6
7
- data.tar.gz: 45caf05a85101b675925986157b573ccf8d2ff7230435b448711d0078ef9141d6fbe90e426aad8fe878ee9070d1cca31e5d9f65bec811802fb6116b5c09465eb
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
 
@@ -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})").blue
103
+ Rainbow(" (due #{todo.due_date.to_date})")
104
+ .public_send(todo.due_date.overdue? ? :red : :blue)
105
105
  else
106
- Rainbow(" (missing due date)").red
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
@@ -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, path: RequiredArg.new, judge: RequiredArg.new)
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
 
@@ -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
- new(line, :line_number => line_number + 1) if present_in?(line)
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, line_number: RequiredArg.new(:line_number))
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
@@ -2,5 +2,5 @@
2
2
  # it's in its own file so it can be required in the gemspec without requiring
3
3
  # everything else as well
4
4
  module TodoLint
5
- VERSION = "0.3.0".freeze
5
+ VERSION = "0.3.1".freeze
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: todo_lint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Jacobson