Class: Fastlane::Actions::AppetizeViewingUrlGeneratorAction

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

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES

Documentation collapse

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, example_code, lane_context, method_missing, other_action, output, sample_return_value, sh, step_text

Class Method Details

.authorsObject



111
112
113
# File 'lib/fastlane/actions/appetize_viewing_url_generator.rb', line 111

def self.authors
  ["KrauseFx"]
end

.available_optionsObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/fastlane/actions/appetize_viewing_url_generator.rb', line 45

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :public_key,
                                 env_name: "APPETIZE_PUBLICKEY",
                                 description: "Public key of the app you wish to update",
                                 is_string: true,
                                 default_value: Actions.lane_context[SharedValues::APPETIZE_PUBLIC_KEY],
                                 optional: false,
                                 verify_block: proc do |value|
                                   if value.start_with?("private_")
                                     UI.user_error!("You provided a private key to appetize, please provide the public key")
                                   end
                                 end),
    FastlaneCore::ConfigItem.new(key: :device,
                                 env_name: "APPETIZE_VIEWING_URL_GENERATOR_DEVICE",
                                 description: "Device type: iphone4s, iphone5s, iphone6, iphone6plus, ipadair, iphone6s, iphone6splus, ipadair2, nexus5, nexus7 or nexus9",
                                 is_string: true,
                                 default_value: "iphone5s"),
    FastlaneCore::ConfigItem.new(key: :scale,
                                 env_name: "APPETIZE_VIEWING_URL_GENERATOR_SCALE",
                                 description: "Scale of the simulator",
                                 is_string: true,
                                 optional: true,
                                 verify_block: proc do |value|
                                   available = ["25", "50", "75", "100"]
                                   UI.user_error!("Invalid scale, available: #{available.join(', ')}") unless available.include?(value)
                                 end),
    FastlaneCore::ConfigItem.new(key: :orientation,
                                 env_name: "APPETIZE_VIEWING_URL_GENERATOR_ORIENTATION",
                                 description: "Device orientation",
                                 is_string: true,
                                 default_value: "portrait",
                                 verify_block: proc do |value|
                                   available = ["portrait", "landscape"]
                                   UI.user_error!("Invalid device, available: #{available.join(', ')}") unless available.include?(value)
                                 end),
    FastlaneCore::ConfigItem.new(key: :language,
                                 env_name: "APPETIZE_VIEWING_URL_GENERATOR_LANGUAGE",
                                 description: "Device language in ISO 639-1 language code, e.g. 'de'",
                                 is_string: true,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :color,
                                 env_name: "APPETIZE_VIEWING_URL_GENERATOR_COLOR",
                                 description: "Color of the device",
                                 is_string: true,
                                 default_value: "black",
                                 verify_block: proc do |value|
                                   available = ["black", "white", "silver", "gray"]
                                   UI.user_error!("Invalid device color, available: #{available.join(', ')}") unless available.include?(value)
                                 end),
    FastlaneCore::ConfigItem.new(key: :launch_url,
                                 env_name: "APPETIZE_VIEWING_URL_GENERATOR_LAUNCH_URL",
                                 description: "Specify a deep link to open when your app is launched",
                                 is_string: true,
                                 optional: true)
  ]
end

.categoryObject



103
104
105
# File 'lib/fastlane/actions/appetize_viewing_url_generator.rb', line 103

def self.category
  :misc
end

.descriptionObject



37
38
39
# File 'lib/fastlane/actions/appetize_viewing_url_generator.rb', line 37

def self.description
  "Generate an URL for appetize simulator"
end

.detailsObject



41
42
43
# File 'lib/fastlane/actions/appetize_viewing_url_generator.rb', line 41

def self.details
  "Check out the [device_grid guide](https://github.com/fastlane/fastlane/blob/master/fastlane/lib/fastlane/actions/device_grid/README.md) for more information"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


115
116
117
# File 'lib/fastlane/actions/appetize_viewing_url_generator.rb', line 115

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

.return_valueObject



107
108
109
# File 'lib/fastlane/actions/appetize_viewing_url_generator.rb', line 107

def self.return_value
  "The URL to preview the iPhone app"
end

.run(params) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fastlane/actions/appetize_viewing_url_generator.rb', line 7

def self.run(params)
  link = "https://appetize.io/embed/#{params[:public_key]}"

  if params[:scale].nil? # sensible default values for scaling
    case params[:device].downcase.to_sym
    when :iphone6splus, :iphone6plus
      params[:scale] = "50"
    when :ipadair, :ipadair2
      params[:scale] = "50"
    else
      params[:scale] = "75"
    end
  end

  url_params = []
  url_params << "autoplay=true"
  url_params << "orientation=#{params[:orientation]}"
  url_params << "device=#{params[:device]}"
  url_params << "deviceColor=#{params[:color]}"
  url_params << "scale=#{params[:scale]}"
  url_params << "launchUrl=#{params[:launch_url]}" if params[:launch_url]
  url_params << "language=#{params[:language]}" if params[:language]

  return link + "?" + url_params.join("&")
end