class TeamApi::FrontMatter
Constants
- END_MARKER
- MARKER
- START_MARKER
Public Class Methods
update_front_matter(filename) { |front_matter| ... }
click to toggle source
# File lib/team_api/front_matter.rb, line 14 def self.update_front_matter(filename) end_front_matter = front_matter_end_index filename, content front_matter = content[0..end_front_matter] content = content[end_front_matter..-1] front_matter = SafeYAML.load front_matter, safe: true yield front_matter File.write filename.downcase, "#{front_matter.to_yaml}#{content}" end
Private Class Methods
front_matter_end_index(filename, content)
click to toggle source
# File lib/team_api/front_matter.rb, line 23 def self.front_matter_end_index(filename, content) unless content.start_with? START_MARKER fail Error, "#{filename}: contains no front matter" end end_front_matter = content.index END_MARKER, START_MARKER.size return end_front_matter unless end_front_matter.nil? fail Error, "#{filename}: front matter does not end with '#{MARKER}'" end