Class: Jxedt::Sandbox

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = nil) ⇒ Sandbox

Returns a new instance of Sandbox.



5
6
7
# File 'lib/cocoapods-jxedt/binary/prebuild.rb', line 5

def initialize(path=nil)
    @sandbox_path = path
end

Instance Attribute Details

#sandboxObject

Returns the value of attribute sandbox.



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

def sandbox
  @sandbox
end

Class Method Details

.from_sandbox(sandbox) ⇒ Object



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

def self.from_sandbox(sandbox)
    search_path = Jxedt.config.binary_dir
    binary_dir = search_path.empty? ? nil : sandbox.standard_sandbox_root + search_path
    check_sandbox = Sandbox.new(binary_dir)
    check_sandbox.sandbox = sandbox
    check_sandbox
end

Instance Method Details

#binary_dirObject



17
18
19
# File 'lib/cocoapods-jxedt/binary/prebuild.rb', line 17

def binary_dir
    @binary_dir ||= Pathname.new(@sandbox_path)
end

#existed_target_names(name) ⇒ Object



41
42
43
# File 'lib/cocoapods-jxedt/binary/prebuild.rb', line 41

def existed_target_names(name)
    target_paths.select { |pair| "#{pair.basename}" == "#{name}" }.map { |pair| pair.basename }
end

#framework_folder_path_for_target_name(name) ⇒ Object



45
46
47
# File 'lib/cocoapods-jxedt/binary/prebuild.rb', line 45

def framework_folder_path_for_target_name(name)
    target_paths.select { |pair| pair.basename == name }.last
end

#prebuild_bundles(name) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/cocoapods-jxedt/binary/prebuild.rb', line 62

def prebuild_bundles(name)
    target_path = target_paths.select { |pair| "#{pair.basename}" == "#{name}" }.last
    return [] if target_path.nil?

    configuration_enable = target_path.children().select { |path| "#{path.basename}" == 'Debug' || "#{path.basename}" == 'Release' }.count == 2
    if configuration_enable
        xcconfig_configuration_alias = Jxedt.config.xcconfig_configuration_alias
        ["#{xcconfig_configuration_alias}-Release/*.bundle"]
    else
        ["*.bundle"]
    end
end

#prebuild_vendored_frameworks(name) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/cocoapods-jxedt/binary/prebuild.rb', line 49

def prebuild_vendored_frameworks(name)
    target_path = target_paths.select { |pair| "#{pair.basename}" == "#{name}" }.last
    return [] if target_path.nil?

    configuration_enable = target_path.children().select { |path| "#{path.basename}" == 'Debug' || "#{path.basename}" == 'Release' }.count == 2
    if configuration_enable
        xcconfig_configuration_alias = Jxedt.config.xcconfig_configuration_alias
        ["#{xcconfig_configuration_alias}-Release/*.{framework,xcframework}"]
    else
        ["*.{framework,xcframework}"]
    end
end

#target_pathsObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/cocoapods-jxedt/binary/prebuild.rb', line 21

def target_paths
    return [] if @sandbox_path.nil?
    return [] unless binary_dir.exist?
    return [] if @sandbox.source_lockfile.nil?
    @targets ||= begin
        prebuild_targets = binary_dir.children().map do |target_path|
            if target_path.directory? && (not target_path.children.empty?)
                hash_key = @sandbox.source_lockfile.spec_checksums_hash_key(target_path.basename.to_s)
                next if hash_key.nil?
                
                checksum_files = target_path.children().select { |path| path.extname == '.checksum' }
                checksum_exists = (target_path + "#{hash_key}.checksum").exist?
                target_path if checksum_files.count == 1 && checksum_exists
            end
        end.reject(&:nil?).uniq
        prebuild_targets
    end
    @targets
end