Class: BranchableCDNAssets::Manifest
- Inherits:
-
Object
- Object
- BranchableCDNAssets::Manifest
- Defined in:
- lib/branchable_cdn_assets/manifest.rb
Instance Attribute Summary collapse
-
#file_set ⇒ Object
readonly
Returns the value of attribute file_set.
-
#source_file ⇒ Object
readonly
Returns the value of attribute source_file.
Instance Method Summary collapse
-
#files ⇒ Array
list files set as an Array.
-
#initialize(source_file) ⇒ Manifest
constructor
A new instance of Manifest.
-
#merge_files(new_files) ⇒ Set
add new files to the manifest set.
-
#remove_files(files_to_remove) ⇒ Set
remove a set of files from the manifest.
-
#update_source_file! ⇒ Void
updates the manifest file with the most recent set of files.
Constructor Details
#initialize(source_file) ⇒ Manifest
Returns a new instance of Manifest.
8 9 10 11 |
# File 'lib/branchable_cdn_assets/manifest.rb', line 8 def initialize source_file @source_file = source_file @file_set = File.exists?(source_file) ? read_source_file : Set.new end |
Instance Attribute Details
#file_set ⇒ Object (readonly)
Returns the value of attribute file_set.
6 7 8 |
# File 'lib/branchable_cdn_assets/manifest.rb', line 6 def file_set @file_set end |
#source_file ⇒ Object (readonly)
Returns the value of attribute source_file.
6 7 8 |
# File 'lib/branchable_cdn_assets/manifest.rb', line 6 def source_file @source_file end |
Instance Method Details
#files ⇒ Array
list files set as an Array
15 16 17 |
# File 'lib/branchable_cdn_assets/manifest.rb', line 15 def files file_set.to_a end |
#merge_files(new_files) ⇒ Set
add new files to the manifest set
22 23 24 |
# File 'lib/branchable_cdn_assets/manifest.rb', line 22 def merge_files new_files file_set.merge Array(new_files) end |
#remove_files(files_to_remove) ⇒ Set
remove a set of files from the manifest
29 30 31 |
# File 'lib/branchable_cdn_assets/manifest.rb', line 29 def remove_files files_to_remove file_set.subtract Array(files_to_remove) end |
#update_source_file! ⇒ Void
updates the manifest file with the most recent set of files
36 37 38 39 40 41 42 |
# File 'lib/branchable_cdn_assets/manifest.rb', line 36 def update_source_file! destroy! && return if file_set.empty? File.open( source_file, 'w' ) do |file| file.write manifest_content end end |