Class: PodPrebuild::BaseCacheValidator
- Inherits:
-
Object
- Object
- PodPrebuild::BaseCacheValidator
show all
- Defined in:
- lib/cocoapods-binary-ht/cache/validator_base.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of BaseCacheValidator.
6
7
8
9
10
11
12
|
# File 'lib/cocoapods-binary-ht/cache/validator_base.rb', line 6
def initialize(options)
@podfile = options[:podfile]
@pod_lockfile = options[:pod_lockfile] && PodPrebuild::Lockfile.new(options[:pod_lockfile])
@prebuilt_lockfile = options[:prebuilt_lockfile] && PodPrebuild::Lockfile.new(options[:prebuilt_lockfile])
@validate_prebuilt_settings = options[:validate_prebuilt_settings]
@generated_framework_path = options[:generated_framework_path]
end
|
Instance Attribute Details
#generated_framework_path ⇒ Object
Returns the value of attribute generated_framework_path.
4
5
6
|
# File 'lib/cocoapods-binary-ht/cache/validator_base.rb', line 4
def generated_framework_path
@generated_framework_path
end
|
#pod_lockfile ⇒ Object
Returns the value of attribute pod_lockfile.
3
4
5
|
# File 'lib/cocoapods-binary-ht/cache/validator_base.rb', line 3
def pod_lockfile
@pod_lockfile
end
|
#podfile ⇒ Object
Returns the value of attribute podfile.
3
4
5
|
# File 'lib/cocoapods-binary-ht/cache/validator_base.rb', line 3
def podfile
@podfile
end
|
#prebuilt_lockfile ⇒ Object
Returns the value of attribute prebuilt_lockfile.
3
4
5
|
# File 'lib/cocoapods-binary-ht/cache/validator_base.rb', line 3
def prebuilt_lockfile
@prebuilt_lockfile
end
|
#validate_prebuilt_settings ⇒ Object
Returns the value of attribute validate_prebuilt_settings.
4
5
6
|
# File 'lib/cocoapods-binary-ht/cache/validator_base.rb', line 4
def validate_prebuilt_settings
@validate_prebuilt_settings
end
|
Instance Method Details
#changes_of_prebuilt_lockfile_vs_podfile ⇒ Object
18
19
20
21
22
|
# File 'lib/cocoapods-binary-ht/cache/validator_base.rb', line 18
def changes_of_prebuilt_lockfile_vs_podfile
@changes_of_prebuilt_lockfile_vs_podfile ||= Pod::Installer::Analyzer::SpecsState.new(
@prebuilt_lockfile.lockfile.detect_changes_with_podfile(@podfile)
)
end
|
#incompatible_build_settings(name) ⇒ Object
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/cocoapods-binary-ht/cache/validator_base.rb', line 82
def incompatible_build_settings(name)
settings_diff = {}
prebuilt_build_settings = read_prebuilt_build_settings(name)
validate_prebuilt_settings&.(name)&.each do |key, value|
prebuilt_value = prebuilt_build_settings[key]
unless prebuilt_value.nil? || value == prebuilt_value
settings_diff[key] = { :current => value, :prebuilt => prebuilt_value }
end
end
settings_diff
end
|
#incompatible_pod(name) ⇒ Object
76
77
78
79
80
|
# File 'lib/cocoapods-binary-ht/cache/validator_base.rb', line 76
def incompatible_pod(name)
incompatible_build_settings(name)
end
|
94
95
96
97
98
99
100
101
102
|
# File 'lib/cocoapods-binary-ht/cache/validator_base.rb', line 94
def load_metadata(name)
@metadata_cache ||= {}
cache = @metadata_cache[name]
return cache unless cache.nil?
metadata = PodPrebuild::Metadata.in_dir(generated_framework_path + name)
@metadata_cache[name] = metadata
metadata
end
|
#read_prebuilt_build_settings(name) ⇒ Object
104
105
106
|
# File 'lib/cocoapods-binary-ht/cache/validator_base.rb', line 104
def read_prebuilt_build_settings(name)
load_metadata(name).build_settings
end
|
#read_source_hash(name) ⇒ Object
108
109
110
|
# File 'lib/cocoapods-binary-ht/cache/validator_base.rb', line 108
def read_source_hash(name)
load_metadata(name).source_hash
end
|
#validate ⇒ Object
14
15
16
|
# File 'lib/cocoapods-binary-ht/cache/validator_base.rb', line 14
def validate(*)
raise NotImplementedError
end
|
#validate_pods(options) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/cocoapods-binary-ht/cache/validator_base.rb', line 31
def validate_pods(options)
pods = options[:pods]
subspec_pods = options[:subspec_pods]
prebuilt_pods = options[:prebuilt_pods]
missed = {}
hit = Set.new
check_pod = lambda do |name|
root_name = name.split("/")[0]
version = pods[name]
prebuilt_version = prebuilt_pods[name]
result = false
if prebuilt_version.nil?
missed[name] = "Not available (#{version})"
elsif prebuilt_version != version
missed[name] = "Outdated: (prebuilt: #{prebuilt_version}) vs (#{version})"
elsif load_metadata(root_name).blank?
missed[name] = "Metadata not available (probably #{root_name}.zip is not in GeneratedFrameworks)"
else
diff = incompatible_pod(root_name)
if diff.empty?
hit << name
result = true
else
missed[name] = "Incompatible: #{diff}"
end
end
result
end
subspec_pods.each do |parent, children|
missed_children = children.reject { |child| check_pod.call(child) }
if missed_children.empty?
hit << parent
else
missed[parent] = "Subspec pods were missed: #{missed_children}"
end
end
non_subspec_pods = pods.reject { |pod| subspec_pods.include?(pod) }
non_subspec_pods.each { |pod, _| check_pod.call(pod) }
PodPrebuild::CacheValidationResult.new(missed, hit)
end
|
#validate_with_podfile ⇒ Object
24
25
26
27
28
29
|
# File 'lib/cocoapods-binary-ht/cache/validator_base.rb', line 24
def validate_with_podfile
changes = changes_of_prebuilt_lockfile_vs_podfile
missed = changes.added.map { |pod| [pod, "Added from Podfile"] }.to_h
missed.merge!(changes.changed.map { |pod| [pod, "Updated from Podfile"] }.to_h)
PodPrebuild::CacheValidationResult.new(missed, changes.unchanged)
end
|