Class: Fastlane::Actions::AppetizeViewingUrlGeneratorAction

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

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES, Fastlane::Action::RETURN_TYPES

Documentation collapse

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, deprecated_notes, example_code, lane_context, method_missing, other_action, output, return_type, sample_return_value, shell_out_should_use_bundle_exec?, step_text

Class Method Details

.authorsObject



137
138
139
# File 'fastlane/lib/fastlane/actions/appetize_viewing_url_generator.rb', line 137

def self.authors
  ["KrauseFx"]
end

.available_optionsObject



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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'fastlane/lib/fastlane/actions/appetize_viewing_url_generator.rb', line 48

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,
                                 sensitive: true,
                                 default_value: Actions.lane_context[SharedValues::APPETIZE_PUBLIC_KEY],
                                 default_value_dynamic: true,
                                 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: :base_url,
                                 env_name: "APPETIZE_VIEWING_URL_GENERATOR_BASE",
                                 description: "Base URL of Appetize service",
                                 is_string: true,
                                 default_value: "https://appetize.io/embed",
                                 optional: true),
    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),
    FastlaneCore::ConfigItem.new(key: :os_version,
                                 env_name: "APPETIZE_VIEWING_URL_GENERATOR_OS_VERSION",
                                 description: "The operating system version on which to run your app, e.g. 10.3, 8.0",
                                 is_string: true,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :params,
                                 env_name: "APPETIZE_VIEWING_URL_GENERATOR_PARAMS",
                                 description: "Specify params value to be passed to Appetize",
                                 is_string: true,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :proxy,
                                 env_name: "APPETIZE_VIEWING_URL_GENERATOR_PROXY",
                                 description: "Specify a HTTP proxy to be passed to Appetize",
                                 is_string: true,
                                 optional: true)
  ]
end

.categoryObject



129
130
131
# File 'fastlane/lib/fastlane/actions/appetize_viewing_url_generator.rb', line 129

def self.category
  :misc
end

.descriptionObject



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

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

.detailsObject



44
45
46
# File 'fastlane/lib/fastlane/actions/appetize_viewing_url_generator.rb', line 44

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:



141
142
143
# File 'fastlane/lib/fastlane/actions/appetize_viewing_url_generator.rb', line 141

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

.return_valueObject



133
134
135
# File 'fastlane/lib/fastlane/actions/appetize_viewing_url_generator.rb', line 133

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
32
33
34
# File 'fastlane/lib/fastlane/actions/appetize_viewing_url_generator.rb', line 7

def self.run(params)
  link = "#{params[:base_url]}/#{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]
  url_params << "osVersion=#{params[:os_version]}" if params[:os_version]
  url_params << "params=#{CGI.escape(params[:params])}" if params[:params]
  url_params << "proxy=#{CGI.escape(params[:proxy])}" if params[:proxy]

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