Class: Lono::AppFile::Registry::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/lono/app_file/registry/item.rb

Overview

Holds metadata about the item in the regsitry.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, blueprint, options = {}) ⇒ Item

Returns a new instance of Item.



6
7
8
# File 'lib/lono/app_file/registry/item.rb', line 6

def initialize(name, blueprint, options={})
  @name, @blueprint, @options = name, blueprint, options
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/lono/app_file/registry/item.rb', line 5

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/lono/app_file/registry/item.rb', line 5

def options
  @options
end

Instance Method Details

#directory?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/lono/app_file/registry/item.rb', line 14

def directory?
  File.directory?(path)
end

#file?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/lono/app_file/registry/item.rb', line 18

def file?
  File.file?(path)
end

#pathObject



10
11
12
# File 'lib/lono/app_file/registry/item.rb', line 10

def path
  "#{Lono.root}/output/#{@blueprint}/files/#{@name}"
end

#s3_pathObject



22
23
24
25
# File 'lib/lono/app_file/registry/item.rb', line 22

def s3_path
  file_path = zip_file_path.sub(%r{.*/output/[\w_-]+/files/}, '') # dont use basename. there might be subfolders
  "#{s3_prefix}/#{file_path}"
end

#zip_file_nameObject



32
33
34
# File 'lib/lono/app_file/registry/item.rb', line 32

def zip_file_name
  "#{File.basename(path)}-#{Lono::Md5.sum(path)}.zip"
end

#zip_file_pathObject

full path



28
29
30
# File 'lib/lono/app_file/registry/item.rb', line 28

def zip_file_path
  "#{File.dirname(path)}/#{zip_file_name}"
end