Class: CarthageCacheRes::Archiver
- Inherits:
-
Object
- Object
- CarthageCacheRes::Archiver
- Defined in:
- lib/carthage_cache_res/archiver.rb
Instance Attribute Summary collapse
-
#executor ⇒ Object
readonly
Returns the value of attribute executor.
Instance Method Summary collapse
- #archive(archive_path, destination_path, &filter_block) ⇒ Object
-
#initialize(executor = ShellCommandExecutor.new) ⇒ Archiver
constructor
A new instance of Archiver.
- #unarchive(archive_path, destination_path) ⇒ Object
Constructor Details
#initialize(executor = ShellCommandExecutor.new) ⇒ Archiver
Returns a new instance of Archiver.
7 8 9 |
# File 'lib/carthage_cache_res/archiver.rb', line 7 def initialize(executor = ShellCommandExecutor.new) @executor = executor end |
Instance Attribute Details
#executor ⇒ Object (readonly)
Returns the value of attribute executor.
5 6 7 |
# File 'lib/carthage_cache_res/archiver.rb', line 5 def executor @executor end |
Instance Method Details
#archive(archive_path, destination_path, &filter_block) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/carthage_cache_res/archiver.rb', line 11 def archive(archive_path, destination_path, &filter_block) files = Dir.entries(archive_path).select { |x| !x.start_with?(".") } files = files.select(&filter_block) if filter_block files = files.sort_by(&:downcase) executor.execute("cd #{archive_path} && zip -r -X #{File.(destination_path)} #{files.join(' ')} > /dev/null") end |
#unarchive(archive_path, destination_path) ⇒ Object
18 19 20 |
# File 'lib/carthage_cache_res/archiver.rb', line 18 def unarchive(archive_path, destination_path) executor.execute("unzip -o #{archive_path} -d #{destination_path} > /dev/null") end |