Class: Headdesk::Checks::Teak::Api21Icon
- Inherits:
-
Object
- Object
- Headdesk::Checks::Teak::Api21Icon
- Includes:
- APK
- Defined in:
- lib/headdesk/checks/teak/api21_icon.rb
Overview
Check to make sure that an APK, which uses Teak, has an API 21+ icon.
Instance Method Summary collapse
-
#call ⇒ Object
:reek:NilCheck and :reek:UncommunicativeVariableName { accept: [‘icon_v21’] }.
Methods included from APK
Instance Method Details
#call ⇒ Object
:reek:NilCheck and :reek:UncommunicativeVariableName { accept: [‘icon_v21’] }
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/headdesk/checks/teak/api21_icon.rb', line 17 def call skip_check if: -> { apk.min_sdk 21 } icon = apk.resources .values(v: 20) .drawable.io_teak_small_notification_icon icon_v21 = apk.resources .values(v: 21) .drawable.io_teak_small_notification_icon export icon: icon, icon_v21: icon_v21 describe "APK contains a drawable for 'io_teak_small_notification_icon'" fail_check if: -> { icon.nil? || icon_v21.nil? } describe "'io_teak_small_notification_icon' for v21 is different from < v21" fail_check unless: -> { icon != icon_v21 } resolutions = [['drawable-mdpi', 24], ['drawable-hdpi', 36], ['drawable-xhdpi', 48], ['drawable-xxhdpi', 72], ['drawable-xxxhdpi', 96]] resolutions.each do |rname, size| resource_file = icon_v21.sub('@drawable', "res/#{rname}") + '.png' fail_check unless: -> { apk.resources.file?(resource_file) } describe "'#{resource_file}' is #{size}x#{size}" image = ChunkyPNG::Image.from_file(apk.resources.path_for(resource_file)) fail_check unless: -> { size == image.width && size == image.height } end end |