Class: Fastlane::Actions::ResizeScreenshotsAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/resize_screenshots/actions/resize_screenshots_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



43
44
45
# File 'lib/fastlane/plugin/resize_screenshots/actions/resize_screenshots_action.rb', line 43

def self.authors
  ["Levi Bostian"]
end

.available_optionsObject



56
57
58
59
60
61
62
63
64
# File 'lib/fastlane/plugin/resize_screenshots/actions/resize_screenshots_action.rb', line 56

def self.available_options
  [
    # FastlaneCore::ConfigItem.new(key: :your_option,
    #                         env_name: "RESIZE_SCREENSHOTS_YOUR_OPTION",
    #                      description: "A description of your option",
    #                         optional: false,
    #                             type: String)
  ]
end

.descriptionObject



39
40
41
# File 'lib/fastlane/plugin/resize_screenshots/actions/resize_screenshots_action.rb', line 39

def self.description
  "Resize screenshots taken from your simulator to use for Frameit."
end

.detailsObject



51
52
53
54
# File 'lib/fastlane/plugin/resize_screenshots/actions/resize_screenshots_action.rb', line 51

def self.details
  # Optional:
  "Take screenshots from your simulator, resize them to their appropriate size, then send the screenshots into Frameit to generate screenshots for the store!"
end

.get_device_dimensions(filename) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fastlane/plugin/resize_screenshots/actions/resize_screenshots_action.rb', line 25

def self.get_device_dimensions(filename)
  if filename.include? "iPhone X"
    return "1125x2436"
  elsif filename.include? "iPhone 6"
    return "750x1334"
  elsif filename.include? "iPhone 5"
    return "640x1136"
  elsif filename.include? "iPhone 6 Plus"
    return "1080x1920"
  else
    UI.error("Unknown device for file: #{filename}. Make sure to use iPhone 5, 6, 6 Plus, or X.")
  end
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


66
67
68
69
70
71
72
# File 'lib/fastlane/plugin/resize_screenshots/actions/resize_screenshots_action.rb', line 66

def self.is_supported?(platform)
  # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
  # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
  #
  # [:ios, :mac, :android].include?(platform)
  true
end

.return_valueObject



47
48
49
# File 'lib/fastlane/plugin/resize_screenshots/actions/resize_screenshots_action.rb', line 47

def self.return_value
  # If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fastlane/plugin/resize_screenshots/actions/resize_screenshots_action.rb', line 8

def self.run(params)
  Dir.foreach(Dir.pwd) do |item|
    next if item == '.' or item == '..' or !item.include? "Simulator Screen Shot - "

    UI.message("Resizing screenshot: #{item} to size: #{get_device_dimensions(item)}.")

    image = MiniMagick::Image.open(item)
    image.resize get_device_dimensions(item)
    image.format "png"
    image.write item

    UI.message("Resizing of #{item} complete.")
  end

  UI.message("Resizing of images complete!")
end