Class: Fastlane::Helper::CreateDmgHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/create_dmg/helper/create_dmg_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params: nil) ⇒ CreateDmgHelper

Returns a new instance of CreateDmgHelper.



8
9
10
11
12
13
14
15
16
# File 'lib/fastlane/plugin/create_dmg/helper/create_dmg_helper.rb', line 8

def initialize(params: nil)
  self.params = params
  self.verbose = self.params[:verbose] == true
  self.source = File.expand_path(self.params[:source])
  self.source_basename = File.basename(self.source)
  self.source_basename_no_extension = File.basename(self.source, File.extname(self.source))
  output_filename = self.params[:output_filename] || "#{File.dirname(self.source)}/#{self.source_basename_no_extension}.dmg"
  self.output_filename = File.expand_path(output_filename)
end

Instance Attribute Details

#output_filenameObject

Returns the value of attribute output_filename.



6
7
8
# File 'lib/fastlane/plugin/create_dmg/helper/create_dmg_helper.rb', line 6

def output_filename
  @output_filename
end

#sourceObject

Returns the value of attribute source.



6
7
8
# File 'lib/fastlane/plugin/create_dmg/helper/create_dmg_helper.rb', line 6

def source
  @source
end

#source_basenameObject

Returns the value of attribute source_basename.



6
7
8
# File 'lib/fastlane/plugin/create_dmg/helper/create_dmg_helper.rb', line 6

def source_basename
  @source_basename
end

#verboseObject

Returns the value of attribute verbose.



6
7
8
# File 'lib/fastlane/plugin/create_dmg/helper/create_dmg_helper.rb', line 6

def verbose
  @verbose
end

Instance Method Details

#create_dmg_parametersObject

rubocop:disable Metrics/PerceivedComplexity



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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/fastlane/plugin/create_dmg/helper/create_dmg_helper.rb', line 19

def create_dmg_parameters
  volume_name = self.params[:volume_name] || self.source_basename_no_extension
  addiional_files = self.params[:addiional_files] || []

  self.verbose = self.params[:verbose] == true

  if params[:hdiutil_sandbox_safe]
    ## TODO: Warnings about turned off but used options
  end

  parameters = {
    '--volname'         => volume_name,
    '--volicon'         => self.params[:volume_icon],
    '--format'          => self.params[:volume_format],
    '--disk-image-size' => self.params[:volume_size],

    '--window-pos'      => self.params[:window_position],
    '--window_size'     => self.params[:window_size],

    '--background'      => self.params[:background],
    '--text-size'       => self.params[:text_size],
    '--icon-size'       => self.params[:icon_size],

    '--app-drop-link'   => self.params[:applications_folder_position],
    '--ql-drop-link'    => self.params[:quick_look_folder_position],

    '--eula'            => self.params[:eula_filename]
  }

  if self.params[:source_icon_position]
    parameters['--icon'] = "#{self.source_basename} #{self.params[:source_icon_position]}"
  end

  if self.params[:hide_source_extension]
    parameters['--hide-extension'] = self.source_basename
  end

  create_dmg_parameters = []
  parameters.each do |key, value|
    if value
      create_dmg_parameters << key.to_s
      create_dmg_parameters << value.to_s
    end
  end

  addiional_files.each do |additional_file|
    create_dmg_parameters << '--file'
    create_dmg_parameters << additional_file
  end

  create_dmg_parameters << '--hdiutil-verbose'     if self.params[:hdiutil_verbose]
  create_dmg_parameters << '--hdiutil-quiet'       if self.params[:hdiutil_quiet]
  create_dmg_parameters << '--sandbox-safe'        if self.params[:hdiutil_sandbox_safe]

  create_dmg_parameters << '--no-internet-enable' # `internet-enable` is not supported any more.

  create_dmg_parameters << self.output_filename

  return create_dmg_parameters
end