Sha256: 92a8bf1b2d6b148f1b3db50446931b77e001e6224754418b12a413c3684c0206

Contents?: true

Size: 1.41 KB

Versions: 6

Compression:

Stored size: 1.41 KB

Contents

require 'plist'
require 'sigh/spaceship/runner'

module Sigh
  class Manager
    def self.start
      start = Time.now
      path = Sigh::Runner.new.run

      return nil unless path

      if Sigh.config[:filename]
        file_name = Sigh.config[:filename]
      else
        file_name = File.basename(path)
      end

      output = File.join(Sigh.config[:output_path].gsub("~", ENV["HOME"]), file_name)
      (FileUtils.mv(path, output) rescue nil) # in case it already exists

      install_profile(output) unless Sigh.config[:skip_install]

      puts output.green

      return File.expand_path(output)
    end

    def self.install_profile(profile)
      Helper.log.info "Installing provisioning profile..."
      profile_path = File.expand_path("~") + "/Library/MobileDevice/Provisioning Profiles/"
      profile_filename = ENV["SIGH_UDID"] + ".mobileprovision"
      destination = profile_path + profile_filename

      # If the directory doesn't exist, make it first
      unless File.directory?(profile_path)
        FileUtils.mkdir_p(profile_path)
      end

      # copy to Xcode provisioning profile directory
      (FileUtils.copy profile, destination rescue nil) # if the directory doesn't exist yet

      if File.exists? destination
        Helper.log.info "Profile successfully installed".green
      else
        raise "Failed installation of provisioning profile at location: #{destination}".red
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sigh-0.6.0 lib/sigh/manager.rb
sigh-1.0.0.beta6 lib/sigh/manager.rb
sigh-1.0.0.beta5 lib/sigh/manager.rb
sigh-1.0.0.beta3 lib/sigh/manager.rb
sigh-1.0.0.beta2 lib/sigh/manager.rb
sigh-1.0.0.beta1 lib/sigh/manager.rb