Class: Epuber::CheckerTransformerBase

Inherits:
Object
  • Object
show all
Defined in:
lib/epuber/checker_transformer_base.rb

Direct Known Subclasses

Checker, Transformer

Instance Attribute Summary collapse

Registration collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, *options, &block) ⇒ CheckerTransformerBase

Returns a new instance of CheckerTransformerBase.

Parameters:

  • type (Symbol)

    type of checker, see #type

  • options (Array<Symbol>)

    list of other arguments, usually flags



26
27
28
29
30
31
32
33
34
35
# File 'lib/epuber/checker_transformer_base.rb', line 26

def initialize(type, *options, &block)
  @source_type = type
  @block = block

  valid_options_inst = valid_options
  options.each do |opt|
    raise "Unknown option #{opt.inspect}" unless valid_options_inst.include?(opt)
  end
  @options = options
end

Instance Attribute Details

#blockProc (readonly)

Returns:

  • (Proc)


20
21
22
# File 'lib/epuber/checker_transformer_base.rb', line 20

def block
  @block
end

#optionsArray<Symbol> (readonly)

List of options/flags passed in from plugin instance

Returns:

  • (Array<Symbol>)


16
17
18
# File 'lib/epuber/checker_transformer_base.rb', line 16

def options
  @options
end

#source_typeSymbol (readonly)

Type of source value for this checker, valid values are:

:result_text_xhtml_string     just before writing result xhtml to build folder

Returns:

  • (Symbol)


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

def source_type
  @source_type
end

Class Method Details

.class_for_source_type(type) ⇒ Class

Parameters:

  • type (Symbol)

Returns:

  • (Class)


62
63
64
65
66
67
# File 'lib/epuber/checker_transformer_base.rb', line 62

def self.class_for_source_type(type)
  checker_class = map_source_type__class[type]
  raise "#{self} class not found for type: #{type.inspect}" if checker_class.nil?

  checker_class
end

.map_source_type__classHash<Symbol, Class>

Returns:

  • (Hash<Symbol, Class>)


54
55
56
# File 'lib/epuber/checker_transformer_base.rb', line 54

def self.map_source_type__class
  {}
end

Instance Method Details

#call(*args) ⇒ Object

Raises:

  • (NotImplementedError)


43
44
45
# File 'lib/epuber/checker_transformer_base.rb', line 43

def call(*args)
  raise NotImplementedError, 'You should override this method'
end

#valid_optionsArray<Symbol>

Returns:

  • (Array<Symbol>)


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

def valid_options
  [:run_only_before_release]
end