Class: MetatagCop::Cops::Cop
- Inherits:
-
Object
- Object
- MetatagCop::Cops::Cop
- Defined in:
- lib/metatag_cop/cops/cop.rb
Instance Attribute Summary collapse
-
#records ⇒ Object
readonly
Returns the value of attribute records.
Instance Method Summary collapse
-
#initialize(records) ⇒ Cop
constructor
A new instance of Cop.
- #run ⇒ Object
Constructor Details
#initialize(records) ⇒ Cop
Returns a new instance of Cop.
9 10 11 |
# File 'lib/metatag_cop/cops/cop.rb', line 9 def initialize(records) @records = records end |
Instance Attribute Details
#records ⇒ Object (readonly)
Returns the value of attribute records.
7 8 9 |
# File 'lib/metatag_cop/cops/cop.rb', line 7 def records @records end |
Instance Method Details
#run ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/metatag_cop/cops/cop.rb', line 13 def run error_msgs = [] records.each do |record| error_msg = [] parser = MetatagCop::Parser.new(record.url) error_msg.push error_msg(:title, record.title, parser.title) unless parser.title == record.title error_msg.push error_msg(:description, record.description, parser.description) unless parser.description == record.description error_msg.push error_msg(:keywords, record.keywords, parser.keywords) unless parser.keywords == record.keywords error_msg.push error_msg(:h1, record.h1, parser.h1) unless parser.h1 == record.h1 error_msg.unshift "url: #{record.url}" unless error_msg.empty? error_msgs.push error_msg unless error_msg.empty? end error_msgs end |