Sha256: 4716da5004a0974d5bf2baec1f169569e198fa75e58e69354bbffb9960e19a6d

Contents?: true

Size: 734 Bytes

Versions: 6

Compression:

Stored size: 734 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("~/.skylight")
    end

    def disable_dev_warning?
      disable_dev_warning
    end

    def reload
      config = File.exist?(file_path) ? YAML.load_file(file_path) : {}
      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

6 entries across 6 versions & 1 rubygems

Version Path
skylight-0.10.0 lib/skylight/user_config.rb
skylight-0.9.4 lib/skylight/user_config.rb
skylight-0.9.3 lib/skylight/user_config.rb
skylight-0.9.2 lib/skylight/user_config.rb
skylight-0.9.1 lib/skylight/user_config.rb
skylight-0.9.0 lib/skylight/user_config.rb