Sha256: aa83f0054143a08b113ce37f9ddad479d31d13260d4f57ec2bb92afa3e4d0cfa

Contents?: true

Size: 710 Bytes

Versions: 3

Compression:

Stored size: 710 Bytes

Contents

#!/usr/bin/env ruby
# Config class
#
require 'yaml'
require 'git'

class Config
  def initialize
    config_location = ENV['MYOSX_CONFIG'] || '~/.myosx.cnf'
    config_file = File.expand_path(config_location)
    raise "Cannot find config file: #{config_file}" unless File.exist?(config_file)
    $global_config = YAML.load_file(config_file)
    $workspace = workspace_directory
  end

  def workspace_directory
    workspace_dir_name = ENV['MYOSX_WORKSPACE'] || '~/.myosx/'
    return File.expand_path(workspace_dir_name)
  end

  def create_workspace
    unless Dir.exists?($workspace)
      puts "Creating workspace: #{workspace_directory}"
      Dir.mkdir("#{workspace_directory}", 0750)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
myosx-0.2.2 lib/myosx/config.rb
myosx-0.2.1 lib/myosx/config.rb
myosx-0.1.0 lib/myosx/config.rb