yaml-vfs 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 563791b343561d3ba0e548e099d21343a312290e6168e7021c71c76bfc47f785
4
- data.tar.gz: 00fbb4e8b8f040e8d83876f7c22dd297e2ea49c555d1710daa9b3f486457e4ed
3
+ metadata.gz: 2528e2b145ef1734b823a7e4174e391d846f5c6773e19449048b04a38a0522b7
4
+ data.tar.gz: 97a724b9fc2af1dce2cd0887af5620989643021249deb5bd68e52c8dfe460ea0
5
5
  SHA512:
6
- metadata.gz: a1da9ac68ecfd753d4e51c013d7ff0f36cc4c506d259ed911dab334392fbde68ec2b8a00abb66332a1b6e0ac6f3df3bcb09aee3347f95a686bb1ce888db35578
7
- data.tar.gz: cc0eefdb0598185f80861f68d93e71fcdb092c4eaf713c06bf49b9bd8d03eb0f110d3c8158fb34a9e87fabb09efb32df4dfe0121c7a687c1cdac8989a1bd6d59
6
+ metadata.gz: c430b27aa060bc8ea91e0b762d9a54a44b3dfb826e791bef313017aa434dd2982730b967cdd3f28b0e3a7e64ab3e97baea9287c3d2113d79ad7c54a7a6026282
7
+ data.tar.gz: 4d7db0450e0e45ac155329d845264ce261e6ef85c73fbbdef993b46b6ae0cadaa7e2eaa8aeafa6b9a16f71f610a7c09021f230bd6d92802a5e02f6f3353911ac
@@ -3,7 +3,7 @@
3
3
  module VFS
4
4
  class Command
5
5
  # vfs yaml file gen cmd
6
- class YAMLWriter < Command
6
+ class Framework < Command
7
7
  # summary
8
8
  self.summary = 'Virtual the framework and modules dir, and map to real path'
9
9
 
@@ -51,8 +51,61 @@ module VFS
51
51
  def run
52
52
  require 'yaml_vfs'
53
53
 
54
- entry = VFS::FileCollectorEntry.new_from_real_headers_dir(@framework_path, @real_modules_dir, @real_header_dir)
55
- VFS::FileCollector.new([entry]).write_mapping(@output_path)
54
+ entrys = VFS::FileCollectorEntry.entrys_from_framework_dir(@framework_path, @real_header_dir, @real_modules_dir)
55
+ VFS::FileCollector.new(entrys).write_mapping(@output_path)
56
+ end
57
+ end
58
+ class Target < Command
59
+ # summary
60
+ self.summary = 'Virtual the target public and private headers, and map to real path'
61
+
62
+ self.description = <<-DESC
63
+ Gen VFS Yaml file. To map target virtual path to real path.
64
+ DESC
65
+
66
+ self.arguments = [
67
+ # target_p, public_header, private_header
68
+ CLAide::Argument.new('--target-path', true),
69
+ CLAide::Argument.new('--public-headers-dir', true),
70
+ CLAide::Argument.new('--private-headers-dir', true),
71
+ CLAide::Argument.new('--output-path', false)
72
+ ]
73
+
74
+ def initialize(argv)
75
+ super
76
+
77
+ target_path = argv.option('target-path')
78
+ @target_path = Pathname(target_path) unless target_path.nil?
79
+ public_headers_dir = argv.option('public-headers-dir')
80
+ @public_headers_dir = Pathname(public_headers_dir) unless public_headers_dir.nil?
81
+ private_headers_dir = argv.option('private-headers-dir')
82
+ @private_headers_dir = Pathname(private_headers_dir) unless private_headers_dir.nil?
83
+ output_path = argv.option('output-path')
84
+ @output_path = output_path.nil? ? Pathname('.') : Pathname(output_path)
85
+ end
86
+
87
+ def validate!
88
+ super
89
+ help! 'must set --target-path' if @target_path.nil?
90
+ help! 'must set --public-headers-dir' if @public_headers_dir.nil?
91
+ help! 'must set --private-headers-dir' if @private_headers_dir.nil?
92
+ end
93
+
94
+ # help
95
+ def self.options
96
+ [
97
+ ['--target-pathh=<path>', 'target path'],
98
+ ['--public-headers-dir=<path>', 'real public headers path'],
99
+ ['--private-headers-dir=<path>', 'real private headers path'],
100
+ ['--output-path=<path>', 'vfs yaml file output path']
101
+ ].concat(super)
102
+ end
103
+
104
+ def run
105
+ require 'yaml_vfs'
106
+
107
+ entrys = VFS::FileCollectorEntry.entrys_from_target_dir(@target_path, @public_headers_dir, @private_headers_dir)
108
+ VFS::FileCollector.new(entrys).write_mapping(@output_path)
56
109
  end
