Class: Jxedt::PostInstall

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-jxedt/binary/hooks/post_install.rb

Instance Method Summary collapse

Constructor Details

#initialize(installer_context) ⇒ PostInstall

Returns a new instance of PostInstall.



3
4
5
# File 'lib/cocoapods-jxedt/binary/hooks/post_install.rb', line 3

def initialize(installer_context)
    @installer_context = installer_context
end

Instance Method Details

#runObject



7
8
9
10
11
12
13
14
15
# File 'lib/cocoapods-jxedt/binary/hooks/post_install.rb', line 7

def run
    # check binary switch
    return unless Jxedt.config.binary_switch?
    
    require_relative '../helper/prebuild_sandbox'

    # :post_install过程校验两次`pod install`的值
    validate_pod_checksum unless @installer_context.sandbox.is_a?(Pod::JxedtPrebuildSandbox)
end

#validate_pod_checksumObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/cocoapods-jxedt/binary/hooks/post_install.rb', line 17

def validate_pod_checksum
    original_installer = ObjectSpace.each_object(Pod::Installer).reject {|installer| installer.sandbox.is_a?(Pod::JxedtPrebuildSandbox) }.first
    return if original_installer.nil?

    check_result = original_installer.lockfile == @installer_context.sandbox.source_lockfile
    unless check_result
        validation_failed = []
        lockfile = original_installer.lockfile
        source_lockfile = @installer_context.sandbox.source_lockfile
        lockfile.internal_data["SPEC CHECKSUMS"].each_key { |name| 
            value1 = lockfile.spec_checksums_hash_key(name)
            value2 = source_lockfile.spec_checksums_hash_key(name)
            validation_failed << name if value1.nil? || value2.nil? || value1 != value2
        }
        Pod::UI.warn "⚠️  ⚠️  ⚠️  Lockfile文件校验失败,请检查Pod组件: #{validation_failed}"
    end
end