Class: Shakapacker::Commands
- Inherits:
- 
      Object
      
        - Object
- Shakapacker::Commands
 
- Defined in:
- lib/shakapacker/commands.rb
Instance Method Summary collapse
- #bootstrap ⇒ Object
- 
  
    
      #clean(count = 2, age = 3600)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Cleanup old assets in the compile directory. 
- #clobber ⇒ Object
- #compile ⇒ Object
- 
  
    
      #initialize(instance)  ⇒ Commands 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Commands. 
Constructor Details
#initialize(instance) ⇒ Commands
Returns a new instance of Commands.
| 4 5 6 | # File 'lib/shakapacker/commands.rb', line 4 def initialize(instance) @instance = instance end | 
Instance Method Details
#bootstrap ⇒ Object
| 47 48 49 | # File 'lib/shakapacker/commands.rb', line 47 def bootstrap manifest.refresh end | 
#clean(count = 2, age = 3600) ⇒ Object
Cleanup old assets in the compile directory. By default it will keep the latest version, 2 backups created within the past hour.
Examples
To force only 1 backup to be kept, set count=1 and age=0.
To only keep files created within the last 10 minutes, set count=0 and
age=600.
| 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | # File 'lib/shakapacker/commands.rb', line 18 def clean(count = 2, age = 3600) if config.public_output_path.exist? && config.manifest_path.exist? packs .map do |paths| paths.map { |path| [Time.now - File.mtime(path), path] } .sort .reject.with_index do |(file_age, _), index| file_age < age || index < count end .map { |_, path| path } end .flatten .compact .each do |file| if File.file?(file) File.delete(file) logger.info "Removed #{file}" end end end true end | 
#clobber ⇒ Object
| 42 43 44 45 | # File 'lib/shakapacker/commands.rb', line 42 def clobber config.public_output_path.rmtree if config.public_output_path.exist? config.cache_path.rmtree if config.cache_path.exist? end | 
#compile ⇒ Object
| 51 52 53 54 55 | # File 'lib/shakapacker/commands.rb', line 51 def compile compiler.compile.tap do |success| manifest.refresh if success end end |