Class: Deliver::HtmlGenerator
- Inherits:
-
Object
- Object
- Deliver::HtmlGenerator
- Defined in:
- deliver/lib/deliver/html_generator.rb
Constant Summary collapse
- KEYWORD_SPLITTER =
Splits keywords supporting:
-
separated by commas (with optional whitespace)
-
separated by newlines
-
/(?:,\s?|\r?\n)/
Instance Method Summary collapse
-
#render(options, screenshots, export_path = nil) ⇒ Object
Renders all data available to quickly see if everything was correctly generated.
-
#render_relative_path(export_path, path) ⇒ Object
Returns a path relative to FastlaneFolder.path This is needed as the Preview.html file is located inside FastlaneFolder.path.
- #run(options, screenshots) ⇒ Object
-
#split_keywords(keywords) ⇒ Object
Splits a string of keywords separated by comma or newlines into a presentable list.
Instance Method Details
#render(options, screenshots, export_path = nil) ⇒ Object
Renders all data available to quickly see if everything was correctly generated.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'deliver/lib/deliver/html_generator.rb', line 44 def render(, screenshots, export_path = nil) @screenshots = screenshots || [] @options = @export_path = export_path @app_name = ([:name]['en-US'] || [:name].values.first) if [:name] @app_name ||= [:app].name @languages = [:description].keys if [:description] @languages ||= [:app].latest_version.description.languages html_path = File.join(Deliver::ROOT, "lib/assets/summary.html.erb") html = ERB.new(File.read(html_path)).result(binding) # https://web.archive.org/web/20160430190141/www.rrn.dk/rubys-erb-templating-system export_path = File.join(export_path, "Preview.html") File.write(export_path, html) return export_path end |
#render_relative_path(export_path, path) ⇒ Object
Returns a path relative to FastlaneFolder.path This is needed as the Preview.html file is located inside FastlaneFolder.path
36 37 38 39 40 |
# File 'deliver/lib/deliver/html_generator.rb', line 36 def render_relative_path(export_path, path) export_path = Pathname.new(export_path) path = Pathname.new(path).relative_path_from(export_path) return path.to_path end |
#run(options, screenshots) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'deliver/lib/deliver/html_generator.rb', line 10 def run(, screenshots) begin fastlane_path = FastlaneCore::FastlaneFolder.path html_path = self.render(, screenshots, fastlane_path) rescue => ex UI.error(ex.inspect) UI.error(ex.backtrace.join("\n")) okay = UI.input("Could not render HTML preview. Do you still want to continue?") return if okay UI.crash!("Could not render HTML page") end UI.important("Verifying the upload via the HTML file can be disabled by either adding") UI.important("`force true` to your Deliverfile or using `fastlane deliver --force`") system("open '#{html_path}'") okay = UI.confirm("Does the Preview on path '#{html_path}' look okay for you?") if okay UI.success("HTML file confirmed...") # print this to give feedback to the user immediately else UI.user_error!("Did not upload the metadata, because the HTML file was rejected by the user") end end |
#split_keywords(keywords) ⇒ Object
Splits a string of keywords separated by comma or newlines into a presentable list
66 67 68 |
# File 'deliver/lib/deliver/html_generator.rb', line 66 def split_keywords(keywords) keywords.split(KEYWORD_SPLITTER) end |