Class: Fastlane::Actions::QrCodeAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::QrCodeAction
- Defined in:
- lib/fastlane/plugin/qr_code/actions/qr_code_action.rb
Constant Summary collapse
- @@temp_files =
Hold references to the temporary files, so that they aren’t garbage collected (and deleted) before the Fastlane workflow is finished.
[]
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .return_value ⇒ Object
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
51 52 53 |
# File 'lib/fastlane/plugin/qr_code/actions/qr_code_action.rb', line 51 def self. ["Mathijs Bernson"] end |
.available_options ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/fastlane/plugin/qr_code/actions/qr_code_action.rb', line 63 def self. [ FastlaneCore::ConfigItem.new(key: :contents, env_name: "QR_CODE_CONTENTS", description: "The contents of the QR code", optional: false, type: String) ] end |
.description ⇒ Object
47 48 49 |
# File 'lib/fastlane/plugin/qr_code/actions/qr_code_action.rb', line 47 def self.description "Generates QR codes that you may use in the rest of your workflow." end |
.details ⇒ Object
59 60 61 |
# File 'lib/fastlane/plugin/qr_code/actions/qr_code_action.rb', line 59 def self.details "The QR code PNG image is written to the system's temporary directory." end |
.is_supported?(platform) ⇒ Boolean
73 74 75 |
# File 'lib/fastlane/plugin/qr_code/actions/qr_code_action.rb', line 73 def self.is_supported?(platform) true end |
.return_value ⇒ Object
55 56 57 |
# File 'lib/fastlane/plugin/qr_code/actions/qr_code_action.rb', line 55 def self.return_value "Returns the path to the QR code PNG file." end |
.run(params) ⇒ Object
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 |
# File 'lib/fastlane/plugin/qr_code/actions/qr_code_action.rb', line 18 def self.run(params) qr_code_contents = params[:contents].to_s UI.user_error!("No QR code contents given, pass using `contents: 'http://example.com/123'`") unless qr_code_contents.length > 0 qr_code = RQRCode::QRCode.new(qr_code_contents) qr_code_text = qr_code.as_ansi qr_code_png = qr_code.as_png(size: 240) temp_file = Tempfile.new('qrcode') temp_file.write(qr_code_png.to_s) qr_code_png_path = temp_file.path temp_file.close @@temp_files.append(temp_file) # Setting action and environment variables Actions.lane_context[SharedValues::QR_CODE_PNG_PATH] = qr_code_png_path ENV[SharedValues::QR_CODE_PNG_PATH.to_s] = qr_code_png_path Actions.lane_context[SharedValues::QR_CODE_TEXT] = qr_code_text ENV[SharedValues::QR_CODE_TEXT.to_s] = qr_code_text UI.success("Successfully created QR code at path '#{Actions.lane_context[SharedValues::QR_CODE_PNG_PATH]}'") { 'QR_CODE_TEXT' => qr_code_text, 'QR_CODE_PNG_PATH' => qr_code_png_path } end |