Module: Repper

Defined in:
lib/repper/core_ext/kernel_ext.rb,
lib/repper.rb,
lib/repper/theme.rb,
lib/repper/token.rb,
lib/repper/errors.rb,
lib/repper/format.rb,
lib/repper/codemod.rb,
lib/repper/command.rb,
lib/repper/version.rb,
lib/repper/tokenizer.rb,
lib/repper/theme/plain.rb,
lib/repper/format/plain.rb,
lib/repper/format/inline.rb,
lib/repper/theme/default.rb,
lib/repper/theme/monokai.rb,
lib/repper/format/extended.rb,
lib/repper/format/annotated.rb,
lib/repper/format/structured.rb,
lib/repper/core_ext/regexp_ext.rb,
lib/repper/format/tabulo_style.rb

Overview

This extension does not include itself automatically, require ‘repper/core_ext/regexp’ to do so.

Defined Under Namespace

Modules: Codemod, Command, Error, Format, IRBExt, KernelExt, PryExt, RegexpExt, Tokenizer Classes: ArgumentError, Theme, Token

Constant Summary collapse

VERSION =
"1.1.0"
ALREADY_COLORED_MARK =
:@__already_colored__

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.formatObject

Returns the value of attribute format.



12
13
14
# File 'lib/repper.rb', line 12

def format
  @format
end

.themeObject

Returns the value of attribute theme.



12
13
14
# File 'lib/repper.rb', line 12

def theme
  @theme
end

Class Method Details

.call(regexp, format: self.format, theme: self.theme) ⇒ Object



14
15
16
# File 'lib/repper.rb', line 14

def call(regexp, format: self.format, theme: self.theme)
  puts render(regexp, format: format, theme: theme)
end

.prevent_color_override_by_replObject



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

def self.prevent_color_override_by_repl
  # Must be applied lazily because REPLs may be loaded after dependencies.
  return if @prevented_color_override

  if defined?(::IRB::Color)
    ::IRB::Color.singleton_class.prepend(IRBExt)
  end

  if defined?(::Pry::SyntaxHighlighter)
    ::Pry::SyntaxHighlighter.singleton_class.prepend(PryExt)
  end

  @prevented_color_override = true
end

.render(regexp, format: self.format, theme: self.theme) ⇒ Object



18
19
20
21
22
23
# File 'lib/repper.rb', line 18

def render(regexp, format: self.format, theme: self.theme)
  tokens = Tokenizer.call(regexp)
  format = Format.cast(format)
  theme  = Theme.cast(theme)
  format.call(tokens, theme)
end