Sha256: 14774cb42aaf529717652e69d73d149d91525af6c029070c756d5b123257150d
Contents?: true
Size: 1.4 KB
Versions: 11
Compression:
Stored size: 1.4 KB
Contents
module Lookbook class PreviewExample include Taggable attr_reader :name def initialize(name, preview) @name = name @preview = preview end def id path.underscore.tr("_", "-") end def path "#{@preview.lookbook_path}/#{name}" end def label lookbook_label.presence || name.titleize end def method_source code_object.source.split("\n")[1..-2].join("\n").strip_heredoc end def source_lang Lookbook::Lang.find(:ruby) end def template_source(template_path) File.read(full_template_path(template_path)) end def template_lang(template_path) Lookbook::Lang.guess(full_template_path(template_path)) || Lookbook::Lang.find(:html) end def type :example end def matchers [@preview.label, label].map { |m| m.gsub(/\s/, "").downcase } end def hierarchy_depth @preview.lookbook_hierarchy_depth + 1 end private def taggable_object_path "#{@preview.name}##{name}" end def full_template_path(template_path) base_path = Array(Lookbook.config.preview_paths).detect do |p| Dir["#{p}/#{template_path}.html.*"].first end Pathname.new(Dir["#{base_path}/#{template_path}.html.*"].first) end alias_method :group, :lookbook_group alias_method :notes, :lookbook_notes alias_method :hidden?, :lookbook_hidden? end end
Version data entries
11 entries across 11 versions & 1 rubygems