Sha256: 1e8ef9f594c3714624cc0077f1164ca8637da274b363893d6e997ccb0559ce23

Contents?: true

Size: 1.06 KB

Versions: 136

Compression:

Stored size: 1.06 KB

Contents

require_relative 'module'
require_relative 'frame_downloader'

module Frameit
  class Offsets
    # Returns the image offset needed for a certain device type
    def self.image_offset(screenshot)
      require 'json'

      unless @offsets_cache
        offsets_json_path = File.join(FrameDownloader.new.templates_path, "offsets.json")
        UI.user_error!("Could not find offsets.json file at path '#{offsets_json_path}'") unless File.exist?(offsets_json_path)
        @offsets_cache = JSON.parse(File.read(offsets_json_path))
      end

      offset_value = @offsets_cache["portrait"][sanitize_device_name(screenshot.device_name)]
      UI.error("Tried looking for offset information for 'portrait', #{screenshot.device_name} in '#{offsets_json_path}'") unless offset_value
      return offset_value
    end

    def self.sanitize_device_name(basename)
      # this should be the same as frames_generator's sanitize_device_name (except stripping colors):
      basename = basename.gsub("Apple", "")
      basename = basename.gsub("-", " ")
      basename.strip.to_s
    end
  end
end

Version data entries

136 entries across 136 versions & 4 rubygems

Version Path
fastlane-2.225.0 frameit/lib/frameit/offsets.rb
fastlane-2.224.0 frameit/lib/frameit/offsets.rb
fastlane-2.223.1 frameit/lib/frameit/offsets.rb
fastlane-2.223.0 frameit/lib/frameit/offsets.rb
fastlane-2.222.0 frameit/lib/frameit/offsets.rb
fastlane-2.221.1 frameit/lib/frameit/offsets.rb
fastlane-2.221.0 frameit/lib/frameit/offsets.rb
fastlane-2.220.0 frameit/lib/frameit/offsets.rb
fastlane-2.219.0 frameit/lib/frameit/offsets.rb
fastlane-2.218.0 frameit/lib/frameit/offsets.rb
fastlane-security-patched-2.216.0 frameit/lib/frameit/offsets.rb
fastlane-2.217.0 frameit/lib/frameit/offsets.rb
fastlane-2.216.0 frameit/lib/frameit/offsets.rb
fastlane-2.215.1 frameit/lib/frameit/offsets.rb
fastlane-2.215.0 frameit/lib/frameit/offsets.rb
fastlane-mercafacil-2.214.0 frameit/lib/frameit/offsets.rb
fastlane-2.214.0 frameit/lib/frameit/offsets.rb
fastlane-2.213.0 frameit/lib/frameit/offsets.rb
fastlane-2.212.2 frameit/lib/frameit/offsets.rb
fastlane_pricing_fix-2.212.1 frameit/lib/frameit/offsets.rb