Class: Fastlane::Actions::AnsiQrCodeAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/jira_update/actions/ansi_qr_code_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



69
70
71
# File 'lib/fastlane/plugin/jira_update/actions/ansi_qr_code_action.rb', line 69

def self.authors
  ["Flop Butylkin"]
end

.available_optionsObject



59
60
61
62
63
64
65
66
67
# File 'lib/fastlane/plugin/jira_update/actions/ansi_qr_code_action.rb', line 59

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :text,
                                 description: "Text for QR code",
                                 env_name: "FL_QR_TEXT",
                                 type: String,
                                 default_value: "Hello, world!")
  ]
end

.categoryObject



87
88
89
# File 'lib/fastlane/plugin/jira_update/actions/ansi_qr_code_action.rb', line 87

def self.category
  :misc
end

.descriptionObject



43
44
45
# File 'lib/fastlane/plugin/jira_update/actions/ansi_qr_code_action.rb', line 43

def self.description
  "Generate QR code"
end

.detailsObject



47
48
49
# File 'lib/fastlane/plugin/jira_update/actions/ansi_qr_code_action.rb', line 47

def self.details
  "Generate QR code"
end

.example_codeObject



77
78
79
80
81
82
83
84
85
# File 'lib/fastlane/plugin/jira_update/actions/ansi_qr_code_action.rb', line 77

def self.example_code
  [
    '
    ansi_qr_code(
      text: "https://www.google.com"
    )
    '
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/fastlane/plugin/jira_update/actions/ansi_qr_code_action.rb', line 73

def self.is_supported?(platform)
  true
end

.outputObject



35
36
37
38
39
40
41
# File 'lib/fastlane/plugin/jira_update/actions/ansi_qr_code_action.rb', line 35

def self.output
  [
      ['QR_CODE_ORIGINAL_TEXT', 'Original text for QR code'],
      ['QR_CODE_ASCII_ART', 'QR code ascii art'],
      ['QR_CODE_IMAGE_LINK', 'URL to QR code image']
  ]
end

.return_typeObject



55
56
57
# File 'lib/fastlane/plugin/jira_update/actions/ansi_qr_code_action.rb', line 55

def self.return_type
  :string
end

.return_valueObject



51
52
53
# File 'lib/fastlane/plugin/jira_update/actions/ansi_qr_code_action.rb', line 51

def self.return_value
  "QR code link"
end

.run(params) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fastlane/plugin/jira_update/actions/ansi_qr_code_action.rb', line 11

def self.run(params)
  Actions.verify_gem!('rqrcode')
  require 'rqrcode'
  text = params[:text]
  qrcode = RQRCode::QRCode.new(text)
  ascii_art = qrcode.as_ansi(
    light: "\033[47m", dark: "\033[40m",
    fill_character: "  ",
    quiet_zone_size: 4
  )
  UI.message("QR code:\n#{ascii_art}")

  urlencoded_text = URI.encode_www_form_component(text)
  link = "https://kissapi-qrcode.vercel.app/api/qrcode?chl=#{urlencoded_text}"
  UI.message("QR code link: #{link}")

  Actions.lane_context[SharedValues::QR_CODE_ORIGINAL_TEXT] = text
  Actions.lane_context[SharedValues::QR_CODE_ASCII_ART] = ascii_art
  Actions.lane_context[SharedValues::QR_CODE_IMAGE_LINK] = link        

  return link

end