Sha256: 47d84b2774af0b0324e2570a8d822675c2d5c7258b5b277c66f9b9338e5b5fc4

Contents?: true

Size: 828 Bytes

Versions: 8

Compression:

Stored size: 828 Bytes

Contents

require 'yaml'

module Ufo
  class Settings
    def initialize(project_root='.')
      @project_root = project_root
    end

    # data contains the settings.yml config.  The order or precedence for settings
    # is the project ufo/settings.yml and then the ~/.ufo/settings.yml.
    def data
      return @data if @data

      if File.exist?(settings_path)
        @data = YAML.load_file(settings_path)
        @data = user_settings.merge(@data)
      else
        puts "ERROR: No settings file file at #{settings_path}"
        puts "Please create a settings file via: ufo init"
        exit 1
      end
    end

    def user_settings
      path = "#{ENV['HOME']}/.ufo/settings.yml"
      File.exist?(path) ? YAML.load_file(path) : {}
    end

    def settings_path
      "#{@project_root}/ufo/settings.yml"
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ufo-0.1.6 lib/ufo/settings.rb
ufo-0.1.5 lib/ufo/settings.rb
ufo-0.1.4 lib/ufo/settings.rb
ufo-0.1.3 lib/ufo/settings.rb
ufo-0.1.2 lib/ufo/settings.rb
ufo-0.1.1 lib/ufo/settings.rb
ufo-0.1.0 lib/ufo/settings.rb
ufo-0.0.6 lib/ufo/settings.rb