class Object

Constants

DEFAULT_CONFIGURATION
DEFAULT_GTD_PATTERN

Grep format, case insensitive

DEFAULT_IGNORES
DEFAULT_LINES_AFTER
DEFAULT_LINES_BEFORE

Public Class Methods

check(filename, configuration = nil) click to toggle source
# 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) click to toggle source
# 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