Class: Fuzz::FileObject
- Inherits:
-
Object
- Object
- Fuzz::FileObject
- 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
-
#ext ⇒ Object
readonly
LinePointer.
-
#fullpath ⇒ Object
readonly
LinePointer.
-
#lines ⇒ Object
readonly
LinePointer.
-
#name ⇒ Object
readonly
LinePointer.
-
#path ⇒ Object
readonly
LinePointer.
Class Method Summary collapse
Instance Method Summary collapse
- #changed? ⇒ Boolean
-
#initialize(path) ⇒ FileObject
constructor
A new instance of FileObject.
- #iterate(fzzr_id, &block) ⇒ Object
- #to_s ⇒ Object
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.(path) @name = File.basename(path) @ext = File.extname(path).sub(/^\./,'') @lines = nil @pointer = nil @changed = false end |
Instance Attribute Details
#ext ⇒ Object (readonly)
LinePointer
224 225 226 |
# File 'lib/fuzz/fzzr.rb', line 224 def ext @ext end |
#fullpath ⇒ Object (readonly)
LinePointer
224 225 226 |
# File 'lib/fuzz/fzzr.rb', line 224 def fullpath @fullpath end |
#lines ⇒ Object (readonly)
LinePointer
224 225 226 |
# File 'lib/fuzz/fzzr.rb', line 224 def lines @lines end |
#name ⇒ Object (readonly)
LinePointer
224 225 226 |
# File 'lib/fuzz/fzzr.rb', line 224 def name @name end |
#path ⇒ Object (readonly)
LinePointer
224 225 226 |
# File 'lib/fuzz/fzzr.rb', line 224 def path @path end |
Class Method Details
.extensions ⇒ Object
120 121 122 |
# File 'lib/fuzz/fzzr.rb', line 120 def self.extensions EXTS end |
.filenames ⇒ Object
124 125 126 |
# File 'lib/fuzz/fzzr.rb', line 124 def self.filenames FILES end |
Instance Method Details
#changed? ⇒ 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_s ⇒ Object
254 255 256 |
# File 'lib/fuzz/fzzr.rb', line 254 def to_s "File:#{fullpath}" end |