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.
36 37 38 39 |
# File 'lib/html_acceptance.rb', line 36 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.
43 44 45 46 47 48 49 50 |
# File 'lib/html_acceptance.rb', line 43 def each_exception Dir.chdir(@data_folder) Dir.glob("*.exceptions.txt").each do |file| if File.open(File.join(@data_folder, file), 'r').read != '' yield HTMLAcceptanceResult.load_from_files(file.gsub('.exceptions.txt','')) end end end |
#validator(html, resource) ⇒ Object
52 53 54 55 |
# File 'lib/html_acceptance.rb', line 52 def validator(html, resource) datapath=File.join(@data_folder, filenameize(resource)) HTMLAcceptanceResult.new(resource, html, datapath, @options) end |