Sha256: b4e8101f1acdc971412be9875fab72bea9de3f242ecadfa934bae7fdadfe0f58

Contents?: true

Size: 551 Bytes

Versions: 2

Compression:

Stored size: 551 Bytes

Contents

require "style_guide/partial"

module StyleGuide
  class Section
    attr_reader :path

    def initialize(path)
      @path = path
    end

    def id
      @id ||= path.to_s.downcase.gsub(/[^a-zA-Z0-9]/, " ").strip.gsub(/\s+/, "_")
    end

    def title
      @title ||= File.basename(path).titleize
    end

    def partials
      partial_paths.map { |path| StyleGuide::Partial.new(path) }.sort_by { |p| p.title }
    end

    private

    def partial_paths
      @partial_paths ||= Dir.glob(File.expand_path("**/_*.erb", path))
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
style-guide-0.2.1 lib/style_guide/section.rb
style-guide-0.2.0 lib/style_guide/section.rb