Class: Stylo::Processor
- Inherits:
-
Object
- Object
- Stylo::Processor
- Defined in:
- lib/stylo/processor.rb
Instance Method Summary collapse
- #get_file_content(asset_path) ⇒ Object
- #get_stylesheet_path(asset) ⇒ Object
-
#initialize ⇒ Processor
constructor
A new instance of Processor.
- #process_asset(asset) ⇒ Object
Constructor Details
#initialize ⇒ Processor
Returns a new instance of Processor.
3 4 |
# File 'lib/stylo/processor.rb', line 3 def initialize end |
Instance Method Details
#get_file_content(asset_path) ⇒ Object
26 27 28 29 30 |
# File 'lib/stylo/processor.rb', line 26 def get_file_content(asset_path) return nil if !File.exist?(asset_path) File.read(asset_path) end |
#get_stylesheet_path(asset) ⇒ Object
6 7 8 |
# File 'lib/stylo/processor.rb', line 6 def get_stylesheet_path(asset) File.join(Stylo::Config.asset_location, asset) end |
#process_asset(asset) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/stylo/processor.rb', line 10 def process_asset(asset) asset_path = get_stylesheet_path(asset) asset_extension = File.extname(asset_path) file_content = get_file_content(asset_path) if !file_content.nil? asset_dir = File.dirname(asset_path) import_regex = asset_extension == '.css' ? /@import "(.*)";/ : /\/\/\/require "(.*)";/ process_requires file_content, asset_dir, import_regex else nil end end |