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
- #target ⇒ Epuber::Book::Target readonly
- #verbose ⇒ Bool
Instance Method Summary collapse
-
#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.
80 81 82 83 |
# File 'lib/epuber/compiler/compilation_context.rb', line 80 def initialize(book, target) @book = book @target = 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
69 70 71 |
# File 'lib/epuber/compiler/compilation_context.rb', line 69 def release_build @release_build end |
#should_check ⇒ Bool
61 62 63 |
# File 'lib/epuber/compiler/compilation_context.rb', line 61 def should_check @should_check end |
#should_write ⇒ Bool
65 66 67 |
# File 'lib/epuber/compiler/compilation_context.rb', line 65 def should_write @should_write end |
#target ⇒ Epuber::Book::Target (readonly)
13 14 15 |
# File 'lib/epuber/compiler/compilation_context.rb', line 13 def target @target end |
#verbose ⇒ Bool
73 74 75 |
# File 'lib/epuber/compiler/compilation_context.rb', line 73 def verbose @verbose end |
Instance Method Details
#perform_plugin_things(klass, source_type) {|instance| ... } ⇒ Object
Returns nil.
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/epuber/compiler/compilation_context.rb', line 43 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>
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/epuber/compiler/compilation_context.rb', line 21 def plugins @plugins ||= @target.plugins.map do |path| begin plugin = Plugin.new(File.(path, Config.instance.project_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
75 76 77 |
# File 'lib/epuber/compiler/compilation_context.rb', line 75 def verbose? verbose end |