fastlane-plugin-report 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f421c7f61f489d6e8005e497f475af5aedf2f99c
4
- data.tar.gz: c9dc98b43d79ce6e68e0c485f175986bc775d78b
3
+ metadata.gz: 3aea0e9eb168fef5034f4b5286a2343b185d9f98
4
+ data.tar.gz: ea326fca70a2bbe4ffad53eb514011aff5dc7349
5
5
  SHA512:
6
- metadata.gz: dc4bab0dc964da617d08ce0c37470fc2a472674d5dacfe854b45030a00541b2fe3df7a2fa313c266053e195fe694efb7321f88df535c93da4178050383953048
7
- data.tar.gz: d62ad6101389de58ff1bd343b2923004344f011c8ba913e6ca49f56a28127c505c245d359a29edfd88153e705fd1debd5f4c8d10a7bb6142eecd608f009cf46a
6
+ metadata.gz: 3ce18397600e043bd04421ca5c6ace2f1f6900f09a955572751da4b264113980f4f0543d8e7d6dd60ebbb66f711119c080bc0e6f8648ef4aaae52c6387c8997e
7
+ data.tar.gz: 895c37ea977ff55b1d998a4f3fc091e8cb9669696bd81e58065ebee0e9019c5774a53d4127897d67b2fc70ddf77ead76d72ebdc72c6432647849f222cfaf0a06
@@ -21,6 +21,11 @@ module Fastlane
21
21
  path = options[:path]
22
22
  path_type = options[:path_type]
23
23
  file_name = options[:file_name]
24
+ scan_as_pdf = options[:scan_as_pdf] ||= path_type == 'text/html'
25
+
26
+ if scan_as_pdf
27
+ path = pdf(path: path)
28
+ end
24
29
 
25
30
  client = Slack::Web::Client.new
26
31
  client.files_upload(
@@ -39,6 +44,40 @@ module Fastlane
39
44
 
40
45
  end
41
46
 
47
+ def self.pdf(options)
48
+ require 'pdfkit'
49
+ require 'nokogiri'
50
+
51
+ PDFKit.configure do |config|
52
+
53
+ config.default_options = {
54
+ page_size: "Letter",
55
+ encoding: "UTF-8",
56
+ disable_smart_shrinking: false,
57
+ footer_spacing: 2,
58
+ footer_center: "Page [page] of [toPage]"
59
+ }
60
+
61
+ end
62
+
63
+ path = options[:path] ||= ''
64
+ html = File.open(path, "r")
65
+
66
+ # Will be removed the segmented bar in case of you are uploading a Fastlane Scan report
67
+ html_doc = Nokogiri::HTML(html)
68
+ html_doc.css('section#segment-bar').remove
69
+ html = html_doc.to_html
70
+
71
+ kit = PDFKit.new(html, :page_size => 'Letter')
72
+
73
+ if !kit.nil?
74
+ path = path.gsub('.html', '.pdf')
75
+ file = kit.to_file(path)
76
+ return file
77
+ else
78
+ return path
79
+ end
80
+
42
81
  def self.description
43
82
  [
44
83
  "After an action, like scan for instance, you're able to generate a report file.",
@@ -84,7 +123,7 @@ module Fastlane
84
123
  UI.user_error!("You need to provide a 'file_name' parameter") if value.to_s.length == 0
85
124
  end),
86
125
  FastlaneCore::ConfigItem.new(key: :channels,
87
- env_name: "REPORT_CHANNELS",
126
+ env_name: "REPORT_SLACK_CHANNELS",
88
127
  description: "Selected channels to upload and post your report (default: '#channel')",
89
128
  optional: true,
90
129
  type: String),
@@ -92,7 +131,7 @@ module Fastlane
92
131
  env_name: "REPORT_AS_USER",
93
132
  description: "Report will be post as 'Slack API' if false or the user that created the token (default: 'false')",
94
133
  optional: true,
95
- type: String),
134
+ type: TrueClass),
96
135
  FastlaneCore::ConfigItem.new(key: :title,
97
136
  env_name: "REPORT_TITLE",
98
137
  description: "Title that will be shown on Slack (default: 'Report!')",
@@ -102,7 +141,12 @@ module Fastlane
102
141
  env_name: "REPORT_MESSAGE",
103
142
  description: "Message that will be shown on Slack (default: 'This is your report.')",
104
143
  optional: true,
105
- type: String)
144
+ type: String),
145
+ FastlaneCore::ConfigItem.new(key: :scan_as_pdf,
146
+ env_name: "REPORT_SCAN_AS_PDF",
147
+ description: "Message that will be shown on Slack (default: 'true' if was a HTML file)",
148
+ optional: true,
149
+ type: TrueClass)
106
150
  ]
107
151
  end
108
152
 
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Report
3
- VERSION = "0.1.5"
3
+ VERSION = "0.1.6"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-report
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bruno Miguêns