Sha256: 83665a23e6e426b86c70133b66dcf0fff5a34812ecb8208b056e0351f80d6f63

Contents?: true

Size: 1.7 KB

Versions: 63

Compression:

Stored size: 1.7 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.run_codesign_command(["--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.run_codesign_command(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.run_command_in_context(cmd, options)

      hash[:out]
    end
  end
end

Version data entries

63 entries across 63 versions & 2 rubygems

Version Path
run_loop-4.2.3 lib/run_loop/codesign.rb
run_loop-4.2.2 lib/run_loop/codesign.rb
run_loop-4.2.1 lib/run_loop/codesign.rb
run_loop-4.2.0 lib/run_loop/codesign.rb
run_loop-4.1.0 lib/run_loop/codesign.rb
run_loop-4.0.0 lib/run_loop/codesign.rb
run_loop-3.0.1 lib/run_loop/codesign.rb
run_loop-3.0.0 lib/run_loop/codesign.rb
run_loop-2.7.1 lib/run_loop/codesign.rb
run_loop-2.7.0 lib/run_loop/codesign.rb
run_loop-2.6.6 lib/run_loop/codesign.rb
run_loop-2.6.5 lib/run_loop/codesign.rb
run_loop-2.6.4 lib/run_loop/codesign.rb
run_loop-2.6.3 lib/run_loop/codesign.rb
run_loop-2.6.2 lib/run_loop/codesign.rb
run_loop-2.6.1 lib/run_loop/codesign.rb
run_loop-2.6.0 lib/run_loop/codesign.rb
run_loop-2.5.4 lib/run_loop/codesign.rb
run_loop-2.5.3 lib/run_loop/codesign.rb
run_loop-2.5.2 lib/run_loop/codesign.rb