Sha256: 7a4f18bb63389380d09f5384a32c3f0eea801bc768963fa28cbdc57db20d31da

Contents?: true

Size: 1.05 KB

Versions: 7

Compression:

Stored size: 1.05 KB

Contents

require 'yaml'

module Ufo
  class Param
    extend Memoist

    def initialize
      @params_path = "#{Ufo.root}/.ufo/params.yml"
    end

    def data
      upgrade_message!

      result = RenderMePretty.result(@params_path, context: template_scope)
      data = YAML.load(result) || {}
      data.deep_symbolize_keys
    end
    memoize :data

    def template_scope
      @template_scope ||= Ufo::TemplateScope.new(Ufo::DSL::Helper.new, nil)
    end

    # Ufo version 3.3 to 3.4 added a concept of a .ufo/params.yml file to support
    # fargate: https://github.com/tongueroo/ufo/pull/31
    #
    # Warn user and tell them to run the `ufo upgrade v3_3to3_4` command to upgrade.
    def upgrade_message!
      return if File.exist?(@params_path)

      puts "ERROR: Your project is missing the .ufo/params.yml.".color(:red)
      puts "This was added in ufo version 3.4"
      puts "You can find more info about the params file here: http://ufoships.com/docs/params/"
      puts "To upgrade run:"
      puts "  ufo upgrade v3_3to3_4"
      exit 1
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ufo-4.4.3 lib/ufo/param.rb
ufo-4.4.2 lib/ufo/param.rb
ufo-4.4.1 lib/ufo/param.rb
ufo-4.4.0 lib/ufo/param.rb
ufo-4.3.1 lib/ufo/param.rb
ufo-4.3.0 lib/ufo/param.rb
ufo-4.2.0 lib/ufo/param.rb