class Epuber::Compiler::CompilationContext

Attributes

book[R]

@return [Epuber::Book]

file_resolver[RW]

@return [Epuber::Compiler::FileResolver]

release_build[RW]

@return [Bool]

should_check[RW]

@return [Bool]

should_write[RW]

@return [Bool]

source_file_database[R]

This will track source files regardless of current target

@return [Epuber::Compiler::FileDatabase]

target[R]

@return [Epuber::Book::Target]

target_file_database[R]

This will track source files depend on current target

@return [Epuber::Compiler::FileDatabase]

use_cache[RW]

@return [Bool]

verbose[RW]

@return [Bool]

Public Class Methods

new(book, target) click to toggle source
# File lib/epuber/compiler/compilation_context.rb, line 103
def initialize(book, target)
  @book = book
  @target = target

  @source_file_database = FileDatabase.new(Config.instance.file_stat_database_path)
  @target_file_database = FileDatabase.new(Config.instance.target_file_stat_database_path(target))
end

Public Instance Methods

debug?() click to toggle source
# File lib/epuber/compiler/compilation_context.rb, line 95
def debug?
  !release_build
end
incremental_build?() click to toggle source
# File lib/epuber/compiler/compilation_context.rb, line 99
def incremental_build?
  use_cache
end
perform_plugin_things(klass, source_type) { |instance| ... } click to toggle source

@param [Class] klass class of thing you want to perform (Checker or Transformer) @param [Symbol] source_type source type of that thing (Checker or Transformer)

@yield @yieldparam [Epuber::CheckerTransformerBase] instance of checker or transformer

@return nil

# File lib/epuber/compiler/compilation_context.rb, line 55
def perform_plugin_things(klass, source_type)
  plugins.each do |plugin|
    plugin.instances(klass).each do |instance|
      # @type [Epuber::CheckerTransformerBase] instance

      next if instance.source_type != source_type
      next if instance.options.include?(:run_only_before_release) && !release_build

      yield instance
    end
  end
end
plugins() click to toggle source

@return [Array<Epuber::Plugin>]

# File lib/epuber/compiler/compilation_context.rb, line 33
def plugins
  @plugins ||= @target.plugins.map do |path|
    begin
      plugin = Plugin.new(path)
      plugin.files.each do |file|
        file_resolver.add_file(file)
      end
      plugin
    rescue LoadError
      UI.error "Can't find plugin at path #{path}"
    end
  end.compact
end
verbose?() click to toggle source
# File lib/epuber/compiler/compilation_context.rb, line 91
def verbose?
  verbose
end