Class: WebAssets::Api
- Inherits:
-
Object
- Object
- WebAssets::Api
- Defined in:
- lib/web_assets/api.rb
Instance Attribute Summary collapse
-
#script_processor ⇒ Object
readonly
Returns the value of attribute script_processor.
-
#stylesheet_processor ⇒ Object
readonly
Returns the value of attribute stylesheet_processor.
Instance Method Summary collapse
-
#add_script_load_path(path) ⇒ Object
append a path to the script load path and return :ok.
-
#add_stylesheet_load_path(path) ⇒ Object
append a path to the stylesheet load path and return :ok.
-
#initialize(script_processor, stylesheet_processor) ⇒ Api
constructor
A new instance of Api.
-
#script_content(filename, options = {}) ⇒ Object
return the script content as a string boolean options: - bundle: inline all dependencies - minify: minify the content - gzip: return the gzipped binary content.
-
#script_digest_filename(filename) ⇒ Object
return the script filename with its content digest.
-
#script_filenames(filename) ⇒ Object
return an array of the filenames the script filename depends on and itself.
-
#set_script_path(path) ⇒ Object
set the script path and return :ok.
-
#set_stylesheet_path(path) ⇒ Object
set the stylesheet path and return :ok.
-
#stylesheet_content(filename, options = {}) ⇒ Object
return the stylesheet content processed, as a string boolean options: - minify: minify the content - gzip: return the gzipped binary content.
-
#stylesheet_digest_filename(filename) ⇒ Object
return the stylesheet filename with its content digest.
Constructor Details
#initialize(script_processor, stylesheet_processor) ⇒ Api
Returns a new instance of Api.
7 8 9 10 |
# File 'lib/web_assets/api.rb', line 7 def initialize script_processor, stylesheet_processor @script_processor = script_processor @stylesheet_processor = stylesheet_processor end |
Instance Attribute Details
#script_processor ⇒ Object (readonly)
Returns the value of attribute script_processor.
5 6 7 |
# File 'lib/web_assets/api.rb', line 5 def script_processor @script_processor end |
#stylesheet_processor ⇒ Object (readonly)
Returns the value of attribute stylesheet_processor.
5 6 7 |
# File 'lib/web_assets/api.rb', line 5 def stylesheet_processor @stylesheet_processor end |
Instance Method Details
#add_script_load_path(path) ⇒ Object
append a path to the script load path and return :ok
29 30 31 |
# File 'lib/web_assets/api.rb', line 29 def add_script_load_path path script_processor.add_load_path path end |
#add_stylesheet_load_path(path) ⇒ Object
append a path to the stylesheet load path and return :ok
36 37 38 |
# File 'lib/web_assets/api.rb', line 36 def add_stylesheet_load_path path stylesheet_processor.add_load_path path end |
#script_content(filename, options = {}) ⇒ Object
return the script content as a string boolean options:
- bundle: inline all dependencies
- minify: minify the content
- gzip: return the gzipped binary content
61 62 63 64 65 66 |
# File 'lib/web_assets/api.rb', line 61 def script_content filename, = {} [:bundle] = .fetch :bundle, true [:minify] = .fetch :minify, false [:gzip] = .fetch :gzip, false script_processor.content filename, end |
#script_digest_filename(filename) ⇒ Object
return the script filename with its content digest
50 51 52 |
# File 'lib/web_assets/api.rb', line 50 def script_digest_filename filename script_processor.digest_filename filename end |
#script_filenames(filename) ⇒ Object
return an array of the filenames the script filename depends on and itself
43 44 45 |
# File 'lib/web_assets/api.rb', line 43 def script_filenames filename script_processor.filenames filename end |
#set_script_path(path) ⇒ Object
set the script path and return :ok
15 16 17 |
# File 'lib/web_assets/api.rb', line 15 def set_script_path path script_processor.set_path path end |
#set_stylesheet_path(path) ⇒ Object
set the stylesheet path and return :ok
22 23 24 |
# File 'lib/web_assets/api.rb', line 22 def set_stylesheet_path path stylesheet_processor.set_path path end |
#stylesheet_content(filename, options = {}) ⇒ Object
return the stylesheet content processed, as a string boolean options:
- minify: minify the content
- gzip: return the gzipped binary content
81 82 83 84 85 |
# File 'lib/web_assets/api.rb', line 81 def stylesheet_content filename, = {} [:minify] = .fetch :minify, false [:gzip] = .fetch :gzip, false stylesheet_processor.content filename, end |
#stylesheet_digest_filename(filename) ⇒ Object
return the stylesheet filename with its content digest
71 72 73 |
# File 'lib/web_assets/api.rb', line 71 def stylesheet_digest_filename filename stylesheet_processor.digest_filename filename end |