Class: Headdesk::Checks::FacebookSDK
- Inherits:
-
Object
- Object
- Headdesk::Checks::FacebookSDK
- Includes:
- Headdesk::Check::APK
- Defined in:
- lib/headdesk/checks/facebook.rb
Overview
Check the version of the Facebook SDK
Facebook deprecates SDKs 2 years after they are released.
Instance Method Summary collapse
Methods included from Headdesk::Check::APK
Instance Method Details
#call ⇒ Object
15 16 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/facebook.rb', line 15 def call skip_check unless: -> { apk.class?('com/facebook/FacebookSdk') } facebook_sdk = apk.find_class('com/facebook/FacebookSdk') # TODO: Parse https://developers.facebook.com/docs/android/change-log-4x # and fail if > 2 years old, warn if < 3 months remaining get_sdk_version = facebook_sdk.method('getSdkVersion').code describe 'com.facebook.FacebookSdk contains getSdkVersion method' fail_check if: -> { !get_sdk_version } facebook_sdks = YAML.load_file(Headdesk::FACEBOOK_SDK_VERSIONS_YAML) major, minor, patch = get_sdk_version.match(/const-string v0, "(\d+)\.(\d+)\.(\d+)"/).captures.map(&:to_i) sdk_in_use = (facebook_sdks.select do |sdk| sdk[:major] == major && sdk[:minor] == minor && sdk[:patch] == patch end).first begin describe "Found Facebook SDK version #{sdk_in_use[:version]}" fail_check if: -> { !sdk_in_use } rescue NoMethodError => _e describe "Facebook SDK version #{major}.#{minor}.#{patch} not found, run 'bundle exec bin/facebook_sdk_versions'" fail_check end export facebook_sdk: sdk_in_use describe "Facebook SDK was released in the last 2 years (using #{sdk_in_use[:version]}, released #{sdk_in_use[:date]})" fail_check if: -> { sdk_in_use[:date] < (Date.today - (365 * 2)) } end |