3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/compath/cli.rb', line 3
def self.run
finder = Compath::Finder.new
paths = Compath::PathSorter.sort(finder.paths.keys)
guides = paths.map {|path| Compath::Guide.new(path) }
guides.select!(&:directory?)
guide_book = Compath::GuideBook.new(guides)
if FileTest.exist?('.compath.yml')
config = Compath::ConfigLoader.load(File.read('.compath.yml'))
guide_book.merge(config)
else
initial_config_guides = paths.map {|path| Compath::Guide.new(path, scan: false) }
initial_config_guides.select!(&:directory?)
initial_config = Compath::GuideBook.new(initial_config_guides)
guide_book.merge(initial_config.guides)
end
yaml = guide_book.publish_yaml
formatted_yaml = YamlFormatter.new(yaml).format
File.write('.compath.yml', formatted_yaml)
puts 'Write .compath.yml'
end
|