8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/ree/core/packages_detector.rb', line 8
def call(dir, gem_name = nil)
if !Dir.exist?(dir)
raise Ree::Error.new("dir does not exist: #{dir}", :invalid_dir)
end
files = File.join(dir, "**/", Ree::PACKAGE_SCHEMA_FILE)
names = {}
Dir[files].map do |file|
package_schema_path = Pathname
.new(file)
.relative_path_from(Pathname.new(dir))
.to_s
name = package_schema_path.split('/')[-2]
entry_path = Ree::PathHelper.package_entry_path(package_schema_path)
if !File.exist?(File.join(dir, entry_path))
Ree.logger.error("Entry file does not exist for '#{name}' package: #{entry_path}")
end
if names.has_key?(name)
raise Ree::Error.new("package '#{name}' has duplicate defintions.\n\t1) #{names[name]},\n\t2) #{entry_path}", :duplicate_package)
end
names[name] = entry_path
{
name: name.to_sym,
entry_path: entry_path,
package_schema_path: package_schema_path,
gem_name: gem_name
}
end
end
|