Class: Epuber::Compiler::FileTypes::StylusFile
- Inherits:
-
CSSFile
- Object
- AbstractFile
- SourceFile
- CSSFile
- Epuber::Compiler::FileTypes::StylusFile
- Defined in:
- lib/epuber/compiler/file_types/stylus_file.rb
Constant Summary
Constants inherited from CSSFile
CSSFile::DECLARATION_TO_FILE_GROUP_MAP, CSSFile::URL_REGEXP
Instance Attribute Summary
Attributes inherited from SourceFile
#abs_source_path, #file_request, #source_path
Attributes inherited from AbstractFile
#compilation_context, #destination_path, #final_destination_path, #group, #path_type, #pkg_destination_path, #properties
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from CSSFile
Methods inherited from SourceFile
#default_file_copy, #destination_file_exist?, #destination_file_up_to_date?, #initialize, #properties, resolve_relative_file, #source_file_up_to_date?, #update_metadata!, #write_compiled, #write_processed
Methods inherited from AbstractFile
#==, file_copy!, write_to_file, write_to_file!, write_to_file?
Constructor Details
This class inherits a constructor from Epuber::Compiler::FileTypes::SourceFile
Class Method Details
.find_imports(content) ⇒ Array<String>
38 39 40 |
# File 'lib/epuber/compiler/file_types/stylus_file.rb', line 38 def self.find_imports(content) content.to_enum(:scan, /^\s*@import ("|')([^'"]*)("|')/).map { Regexp.last_match[2] } end |
Instance Method Details
#find_dependencies ⇒ Object
32 33 34 |
# File 'lib/epuber/compiler/file_types/stylus_file.rb', line 32 def find_dependencies self.class.find_imports(File.read(abs_source_path)) end |
#process(compilation_context) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/epuber/compiler/file_types/stylus_file.rb', line 13 def process(compilation_context) if destination_file_up_to_date? # HACK: for now, we need to process the file again, because we need to find linked files process_css(File.read(final_destination_path), compilation_context) return end Stylus.define('__is_debug', !compilation_context.release_build) Stylus.define('__is_verbose_mode', compilation_context.verbose?) Stylus.define('__target_name', compilation_context.target.name) Stylus.define('__book_title', compilation_context.book.title) Stylus.define('__const', compilation_context.target.constants) css = Stylus.compile(File.new(abs_source_path)) write_compiled(process_css(css, compilation_context)) end |