Class: Fuzz::FileObject

Inherits:
Object
  • Object
show all
Defined in:
lib/fuzz/fzzr.rb

Overview

DirObject

Defined Under Namespace

Classes: LinePointer

Constant Summary collapse

EXTS =
[
'h', 'hxx', 'hpp', 'c', 'cc', 'cxx', 'cpp', 'H', 'C', 'inl', 'asm',
'rb', 'erb', 'pl', 'pm', 'py',
'idl', 'pidl',
'mwc', 'mpc', 'mpb', 'mpt', 'mpd',
'cdp', 'xml', 'conf', 'html',
'asc', 'adoc'
]
FILES =
[
'ChangeLog', 'README'
]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ FileObject

Returns a new instance of FileObject.



226
227
228
229
230
231
232
233
234
# File 'lib/fuzz/fzzr.rb', line 226

def initialize(path)
  @path = path
  @fullpath = File.expand_path(path)
  @name = File.basename(path)
  @ext = File.extname(path).sub(/^\./,'')
  @lines = nil
  @pointer = nil
  @changed = false
end

Instance Attribute Details

#extObject (readonly)

LinePointer



224
225
226
# File 'lib/fuzz/fzzr.rb', line 224

def ext
  @ext
end

#fullpathObject (readonly)

LinePointer



224
225
226
# File 'lib/fuzz/fzzr.rb', line 224

def fullpath
  @fullpath
end

#linesObject (readonly)

LinePointer



224
225
226
# File 'lib/fuzz/fzzr.rb', line 224

def lines
  @lines
end

#nameObject (readonly)

LinePointer



224
225
226
# File 'lib/fuzz/fzzr.rb', line 224

def name
  @name
end

#pathObject (readonly)

LinePointer



224
225
226
# File 'lib/fuzz/fzzr.rb', line 224

def path
  @path
end

Class Method Details

.extensionsObject



120
121
122
# File 'lib/fuzz/fzzr.rb', line 120

def self.extensions
  EXTS
end

.filenamesObject



124
125
126
# File 'lib/fuzz/fzzr.rb', line 124

def self.filenames
  FILES
end

Instance Method Details

#changed?Boolean

Returns:

  • (Boolean)


236
237
238
# File 'lib/fuzz/fzzr.rb', line 236

def changed?
  @changed
end

#iterate(fzzr_id, &block) ⇒ Object



240
241
242
243
244
245
246
247
248
249
250
251
252
# File 'lib/fuzz/fzzr.rb', line 240

def iterate(fzzr_id, &block)
  @lines ||= IO.readlines(fullpath)
  lines_copy = @lines.collect {|l| l.dup }
  pointer = LinePointer.new(@lines, fzzr_id)
  begin
    block.call(pointer) unless pointer.fzzr_disabled?
    pointer.move(1)
  end while !pointer.eof?
  Fuzz.log_error(%Q{#{self.path}[#{pointer.err_lines.join(',')}] #{Fuzz.get_fzzr(fzzr_id).errormsg}}) unless pointer.err_lines.empty?
  @changed |= (@lines != lines_copy)
  lines_copy = nil
  return pointer.err_lines.empty?
end

#to_sObject



254
255
256
# File 'lib/fuzz/fzzr.rb', line 254

def to_s
  "File:#{fullpath}"
end