yaml-vfs 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/yaml-vfs/command/yaml_vfs_writer.rb +56 -3
- data/lib/yaml-vfs/file_collector.rb +72 -32
- data/lib/yaml-vfs/version.rb +1 -1
- metadata +9 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2528e2b145ef1734b823a7e4174e391d846f5c6773e19449048b04a38a0522b7
|
4
|
+
data.tar.gz: 97a724b9fc2af1dce2cd0887af5620989643021249deb5bd68e52c8dfe460ea0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
|
55
|
-
VFS::FileCollector.new(
|
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
|
-
|
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
|
-
|
14
|
-
|
15
|
-
|
16
|
+
@real_path = Pathname(real_path)
|
17
|
+
@virtual_path = Pathname(virtual_path)
|
18
|
+
end
|
16
19
|
|
17
|
-
|
18
|
-
|
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
|
-
|
21
|
-
new(framework_path, real_modules, files)
|
40
|
+
entrys
|
22
41
|
end
|
23
42
|
|
24
|
-
def
|
25
|
-
raise ArgumentError, '
|
26
|
-
raise ArgumentError, 'real_modules
|
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
|
-
|
29
|
-
|
30
|
-
|
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(
|
37
|
-
|
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
|
-
|
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
|
-
|
57
|
-
|
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
|
data/lib/yaml-vfs/version.rb
CHANGED
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.
|
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-
|
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
|
-
-
|
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
|