Method: Webgen::Page.parse_meta_info
- Defined in:
- lib/webgen/page.rb
.parse_meta_info(mi_data, has_mi_start) ⇒ Object
Parse the meta info string in mi_data and return the hash with the meta information. The original data is used for checking the validness of the meta information block.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/webgen/page.rb', line 45 def (mi_data, has_mi_start) if mi_data.nil? && has_mi_start raise FormatError, 'Found start line for meta information block but no valid meta information block' elsif mi_data.nil? {} else begin = YAML::load(mi_data.to_s) unless .kind_of?(Hash) raise FormatError, "Invalid structure of meta information block: expected YAML hash but found #{.class}" end rescue ArgumentError, SyntaxError, YAML::SyntaxError => e raise FormatError, "Invalid YAML syntax in meta information block: #{e.}" end end end |