Class: Frontsau::Assets::Sprockets
- Inherits:
-
Sprockets::Environment
- Object
- Sprockets::Environment
- Frontsau::Assets::Sprockets
- Defined in:
- lib/frontsau/assets/sprockets.rb
Instance Attribute Summary collapse
-
#output_path ⇒ Object
Returns the value of attribute output_path.
-
#source_paths ⇒ Object
Returns the value of attribute source_paths.
Instance Method Summary collapse
- #compilable_paths ⇒ Object
- #dump(path) ⇒ Object
-
#initialize ⇒ Sprockets
constructor
A new instance of Sprockets.
- #manifest ⇒ Object
Constructor Details
#initialize ⇒ Sprockets
Returns a new instance of Sprockets.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/frontsau/assets/sprockets.rb', line 6 def initialize super() self.output_path = File. Frontsau.config[:assets][:path] Frontsau.config[:assets][:sources].each do |glob_dir| Dir[File.(glob_dir)].each do |dir| append_path dir end end self.register_postprocessor 'text/css', UrlRewriter end |
Instance Attribute Details
#output_path ⇒ Object
Returns the value of attribute output_path.
4 5 6 |
# File 'lib/frontsau/assets/sprockets.rb', line 4 def output_path @output_path end |
#source_paths ⇒ Object
Returns the value of attribute source_paths.
4 5 6 |
# File 'lib/frontsau/assets/sprockets.rb', line 4 def source_paths @source_paths end |
Instance Method Details
#compilable_paths ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/frontsau/assets/sprockets.rb', line 30 def compilable_paths return enum_for(:compilable_paths) unless block_given? each_logical_path do |path| Frontsau.config[:assets][:compile].each do |glob| yield path if File.fnmatch(glob, path) #puts "#{path} => #{glob} :: #{File.fnmatch(glob, path)}" end end end |
#dump(path) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/frontsau/assets/sprockets.rb', line 40 def dump path file = File.join output_path, path if !Dir.exist? File.dirname(file) FileUtils.mkpath File.dirname(file) end begin content = self[path].to_s File.write file, content return true rescue return false end end |
#manifest ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/frontsau/assets/sprockets.rb', line 17 def manifest m = {} compilable_paths.each do |path| asset = self[path] next unless asset.present? m[path] = { digest: asset.digest, modified: asset.mtime } end m end |