Class: FileParser

Inherits:
Object
  • Object
show all
Defined in:
lib/rstub/file_parser.rb

Overview

FileParser goes through a file and writes the contents of it to a target file, but it ignores anything between the delimiters # STUB and # ENDSTUB.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#end_stub_regexObject

Returns the value of attribute end_stub_regex.



4
5
6
# File 'lib/rstub/file_parser.rb', line 4

def end_stub_regex
  @end_stub_regex
end

#stub_regexObject

Returns the value of attribute stub_regex.



4
5
6
# File 'lib/rstub/file_parser.rb', line 4

def stub_regex
  @stub_regex
end

#stubbingObject

Returns the value of attribute stubbing.



4
5
6
# File 'lib/rstub/file_parser.rb', line 4

def stubbing
  @stubbing
end

Instance Method Details

#stub(target_file, file) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/rstub/file_parser.rb', line 6

def stub(target_file, file)
  determine_delimiters(file)
  File.open(file, 'r') do |readable_file|
    File.open(target_file, 'w') do |target|
      write_text(target, readable_file)
    end
  end
end