Class: Danger::DangerDeviceGrid
- Inherits:
-
Plugin
- Object
- Plugin
- Danger::DangerDeviceGrid
- Defined in:
- lib/device_grid/plugin.rb
Overview
A danger plugin: github.com/danger/danger
Instance Method Summary collapse
Instance Method Details
#run(public_key: nil, languages: nil, devices: nil, prefix_command: nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 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 57 58 59 60 61 62 63 64 |
# File 'lib/device_grid/plugin.rb', line 11 def run(public_key: nil, languages: nil, devices: nil, prefix_command: nil) # since we fetch the URL from the output we don't need colors # this will only be changed in the danger sub-process fastlane_colors_env = "FASTLANE_DISABLE_COLORS" fastlane_colors_were_disabled = ENV.key?(fastlane_colors_env) ENV[fastlane_colors_env] = "true" devices ||= %w(iphone4s iphone5s iphone6s iphone6splus ipadair) languages ||= ["en"] prefix_command ||= "" # To use the local fastlane instead of bundle prefix_command = "./bin/" if FastlaneCore::Helper.test? deep_link_matches = github.pr_body.match(/:link:\s(.*)/) # :link: emoji deep_link = deep_link_matches[1] if deep_link_matches markdown("<table>") languages.each do |current_language| markdown("<tr>") markdown("<td>") markdown("<b>#{current_language[0..1]}</b>") markdown("</td>") devices.each do |current_device| markdown("<td>") params = { public_key: public_key, language: current_language, device: current_device } params[:launch_url] = deep_link if deep_link params_str = params.map { |k, v| "#{k}:\"#{v}\"" }.join(" ") url = Fastlane::Helper.backticks("#{prefix_command}fastlane run appetize_viewing_url_generator #{params_str}") url = url.match(%r{Result:.*(https\:\/\/.*)})[1].strip markdown("<a href='#{url}'>") markdown("<p align='center'>") markdown("<img height='130' src='#{url_for_device(current_device)}' />") markdown("<br />") markdown(beautiful_device_name(current_device)) markdown("</p>") markdown("</a>") markdown("</td>") end markdown("</tr>") end markdown("</table>") ensure ENV.delete(fastlane_colors_env) unless fastlane_colors_were_disabled end |