Class: PodPrebuild::BaseCacheValidator
- Inherits:
-
Object
- Object
- PodPrebuild::BaseCacheValidator
- Defined in:
- lib/cocoapods-binary-cache/cache/validator_base.rb
Direct Known Subclasses
AccumulatedCacheValidator, CacheValidator, DevPodsCacheValidator, NonDevPodsCacheValidator, PodfileChangesCacheValidator
Instance Attribute Summary collapse
-
#generated_framework_path ⇒ Object
readonly
Returns the value of attribute generated_framework_path.
-
#pod_lockfile ⇒ Object
readonly
Returns the value of attribute pod_lockfile.
-
#podfile ⇒ Object
readonly
Returns the value of attribute podfile.
-
#prebuilt_lockfile ⇒ Object
readonly
Returns the value of attribute prebuilt_lockfile.
-
#validate_prebuilt_settings ⇒ Object
readonly
Returns the value of attribute validate_prebuilt_settings.
Instance Method Summary collapse
- #changes_of_prebuilt_lockfile_vs_podfile ⇒ Object
- #incompatible_build_settings(name) ⇒ Object
-
#initialize(options) ⇒ BaseCacheValidator
constructor
A new instance of BaseCacheValidator.
- #read_prebuilt_build_settings(name) ⇒ Object
- #validate ⇒ Object
- #validate_pods(options) ⇒ Object
- #validate_with_podfile ⇒ Object
Constructor Details
#initialize(options) ⇒ BaseCacheValidator
Returns a new instance of BaseCacheValidator.
6 7 8 9 10 11 12 |
# File 'lib/cocoapods-binary-cache/cache/validator_base.rb', line 6 def initialize() @podfile = [:podfile] @pod_lockfile = [:pod_lockfile] && PodPrebuild::Lockfile.new([:pod_lockfile]) @prebuilt_lockfile = [:prebuilt_lockfile] && PodPrebuild::Lockfile.new([:prebuilt_lockfile]) @validate_prebuilt_settings = [:validate_prebuilt_settings] @generated_framework_path = [:generated_framework_path] end |
Instance Attribute Details
#generated_framework_path ⇒ Object (readonly)
Returns the value of attribute generated_framework_path.
4 5 6 |
# File 'lib/cocoapods-binary-cache/cache/validator_base.rb', line 4 def generated_framework_path @generated_framework_path end |
#pod_lockfile ⇒ Object (readonly)
Returns the value of attribute pod_lockfile.
3 4 5 |
# File 'lib/cocoapods-binary-cache/cache/validator_base.rb', line 3 def pod_lockfile @pod_lockfile end |
#podfile ⇒ Object (readonly)
Returns the value of attribute podfile.
3 4 5 |
# File 'lib/cocoapods-binary-cache/cache/validator_base.rb', line 3 def podfile @podfile end |
#prebuilt_lockfile ⇒ Object (readonly)
Returns the value of attribute prebuilt_lockfile.
3 4 5 |
# File 'lib/cocoapods-binary-cache/cache/validator_base.rb', line 3 def prebuilt_lockfile @prebuilt_lockfile end |
#validate_prebuilt_settings ⇒ Object (readonly)
Returns the value of attribute validate_prebuilt_settings.
4 5 6 |
# File 'lib/cocoapods-binary-cache/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-cache/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
80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/cocoapods-binary-cache/cache/validator_base.rb', line 80 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 |
#read_prebuilt_build_settings(name) ⇒ Object
73 74 75 76 77 78 |
# File 'lib/cocoapods-binary-cache/cache/validator_base.rb', line 73 def read_prebuilt_build_settings(name) return {} if generated_framework_path.nil? = PodPrebuild::Metadata.in_dir(generated_framework_path + name) .build_settings end |
#validate ⇒ Object
14 15 16 |
# File 'lib/cocoapods-binary-cache/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 |
# File 'lib/cocoapods-binary-cache/cache/validator_base.rb', line 31 def validate_pods() pods = [:pods] subspec_pods = [:subspec_pods] prebuilt_pods = [:prebuilt_pods] missed = {} hit = Set.new check_pod = lambda do |name| 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})" else settings_diff = incompatible_build_settings(name) if settings_diff.empty? hit << name result = true else missed[name] = "Incompatible build settings: #{settings_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-cache/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 |