Sha256: 02b9981bcdc2eabe6eec3f85f99a5771ce5c57dc9980fc6fbed28238fa5b9924

Contents?: true

Size: 812 Bytes

Versions: 1

Compression:

Stored size: 812 Bytes

Contents

class StyleguideController < ActionController::Base
  extend ActiveSupport::Memoizable
  layout "styleguide"

  def self.initialize_stylesheets_path_config
    self.config.stylesheets_path ||= {}
    self.config.stylesheets_path[:default] ||= File.join(Rails.root, Rails.application.paths["app/assets"], "stylesheets")
  end
  self.initialize_stylesheets_path_config

  def show 
    id = params[:id]
    id ||= :default

    @styleguide = styleguide(id)

    respond_to do |format|
      format.html { render id.to_s }
    end
  end

  protected
  def stylesheets_path id
    config = self.class.config.stylesheets_path[id.to_sym]
    raise RoutingError unless config
    config
  end

  def styleguide id
    path = stylesheets_path(id)
    @styleguide = Kss::Parser.new(path)
  end
  memoize :styleguide

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails-styleguide-0.0.3 app/controllers/styleguide_controller.rb