Class: Omnizip::Formats::SevenZip::FileCollector
- Inherits:
-
Object
- Object
- Omnizip::Formats::SevenZip::FileCollector
- Defined in:
- lib/omnizip/formats/seven_zip/file_collector.rb
Overview
Collects files and directories for archiving Handles file metadata, timestamps, and attributes
Instance Attribute Summary collapse
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
Instance Method Summary collapse
-
#add_glob(pattern, base_path: nil) ⇒ Object
Add files matching glob pattern.
-
#add_path(path, archive_path: nil, recursive: true) ⇒ Object
Add path (file or directory) to collection.
-
#collect_files ⇒ Array<Models::FileEntry>
Get collected file entries.
-
#initialize ⇒ FileCollector
constructor
Initialize collector.
Constructor Details
#initialize ⇒ FileCollector
Initialize collector
14 15 16 17 |
# File 'lib/omnizip/formats/seven_zip/file_collector.rb', line 14 def initialize @entries = [] @base_path = nil end |
Instance Attribute Details
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
11 12 13 |
# File 'lib/omnizip/formats/seven_zip/file_collector.rb', line 11 def entries @entries end |
Instance Method Details
#add_glob(pattern, base_path: nil) ⇒ Object
Add files matching glob pattern
41 42 43 44 45 46 47 |
# File 'lib/omnizip/formats/seven_zip/file_collector.rb', line 41 def add_glob(pattern, base_path: nil) @base_path ||= base_path || Dir.pwd Dir.glob(pattern).each do |path| add_path(path) end end |
#add_path(path, archive_path: nil, recursive: true) ⇒ Object
Add path (file or directory) to collection
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/omnizip/formats/seven_zip/file_collector.rb', line 24 def add_path(path, archive_path: nil, recursive: true) path = File.(path) raise "Path not found: #{path}" unless File.exist?(path) @base_path ||= File.dirname(path) if File.directory?(path) add_directory(path, archive_path, recursive) else add_file(path, archive_path) end end |
#collect_files ⇒ Array<Models::FileEntry>
Get collected file entries
52 53 54 |
# File 'lib/omnizip/formats/seven_zip/file_collector.rb', line 52 def collect_files @entries.sort_by(&:name) end |