Method: Licensed::Migrations::V2.parse_file

Defined in:
lib/licensed/migrations/v2.rb

.parse_file(filename) ⇒ Object

find the yaml and non-yaml data according to parsing logic from v1



57
58
59
60
61
62
63
64
# File 'lib/licensed/migrations/v2.rb', line 57

def self.parse_file(filename)
  match = File.read(filename).scrub.match(YAML_FRONTMATTER_PATTERN)
  yaml = YAML.load(match[1])
  # in v1, licenses and notices are separated by special text dividers
  licenses, *notices = match[2].split(TEXT_SEPARATOR).map(&:strip)
  licenses = licenses.split(LICENSE_SEPARATOR).map(&:strip)
  [yaml, licenses, notices]
end