module Lookbook::InspectableEntity

def custom_source?

Other tags:
    Api: - private
def custom_source?
  source_file_path.present?
end

def source

Returns:
  • (String) - The source code0
def source
  source_code = if custom_source?
    File.read(source_file_path)
  else
    src = CodeIndenter.call(code_object.source)
    begin
      send(:format_source, src)
    rescue NoMethodError
      src
    end
  end
  source_code.strip_heredoc.strip
end

def source_file_path

def source_file_path
  @_source_path ||= if code_object.has_tag?(:source)
    source_path = code_object.tag(:source).value
    unless source_path.present? && File.exist?(source_path)
      raise Lookbook::Error, "Could not find source file '#{source_path}'"
    end
    source_path
  end
end

def source_lang

Returns:
  • (Hash) - Language info hash

Other tags:
    Example: :ruby -
def source_lang
  custom_source? ? Lang.guess(source_file_path, :ruby) : Lang.find(:ruby)
end