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>
- #verbose? ⇒ Boolean
Constructor Details
#initialize(book, target) ⇒ CompilationContext
Returns a new instance of CompilationContext.
103 104 105 106 107 108 109 |
# 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 |
Instance Attribute Details
#book ⇒ Epuber::Book (readonly)
9 10 11 |
# File 'lib/epuber/compiler/compilation_context.rb', line 9 def book @book end |
#file_resolver ⇒ Epuber::Compiler::FileResolver
17 18 19 |
# File 'lib/epuber/compiler/compilation_context.rb', line 17 def file_resolver @file_resolver end |
#release_build ⇒ Bool
81 82 83 |
# File 'lib/epuber/compiler/compilation_context.rb', line 81 def release_build @release_build end |
#should_check ⇒ Bool
73 74 75 |
# File 'lib/epuber/compiler/compilation_context.rb', line 73 def should_check @should_check end |
#should_write ⇒ Bool
77 78 79 |
# File 'lib/epuber/compiler/compilation_context.rb', line 77 def should_write @should_write end |
#source_file_database ⇒ Epuber::Compiler::FileDatabase (readonly)
This will track source files regardless of current target
23 24 25 |
# File 'lib/epuber/compiler/compilation_context.rb', line 23 def source_file_database @source_file_database end |
#target ⇒ Epuber::Book::Target (readonly)
13 14 15 |
# File 'lib/epuber/compiler/compilation_context.rb', line 13 def target @target end |
#target_file_database ⇒ Epuber::Compiler::FileDatabase (readonly)
This will track source files depend on current target
29 30 31 |
# File 'lib/epuber/compiler/compilation_context.rb', line 29 def target_file_database @target_file_database end |
#use_cache ⇒ Bool
85 86 87 |
# File 'lib/epuber/compiler/compilation_context.rb', line 85 def use_cache @use_cache end |
#verbose ⇒ Bool
89 90 91 |
# File 'lib/epuber/compiler/compilation_context.rb', line 89 def verbose @verbose end |
Instance Method Details
#debug? ⇒ Boolean
95 96 97 |
# File 'lib/epuber/compiler/compilation_context.rb', line 95 def debug? !release_build end |
#incremental_build? ⇒ Boolean
99 100 101 |
# File 'lib/epuber/compiler/compilation_context.rb', line 99 def incremental_build? use_cache end |
#perform_plugin_things(klass, source_type) {|instance| ... } ⇒ Object
Returns nil.
55 56 57 58 59 60 61 62 63 64 65 66 |
# 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..include?(:run_only_before_release) && !release_build yield instance end end end |
#plugins ⇒ Array<Epuber::Plugin>
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# 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? ⇒ Boolean
91 92 93 |
# File 'lib/epuber/compiler/compilation_context.rb', line 91 def verbose? verbose end |