Class: Tres::Packager
- Inherits:
-
Object
- Object
- Tres::Packager
- Includes:
- FileMethods
- Defined in:
- lib/tres/packager.rb
Instance Attribute Summary collapse
-
#asset_manager ⇒ Object
Returns the value of attribute asset_manager.
-
#root ⇒ Object
Returns the value of attribute root.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Packager
constructor
A new instance of Packager.
- #write(path) ⇒ Object
- #write_all ⇒ Object
Methods included from FileMethods
#append_to_file, #basename, #change_dir, #copy, #create_file, #delete!, #dir?, #dirname, #erb, #expand, #extname, #file?, #json, #mkdir_p, #move, #name_and_extension, #new_dir, #new_file, #read_file, #readlines, #relativize
Constructor Details
#initialize(options = {}) ⇒ Packager
Returns a new instance of Packager.
9 10 11 12 |
# File 'lib/tres/packager.rb', line 9 def initialize = {} @root = [:root] @asset_manager = [:asset_manager] end |
Instance Attribute Details
#asset_manager ⇒ Object
Returns the value of attribute asset_manager.
7 8 9 |
# File 'lib/tres/packager.rb', line 7 def asset_manager @asset_manager end |
#root ⇒ Object
Returns the value of attribute root.
7 8 9 |
# File 'lib/tres/packager.rb', line 7 def root @root end |
Instance Method Details
#write(path) ⇒ Object
14 15 16 |
# File 'lib/tres/packager.rb', line 14 def write path @asset_manager.compile_to_build path end |
#write_all ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/tres/packager.rb', line 18 def write_all index = Nokogiri::HTML(read_file(@root/'build'/'index.html')) scripts = index.css('script[src]') scripts.each do |script| write relativize(script['src'], '.') end styles = index.css('link[rel="stylesheet"][href]') styles.each do |style| write relativize(style['href'], '.') rescue nil end end |