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 109
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 97
def debug?
  !release_build
end
incremental_build?() click to toggle source
# File lib/epuber/compiler/compilation_context.rb, line 101
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) @param [String] processing_time_step_name name of step for processing time

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

@return nil

# File lib/epuber/compiler/compilation_context.rb, line 53
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

      location = instance.block.source_location.map(&:to_s).join(':')
      message = "performing #{source_type.inspect} from plugin #{location}"
      UI.print_step_processing_time(message) do
        yield instance
      end
    end
  end
end
plugins() click to toggle source

@return [Array<Epuber::Plugin>]

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