Class: ChocTop::Configuration

Inherits:
Object
  • Object
show all
Includes:
Appcast, Dmg, RakeTasks
Defined in:
lib/choctop.rb

Constant Summary collapse

VERSION =
'0.13.1'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RakeTasks

#define_tasks

Methods included from Dmg

#add_eula, #add_file_to_dmg_src_folder, #add_link_to_dmg_src_folder, #background_bounds, #configure_applications_icon, #configure_dmg_window, #configure_volume_icon, #convert_dmg_readonly, #copy_files, #detach_dmg, #include_applications_icon?, #make_dmg, #prepare_files, #run_applescript, #set_position_of_files, #set_position_of_shortcuts, #statusbar_height, #tmp_dmg_src_folder, #volume_background, #window_bounds, #window_position

Methods included from Appcast

#dsa_signature, #make_appcast, #make_build, #make_dmg_symlink, #make_index_redirect, #make_release_notes, #private_key, #release_notes_content, #release_notes_html, #skip_xcode_build, #upload_appcast

Constructor Details

#initialize {|_self| ... } ⇒ Configuration

Returns a new instance of Configuration.

Yields:

  • (_self)

Yield Parameters:



301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
# File 'lib/choctop.rb', line 301

def initialize
  $choctop = $sparkle = self # define a global variable for this object ($sparkle is legacy)

  yield self if block_given?

  # Defaults
  @name ||= info_plist['CFBundleExecutable'] || File.basename(File.expand_path("."))
  @name = File.basename(File.expand_path(".")) if @name == '${EXECUTABLE_NAME}'
  @version ||= info_plist['CFBundleVersion']
  @build_type = ENV['BUILD_TYPE'] || 'Release'

  if base_url
    @host ||= URI.parse(base_url).host
  end

  @release_notes ||= 'release_notes.html'
  @readme        ||= 'README.txt'
  @release_notes_template ||= "release_notes_template.html.erb"
  @rsync_args ||= '-aCv --progress'

  @background_file ||= File.dirname(__FILE__) + "/../assets/sky_background.jpg"
  @app_icon_position ||= [175, 65]
  @applications_icon_position ||= [347, 270]
  @volume_icon ||= File.dirname(__FILE__) + "/../assets/DefaultVolumeIcon.icns"
  @icon_size ||= 104
  @icon_text_size ||= 12

  add_file :target_bundle, :position => app_icon_position

  define_tasks
end

Instance Attribute Details

#app_icon_positionObject

x, y position of this project’s icon on the custom DMG Default: a useful position for the icon against the default background



201
202
203
# File 'lib/choctop.rb', line 201

def app_icon_position
  @app_icon_position
end

#appcast_filenameObject



123
124
125
# File 'lib/choctop.rb', line 123

def appcast_filename
  @appcast_filename ||= su_feed_url ? File.basename(su_feed_url) : 'my_feed.xml'
end

#applications_iconObject

Custom icon for the Applications symlink icon Default: none



214
215
216
# File 'lib/choctop.rb', line 214

def applications_icon
  @applications_icon
end

#applications_icon_positionObject

x, y position of the Applications symlink icon on the custom DMG Default: a useful position for the icon against the default background



205
206
207
# File 'lib/choctop.rb', line 205

def applications_icon_position
  @applications_icon_position
end

#background_fileObject

Path to background .icns image file for custom DMG Value should be file path relative to root of project Default: a choctop supplied background image that matches to default app_icon_position + applications_icon_position To have no custom background, set value to nil



197
198
199
# File 'lib/choctop.rb', line 197

def background_file
  @background_file
end

#base_urlObject



90
91
92
93
94
95
96
# File 'lib/choctop.rb', line 90

def base_url
  if su_feed_url
    @base_url ||= File.dirname(su_feed_url)
  else
    @base_url
  end
end

#build_optsObject



24
25
26
# File 'lib/choctop.rb', line 24

def build_opts
  @build_opts ||= ''
end

#build_productsObject

Returns the value of attribute build_products.



144
145
146
# File 'lib/choctop.rb', line 144

def build_products
  @build_products
end

#build_targetObject

The name of the target in Xcode, such as MacRuby’s Compile or Embed. Uses the application name by default.



59
60
61
# File 'lib/choctop.rb', line 59

def build_target
  @build_target
end

#build_typeObject

The build type of the distributed DMG file Default: Release



70
71
72
# File 'lib/choctop.rb', line 70

