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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -0
  3. data/lib/gtdlint.rb +26 -14
  4. data/lib/version.rb +1 -1
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3fbc233bec15bdb84f7e239addc236f4b2d0c650
4
- data.tar.gz: 655b4888df40991b13c6dc8d9c167a60ea81cfa7
3
+ metadata.gz: a1da6f127afe0bb3c5653d0002fcb4efb770e692
4
+ data.tar.gz: 1bbcb3d4702285a9ed6c95419c07a22ca664309f
5
5
  SHA512:
6
- metadata.gz: 9ca071200dbd35abeba32ce17e6782ab261120d1e4054829e32d9b7e0afc81212c544c067e3d0146bfc32c7652b30bd84d843ebb3924add872e3b676ec50a3ec
7
- data.tar.gz: 1b4868f8db94818b0dbc73c4dde2a7a028b093d03d2d6dbd03e74d8e5efa9d697db62680402b49b489bb88b37b06fdcea4cc9a62eed28695376517fedbc2946a
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
- "gtd_pattern" => DEFAULT_GTD_PATTERN,
37
- "lines_before" => DEFAULT_LINES_BEFORE,
38
- "lines_after" => DEFAULT_LINES_AFTER
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(/^--$/) then
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 =~ %r(#{ignore}) } ||
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["gtd_pattern"]
86
- lines_before = configuration["lines_before"]
87
- lines_after = configuration["lines_after"]
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 -B #{lines_before} -A #{lines_after} -n -i #{gtd_pattern} \"#{filename}\"`
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["gtd_pattern"]
108
- lines_before = configuration["lines_before"]
109
- lines_after = configuration["lines_after"]
110
-
111
- output = `grep -B #{lines_before} -A #{lines_after} -n -i #{gtd_pattern} \"#{filename}\"`
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
@@ -2,5 +2,5 @@
2
2
  # GTDLint
3
3
  #
4
4
  module GTDLint
5
- VERSION = '0.1'
5
+ VERSION = '0.2'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gtdlint
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Pennebaker