Class: VFS::FileCollector
- Inherits:
-
Object
- Object
- VFS::FileCollector
- Defined in:
- lib/yaml-vfs/file_collector.rb
Overview
vfs gen
Constant Summary collapse
- HEADER_FILES_EXTENSIONS =
%w[.h .hh .hpp .ipp .tpp .hxx .def .inl .inc].freeze
Instance Attribute Summary collapse
-
#framework_path ⇒ Object
readonly
Returns the value of attribute framework_path.
-
#real_headers ⇒ Object
readonly
Returns the value of attribute real_headers.
-
#real_modules ⇒ Object
readonly
Returns the value of attribute real_modules.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(framework_path, real_modules, real_headers) ⇒ FileCollector
constructor
A new instance of FileCollector.
- #write_mapping(name) ⇒ Object
Constructor Details
#initialize(framework_path, real_modules, real_headers) ⇒ FileCollector
Returns a new instance of FileCollector.
23 24 25 26 27 28 29 |
# File 'lib/yaml-vfs/file_collector.rb', line 23 def initialize(framework_path, real_modules, real_headers) @seen = Set.new @vfs_writer = YAMLVFSWriter.new @real_headers = real_headers @framework_path = Pathname(framework_path) @real_modules = real_modules end |
Instance Attribute Details
#framework_path ⇒ Object (readonly)
Returns the value of attribute framework_path.
11 12 13 |
# File 'lib/yaml-vfs/file_collector.rb', line 11 def framework_path @framework_path end |
#real_headers ⇒ Object (readonly)
Returns the value of attribute real_headers.
11 12 13 |
# File 'lib/yaml-vfs/file_collector.rb', line 11 def real_headers @real_headers end |
#real_modules ⇒ Object (readonly)
Returns the value of attribute real_modules.
11 12 13 |
# File 'lib/yaml-vfs/file_collector.rb', line 11 def real_modules @real_modules end |
Class Method Details
.new_from_real_headers_dir(framework_path, real_modules_dir, real_header_dir) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/yaml-vfs/file_collector.rb', line 13 def self.new_from_real_headers_dir(framework_path, real_modules_dir, real_header_dir) raise ArgumentError, 'real_header_dir must set and exist' if real_header_dir.nil? || !real_header_dir.exist? files = Pathname.glob(Pathname(real_header_dir).join('**').join('*')).select do |file| HEADER_FILES_EXTENSIONS.include?(file.extname) end real_modules = Pathname(real_modules_dir).glob('module*.modulemap') new(framework_path, real_modules, files) end |
Instance Method Details
#write_mapping(name) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/yaml-vfs/file_collector.rb', line 31 def write_mapping(name) raise ArgumentError, 'framework_path must set' if @framework_path.nil? raise ArgumentError, 'real_headers or real_header_dir one of them must set' if @real_headers.empty? add_write_file @vfs_writer.case_sensitive = false path = Pathname(name). path = path.join('all-product-headers.yaml') if path.directory? stream = @vfs_writer.write path.dirname.mkpath File.open(path, 'w') { |f| f.write(stream) } end |