Class: Watnow::Extractor

Inherits:
Object
  • Object
show all
Includes:
Config
Defined in:
lib/watnow.rb

Constant Summary

Constants included from Config

Config::FILE_EXTENSION_IGNORE, Config::FOLDER_IGNORE, Config::PATTERNS

Instance Method Summary collapse

Methods included from Config

included

Constructor Details

#initializeExtractor

Returns a new instance of Extractor.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/watnow.rb', line 12

def initialize
  # Parse options and scan given directory
  options = OptParser.parse(ARGV)
  scan(options[:directory])

  # If open command is parsed (`watnow open 13`)
  if options[:open]
    id = Integer(options[:open])
    annotation_line = AnnotationLine.find(id)
    open_file_at_line(annotation_line.annotation.file, annotation_line.lineno)

  # If remove command is parsed (`watnow remove 13`)
  elsif options[:remove]
    id = Integer(options[:remove])
    annotation_line = AnnotationLine.find(id)
    remove_line_of_file(annotation_line.annotation.file, annotation_line.lineno)

  # No specific command parsed. Output the annotations list
  else
    output(Annotation.all)
  end
end