require 'mote'
require 'fileutils'

module Musket
  def self.initialize
    config_dir = Dir.home + '/.musket/'
    config_file = config_dir + 'config.yml'
    if File.exist?config_file
      config = File.open(config_file, 'r')
    else
      puts "#{config_file} does not exist. Creating file."
      FileUtils.mkdir(config_dir)
      config = File.open(config_file, 'w')
      config.puts('# This is the musket configuration file')
      config.close
    end
  end
end
require 'mote'
require 'fileutils'
require 'yaml'

module Musket
  def self.initialize
    @config_dir = Dir.home + '/.musket/'
    @config_file = @config_dir + 'config.yml'

    Musket.create_config unless File.exists?@config_file
    Musket.read_config if File.exists?@config_file
  end

  def self.read_config
    config = File.open(@config_file, 'r')
    @config = []
    @config.push(YAML.load(config.read()))
  end

  def self.create_config
    puts "#{@config_file} does not exist. Creating file."
    FileUtils.mkdir(@config_dir) unless File.exists?@config_dir
    config = File.open(@config_file, 'w+')
    output = []
    output.push({'author' => 'TODO: Write Author Name'}.to_yaml)
    config.puts(output.join('\n'))
    config.close
  end
end
Add config file Using yaml to read/write config file Code made DRYer
Add config file
Using yaml to read/write config file
Code made DRYer

Signed-off-by: Aniket Pant <b1c1d8736f20db3fb6c1c66bb1455ed43909f0d8@aniketpant.com>
