Class: Fastlane::Actions::ImagesgoldenrunAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::ImagesgoldenrunAction
- Defined in:
- lib/fastlane/plugin/imagesgoldenrun/actions/imagesgoldenrun_action.rb
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
68 69 70 |
# File 'lib/fastlane/plugin/imagesgoldenrun/actions/imagesgoldenrun_action.rb', line 68 def self. ["Luís Esteves"] end |
.available_options ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/fastlane/plugin/imagesgoldenrun/actions/imagesgoldenrun_action.rb', line 81 def self. [ FastlaneCore::ConfigItem.new(key: :goldenRunLoc, description: "Golden run images relative path (e.g. 'images/goldenRun')", optional: false), FastlaneCore::ConfigItem.new(key: :resultLoc, description: "Results images relative path (e.g. 'images/results)", optional: false), FastlaneCore::ConfigItem.new(key: :excludeArea, description: 'Area for the exclusion', optional: false), FastlaneCore::ConfigItem.new(key: :failWhenDiffs, description: 'Area for the exclusion', optional: true, default_value: false) ] end |
.description ⇒ Object
64 65 66 |
# File 'lib/fastlane/plugin/imagesgoldenrun/actions/imagesgoldenrun_action.rb', line 64 def self.description "this allows comparing images from a golden run with the actual results" end |
.details ⇒ Object
76 77 78 79 |
# File 'lib/fastlane/plugin/imagesgoldenrun/actions/imagesgoldenrun_action.rb', line 76 def self.details # Optional: "this allows comparing images from a golden run with the actual results" end |
.is_supported?(platform) ⇒ Boolean
99 100 101 |
# File 'lib/fastlane/plugin/imagesgoldenrun/actions/imagesgoldenrun_action.rb', line 99 def self.is_supported?(platform) true end |
.return_value ⇒ Object
72 73 74 |
# File 'lib/fastlane/plugin/imagesgoldenrun/actions/imagesgoldenrun_action.rb', line 72 def self.return_value # If your method provides a return value, you can describe here what it does end |
.run(params) ⇒ Object
9 10 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 |
# File 'lib/fastlane/plugin/imagesgoldenrun/actions/imagesgoldenrun_action.rb', line 9 def self.run(params) differencesFolder = "imagesGoldenRunReport" differencesPath = "#{differencesFolder}/differences" FileUtils.mkdir_p(differencesPath) Dir.foreach(differencesPath) do |f| fp = File.join(differencesPath, f) File.delete(fp) if !File.directory?(fp) end #html report goldenRunReport = "<html><body><h2>Images Gonden Run results<h2><p><htmlImages></body></html>" htmlImages = "" imgExtension = ".png" hasDifferences = false goldenRunLoc = File.(File.join(Dir.pwd, params[:goldenRunLoc])) resultsLoc = File.(File.join(Dir.pwd, params[:resultLoc])) goldenRunImagesNames = Dir.entries(goldenRunLoc).select {|f| f.end_with?(imgExtension)} goldenRunImagesNames.each do |imageName| imgFullPathGolden = "#{params[:goldenRunLoc]}/#{imageName}" #find the full name of the result file resultImageName = Dir.entries(resultsLoc).select {|f| f.start_with? imageName.gsub(imgExtension, "") }.first imgFullPathResult = "#{params[:resultLoc]}/#{resultImageName}" excludeArea = params[:excludeArea].gsub(/\s+/, '').split(",").map { |e| e.to_i } res = Imatcher.compare(imgFullPathGolden, imgFullPathResult, exclude_rect: excludeArea) r = res.match? unless r hasDifferences = true #save the result image imagesGoldenRunReportFullPath = "#{differencesPath}/#{imageName}" res.difference_image.save(imagesGoldenRunReportFullPath) #html report htmlImages += "<h2>#{imageName}</h2><img src='../#{imagesGoldenRunReportFullPath}' style='height:50%;' onclick='window.open(this.src)'>" end end #html report goldenRunReport.gsub!("<htmlImages>", hasDifferences ? htmlImages : "<h3>No differences found<h3>") File.open("#{differencesFolder}/report.html", "w") { |file| file.write(goldenRunReport) } if hasDifferences && params[:failWhenDiffs] UI.("Error: ".red + "Some differences found".red) raise Exception end end |