lib/brief/util.rb in brief-1.4.4 vs lib/brief/util.rb in brief-1.5.0
- old
+ new
@@ -1,5 +1,15 @@
module Brief::Util
+ def self.split_doc_content(raw_content)
+ if raw_content =~ /^(---\s*\n.*?\n?)^(---\s*$\n?)/m
+ content = raw_content[(Regexp.last_match[1].size + Regexp.last_match[2].size)..-1]
+ frontmatter = YAML.load(Regexp.last_match[1]).to_mash
+ [content, frontmatter]
+ else
+ [nil, {}.to_mash]
+ end
+ end
+
def self.create_method_dispatcher_command_for(action, klass)
identifier = "#{ action } #{ klass.type_alias.to_s.pluralize }"
Object.class.class_eval do
command "#{identifier}" do |c|