class Compath::CLI
Public Class Methods
run()
click to toggle source
# 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