Sha256: 4332727ae267b8cd8938d1682df526a93e6b7d568dea1eb1b3517aa78749384a

Contents?: true

Size: 1.65 KB

Versions: 14

Compression:

Stored size: 1.65 KB

Contents

module RunLoop
  # @!visibility private
  # A wrapper around codesign command line tool
  class Codesign

    # @!visibility private
    DEV_REGEX = /Authority=iPhone Developer:/

    # @!visibility private
    APP_STORE_REGEX = /Authority=Apple iPhone OS Application Signing/

    # @!visibility private
    DISTR_REGEX = /Authority=iPhone Distribution:/

    # @!visibility private
    NOT_SIGNED_REGEX = /code object is not signed at all/

    # @!visibility private
    def self.info(path)
      self.expect_path_exists(path)
      self.exec(["--display", "--verbose=4", path])
    end

    # @!visibility private
    #
    # True if the asset is signed.
    def self.signed?(path)
      info = self.info(path)
      info[NOT_SIGNED_REGEX, 0] == nil
    end

    # @!visibility private
    #
    # True if the asset is signed with anything other than a dev cert.
    def self.distribution?(path)
      info = self.info(path)

      info[NOT_SIGNED_REGEX, 0] == nil &&
        info[DEV_REGEX, 0] == nil
    end

    # @!visibility private
    #
    # True if the asset is signed with a dev cert
    def self.developer?(path)
      info = self.info(path)
      info[DEV_REGEX, 0] != nil
    end

    private

    def self.expect_path_exists(path)
      if !File.exist?(path)
        raise ArgumentError,
%Q{There is no file or directory at path:

#{path}
}
      end
    end

    def self.exec(args)
      if !args.is_a?(Array)
        raise ArgumentError, "Expected args: '#{args}' to be an Array"
      end

      xcrun = RunLoop::Xcrun.new
      cmd = ["codesign"] + args
      options = {:log_cmd => true}
      hash = xcrun.exec(cmd, options)

      hash[:out]
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
run_loop-2.1.3 lib/run_loop/codesign.rb
run_loop-2.1.2 lib/run_loop/codesign.rb
run_loop-2.1.1 lib/run_loop/codesign.rb
run_loop-2.1.1.pre5 lib/run_loop/codesign.rb
run_loop-2.1.1.pre4 lib/run_loop/codesign.rb
run_loop-2.1.1.pre3 lib/run_loop/codesign.rb
run_loop-2.1.1.pre2 lib/run_loop/codesign.rb
run_loop-2.1.1.pre1 lib/run_loop/codesign.rb
run_loop-2.1.0 lib/run_loop/codesign.rb
run_loop-2.1.0.pre1 lib/run_loop/codesign.rb
run_loop-2.0.10.pre1 lib/run_loop/codesign.rb
run_loop-2.0.9 lib/run_loop/codesign.rb
run_loop-2.0.8 lib/run_loop/codesign.rb
run_loop-2.0.7 lib/run_loop/codesign.rb