57
110
  end
58
111
  end
@@ -4,39 +4,87 @@ require 'set'
4
4
 
5
5
  module VFS
6
6
  HEADER_FILES_EXTENSIONS = %w[.h .hh .hpp .ipp .tpp .hxx .def .inl .inc].freeze
7
+ VFS_FILES_EXTENSIONS = %w[.yaml .yml .json].freeze
7
8
 
8
9
  # vfs file collector entry
9
10
  class FileCollectorEntry
11
+ attr_reader :real_path, :virtual_path
10
12
 
11
- attr_reader :framework_path, :real_modules, :real_headers
13
+ def initialize(real_path, virtual_path)
14
+ raise ArgumentError, 'real_path or virtual_path must set' if real_path.nil? || virtual_path.empty?
12
15
 
13
- def self.new_from_real_headers_dir(framework_path, real_modules_dir, real_header_dir)
14
- raise ArgumentError, 'real_header_dir must set and exist' if real_header_dir.nil? || !real_header_dir.exist?
15
- raise ArgumentError, 'real_modules_dir must set and exist' if real_modules_dir.nil? || !real_modules_dir.exist?
16
+ @real_path = Pathname(real_path)
17
+ @virtual_path = Pathname(virtual_path)
18
+ end
16
19
 
17
- files = Pathname.glob(Pathname(real_header_dir).join('**').join('*')).select do |file|
18
- HEADER_FILES_EXTENSIONS.include?(file.extname)
20
+ def self.entrys_from_framework(framework_path, public_headers, private_headers, real_modules)
21
+ entrys = []
22
+ unless public_headers.empty?
23
+ entrys += public_headers.map do |header|
24
+ v_p = File.join(framework_path, 'Headers', File.basename(header))
25
+ new(header, v_p)
26
+ end
27
+ end
28
+ unless private_headers.empty?
29
+ entrys += private_headers.map do |header|
30
+ v_p = File.join(framework_path, 'PrivateHeaders', File.basename(header))
31
+ new(header, v_p)
32
+ end
33
+ end
34
+ unless real_modules.empty?
35
+ entrys += real_modules.map do |m|
36
+ v_p = File.join(framework_path, 'Modules', File.basename(m))
37
+ new(m, v_p)
38
+ end
19
39
  end
20
- real_modules = Pathname(real_modules_dir).glob('module*.modulemap')
21
- new(framework_path, real_modules, files)
40
+ entrys
22
41
  end
23
42
 
