Class: ReVIEW::Preprocessor

Inherits:
Object show all
Includes:
Loggable
Defined in:
lib/review/preprocessor.rb,
lib/review/preprocessor/line.rb,
lib/review/preprocessor/directive.rb,
lib/review/preprocessor/repository.rb

Defined Under Namespace

Classes: Directive, Line, Repository

Constant Summary collapse

TYPES =
%w[file range].freeze
KNOWN_DIRECTIVES =
%w[require provide warn ok].freeze
INF_INDENT =
9999

Instance Attribute Summary

Attributes included from Loggable

#logger

Instance Method Summary collapse

Methods included from Loggable

#app_error, #debug, #error, #error!, #warn

Constructor Details

#initialize(param) ⇒ Preprocessor

Returns a new instance of Preprocessor.



26
27
28
29
30
31
# File 'lib/review/preprocessor.rb', line 26

def initialize(param)
  @repository = ReVIEW::Preprocessor::Repository.new(param)
  @config = param ## do not use params in this class; only used in Repository
  @logger = ReVIEW.logger
  @leave_content = nil
end

Instance Method Details

#process(path) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/review/preprocessor.rb', line 33

def process(path)
  File.open(path) do |inf|
    @inf = inf
    @f = StringIO.new
    begin
      preproc(@inf)
    rescue Errno::ENOENT => e
      error! e.message
    end
    @f.string
  end
end