Module: Showcase

Defined in:
lib/showcase.rb,
lib/showcase/engine.rb,
lib/showcase/version.rb

Defined Under Namespace

Modules: RouteHelper Classes: Engine, EngineController, Options, Path, Preview, PreviewsController, PreviewsTest, Sample

Constant Summary collapse

VERSION =
"0.4.6"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#sample_renderer=(value) ⇒ Object (writeonly)

Sets the attribute sample_renderer

Parameters:

  • value

    the value to set the attribute sample_renderer to.



15
16
17
# File 'lib/showcase.rb', line 15

def sample_renderer=(value)
  @sample_renderer = value
end

#tree_opensObject (readonly)

Returns the value of attribute tree_opens.



8
9
10
# File 'lib/showcase.rb', line 8

def tree_opens
  @tree_opens
end

Class Method Details

.optionsObject



39
40
41
# File 'lib/showcase.rb', line 39

def self.options
  Options
end

.previewsObject



33
34
35
36
37
# File 'lib/showcase.rb', line 33

def self.previews
  Showcase::EngineController.view_paths.map(&:path).flat_map do |root|
    Dir.glob("**/*.*", base: File.join(root, "showcase/previews"))
  end.uniq
end

.sample_rendererObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/showcase.rb', line 17

def self.sample_renderer
  @sample_renderer ||=
    begin
      gem "rouge" # Activate the app-bundled Rouge gem to setup default syntax highlighting.
      require "rouge"

      formatter = Rouge::Formatters::HTML.new
      @sample_renderer = ->(source, syntax) do
        lexed = Rouge::Lexer.find(syntax).lex(source)
        formatter.format(lexed).html_safe
      end
    rescue LoadError
      proc { _1 }
    end
end

.tree_opens=(opens) ⇒ Object



10
11
12
# File 'lib/showcase.rb', line 10

def self.tree_opens=(opens)
  @tree_opens = opens.respond_to?(:call) ? opens : proc { opens }
end