Sha256: cda9425a45e1bca8dbd9f1c7e42d85799d49df91ff7cc30d164b793fbbc8291f

Contents?: true

Size: 765 Bytes

Versions: 4

Compression:

Stored size: 765 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) : 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

4 entries across 4 versions & 1 rubygems

Version Path
skylight-1.0.0.beta3 lib/skylight/user_config.rb
skylight-0.10.3 lib/skylight/user_config.rb
skylight-0.10.2 lib/skylight/user_config.rb
skylight-1.0.0.beta2 lib/skylight/user_config.rb