Class: Lono::Configset::S3File::Item

Inherits:
Object
  • Object
show all
Includes:
Utils::Item::FileMethods
Defined in:
lib/lono/configset/s3_file/item.rb

Overview

Holds metadata about the item in the regsitry.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils::Item::FileMethods

#directory?, #exist?, #file?, #s3_path, #zip_file_name, #zip_file_path

Constructor Details

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

Returns a new instance of Item.



7
8
9
10
11
12
13
# File 'lib/lono/configset/s3_file/item.rb', line 7

def initialize(name, options={})
  @name, @options = name, options
  @blueprint = options[:blueprint]
  @configset = options[:configset]
  @root = options[:root]
  @type = options[:type] || 'file'
end

Instance Attribute Details

#configsetObject (readonly)

Returns the value of attribute configset.



6
7
8
# File 'lib/lono/configset/s3_file/item.rb', line 6

def configset
  @configset
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/lono/configset/s3_file/item.rb', line 6

def name
  @name
end

#rootObject (readonly)

Returns the value of attribute root.



6
7
8
# File 'lib/lono/configset/s3_file/item.rb', line 6

def root
  @root
end

Instance Method Details

#output_pathObject



19
20
21
# File 'lib/lono/configset/s3_file/item.rb', line 19

def output_path
  "#{Lono.config.output_path}/#{@blueprint}/configsets/#{@configset}/files/#{@name}"
end

#replacement_valueObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/lono/configset/s3_file/item.rb', line 23

def replacement_value
  aws_data = AwsData.new
  #
  #   "https://s3.amazonaws.com/#{Lono::S3::Bucket.name}/#{s3_path}"
  #   "https://lono-bucket-12di8xz5sy72z.s3-us-west-2.amazonaws.com/stuff/s3-antivirus.tgz"
  #
  # us-east-1 is special case:
  #
  #   "https://lono-bucket-12di8xz5sy72z.s3.amazonaws.com/stuff/s3-antivirus.tgz"
  #
  region = ""
  region = "-#{aws_data.region}" unless aws_data.region == "us-east-1"
  "https://#{Lono::S3::Bucket.name}.s3#{region}.amazonaws.com/#{s3_path}"
end

#src_pathObject



15
16
17
# File 'lib/lono/configset/s3_file/item.rb', line 15

def src_path
  "#{@root}/lib/files"
end