Class: Beanstalkify::Archive

Inherits:
Object
  • Object
show all
Defined in:
lib/beanstalkify/archive.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Archive

Returns a new instance of Archive.



7
8
9
10
11
# File 'lib/beanstalkify/archive.rb', line 7

def initialize(filename)
  @filename = filename
  @archive_name = File.basename(@filename)
  @app_name, hyphen, @version = File.basename(filename, '.*').rpartition("-")
end

Instance Attribute Details

#app_nameObject (readonly)

Returns the value of attribute app_name.



5
6
7
# File 'lib/beanstalkify/archive.rb', line 5

def app_name
  @app_name
end

#versionObject (readonly)

Returns the value of attribute version.



5
6
7
# File 'lib/beanstalkify/archive.rb', line 5

def version
  @version
end

Instance Method Details

#upload(beanstalk_api, s3_client = AWS::S3.new.client) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/beanstalkify/archive.rb', line 13

def upload(beanstalk_api, s3_client=AWS::S3.new.client)
  if already_uploaded?(beanstalk_api)
    return puts "#{version} is already uploaded."
  end
  bucket = beanstalk_api.create_storage_location.data[:s3_bucket]
  upload_to_s3(s3_client, bucket)
  make_application_version_available_to_beanstalk(beanstalk_api, bucket)
end