Class: VFS::FileCollectorEntry
- Inherits:
-
Object
- Object
- VFS::FileCollectorEntry
- Defined in:
- lib/yaml-vfs/file_collector.rb
Overview
vfs file collector entry
Instance Attribute Summary collapse
-
#real_path ⇒ Object
readonly
Returns the value of attribute real_path.
-
#virtual_path ⇒ Object
readonly
Returns the value of attribute virtual_path.
Class Method Summary collapse
- .entrys_from_framework(framework_path, public_headers, private_headers, real_modules) ⇒ Object
- .entrys_from_framework_dir(framework_path, real_header_dir, real_modules_dir) ⇒ Object
- .entrys_from_target(target_path, public_headers, private_headers) ⇒ Object
- .entrys_from_target_dir(target_path, public_dir, private_dir) ⇒ Object
Instance Method Summary collapse
-
#initialize(real_path, virtual_path) ⇒ FileCollectorEntry
constructor
A new instance of FileCollectorEntry.
Constructor Details
#initialize(real_path, virtual_path) ⇒ FileCollectorEntry
Returns a new instance of FileCollectorEntry.
12 13 14 15 16 17 |
# File 'lib/yaml-vfs/file_collector.rb', line 12 def initialize(real_path, virtual_path) raise ArgumentError, 'real_path or virtual_path must set' if real_path.nil? || virtual_path.empty? @real_path = Pathname(real_path) @virtual_path = Pathname(virtual_path) end |
Instance Attribute Details
#real_path ⇒ Object (readonly)
Returns the value of attribute real_path.
10 11 12 |
# File 'lib/yaml-vfs/file_collector.rb', line 10 def real_path @real_path end |
#virtual_path ⇒ Object (readonly)
Returns the value of attribute virtual_path.
10 11 12 |
# File 'lib/yaml-vfs/file_collector.rb', line 10 def virtual_path @virtual_path end |
Class Method Details
.entrys_from_framework(framework_path, public_headers, private_headers, real_modules) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/yaml-vfs/file_collector.rb', line 19 def self.entrys_from_framework(framework_path, public_headers, private_headers, real_modules) entrys = {} entrys['Headers'] = public_headers unless public_headers.empty? entrys['PrivateHeaders'] = private_headers unless private_headers.empty? entrys['Modules'] = real_modules unless real_modules.empty? entrys.flat_map do |key, values| values.map do |path| v_p = File.join(framework_path, key, File.basename(path)) new(path, v_p) end end end |
.entrys_from_framework_dir(framework_path, real_header_dir, real_modules_dir) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/yaml-vfs/file_collector.rb', line 33 def self.entrys_from_framework_dir(framework_path, real_header_dir, real_modules_dir) raise ArgumentError, 'real_header must set and exist' unless File.exist?(real_header_dir || '') raise ArgumentError, 'real_modules must set and exist' unless File.exist?(real_header_dir || '') real_header_dir = File.join(real_header_dir, '**', '*') real_headers = Pathname.glob(real_header_dir).select { |file| HEADER_FILES_EXTENSIONS.include?(file.extname) } real_modules = Pathname(real_modules_dir).glob('module*.modulemap') || [] entrys_from_framework(framework_path, real_headers, real_modules) end |
.entrys_from_target(target_path, public_headers, private_headers) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/yaml-vfs/file_collector.rb', line 43 def self.entrys_from_target(target_path, public_headers, private_headers) entrys = {} entrys['Headers'] = public_headers unless public_headers.empty? entrys['PrivateHeaders'] = private_headers unless private_headers.empty? entrys.flat_map do |key, values| values.map do |path| v_p = File.join(target_path, key, File.basename(path)) new(path, v_p) end end end |
.entrys_from_target_dir(target_path, public_dir, private_dir) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/yaml-vfs/file_collector.rb', line 56 def self.entrys_from_target_dir(target_path, public_dir, private_dir) headers = lambda do |dir| unless dir.nil? && File.exist?(dir) Pathname.glob(File.join(dir, '**', '*')).select do |file| HEADER_FILES_EXTENSIONS.include?(file.extname) end end end private_headers = headers.call(private_dir) || [] public_headers = headers.call(public_dir) || [] entrys_from_target(target_path, public_headers, private_headers) end |