Class: Dpl::Assets::Asset

Inherits:
Struct
  • Object
show all
Includes:
FileUtils
Defined in:
lib/dpl/helper/assets.rb

Constant Summary collapse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



7
8
9
# File 'lib/dpl/helper/assets.rb', line 7

def name
  @name
end

#namespaceObject

Returns the value of attribute namespace

Returns:

  • (Object)

    the current value of namespace



7
8
9
# File 'lib/dpl/helper/assets.rb', line 7

def namespace
  @namespace
end

#providerObject

Returns the value of attribute provider

Returns:

  • (Object)

    the current value of provider



7
8
9
# File 'lib/dpl/helper/assets.rb', line 7

def provider
  @provider
end

Instance Method Details

#copy(target) ⇒ Object



12
13
14
# File 'lib/dpl/helper/assets.rb', line 12

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

#exists?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/dpl/helper/assets.rb', line 20

def exists?
  File.exist?(path)
end

#pathObject



28
29
30
# File 'lib/dpl/helper/assets.rb', line 28

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

#readObject



16
17
18
# File 'lib/dpl/helper/assets.rb', line 16

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

#unknownObject



24
25
26
# File 'lib/dpl/helper/assets.rb', line 24

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