Class: PodPrebuild::CacheValidationResult
- Inherits:
-
Object
- Object
- PodPrebuild::CacheValidationResult
- Defined in:
- lib/cocoapods-binary-cache/cache/validation_result.rb
Instance Attribute Summary collapse
-
#hit ⇒ Object
readonly
Returns the value of attribute hit.
-
#missed_with_reasons ⇒ Object
readonly
Returns the value of attribute missed_with_reasons.
Instance Method Summary collapse
- #discard(names) ⇒ Object
- #hit?(name) ⇒ Boolean
- #include?(name) ⇒ Boolean
-
#initialize(missed_with_reasons = {}, hit = Set.new) ⇒ CacheValidationResult
constructor
A new instance of CacheValidationResult.
- #keep(names) ⇒ Object
- #merge(other) ⇒ Object
- #missed ⇒ Object
- #missed?(name) ⇒ Boolean
- #print_summary ⇒ Object
- #reject(&predicate) ⇒ Object
- #select(&predicate) ⇒ Object
- #update_to(path) ⇒ Object
Constructor Details
#initialize(missed_with_reasons = {}, hit = Set.new) ⇒ CacheValidationResult
5 6 7 8 |
# File 'lib/cocoapods-binary-cache/cache/validation_result.rb', line 5 def initialize(missed_with_reasons = {}, hit = Set.new) @missed_with_reasons = missed_with_reasons @hit = hit.to_set - missed_with_reasons.keys end |
Instance Attribute Details
#hit ⇒ Object (readonly)
Returns the value of attribute hit.
3 4 5 |
# File 'lib/cocoapods-binary-cache/cache/validation_result.rb', line 3 def hit @hit end |
#missed_with_reasons ⇒ Object (readonly)
Returns the value of attribute missed_with_reasons.
3 4 5 |
# File 'lib/cocoapods-binary-cache/cache/validation_result.rb', line 3 def missed_with_reasons @missed_with_reasons end |
Instance Method Details
#discard(names) ⇒ Object
46 47 48 49 |
# File 'lib/cocoapods-binary-cache/cache/validation_result.rb', line 46 def discard(names) base_names = names.map { |name| name.split("/")[0] }.to_set reject { |name| base_names.include?(name.split("/")[0]) } end |
#hit?(name) ⇒ Boolean
18 19 20 |
# File 'lib/cocoapods-binary-cache/cache/validation_result.rb', line 18 def hit?(name) @hit.include?(name) end |
#include?(name) ⇒ Boolean
22 23 24 |
# File 'lib/cocoapods-binary-cache/cache/validation_result.rb', line 22 def include?(name) missed?(name) || hit?(name) end |
#keep(names) ⇒ Object
41 42 43 44 |
# File 'lib/cocoapods-binary-cache/cache/validation_result.rb', line 41 def keep(names) base_names = names.map { |name| name.split("/")[0] }.to_set select { |name| base_names.include?(name.split("/")[0]) } end |
#merge(other) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/cocoapods-binary-cache/cache/validation_result.rb', line 26 def merge(other) PodPrebuild::CacheValidationResult.new( @missed_with_reasons.merge(other.missed_with_reasons), @hit + other.hit ) end |
#missed ⇒ Object
10 11 12 |
# File 'lib/cocoapods-binary-cache/cache/validation_result.rb', line 10 def missed @missed_with_reasons.keys.to_set end |
#missed?(name) ⇒ Boolean
14 15 16 |
# File 'lib/cocoapods-binary-cache/cache/validation_result.rb', line 14 def missed?(name) @missed_with_reasons.key?(name) end |
#print_summary ⇒ Object
62 63 64 65 66 67 |
# File 'lib/cocoapods-binary-cache/cache/validation_result.rb', line 62 def print_summary Pod::UI.puts "Cache validation: hit (#{@hit.count}) #{@hit.to_a}" @missed_with_reasons.each do |name, reason| Pod::UI.puts "Cache validation: missed #{name}. Reason: #{reason}".yellow end end |
#reject(&predicate) ⇒ Object
58 59 60 |
# File 'lib/cocoapods-binary-cache/cache/validation_result.rb', line 58 def reject(&predicate) select { |name| !predicate.call(name) } end |
#select(&predicate) ⇒ Object
51 52 53 54 55 56 |
# File 'lib/cocoapods-binary-cache/cache/validation_result.rb', line 51 def select(&predicate) PodPrebuild::CacheValidationResult.new( @missed_with_reasons.select { |name, _| predicate.call(name) }, @hit.select(&predicate) ) end |
#update_to(path) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/cocoapods-binary-cache/cache/validation_result.rb', line 33 def update_to(path) FileUtils.mkdir_p(File.dirname(path)) json_file = PodPrebuild::JSONFile.new(path) json_file["cache_missed"] = missed.to_a json_file["cache_hit"] = hit.to_a json_file.save! end |