class Deliver::ScreenshotComparable
This clsas enables you to compare equality between different representations of the screenshots in the standard API `Array#-` that requires objects to implements `eql?` and `hash`.
Attributes
context[R]
A hash object that contains the source data of this representation class
key[R]
A unique key value that is consist of locale, filename, and checksum.
Public Class Methods
calculate_checksum(path)
click to toggle source
# File deliver/lib/deliver/screenshot_comparable.rb, line 44 def self.calculate_checksum(path) bytes = File.binread(path) Digest::MD5.hexdigest(bytes) end
create_from_local(screenshot:, app_screenshot_set:)
click to toggle source
# File deliver/lib/deliver/screenshot_comparable.rb, line 16 def self.create_from_local(screenshot:, app_screenshot_set:) raise ArgumentError unless screenshot.kind_of?(Deliver::AppScreenshot) raise ArgumentError unless app_screenshot_set.kind_of?(Spaceship::ConnectAPI::AppScreenshotSet) new( path: "#{screenshot.language}/#{File.basename(screenshot.path)}", checksum: calculate_checksum(screenshot.path), context: { screenshot: screenshot, app_screenshot_set: app_screenshot_set } ) end
create_from_remote(app_screenshot:, locale:)
click to toggle source
# File deliver/lib/deliver/screenshot_comparable.rb, line 30 def self.create_from_remote(app_screenshot:, locale:) raise ArgumentError unless app_screenshot.kind_of?(Spaceship::ConnectAPI::AppScreenshot) raise ArgumentError unless locale.kind_of?(String) new( path: "#{locale}/#{app_screenshot.file_name}", checksum: app_screenshot.source_file_checksum, context: { app_screenshot: app_screenshot, locale: locale } ) end
new(path:, checksum:, context:)
click to toggle source
# File deliver/lib/deliver/screenshot_comparable.rb, line 49 def initialize(path:, checksum:, context:) @key = "#{path}/#{checksum}" @context = context end
Public Instance Methods
eql?(other)
click to toggle source
# File deliver/lib/deliver/screenshot_comparable.rb, line 54 def eql?(other) key == other.key end
hash()
click to toggle source
# File deliver/lib/deliver/screenshot_comparable.rb, line 58 def hash key.hash end