Sha256: 5cd5602f95b3b374616a5ba2fe30d066068893bd88cc409c099ca7431e2129cb

Contents?: true

Size: 567 Bytes

Versions: 5

Compression:

Stored size: 567 Bytes

Contents

require "style_guide/partial"

module StyleGuide
  class Section
    attr_reader :path

    def initialize(path)
      @path = path
    end

    def id
      @id ||= File.basename(path).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, self) }.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

5 entries across 5 versions & 1 rubygems

Version Path
style-guide-0.6.2 lib/style_guide/section.rb
style-guide-0.6.1 lib/style_guide/section.rb
style-guide-0.6.0 lib/style_guide/section.rb
style-guide-0.5.0 lib/style_guide/section.rb
style-guide-0.4.0 lib/style_guide/section.rb