Class: Preflight::Rules::MatchInfoEntries
- Inherits:
-
Object
- Object
- Preflight::Rules::MatchInfoEntries
- Defined in:
- lib/preflight/rules/match_info_entries.rb
Overview
Instance Method Summary collapse
- #check_hash(ohash) ⇒ Object
-
#initialize(matches = {}) ⇒ MatchInfoEntries
constructor
A new instance of MatchInfoEntries.
Constructor Details
#initialize(matches = {}) ⇒ MatchInfoEntries
Returns a new instance of MatchInfoEntries.
20 21 22 |
# File 'lib/preflight/rules/match_info_entries.rb', line 20 def initialize(matches = {}) @matches = matches end |
Instance Method Details
#check_hash(ohash) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/preflight/rules/match_info_entries.rb', line 24 def check_hash(ohash) array = [] info = ohash.object(ohash.trailer[:Info]) @matches.each do |key, regexp| if !info.has_key?(key) array << Issue.new("Info dict missing required key", self, :key => key) elsif !info[key].to_s.match(regexp) array << Issue.new("value of Info entry #{key} doesn't match #{regexp}", self, :key => key, :regexp => regexp) end end array end |