class Shenzhen::Plugins::S3::Client
Public Class Methods
new(access_key_id, secret_access_key, region)
click to toggle source
# File lib/shenzhen/plugins/s3.rb, line 6 def initialize(access_key_id, secret_access_key, region) @s3 = AWS::S3.new(:access_key_id => access_key_id, :secret_access_key => secret_access_key, :region => region) end
Public Instance Methods
upload_build(ipa, options)
click to toggle source
# File lib/shenzhen/plugins/s3.rb, line 12 def upload_build(ipa, options) path = expand_path_with_substitutions_from_ipa_plist(ipa, options[:path]) if options[:path] @s3.buckets.create(options[:bucket]) if options[:create] bucket = @s3.buckets[options[:bucket]] uploaded_urls = [] files = [] files << ipa files << options[:dsym] if options[:dsym] files.each do |file| basename = File.basename(file) key = path ? File.join(path, basename) : basename File.open(file) do |descriptor| obj = bucket.objects.create(key, descriptor, :acl => options[:acl]) uploaded_urls << obj.public_url.to_s end end uploaded_urls end
Private Instance Methods
expand_path_with_substitutions_from_ipa_plist(ipa, path)
click to toggle source
# File lib/shenzhen/plugins/s3.rb, line 38 def expand_path_with_substitutions_from_ipa_plist(ipa, path) substitutions = path.scan(/\{CFBundle[^}]+\}/) return path if substitutions.empty? Dir.mktmpdir do |dir| system "unzip -q #{ipa} -d #{dir} 2> /dev/null" plist = Dir["#{dir}/**/*.app/Info.plist"].last substitutions.uniq.each do |substitution| key = substitution[1...-1] value = Shenzhen::PlistBuddy.print(plist, key) path.gsub!(Regexp.new(substitution), value) if value end end return path end