Class: Snapshot::Update

Inherits:
Object
  • Object
show all
Defined in:
lib/snapshot/update.rb

Overview

Migrate helper files

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find_helperArray

Returns A list of helper files (usually just one).

Returns:

  • (Array)

    A list of helper files (usually just one)



5
6
7
# File 'lib/snapshot/update.rb', line 5

def self.find_helper
  Dir["./**/SnapshotHelper.swift"]
end

Instance Method Details

#updateObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/snapshot/update.rb', line 9

def update
  gem_path = Helper.gem_path("snapshot")
  paths = self.class.find_helper

  Helper.log.info "Found the following SnapshotHelper:"
  puts ''
  paths.each { |p| Helper.log.info "\t#{p}" }
  puts ''
  Helper.log.info "Are you sure you want to automatically update the helpers listed above?"
  Helper.log.info "This will overwrite all its content with the latest code."
  Helper.log.info "The underlying API will not change. You can always migrate manually by looking at"
  Helper.log.info "https://github.com/fastlane/snapshot/blob/master/lib/assets/SnapshotHelper.swift"

  return 1 unless agree("Overwrite configuration files? (y/n)".red, true)

  paths.each do |path|
    Helper.log.info "Updating '#{path}'..."
    File.write(path, File.read("#{gem_path}/lib/assets/SnapshotHelper.swift"))
  end

  Helper.log.info "Successfully updated helper files".green
end