Sha256: 4a3867c537cd18bce745fc1de08a715fdcf19320001a4b5db7e574faf4bdc971

Contents?: true

Size: 715 Bytes

Versions: 12

Compression:

Stored size: 715 Bytes

Contents

# frozen_string_literal: true

require 'fileutils'

module Dpl
  module Assets
    class Asset < Struct.new(:provider, :namespace, :name)
      include FileUtils

      DIR = File.expand_path('../assets', __dir__)

      def copy(target)
        cp path, File.expand_path(target)
      end

      def read
        exists? ? provider.interpolate(File.read(path)) : unknown
      end

      def exists?
        File.exist?(path)
      end

      def unknown
        raise "Could not find asset #{path}"
      end

      def path
        "#{DIR}/#{namespace}/#{name}"
      end
    end

    def asset(*args)
      name, namespace = args.reverse
      Asset.new(self, namespace || registry_key, name)
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
dpl-2.0.5.3 lib/dpl/helper/assets.rb
dpl-2.0.5.3.beta.1 lib/dpl/helper/assets.rb
dpl-2.0.5.2 lib/dpl/helper/assets.rb
dpl-2.0.5.2.beta.1 lib/dpl/helper/assets.rb
dpl-2.0.5.1 lib/dpl/helper/assets.rb
dpl-2.0.5.beta.2.1 lib/dpl/helper/assets.rb
dpl-2.0.5.beta.2 lib/dpl/helper/assets.rb
dpl-2.0.5 lib/dpl/helper/assets.rb
dpl-2.0.5.beta.1 lib/dpl/helper/assets.rb
dpl-2.0.5.beta lib/dpl/helper/assets.rb
travis_dpl_test-2.0.3.beta.4.ror.1 lib/dpl/helper/assets.rb
travis_dpl_test-2.0.3.beta.4.ror lib/dpl/helper/assets.rb