def build_type
  @build_type
end

#dmg_src_folderObject

Folder from where all files will be copied into the DMG Files are copied here if specified with add_file before DMG creation



151
152
153
# File 'lib/choctop.rb', line 151

def dmg_src_folder
  @dmg_src_folder
end

#filesObject

List of files/bundles to be packaged into the DMG



107
108
109
# File 'lib/choctop.rb', line 107

def files
  @files
end

#hostObject

The host name, e.g. some-domain.com Default: host from base_url



81
82
83
# File 'lib/choctop.rb', line 81

def host
  @host
end

#icon_sizeObject

Size of icons, in pixels, within custom DMG (between 16 and 128) Default: 104 - this is nice and big



218
219
220
# File 'lib/choctop.rb', line 218

def icon_size
  @icon_size
end

#icon_text_sizeObject

Icon text size Can pass integer (12) or string (“12” or “12 px”) Default: 12 (px)



223
224
225
# File 'lib/choctop.rb', line 223

def icon_text_size
  @icon_text_size
end

#nameObject

The name of the Cocoa application Default: info_plist or project folder name if “$EXECUTABLE_NAME”



43
44
45
# File 'lib/choctop.rb', line 43

def name
  @name
end

#readmeObject

The file name for the project readme file Default: README.txt



104
105
106
# File 'lib/choctop.rb', line 104

def readme
  @readme
end

#release_notesObject

The file name for generated release notes for the latest release Default: release_notes.html



100
101
102
# File 'lib/choctop.rb', line 100

def release_notes
  @release_notes
end

#release_notes_templateObject

The path for an HTML template into which the release_notes.txt are inserted after conversion to HTML

The template file is an ERb template, with <%= yield %> as the placeholder for the generated release notes.

Currently, any CSS or JavaScript must be inline

Default: release_notes_template.html.erb, which was generated by install_choctop into each project



118
119
120
# File 'lib/choctop.rb', line 118

def release_notes_template
  @release_notes_template
end

#remote_dirObject

The remote directory where the xml + dmg files will be uploaded



128
129
130
# File 'lib/choctop.rb', line 128

def remote_dir
  @remote_dir
end

#rsync_argsObject

The argument flags passed to rsync Default: -aCv



138
139
140
# File 'lib/choctop.rb', line 138

def rsync_args
  @rsync_args
end

#scp_argsObject

Additional arguments to pass to scp e.g. -P 11222



142
143
144
# File 'lib/choctop.rb', line 142

def scp_args
  @scp_args
end

#su_feed_urlObject



75
76
77
# File 'lib/choctop.rb', line 75

def su_feed_url
  @su_feed_url ||= info_plist['SUFeedURL']
end

#targetObject

The target name of the distributed DMG file Default: ##name.app



51
52
53
# File 'lib/choctop.rb', line 51

def target
  @target
end

#transportObject

Defines the transport to use for upload, default is :rsync, :scp is also available



131
132
133
# File 'lib/choctop.rb', line 131

def transport
  @transport
end

#userObject

The user to log in on the remote server. Default: empty



85
86
87
# File 'lib/choctop.rb', line 85

def user
  @user
end

#versionObject

The version of the Cocoa application Default: info_plist



47
48
49
# File 'lib/choctop.rb', line 47

def version
  @version
end

#volume_iconObject

Path to an .icns file for the DMG’s volume icon (looks like a disk or drive) Default: a DMG icon provided within choctop To get default, boring blank DMG volume icon, set value to nil



210
211
212
# File 'lib/choctop.rb', line 210

def volume_icon
  @volume_icon
end

Instance Method Details

#build_pathObject

Path to built DMG, sparkle’s xml file and other assets to be uploaded to remote server



174
175
176
# File 'lib/choctop.rb', line 174

def build_path
  "appcast/build"
end

#file(*args, &block) ⇒ Object Also known as: add_file

Add an explicit file/bundle/folder into the DMG Examples:

file 'build/Release/SampleApp.app', :position => [50, 100]
file :target_bundle, :position => [50, 100]
file proc { 'README.txt' }, :position => [50, 100]
file :position => [50, 100] { 'README.txt' }

Required option:

+:position+ - two item array [x, y] window position

Options:

+:name+    - override the name of the project when mounted in the DMG
+:exclude+ - do not include files/folders


255
256
257
258
259
260
# File 'lib/choctop.rb', line 255

