Sha256: 8bcf36a3ad5b15369367f44351649ecb6d5ca2a4640c5ee6a2346634ceff1a75

Contents?: true

Size: 801 Bytes

Versions: 7

Compression:

Stored size: 801 Bytes

Contents

require 'yaml'

module Skylight
  class UserConfig

    attr_accessor :disable_dev_warning

    def self.instance
      @instance ||= new
    end

    def initialize
      reload
    end

    def file_path
      File.expand_path(ENV["SKYLIGHT_USER_CONFIG_PATH"] || "~/.skylight")
    end

    def disable_dev_warning?
      disable_dev_warning
    end

    def reload
      config = File.exist?(file_path) ? YAML.load_file(file_path) : false
      return unless config

      self.disable_dev_warning = !!config['disable_dev_warning']
    end

    def save
      FileUtils.mkdir_p(File.dirname(file_path))
      File.open(file_path, 'w') do |f|
        f.puts YAML.dump(to_hash)
      end
    end

    def to_hash
      {
        'disable_dev_warning' => disable_dev_warning
      }
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
skylight-1.0.1 lib/skylight/user_config.rb
skylight-1.0.0 lib/skylight/user_config.rb
skylight-0.10.6 lib/skylight/user_config.rb
skylight-1.0.0.beta5 lib/skylight/user_config.rb
skylight-0.10.5 lib/skylight/user_config.rb
skylight-0.10.4 lib/skylight/user_config.rb
skylight-1.0.0.beta4 lib/skylight/user_config.rb