Sha256: 77eb573ece437f700f8f47173cbd9bcdecfde17a1f2bb0efbd8ed3cc669e3847

Contents?: true

Size: 689 Bytes

Versions: 19

Compression:

Stored size: 689 Bytes

Contents

require 'fileutils'

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

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

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

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

      def exists?
        File.exists?(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

19 entries across 19 versions & 1 rubygems

Version Path
dpl-2.0.3.beta.4 lib/dpl/helper/assets.rb
dpl-2.0.3.beta.3 lib/dpl/helper/assets.rb
dpl-2.0.3.beta.2 lib/dpl/helper/assets.rb
dpl-2.0.3.beta.1 lib/dpl/helper/assets.rb
dpl-2.0.2.beta.1 lib/dpl/helper/assets.rb
dpl-2.0.0.beta.3 lib/dpl/helper/assets.rb
dpl-2.0.0.beta.2 lib/dpl/helper/assets.rb
dpl-2.0.0.alpha.14 lib/dpl/helper/assets.rb
dpl-2.0.0.alpha.13 lib/dpl/helper/assets.rb
dpl-2.0.0.alpha.12 lib/dpl/helper/assets.rb
dpl-2.0.0.alpha.11 lib/dpl/helper/assets.rb
dpl-2.0.0.alpha.10 lib/dpl/helper/assets.rb
dpl-2.0.0.alpha.9 lib/dpl/helper/assets.rb
dpl-2.0.0.alpha.8 lib/dpl/helper/assets.rb
dpl-2.0.0.alpha.7 lib/dpl/helper/assets.rb
dpl-2.0.0.alpha.6 lib/dpl/helper/assets.rb
dpl-2.0.0.alpha.5 lib/dpl/helper/assets.rb
dpl-2.0.0.alpha.2 lib/dpl/helper/assets.rb
dpl-2.0.0.alpha.1 lib/dpl/helper/assets.rb