Class: Frameit::TemplateFinder
- Inherits:
-
Object
- Object
- Frameit::TemplateFinder
- Defined in:
- lib/frameit/template_finder.rb
Overview
Responsible for finding the correct device
Class Method Summary collapse
-
.get_template(screenshot) ⇒ Object
This will detect the screen size and choose the correct template.
Class Method Details
.get_template(screenshot) ⇒ Object
This will detect the screen size and choose the correct template
5 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 |
# File 'lib/frameit/template_finder.rb', line 5 def self.get_template(screenshot) return nil if screenshot.mac? filename = "Apple #{screenshot.device_name} #{screenshot.color}" templates = Dir["#{FrameDownloader.templates_path}/#{filename}.{png,jpg}"] # ~/.frameit folder UI.verbose "Looking for #{filename} and found #{templates.count} template(s)" if templates.count == 0 if screenshot.screen_size == Deliver::AppScreenshot::ScreenSize::IOS_35 UI.important "Unfortunately 3.5\" device frames were discontinued. Skipping screen '#{screenshot.path}'" UI.error "Looked for: '#{filename}.png'" elsif screenshot.color == Frameit::Color::ROSE_GOLD || screenshot.color == Frameit::Color::GOLD # Unfortunately not every device type is available in rose gold or gold # This is why we can't have nice things #yatusabes # fallback to a white iPhone, which looks similar UI.important("Unfortunatey device type '#{screenshot.device_name}' is not available in #{screenshot.color}, falling back to silver...") screenshot.color = Frameit::Color::SILVER return self.get_template(screenshot) else UI.error("Couldn't find template for screenshot type '#{filename}'") UI.error("Please run `frameit download_frames` to download the latest frames") end return filename if Helper.test? return nil else return templates.first.tr(" ", "\ ") end end |