Class: Sprockets::Secretary
- Inherits:
-
Object
- Object
- Sprockets::Secretary
- Defined in:
- lib/sprockets/secretary.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ :root => ".", :load_path => [], :source_files => [], :expand_paths => true }
Instance Attribute Summary collapse
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#preprocessor ⇒ Object
readonly
Returns the value of attribute preprocessor.
Instance Method Summary collapse
- #add_load_location(load_location, options = {}) ⇒ Object
- #add_load_locations(load_locations, options = {}) ⇒ Object
- #add_source_file(source_file, options = {}) ⇒ Object
- #add_source_files(source_files, options = {}) ⇒ Object
- #concatenation ⇒ Object
-
#initialize(options = {}) ⇒ Secretary
constructor
A new instance of Secretary.
- #install_assets ⇒ Object
- #reset!(options = @options) ⇒ Object
- #source_last_modified ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Secretary
Returns a new instance of Secretary.
12 13 14 |
# File 'lib/sprockets/secretary.rb', line 12 def initialize( = {}) reset!() end |
Instance Attribute Details
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
10 11 12 |
# File 'lib/sprockets/secretary.rb', line 10 def environment @environment end |
#preprocessor ⇒ Object (readonly)
Returns the value of attribute preprocessor.
10 11 12 |
# File 'lib/sprockets/secretary.rb', line 10 def preprocessor @preprocessor end |
Instance Method Details
#add_load_location(load_location, options = {}) ⇒ Object
25 26 27 |
# File 'lib/sprockets/secretary.rb', line 25 def add_load_location(load_location, = {}) add_load_locations([load_location], ) end |
#add_load_locations(load_locations, options = {}) ⇒ Object
29 30 31 32 33 |
# File 'lib/sprockets/secretary.rb', line 29 def add_load_locations(load_locations, = {}) (load_locations, ).each do |load_location| environment.register_load_location(load_location) end end |
#add_source_file(source_file, options = {}) ⇒ Object
35 36 37 |
# File 'lib/sprockets/secretary.rb', line 35 def add_source_file(source_file, = {}) add_source_files([source_file], ) end |
#add_source_files(source_files, options = {}) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/sprockets/secretary.rb', line 39 def add_source_files(source_files, = {}) (source_files, ).each do |source_file| if pathname = environment.find(source_file) preprocessor.require(pathname.source_file) else raise Sprockets::LoadError, "no such file `#{source_file}'" end end end |
#concatenation ⇒ Object
49 50 51 |
# File 'lib/sprockets/secretary.rb', line 49 def concatenation preprocessor.concatenation end |
#install_assets ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/sprockets/secretary.rb', line 53 def install_assets if @options[:asset_root] preprocessor.asset_paths.each do |asset_path| copy_assets_from(asset_path.absolute_location) end end end |
#reset!(options = @options) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/sprockets/secretary.rb', line 16 def reset!( = @options) @options = DEFAULT_OPTIONS.merge() @environment = Sprockets::Environment.new(@options[:root]) @preprocessor = Sprockets::Preprocessor.new(@environment) add_load_locations(@options[:load_path]) add_source_files(@options[:source_files]) end |
#source_last_modified ⇒ Object
61 62 63 |
# File 'lib/sprockets/secretary.rb', line 61 def source_last_modified preprocessor.source_files.map { |s| s.mtime }.max end |