class Apidoco::FileParser

Parse a folder and find all the sub folders and files

Attributes

file[RW]
parents[RW]

Public Class Methods

new(file, parents:) click to toggle source
# File lib/apidoco/file_parser.rb, line 6
def initialize(file, parents:)
  self.file = file
  self.parents = parents
end

Public Instance Methods

as_json() click to toggle source
# File lib/apidoco/file_parser.rb, line 11
def as_json
  content.merge(parents: parents, id: id)
end
content() click to toggle source
# File lib/apidoco/file_parser.rb, line 15
def content
  @content ||= JSON.parse(File.read(file))
rescue JSON::ParserError => e
  raise Apidoco::FileParseError.new file, e.message
end
id() click to toggle source
# File lib/apidoco/file_parser.rb, line 21
def id
  parents.push(content['name']).join('-').downcase.delete(' ')
end
published?() click to toggle source
# File lib/apidoco/file_parser.rb, line 25
def published?
  content['published'].nil? || content['published']
end
sort_order() click to toggle source
# File lib/apidoco/file_parser.rb, line 29
def sort_order
  content['sort_order'] || 999
end