Class: HTMLAcceptance
- Inherits:
-
Object
- Object
- HTMLAcceptance
- Defined in:
- lib/html_acceptance.rb
Instance Method Summary collapse
-
#each_exception ⇒ Object
For each stored exception, yield an HTMLAcceptanceResult object to allow the user to call .accept! on the exception if it is OK.
-
#initialize(data_folder, options = {}) ⇒ HTMLAcceptance
constructor
It may be useful to pass a subfolder in your project as the data_folder, so your html acceptance status and validation results are stored along with your source.
- #validator(html, resource) ⇒ Object
Constructor Details
#initialize(data_folder, options = {}) ⇒ HTMLAcceptance
It may be useful to pass a subfolder in your project as the data_folder, so your html acceptance status and validation results are stored along with your source.
32 33 34 35 |
# File 'lib/html_acceptance.rb', line 32 def initialize(data_folder, ={}) @data_folder = data_folder @options= end |
Instance Method Details
#each_exception ⇒ Object
For each stored exception, yield an HTMLAcceptanceResult object to allow the user to call .accept! on the exception if it is OK.
39 40 41 42 43 44 45 46 |
# File 'lib/html_acceptance.rb', line 39 def each_exception Dir.chdir(@data_folder) Dir.glob("*.exceptions.txt").each do |file| if File.open(file, 'r').read != '' yield HTMLAcceptanceResult.load_from_files(file.gsub('.exceptions.txt','')) end end end |
#validator(html, resource) ⇒ Object
48 49 50 51 |
# File 'lib/html_acceptance.rb', line 48 def validator(html, resource) datapath=File.join(@data_folder, filenameize(resource)) HTMLAcceptanceResult.new(resource, html, datapath, @options) end |