Class: WebAssets::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/web_assets/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_processorObject (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_processorObject (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, options = {}
  options[:bundle] = options.fetch :bundle, true
  options[:minify] = options.fetch :minify, false
  options[:gzip]   = options.fetch :gzip, false
  script_processor.content filename, options
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, options = {}
  options[:minify] = options.fetch :minify, false
  options[:gzip]   = options.fetch :gzip, false
  stylesheet_processor.content filename, options
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