def file(*args, &block)
  path_or_helper, options = args.first.is_a?(Hash) ? [block, args.first] : [args.first, args.last]
  throw "add_files #{path_or_helper}, :position => [x,y] option is missing" unless options[:position]
  self.files ||= {}
  files[path_or_helper] = options
end

#info_plistObject



240
241
242
# File 'lib/choctop.rb', line 240

def info_plist
  @info_plist ||= OSX::NSDictionary.dictionaryWithContentsOfFile(info_plist_path) || {}
end

#info_plist_nameObject

Name of the Info.plist file Default: “Info.plist”



36
37
38
# File 'lib/choctop.rb', line 36

def info_plist_name
  @info_plist_name ||= 'Info.plist'
end

#info_plist_pathObject

Path to the Info.plist Default: project directory



30
31
32
# File 'lib/choctop.rb', line 30

def info_plist_path
  @info_plist_path ||= File.expand_path(info_plist_name)
end

Add the whole project as a mounted item; e.g. a TextMate bundle Examples:

add_link "http://github.com/drnic/choctop", :name => 'Github', :position => [50, 100]
add_link "http://github.com/drnic/choctop", 'Github.webloc', :position => [50, 100]

Required option:

+:position+ - two item array [x, y] window position
+:name+    - override the name of the project when mounted in the DMG


287
288
289
290
291
292
293
294
295
296
297
298
# File 'lib/choctop.rb', line 287

def link(url, *options)
  name = options.first if options.first.is_a?(String)
  options = options.last || {}
  options[:url] = url
  options[:name] = name if name
  throw "add_link :position => [x,y] option is missing" unless options[:position]
  throw "add_link :name => 'Name' option is missing" unless options[:name]
  options[:name].gsub!(/(\.webloc|\.url)$/, '')
  options[:name] += ".webloc"
  self.files ||= {}
  files[options[:name]] = options
end

#mountpointObject



178
179
180
181
# File 'lib/choctop.rb', line 178

def mountpoint
  # @mountpoint ||= "/tmp/build/mountpoint#{rand(10000000)}"
  @mountpoint ||= "/Volumes"
end

#pkgObject

Path to generated package DMG



169
170
171
# File 'lib/choctop.rb', line 169

def pkg
  "#{build_path}/#{pkg_name}"
end

#pkg_nameObject

Generated filename for a distribution, from name, version and .dmg e.g. MyApp-1.0.0.dmg



158
159
160
# File 'lib/choctop.rb', line 158

def pkg_name
  version ? "#{name}-#{version}.dmg" : versionless_pkg_name
end

#pkg_relative_urlObject

The url for the remote package, without the protocol + host e.g. if absolute url is mydomain.com/downloads/MyApp-1.0.dmg then pkg_relative_url is /downloads/MyApp-1.0.dmg



232
233
234
235
236
237
238
# File 'lib/choctop.rb', line 232

def pkg_relative_url
  unless base_url
    raise "The base url should be set in order to create a sparkle feed. Set the SUFeedURL in your Info.plist."
  end
  _base_url = base_url.gsub(%r{/$}, '')
  "#{_base_url}/#{pkg_name}".gsub(%r{^.*#{host}}, '')
end

#root(options) ⇒ Object Also known as: add_root

Add the whole project as a mounted item; e.g. a TextMate bundle Examples:

root :position => [50, 100]
add_root :position => [50, 100], :name => 'My Thing'

Required option:

+:position+ - two item array [x, y] window position

Options:

+:name+    - override the name of the project when mounted in the DMG
+:exclude+ - do not include files/folders


272
273
274
275
276
277
# File 'lib/choctop.rb', line 272

def root(options)
  throw "add_root :position => [x,y] option is missing" unless options[:position]
  options[:name] ||= File.basename(File.expand_path("."))
  self.files ||= {}
  files['.'] = options
end

#target_bundleObject



64
65
66
# File 'lib/choctop.rb', line 64

def target_bundle
  @target_bundle ||= Dir["#{build_products}/#{name}.*"].first
end

#versionless_pkg_nameObject

Version-less generated filename for a distribution, from name and .dmg e.g. MyApp.dmg



164
165
166
# File 'lib/choctop.rb', line 164

def versionless_pkg_name
  "#{name}.dmg"
end

#volume_pathObject

Path to Volume when DMG is mounted



184
185
186
# File 'lib/choctop.rb', line 184

def volume_path
  "#{mountpoint}/#{name}"
end