Class: Epuber::Compiler::CompilationContext
- Inherits:
-
Object
- Object
- Epuber::Compiler::CompilationContext
- Defined in:
- lib/epuber/compiler/compilation_context.rb
Instance Attribute Summary collapse
- #book ⇒ Epuber::Book readonly
- #file_resolver ⇒ Epuber::Compiler::FileResolver
- #release_build ⇒ Bool
- #should_check ⇒ Bool
- #should_write ⇒ Bool
-
#source_file_database ⇒ Epuber::Compiler::FileDatabase
readonly
This will track source files regardless of current target.
- #target ⇒ Epuber::Book::Target readonly
-
#target_file_database ⇒ Epuber::Compiler::FileDatabase
readonly
This will track source files depend on current target.
- #use_cache ⇒ Bool
- #verbose ⇒ Bool
Instance Method Summary collapse
- #debug? ⇒ Boolean
- #incremental_build? ⇒ Boolean
-
#initialize(book, target) ⇒ CompilationContext
constructor
A new instance of CompilationContext.
-
#perform_plugin_things(klass, source_type) {|instance| ... } ⇒ Object
Nil.
- #plugins ⇒ Array<Epuber::Plugin>
- #release_build? ⇒ Boolean
- #verbose? ⇒ Boolean
Constructor Details
#initialize(book, target) ⇒ CompilationContext
Returns a new instance of CompilationContext.
109 110 111 112 113 114 115 |
# 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 |
Instance Attribute Details
#book ⇒ Epuber::Book (readonly)
8 9 10 |
# File 'lib/epuber/compiler/compilation_context.rb', line 8 def book @book end |
#file_resolver ⇒ Epuber::Compiler::FileResolver
16 17 18 |
# File 'lib/epuber/compiler/compilation_context.rb', line 16 def file_resolver @file_resolver end |
#release_build ⇒ Bool
83 84 85 |
# File 'lib/epuber/compiler/compilation_context.rb', line 83 def release_build @release_build end |
#should_check ⇒ Bool
75 76 77 |
# File 'lib/epuber/compiler/compilation_context.rb', line 75 def should_check @should_check end |
#should_write ⇒ Bool
79 80 81 |
# File 'lib/epuber/compiler/compilation_context.rb', line 79 def should_write @should_write end |
#source_file_database ⇒ Epuber::Compiler::FileDatabase (readonly)
This will track source files regardless of current target
22 23 24 |
# File 'lib/epuber/compiler/compilation_context.rb', line 22 def source_file_database @source_file_database end |
#target ⇒ Epuber::Book::Target (readonly)
12 13 14 |
# File 'lib/epuber/compiler/compilation_context.rb', line 12 def target @target end |
#target_file_database ⇒ Epuber::Compiler::FileDatabase (readonly)
This will track source files depend on current target
28 29 30 |
# File 'lib/epuber/compiler/compilation_context.rb', line 28 def target_file_database @target_file_database end |
#use_cache ⇒ Bool
87 88 89 |
# File 'lib/epuber/compiler/compilation_context.rb', line 87 def use_cache @use_cache end |
#verbose ⇒ Bool
91 92 93 |
# File 'lib/epuber/compiler/compilation_context.rb', line 91 def verbose @verbose end |
Instance Method Details
#debug? ⇒ Boolean
97 98 99 |
# File 'lib/epuber/compiler/compilation_context.rb', line 97 def debug? !release_build end |
#incremental_build? ⇒ Boolean
101 102 103 |
# File 'lib/epuber/compiler/compilation_context.rb', line 101 def incremental_build? use_cache end |
#perform_plugin_things(klass, source_type) {|instance| ... } ⇒ Object
Returns nil.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# 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..include?(:run_only_before_release) && !release_build location = instance.block.source_location.map(&:to_s).join(':') = "performing #{source_type.inspect} from plugin #{location}" UI.print_step_processing_time() do yield instance end end end end |
#plugins ⇒ Array<Epuber::Plugin>
32 33 34 35 36 37 38 39 40 41 42 |
# 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? ⇒ Boolean
105 106 107 |
# File 'lib/epuber/compiler/compilation_context.rb', line 105 def release_build? release_build end |
#verbose? ⇒ Boolean
93 94 95 |
# File 'lib/epuber/compiler/compilation_context.rb', line 93 def verbose? verbose end |