Class: Paste::Parser::Sprockets
- Inherits:
-
Object
- Object
- Paste::Parser::Sprockets
- Defined in:
- lib/paste/parser/sprockets.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#glue ⇒ Object
readonly
Returns the value of attribute glue.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #copy_if_needed ⇒ Object
- #css_dependencies ⇒ Object
-
#initialize(glue, source) ⇒ Sprockets
constructor
A new instance of Sprockets.
- #js_dependencies ⇒ Object
- #reset_if_needed ⇒ Object
Constructor Details
#initialize(glue, source) ⇒ Sprockets
Returns a new instance of Sprockets.
9 10 11 12 13 14 |
# File 'lib/paste/parser/sprockets.rb', line 9 def initialize glue, source @glue = glue @source = source @file = glue.find source reset_if_needed end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
7 8 9 |
# File 'lib/paste/parser/sprockets.rb', line 7 def file @file end |
#glue ⇒ Object (readonly)
Returns the value of attribute glue.
7 8 9 |
# File 'lib/paste/parser/sprockets.rb', line 7 def glue @glue end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
7 8 9 |
# File 'lib/paste/parser/sprockets.rb', line 7 def source @source end |
Instance Method Details
#copy_if_needed ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/paste/parser/sprockets.rb', line 26 def copy_if_needed dest = glue.destination(source) if !File.exists?(dest) || File.mtime(dest) != File.mtime(@file) FileUtils.mkdir_p File.dirname(dest) FileUtils.cp @file, dest File.utime File.mtime(@file), File.mtime(@file), dest end end |
#css_dependencies ⇒ Object
21 22 23 24 |
# File 'lib/paste/parser/sprockets.rb', line 21 def css_dependencies reset_if_needed @css_dependencies end |
#js_dependencies ⇒ Object
16 17 18 19 |
# File 'lib/paste/parser/sprockets.rb', line 16 def js_dependencies reset_if_needed @js_dependencies end |
#reset_if_needed ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/paste/parser/sprockets.rb', line 36 def reset_if_needed if @js_dependencies.nil? || @css_dependencies.nil? || @last_updated.nil? || @last_updated < File.mtime(@file) @last_updated = Time.now @secretary = ::Sprockets::Secretary.new( :root => glue.root, :expand_paths => false, :load_path => glue.load_path, :source_files => [@file] ) generate_dependencies end end |