Class: PodPrebuild::Output

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-binary-cache/prebuild_output/output.rb

Instance Method Summary collapse

Constructor Details

#initialize(prebuild_sandbox) ⇒ Output

Returns a new instance of Output.



6
7
8
# File 'lib/cocoapods-binary-cache/prebuild_output/output.rb', line 6

def initialize(prebuild_sandbox)
  @sandbox = prebuild_sandbox
end

Instance Method Details

#clean_delta_fileObject



18
19
20
21
# File 'lib/cocoapods-binary-cache/prebuild_output/output.rb', line 18

def clean_delta_file
  Pod::UI.message "Clean delta file: #{prebuild_delta_path}"
  FileUtils.rm_rf(prebuild_delta_path)
end

#create_dir_if_needed(dir) ⇒ Object



23
24
25
# File 'lib/cocoapods-binary-cache/prebuild_output/output.rb', line 23

def create_dir_if_needed(dir)
  FileUtils.mkdir_p dir unless File.directory?(dir)
end

#delta_dirObject



14
15
16
# File 'lib/cocoapods-binary-cache/prebuild_output/output.rb', line 14

def delta_dir
  @delta_dir ||= File.dirname(prebuild_delta_path)
end

#prebuild_delta_pathObject



10
11
12
# File 'lib/cocoapods-binary-cache/prebuild_output/output.rb', line 10

def prebuild_delta_path
  @prebuild_delta_path ||= PodPrebuild.config.prebuild_delta_path
end

#write_delta_file(options) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/cocoapods-binary-cache/prebuild_output/output.rb', line 27

def write_delta_file(options)
  updated = options[:updated]
  deleted = options[:deleted]

  if updated.empty? && deleted.empty?
    Pod::UI.puts "No changes in prebuild"
    return
  end

  Pod::UI.message "Write prebuild changes to: #{prebuild_delta_path}"
  create_dir_if_needed(delta_dir)
  changes = PodPrebuild::JSONFile.new(prebuild_delta_path)
  changes["updated"] = updated
  changes["deleted"] = deleted
  changes.save!
end