Top Level Namespace
Defined Under Namespace
Modules: GTDLint Classes: GTDThing
Constant Summary collapse
- DEFAULT_IGNORES =
%w( tmp .hg .svn .git .gtdlintignore .gtdlintrc.yml node_modules bower_components target dist .vagrant Gemfile.lock *.exe *.bin *.apk *.ap_ res *.class *.zip *.jar *.war *.xpi *.dmg *.pkg *.app *.xcodeproj *.lproj *.xcassets *.pmdoc *.dSYM *.jad *.cmo *.cmi *.png *.gif *.jpg *.jpeg *.tiff *.ico *.svg *.dot *.wav *.mp3 *[.-]min.* )
- DEFAULT_GTD_PATTERN =
Grep format, case insensitive
"\'todo\\|to do\\|to-do\\|pending\\|hack\\|fixme\'"
- DEFAULT_LINES_BEFORE =
0
- DEFAULT_LINES_AFTER =
0
- DEFAULT_CONFIGURATION =
{ 'gtd_pattern' => DEFAULT_GTD_PATTERN, 'lines_before' => DEFAULT_LINES_BEFORE, 'lines_after' => DEFAULT_LINES_AFTER }
Class Method Summary collapse
Class Method Details
.check(filename, configuration = nil) ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/gtdlint.rb', line 131 def self.check(filename, configuration = nil) configuration = if configuration.nil? DEFAULT_CONFIGURATION else configuration end gtd_pattern = configuration['gtd_pattern'] lines_before = configuration['lines_before'] lines_after = configuration['lines_after'] output = `grep \ -B #{lines_before} \ -A #{lines_after} \ -n \ -i \ -w #{gtd_pattern} \ \"#{filename}\" ` lines = output.split("\n") gtd_things = lines.map { |line| GTDThing.parse(filename, line) } gtd_things.each { |m| puts m } end |
.check_stdin(configuration = nil) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/gtdlint.rb', line 95 def self.check_stdin(configuration = nil) configuration = if configuration.nil? DEFAULT_CONFIGURATION else configuration end gtd_pattern = configuration['gtd_pattern'] lines_before = configuration['lines_before'] lines_after = configuration['lines_after'] contents = $stdin.read t = Tempfile.new('gtdlint') t.write(contents) t.close filename = t.path output = `grep \ -B #{lines_before} \ -A #{lines_after} \ -n \ -i \ -w #{gtd_pattern} \ \"#{filename}\" ` lines = output.split("\n") gtd_things = lines.map { |line| GTDThing.parse('stdin', line) } gtd_things.each { |m| puts m } end |