Class: Dean::Upload

Inherits:
Object
  • Object
show all
Defined in:
lib/dean/commands/upload.rb

Instance Method Summary collapse

Instance Method Details

#upload_all_environmentsObject



6
7
8
9
10
# File 'lib/dean/commands/upload.rb', line 6

def upload_all_environments
  ConfigurationHelper.new().all_environments.each do |environment|
    upload_environment environment
  end
end

#upload_environment(environment) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/dean/commands/upload.rb', line 12

def upload_environment(environment)
  configurations = ConfigurationHelper.new().s3_settings_for_environment environment
  
  s3 = AWS::S3.new
  bucket = s3.buckets[configurations[:bucket_name]]

  version = ProjectVersionHelper.new.version_from_plist environment[:plist]

  s3_location = "#{configurations[:bucket_location]}/v#{version}/app.ipa"

  ipa_on_s3 = bucket.objects[s3_location]
  if ipa_on_s3.exists?
    puts "The file already exists on the bucket!"
  else
    #
    # TODO this shouldn't be static, but I need more time to think about how to structure it
    #
    build_settings = ConfigurationHelper.new().build_settings_for_environment environment
    disk_location = "#{Dir.pwd}/#{build_settings[:location]}/#{version}/Bizzby.ipa"

    puts "Uploading .ipa to #{s3_location}"
    ipa_on_s3.write( :file => disk_location)
    puts "Uploaded :)"
  end
end