6
7
8
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
|
# File 'lib/snapshot/reports_generator.rb', line 6
def generate
config = SnapshotConfig.shared_instance
screens_path = config.screenshots_path
@title = config.html_title
@data = {}
Dir["#{screens_path}/*"].sort.each do |language_path|
language = File.basename(language_path)
Dir[File.join(language_path, '*')].sort.each do |screenshot|
["portrait", "landscape"].each do |orientation|
available_devices.each do |key_name, output_name|
if File.basename(screenshot).include?key_name and File.basename(screenshot).include?orientation
output_name += " (#{orientation.capitalize})"
@data[language] ||= {}
@data[language][output_name] ||= []
resulting_path = File.join('.', language, File.basename(screenshot))
@data[language][output_name] << resulting_path
break end
end
end
end
end
html_path = File.join(lib_path, "snapshot/page.html.erb")
html = ERB.new(File.read(html_path)).result(binding)
export_path = "#{screens_path}/screenshots.html"
File.write(export_path, html)
export_path = File.expand_path(export_path)
Helper.log.info "Successfully created HTML file with an overview of all the screenshots: '#{export_path}'".green
system("open '#{export_path}'") unless ENV["SNAPSHOT_SKIP_OPEN_SUMMARY"]
end
|