gtdlint 0.1 → 0.2
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 +4 -4
- data/README.md +6 -0
- data/lib/gtdlint.rb +26 -14
- data/lib/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: a1da6f127afe0bb3c5653d0002fcb4efb770e692
|
4
|
+
data.tar.gz: 1bbcb3d4702285a9ed6c95419c07a22ca664309f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec57224fa746f02f709c1c8b07eb2060ef9edcf1233918cd3b0fbae32e8d08749107dc64a28fa54ff31c8b78361df80344d42ebe92c25731d3eff4de61e91eb9
|
7
|
+
data.tar.gz: 47b3cf59340a52d8f4ce4500b9d15c1f062811663dc21e78acc3e61bca179774de8bcee06fef804638c246b393e40cd70459c2874f74cf746f267ac9127e79b0
|
data/README.md
CHANGED
@@ -65,6 +65,12 @@ Usage: gtdlint [options] [<files>|-]
|
|
65
65
|
-v, --version Print version info
|
66
66
|
```
|
67
67
|
|
68
|
+
gtdlint can be combined with other programs. For example, check your most recent git commit for leftover TODOs:
|
69
|
+
|
70
|
+
```
|
71
|
+
$ git diff HEAD~1 | gtdlint
|
72
|
+
```
|
73
|
+
|
68
74
|
# REQUIREMENTS
|
69
75
|
|
70
76
|
* [Ruby](https://www.ruby-lang.org/) 2+
|
data/lib/gtdlint.rb
CHANGED
@@ -33,9 +33,9 @@ DEFAULT_LINES_BEFORE = 0
|
|
33
33
|
DEFAULT_LINES_AFTER = 0
|
34
34
|
|
35
35
|
DEFAULT_CONFIGURATION = {
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
'gtd_pattern' => DEFAULT_GTD_PATTERN,
|
37
|
+
'lines_before' => DEFAULT_LINES_BEFORE,
|
38
|
+
'lines_after' => DEFAULT_LINES_AFTER
|
39
39
|
}
|
40
40
|
|
41
41
|
#
|
@@ -45,7 +45,7 @@ class GTDThing
|
|
45
45
|
attr_accessor :filename, :line_number, :line
|
46
46
|
|
47
47
|
def self.parse(filename, grep_line)
|
48
|
-
if grep_line.match(/^--$/)
|
48
|
+
if grep_line.match(/^--$/)
|
49
49
|
grep_line
|
50
50
|
else
|
51
51
|
match = grep_line.match(/^([0-9]+)(\:|-)(.*)$/)
|
@@ -71,7 +71,7 @@ end
|
|
71
71
|
def self.recursive_list(directory, ignores = DEFAULT_IGNORES)
|
72
72
|
Find.find(directory).reject do |f|
|
73
73
|
File.directory?(f) ||
|
74
|
-
ignores.any? { |ignore| f =~
|
74
|
+
ignores.any? { |ignore| f =~ /#{ignore}/ } ||
|
75
75
|
|
76
76
|
begin
|
77
77
|
File.binary?(f)
|
@@ -82,9 +82,9 @@ def self.recursive_list(directory, ignores = DEFAULT_IGNORES)
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def self.check_stdin(configuration = DEFAULT_CONFIGURATION)
|
85
|
-
gtd_pattern = configuration[
|
86
|
-
lines_before = configuration[
|
87
|
-
lines_after = configuration[
|
85
|
+
gtd_pattern = configuration['gtd_pattern']
|
86
|
+
lines_before = configuration['lines_before']
|
87
|
+
lines_after = configuration['lines_after']
|
88
88
|
|
89
89
|
contents = $stdin.read
|
90
90
|
|
@@ -94,7 +94,13 @@ def self.check_stdin(configuration = DEFAULT_CONFIGURATION)
|
|
94
94
|
|
95
95
|
filename = t.path
|
96
96
|
|
97
|
-
output = `grep
|
97
|
+
output = `grep \
|
98
|
+
-B #{lines_before} \
|
99
|
+
-A #{lines_after} \
|
100
|
+
-n \
|
101
|
+
-i #{gtd_pattern} \
|
102
|
+
\"#{filename}\"
|
103
|
+
`
|
98
104
|
|
99
105
|
lines = output.split("\n")
|
100
106
|
|
@@ -104,11 +110,17 @@ def self.check_stdin(configuration = DEFAULT_CONFIGURATION)
|
|
104
110
|
end
|
105
111
|
|
106
112
|
def self.check(filename, configuration = DEFAULT_CONFIGURATION)
|
107
|
-
gtd_pattern = configuration[
|
108
|
-
lines_before = configuration[
|
109
|
-
lines_after = configuration[
|
110
|
-
|
111
|
-
output = `grep
|
113
|
+
gtd_pattern = configuration['gtd_pattern']
|
114
|
+
lines_before = configuration['lines_before']
|
115
|
+
lines_after = configuration['lines_after']
|
116
|
+
|
117
|
+
output = `grep \
|
118
|
+
-B #{lines_before} \
|
119
|
+
-A #{lines_after} \
|
120
|
+
-n \
|
121
|
+
-i #{gtd_pattern} \
|
122
|
+
\"#{filename}\"
|
123
|
+
`
|
112
124
|
|
113
125
|
lines = output.split("\n")
|
114
126
|
|
data/lib/version.rb
CHANGED