Class: Phase::IPA::EnterpriseDeployment
- Inherits:
-
Object
- Object
- Phase::IPA::EnterpriseDeployment
- Includes:
- Util::Console
- Defined in:
- lib/phase/kit/ipa/enterprise_deployment.rb
Instance Attribute Summary collapse
-
#aws ⇒ Object
readonly
Returns the value of attribute aws.
-
#bucket ⇒ Object
readonly
Returns the value of attribute bucket.
-
#file_paths ⇒ Object
readonly
Returns the value of attribute file_paths.
-
#manifest_key ⇒ Object
readonly
Returns the value of attribute manifest_key.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #copy_ipa!(app) ⇒ Object
-
#initialize(environment, version, *filenames) ⇒ EnterpriseDeployment
constructor
A new instance of EnterpriseDeployment.
- #run! ⇒ Object
- #upload_app!(app) ⇒ Object
- #upload_manifest!(manifest_path) ⇒ Object
- #write_plist!(app) ⇒ Object
Methods included from Util::Console
Constructor Details
#initialize(environment, version, *filenames) ⇒ EnterpriseDeployment
Returns a new instance of EnterpriseDeployment.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/phase/kit/ipa/enterprise_deployment.rb', line 8 def initialize(environment, version, *filenames) @version = version @file_paths = filenames.map do |name| ::Dir.glob( ::File.(name) ) end @file_paths.flatten! @file_paths.uniq! @aws = ::Fog::Storage::AWS.new(region: Phase.config.aws_region) @bucket = aws.directories.get(Phase.config.ipa.bucket_name) @prefix = ::Pathname.new(Phase.config.ipa.directory_prefix) if environment == "production" @manifest_key = "enterprise/manifest.json" else @manifest_key = "enterprise/manifest-staging.json" @prefix = @prefix.join("staging") end end |
Instance Attribute Details
#aws ⇒ Object (readonly)
Returns the value of attribute aws.
6 7 8 |
# File 'lib/phase/kit/ipa/enterprise_deployment.rb', line 6 def aws @aws end |
#bucket ⇒ Object (readonly)
Returns the value of attribute bucket.
6 7 8 |
# File 'lib/phase/kit/ipa/enterprise_deployment.rb', line 6 def bucket @bucket end |
#file_paths ⇒ Object (readonly)
Returns the value of attribute file_paths.
6 7 8 |
# File 'lib/phase/kit/ipa/enterprise_deployment.rb', line 6 def file_paths @file_paths end |
#manifest_key ⇒ Object (readonly)
Returns the value of attribute manifest_key.
6 7 8 |
# File 'lib/phase/kit/ipa/enterprise_deployment.rb', line 6 def manifest_key @manifest_key end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
6 7 8 |
# File 'lib/phase/kit/ipa/enterprise_deployment.rb', line 6 def prefix @prefix end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
6 7 8 |
# File 'lib/phase/kit/ipa/enterprise_deployment.rb', line 6 def version @version end |
Instance Method Details
#copy_ipa!(app) ⇒ Object
69 70 71 |
# File 'lib/phase/kit/ipa/enterprise_deployment.rb', line 69 def copy_ipa!(app) ::FileUtils.cp(app.qualified_path, ipa_path(app)) end |
#run! ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/phase/kit/ipa/enterprise_deployment.rb', line 29 def run! ::FileUtils.mkdir(version) rescue nil manifest_hash = file_paths.reduce({}) do |hash, path| app = App.new(path, version) app.download_url = download_url(app) log "#{app.name}: writing .plist..." write_plist!(app) log "#{app.name}: copying .ipa..." copy_ipa!(app) log "#{app.name}: uploading files..." upload_app!(app) log "#{app.name}: building app manifest..." hash[app.name] = { latest_version: app.version, download_url: manifest_url(app) } log "#{app.name}: done" log "" hash end manifest_path = ::File.join(::Dir.pwd, version, "manifest.json") ::File.write(manifest_path, manifest_hash.to_json) log "uploading release manifest..." upload_manifest!(manifest_path) log "done" end |
#upload_app!(app) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/phase/kit/ipa/enterprise_deployment.rb', line 73 def upload_app!(app) ipa = bucket.files.new({ key: prefix.join(app.ipa_filename), body: ::File.open(ipa_path(app)), acl: "public-read" }) plist = bucket.files.new({ key: prefix.join(app.plist_filename), body: ::File.open(plist_path(app)), acl: "public-read" }) ipa.save plist.save end |
#upload_manifest!(manifest_path) ⇒ Object
90 91 92 93 94 95 96 97 98 |
# File 'lib/phase/kit/ipa/enterprise_deployment.rb', line 90 def upload_manifest!(manifest_path) manifest = bucket.files.new({ key: manifest_key, body: ::File.open(manifest_path), acl: "public-read" }) manifest.save end |
#write_plist!(app) ⇒ Object
65 66 67 |
# File 'lib/phase/kit/ipa/enterprise_deployment.rb', line 65 def write_plist!(app) ::File.open(plist_path(app), 'w') { |file| file << app.plist_xml } end |