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', __FILE__)

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



5
6
7
# File 'lib/dpl/helper/assets.rb', line 5

def name
  @name
end

#namespaceObject

Returns the value of attribute namespace

Returns:

  • (Object)

    the current value of namespace



5
6
7
# File 'lib/dpl/helper/assets.rb', line 5

def namespace
  @namespace
end

#providerObject

Returns the value of attribute provider

Returns:

  • (Object)

    the current value of provider



5
6
7
# File 'lib/dpl/helper/assets.rb', line 5

def provider
  @provider
end

Instance Method Details

#copy(target) ⇒ Object



10
11
12
# File 'lib/dpl/helper/assets.rb', line 10

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

#exists?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/dpl/helper/assets.rb', line 18

def exists?
  File.exists?(path)
end

#pathObject



26
27
28
# File 'lib/dpl/helper/assets.rb', line 26

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

#readObject



14
15
16
# File 'lib/dpl/helper/assets.rb', line 14

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

#unknownObject



22
23
24
# File 'lib/dpl/helper/assets.rb', line 22

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