Class: Udongo::Assets::Precompiler
- Inherits:
-
Object
- Object
- Udongo::Assets::Precompiler
- Defined in:
- lib/udongo/assets/precompiler.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
Instance Method Summary collapse
- #add(type, source) ⇒ Object
- #add_images_to_precompile_list(path) ⇒ Object
- #add_javascripts_to_precompile_list(path) ⇒ Object
- #add_stylesheets_to_precompile_list(path) ⇒ Object
- #glob_files(path, &block) ⇒ Object
-
#initialize(app) ⇒ Precompiler
constructor
A new instance of Precompiler.
Constructor Details
#initialize(app) ⇒ Precompiler
Returns a new instance of Precompiler.
6 7 8 |
# File 'lib/udongo/assets/precompiler.rb', line 6 def initialize(app) @app = app end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
4 5 6 |
# File 'lib/udongo/assets/precompiler.rb', line 4 def app @app end |
Instance Method Details
#add(type, source) ⇒ Object
10 11 12 13 14 |
# File 'lib/udongo/assets/precompiler.rb', line 10 def add(type, source) %W(#{Udongo::PATH}/#{source} #{Rails.root}/#{source}).each do |path| self.send("add_#{type}_to_precompile_list", path) end end |
#add_images_to_precompile_list(path) ⇒ Object
16 17 18 19 20 |
# File 'lib/udongo/assets/precompiler.rb', line 16 def add_images_to_precompile_list(path) glob_files(path) do |f| app.config.assets.precompile += [f.split('images/').last] end end |
#add_javascripts_to_precompile_list(path) ⇒ Object
22 23 24 25 26 |
# File 'lib/udongo/assets/precompiler.rb', line 22 def add_javascripts_to_precompile_list(path) glob_files(path) do |f| app.config.assets.precompile += [f.split('javascripts/').last] end end |
#add_stylesheets_to_precompile_list(path) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/udongo/assets/precompiler.rb', line 28 def add_stylesheets_to_precompile_list(path) glob_files(path) do |f| filepath = f.split('stylesheets/').last filename = filepath.split('.').join('.') next if filename.split('/').last[0] == '_' if File.extname(filename) == '.scss' app.config.assets.precompile += ["#{filename.gsub('.scss', '.css')}"] else app.config.assets.precompile += [filepath] end end end |
#glob_files(path, &block) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/udongo/assets/precompiler.rb', line 42 def glob_files(path, &block) Dir.glob(path).each do |f| next if File.directory?(f) yield f end end |