class Fastlane::Actions::CopyScreenshotsAction
Public Class Methods
available_options()
click to toggle source
# File lib/fastlane/plugin/copy_screenshots/actions/copy_screenshots_action.rb, line 40 def self.available_options [ FastlaneCore::ConfigItem.new(key: :source_device_name, env_name: "SOURCE_DEVICE_NAME", description: "The source device name of copy", is_string: true, optional: false), FastlaneCore::ConfigItem.new(key: :target_device_name, env_name: "TARGET_DEVICE_NAME", description: "The target device name of copyone", is_string: true, optional: false) ] end
category()
click to toggle source
# File lib/fastlane/plugin/copy_screenshots/actions/copy_screenshots_action.rb, line 72 def self.category :screenshots end
description()
click to toggle source
@!group Documentation
# File lib/fastlane/plugin/copy_screenshots/actions/copy_screenshots_action.rb, line 32 def self.description "Copy screenshots with a specified device name. This action should be executed after `capture_ios_screenshots` action." end
details()
click to toggle source
# File lib/fastlane/plugin/copy_screenshots/actions/copy_screenshots_action.rb, line 36 def self.details "Main purpose of this action is copying screenshots for iPad Pro." end
example_code()
click to toggle source
# File lib/fastlane/plugin/copy_screenshots/actions/copy_screenshots_action.rb, line 63 def self.example_code [ 'copy_screenshots( source_device_name: "iPad Pro", target_device_name: "iPad Pro (12.9-inch) (3rd generation)" )' ] end
is_supported?(platform)
click to toggle source
# File lib/fastlane/plugin/copy_screenshots/actions/copy_screenshots_action.rb, line 59 def self.is_supported?(platform) [:ios, :mac].include?(platform) end
run(params)
click to toggle source
# File lib/fastlane/plugin/copy_screenshots/actions/copy_screenshots_action.rb, line 7 def self.run(params) source_device_name = params[:source_device_name] target_device_name = params[:target_device_name] screenshots_dir_path = Actions.lane_context[SharedValues::SNAPSHOT_SCREENSHOTS_PATH] if screenshots_dir_path.nil? raise "Pre Action Required. This action should be executed after `capture_ios_screenshots` action." end # glob iterates files which matched to the given predicate. Dir.glob("#{screenshots_dir_path}/**/#{source_device_name}*.png") do |f| # gsub replaces and returns matched strings. copy_filepath = f.gsub(source_device_name, target_device_name) FileUtils.cp(f, copy_filepath) print("COPIED:".green) print("\"#{f}\"") print(" to ".green) puts("\"#{copy_filepath}\"") end end