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.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



34
35
36
# File 'lib/cocoapods-jxedt/binary/prebuild.rb', line 34

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



38
39
40
# File 'lib/cocoapods-jxedt/binary/prebuild.rb', line 38

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

#prebuild_bundles(name) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/cocoapods-jxedt/binary/prebuild.rb', line 55

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



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/cocoapods-jxedt/binary/prebuild.rb', line 42

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
# 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 ||= 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)
            target_path if !(hash_key.nil?) && (target_path + "#{hash_key}.checksum").exist?
        end
    end.reject(&:nil?).uniq
    @targets
end