Class: Fastlane::Actions::FrameitAction

Inherits:
Fastlane::Action show all
Defined in:
lib/fastlane/actions/frameit.rb

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, authors, details, output, sh, step_text

Class Method Details

.authorObject



58
59
60
# File 'lib/fastlane/actions/frameit.rb', line 58

def self.author
  "KrauseFx"
end

.available_optionsObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/fastlane/actions/frameit.rb', line 30

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :white,
                                   env_name: "FRAMEIT_WHITE_FRAME",
                                   description: "Use white device frames",
                                   optional: true,
                                   is_string: false),
    FastlaneCore::ConfigItem.new(key: :silver,
                                 description: "Use white device frames. Alias for :white",
                                 optional: true,
                                 is_string: false),
    FastlaneCore::ConfigItem.new(key: :path,
                                 env_name: "FRAMEIT_SCREENSHOTS_PATH",
                                 description: "The path to the directory containing the screenshots",
                                 default_value: Actions.lane_context[SharedValues::SNAPSHOT_SCREENSHOTS_PATH] || FastlaneFolder.path),
    FastlaneCore::ConfigItem.new(key: :force_device_type,
                                 env_name: "FRAMEIT_FORCE_DEVICE_TYPE",
                                 description: "Forces a given device type, useful for Mac screenshots, as their sizes vary",
                                 optional: true,
                                 verify_block: Proc.new do |value|
                                  available = ['iPhone_6_Plus', 'iPhone_5s', 'iPhone_4', 'iPad_mini', 'Mac']
                                  unless available.include?value
                                    raise "Invalid device type '#{value}'. Available values: #{available}".red
                                  end
                                 end)
  ]
end

.descriptionObject



26
27
28
# File 'lib/fastlane/actions/frameit.rb', line 26

def self.description
  "Adds device frames around the screenshots using frameit"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/fastlane/actions/frameit.rb', line 62

def self.is_supported?(platform)
  [:ios, :mac].include?platform
end

.run(config) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fastlane/actions/frameit.rb', line 4

def self.run(config)
  return if Helper.test?

  require 'frameit'

  begin
    FastlaneCore::UpdateChecker.start_looking_for_update('frameit') unless Helper.is_test?
    color = Frameit::Color::BLACK
    color = Frameit::Color::SILVER if (config[:white] or config[:silver])

    Helper.log.info "Framing screenshots at path #{config[:path]}"

    Dir.chdir(config[:path]) do
      ENV["FRAMEIT_FORCE_DEVICE_TYPE"] = config[:force_device_type] if config[:force_device_type]
      Frameit::Runner.new.run('.', color)
      ENV.delete("FRAMEIT_FORCE_DEVICE_TYPE") if config[:force_device_type]
    end
  ensure
    FastlaneCore::UpdateChecker.show_update_status('frameit', Frameit::VERSION)
  end
end