24
- def initialize(framework_path, real_modules, real_headers)
25
- raise ArgumentError, 'framework_path must set' if framework_path.nil?
26
- raise ArgumentError, 'real_modules and real_headers must set' if real_modules.empty?
43
+ def self.entrys_from_framework_dir(framework_path, real_header_dir, real_modules_dir)
44
+ raise ArgumentError, 'real_header must set and exist' if real_header_dir.nil? || !File.exist?(real_header_dir)
45
+ raise ArgumentError, 'real_modules must set and exist' if real_header_dir.nil? || !File.exist?(real_header_dir)
46
+
47
+ real_header_dir = File.join(real_header_dir, '**', '*')
48
+ real_headers = Pathname.glob(real_header_dir).select { |file| HEADER_FILES_EXTENSIONS.include?(file.extname) }
49
+ real_modules = Pathname(real_modules_dir).glob('module*.modulemap') || []
50
+ entrys_from_framework(framework_path, real_headers, real_modules)
51
+ end
52
+
53
+ def self.entrys_from_target(target_path, public_headers, private_headers)
54
+ entrys = []
55
+ unless private_headers.empty?
56
+ entrys += private_headers.map do |header|
57
+ v_p = File.join(target_path, 'PrivateHeaders', File.basename(header))
58
+ new(header, v_p)
59
+ end
60
+ end
61
+ unless public_headers.empty?
62
+ entrys += public_headers.map do |header|
63
+ v_p = File.join(target_path, 'Headers', File.basename(header))
64
+ new(header, v_p)
65
+ end
66
+ end
67
+ entrys
68
+ end
27
69
 
28
- @real_headers = real_headers
29
- @framework_path = Pathname(framework_path)
30
- @real_modules = real_modules
70
+ def self.entrys_from_target_dir(target_path, public_dir, private_dir)
71
+ headers = lambda do |dir|
72
+ unless dir.nil? && File.exist?(dir)
73
+ Pathname.glob(File.join(dir, '**', '*')).select do |file|
74
+ HEADER_FILES_EXTENSIONS.include?(file.extname)
75
+ end
76
+ end
77
+ end
78
+ private_headers = headers.call(private_dir) || []
79
+ public_headers = headers.call(public_dir) || []
80
+ entrys_from_target(target_path, public_headers, private_headers)
31
81
  end
32
82
  end
33
83
 
34
84
  # vfs gen
35
85
  class FileCollector
36
- def initialize(entry)
37
- raise ArgumentError, 'entry must not empty' if entry.empty?
38
-
39
- @entry = entry
86
+ def initialize(entrys)
87
+ @entrys = entrys || []
40
88
  @vfs_writer = YAMLVFSWriter.new
41
89
  end
42
90
 
@@ -44,27 +92,19 @@ module VFS
44
92
  add_write_file
45
93
  @vfs_writer.case_sensitive = false
46
94
  path = Pathname(name).expand_path
47
- path = path.join('all-product-headers.yaml') if path.directory?
95
+ unless VFS_FILES_EXTENSIONS.include?(File.extname(path))
96
+ path.mkpath unless path.exist?
97
+ path = path.join('all-product-headers.yaml')
98
+ end
48
99
  stream = @vfs_writer.write
49
- path.dirname.mkpath
50
100
  File.open(path, 'w') { |f| f.write(stream) }
51
101
  end
52
102
 
53
103
  private
54
104
 
55
105
  def add_write_file
56
- wirte_f = lambda { |framework_path, dir, files|
57
- return if dir.empty?
58
-
59
- paths = framework_path.join(dir)
60
- files.each do |file|
61
- path = paths.join(file.basename)
62
- @vfs_writer.add_file_mapping(path, file)
63
- end
64
- }
65
- @entry.each do |entry|
66
- wirte_f.call(entry.framework_path, 'Headers', entry.real_headers)
67
- wirte_f.call(entry.framework_path, 'Modules', entry.real_modules)
106
+ @entrys.each do |entry|
107
+ @vfs_writer.add_file_mapping(entry.virtual_path, entry.real_path)
68
108
  end
69
109
  end
70
110
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module VFS
4
- VERSION = '0.0.3'
4
+ VERSION = '0.0.4'
5
5
  end
metadata CHANGED
@@ -1,43 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yaml-vfs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cat1237
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-10 00:00:00.000000000 Z
11
+ date: 2021-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '2.1'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '3.0'
20
23
  type: :development
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '2.1'
27
- - !ruby/object:Gem::Dependency
28
- name: coveralls
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
30
+ - - "<"
39
31
  - !ruby/object:Gem::Version
40
- version: '0'
32
+ version: '3.0'
41
33
  - !ruby/object:Gem::Dependency
42
34
  name: rake
43
35
  requirement: !ruby/object:Gem::Requirement