Class: Screengrab::Setup

Inherits:
Object
  • Object
show all
Defined in:
screengrab/lib/screengrab/setup.rb

Class Method Summary collapse

Class Method Details

.create(path, is_swift_fastfile: false) ⇒ Object

This method will take care of creating a screengrabfile and other necessary files



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'screengrab/lib/screengrab/setup.rb', line 6

def self.create(path, is_swift_fastfile: false)
  if is_swift_fastfile
    template_location = "#{Screengrab::ROOT}/lib/assets/ScreengrabfileTemplate.swift"
    screengrabfile_path = File.join(path, 'Screengrabfile.swift')
  else
    template_location = "#{Screengrab::ROOT}/lib/assets/ScreengrabfileTemplate"
    screengrabfile_path = File.join(path, 'Screengrabfile')
  end

  if File.exist?(screengrabfile_path)
    UI.user_error!("Screengrabfile already exists at path '#{screengrabfile_path}'. Run 'screengrab' to use screengrab.")
  end

  File.write(screengrabfile_path, File.read(template_location))

  UI.success("Successfully created new Screengrabfile at '#{screengrabfile_path}'")
end