Class: Epuber::Plugin::PluginFile

Inherits:
Compiler::FileTypes::SourceFile show all
Defined in:
lib/epuber/plugin.rb

Instance Attribute Summary collapse

Attributes inherited from Compiler::FileTypes::SourceFile

#abs_source_path, #file_request, #source_path

Attributes inherited from Compiler::FileTypes::AbstractFile

#compilation_context, #destination_path, #final_destination_path, #group, #path_type, #pkg_destination_path, #properties

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Compiler::FileTypes::SourceFile

#default_file_copy, #destination_file_exist?, #destination_file_up_to_date?, #find_dependencies, #process, #properties, resolve_relative_file, #source_file_up_to_date?, #update_metadata!, #write_compiled, #write_processed

Methods inherited from Compiler::FileTypes::AbstractFile

#==, file_copy!, write_to_file, write_to_file!, write_to_file?

Constructor Details

#initialize(file_path) ⇒ PluginFile

Returns a new instance of PluginFile.

Parameters:

  • relative_path (String)

    path to plugin file (relative to project root)



17
18
19
20
21
22
# File 'lib/epuber/plugin.rb', line 17

def initialize(file_path)
  super(file_path)
  @instances = []

  eval(::File.read(file_path), binding, file_path) # rubocop:disable Security/Eval
end

Instance Attribute Details

#instancesArray (readonly)

Returns:

  • (Array)


13
14
15
# File 'lib/epuber/plugin.rb', line 13

def instances
  @instances
end

Class Method Details

.plugin_instance_function(name, klass) ⇒ Object

Returns nil.

Parameters:

  • name (Symbol)

    name of the plugin function

  • klass (Class)

    class of what it should create

Returns:

  • nil



29
30
31
32
33
34
35
36
# File 'lib/epuber/plugin.rb', line 29

def self.plugin_instance_function(name, klass)
  define_method(name) do |source_type, *options, &block|
    checker_class = klass.class_for_source_type(source_type)
    checker = checker_class.new(source_type, *options, &block)
    instances << checker
    checker
  end
end

Instance Method Details

#check { ... } ⇒ Checker

Method for creating new instance of checker in packages

Parameters:

  • source_type (Symbol)

    source type of checker, see Checker#source_type

  • options (Array<Symbol>)

    list of other arguments, usually flags

Yields:

  • value for checking, depends on type of checker

Returns:



47
# File 'lib/epuber/plugin.rb', line 47

plugin_instance_function(:check, Checker)

#transform { ... } ⇒ Transformer

Method for creating new instance of checker in packages

Parameters:

  • source_type (Symbol)

    source type of transformer, see Transformer#source_type

  • options (Array<Symbol>)

    list of other arguments, usually flags

Yields:

  • value for checking, depends on type of checker

Returns:



57
# File 'lib/epuber/plugin.rb', line 57

plugin_instance_function(:transform, Transformer)