Sha256: 2cdb4260782bc8ee8cfee503fd8ed5b2e67058df6b2f7ef226688a2f96263b5c
Contents?: true
Size: 1.28 KB
Versions: 4
Compression:
Stored size: 1.28 KB
Contents
# frozen_string_literal: true module Conductor # Configuration methods class Config attr_reader :config, :tracks def initialize config_file = File.expand_path('~/.config/conductor/tracks.yaml') create_config(config_file) unless File.exist?(config_file) @config ||= YAML.safe_load(IO.read(config_file)) @tracks = @config['tracks'].symbolize_keys end end def create_config(config_file) config_dir = File.dirname(config_file) scripts_dir = File.dirname(File.join(config_dir, 'scripts')) FileUtils.mkdir_p(config_dir) unless File.directory?(config_dir) FileUtils.mkdir_p(scripts_dir) unless File.directory?(scripts_dir) File.open(config_file, 'w') { |f| f.puts sample_config } puts "Sample config created at #{config_file}" Process.exit 0 end def sample_config <<~EOCONFIG tracks: - condition: phase is pre tracks: - condition: tree contains .obsidian tracks: - condition: extension is md script: obsidian-md-filter - condition: extension is md command: rdiscount $file - condition: yaml includes comments script: blog-processor - condition: any command: echo 'NOCUSTOM' EOCONFIG end end
Version data entries
4 entries across 4 versions & 1 rubygems