Class: ChocTop
- Inherits:
-
Object
- Object
- ChocTop
- Defined in:
- lib/choctop.rb
Defined Under Namespace
Constant Summary collapse
- VERSION =
'0.11.0'
Instance Attribute Summary collapse
-
#app_icon_position ⇒ Object
x, y position of this project’s icon on the custom DMG Default: a useful position for the icon against the default background.
-
#appcast_filename ⇒ Object
The name of the local xml file containing the Sparkle item details Default: info_plist or linker_appcast.xml.
-
#applications_icon ⇒ Object
Custom icon for the Applications symlink icon Default: none.
-
#applications_icon_position ⇒ Object
x, y position of the Applications symlink icon on the custom DMG Default: a useful position for the icon against the default background.
-
#background_file ⇒ Object
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. -
#base_url ⇒ Object
The url from where the xml + dmg files will be downloaded Default: dir path from appcast_filename.
-
#build_opts ⇒ Object
Returns the value of attribute build_opts.
-
#build_products ⇒ Object
Returns the value of attribute build_products.
-
#build_type ⇒ Object
The build type of the distributed DMG file Default: Release.
-
#codesign_identity ⇒ Object
Returns the value of attribute codesign_identity.
-
#files ⇒ Object
List of files/bundles to be packaged into the DMG.
-
#generate_index_php ⇒ Object
goddamn nuisance.
-
#host ⇒ Object
The host name, e.g.
-
#icon_size ⇒ Object
Size of icons, in pixels, within custom DMG (between 16 and 128) Default: 104 - this is nice and big.
-
#icon_text_size ⇒ Object
Icon text size Can pass integer (12) or string (“12” or “12 px”) Default: 12 (px).
-
#info_plist_path ⇒ Object
Path to the Info.plist Default: “Info.plist”.
-
#name ⇒ Object
The name of the Cocoa application Default: info_plist or project folder name if “$EXECUTABLE_NAME”.
-
#readme ⇒ Object
The file name for the project readme file Default: README.txt.
-
#release_notes ⇒ Object
The file name for generated release notes for the latest release Default: release_notes.html.
-
#release_notes_template ⇒ Object
The path for an HTML template into which the release_notes.txt are inserted after conversion to HTML.
-
#remote_dir ⇒ Object
The remote directory where the xml + dmg files will be uploaded.
-
#rsync_args ⇒ Object
The argument flags passed to rsync Default: -aCv.
-
#scp_args ⇒ Object
Additional arguments to pass to scp e.g.
-
#src_folder ⇒ Object
Folder from where all files will be copied into the DMG Files are copied here if specified with
add_filebefore DMG creation. -
#su_feed_url ⇒ Object
The Sparkle feed URL Default: info_plist.
-
#target ⇒ Object
The target name of the distributed DMG file Default: ##name.app.
-
#transport ⇒ Object
Defines the transport to use for upload, default is :rsync, :scp is also available.
-
#user ⇒ Object
The user to log in on the remote server.
-
#version ⇒ Object
The version of the Cocoa application Default: info_plist.
-
#volume_icon ⇒ Object
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.
Instance Method Summary collapse
-
#build_path ⇒ Object
Path to built DMG, sparkle’s xml file and other assets to be uploaded to remote server.
- #define_tasks ⇒ Object
-
#file(*args, &block) ⇒ Object
(also: #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. - #info_plist ⇒ Object
-
#initialize {|_self| ... } ⇒ ChocTop
constructor
A new instance of ChocTop.
- #mountpoint ⇒ Object
-
#pkg ⇒ Object
Path to generated package DMG.
-
#pkg_name ⇒ Object
Generated filename for a distribution, from name, version and .dmg e.g.
-
#pkg_relative_url ⇒ Object
The url for the remote package, without the protocol + host e.g.
- #target_bundle ⇒ Object
-
#versionless_pkg_name ⇒ Object
Version-less generated filename for a distribution, from name and .dmg e.g.
-
#volume_path ⇒ Object
Path to Volume when DMG is mounted.
Constructor Details
#initialize {|_self| ... } ⇒ ChocTop
Returns a new instance of ChocTop.
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
# File 'lib/choctop.rb', line 231 def initialize $choctop = $sparkle = self # define a global variable for this object ($sparkle is legacy) yield self if block_given? # Defaults @info_plist_path ||= 'Info.plist' @name ||= info_plist['CFBundleExecutable'] || File.basename(File.(".")) @name = File.basename(File.(".")) if @name == '${EXECUTABLE_NAME}' @version ||= info_plist['CFBundleVersion'] @build_type = ENV['BUILD_TYPE'] || 'Release' if @su_feed_url = info_plist['SUFeedURL'] @appcast_filename ||= File.basename(su_feed_url) @base_url ||= File.dirname(su_feed_url) end 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_position ⇒ Object
x, y position of this project’s icon on the custom DMG Default: a useful position for the icon against the default background
170 171 172 |
# File 'lib/choctop.rb', line 170 def app_icon_position @app_icon_position end |
#appcast_filename ⇒ Object
The name of the local xml file containing the Sparkle item details Default: info_plist or linker_appcast.xml
88 89 90 |
# File 'lib/choctop.rb', line 88 def appcast_filename @appcast_filename end |
#applications_icon ⇒ Object
Custom icon for the Applications symlink icon Default: none
183 184 185 |
# File 'lib/choctop.rb', line 183 def applications_icon @applications_icon end |
#applications_icon_position ⇒ Object
x, y position of the Applications symlink icon on the custom DMG Default: a useful position for the icon against the default background
174 175 176 |
# File 'lib/choctop.rb', line 174 def applications_icon_position @applications_icon_position end |
#background_file ⇒ Object
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
166 167 168 |
# File 'lib/choctop.rb', line 166 def background_file @background_file end |
#base_url ⇒ Object
The url from where the xml + dmg files will be downloaded Default: dir path from appcast_filename
62 63 64 |
# File 'lib/choctop.rb', line 62 def base_url @base_url end |
#build_opts ⇒ Object
Returns the value of attribute build_opts.
16 17 18 |
# File 'lib/choctop.rb', line 16 def build_opts @build_opts end |
#build_products ⇒ Object
Returns the value of attribute build_products.
113 114 115 |
# File 'lib/choctop.rb', line 113 def build_products @build_products end |
#build_type ⇒ Object
The build type of the distributed DMG file Default: Release
46 47 48 |
# File 'lib/choctop.rb', line 46 def build_type @build_type end |
#codesign_identity ⇒ Object
Returns the value of attribute codesign_identity.
198 199 200 |
# File 'lib/choctop.rb', line 198 def codesign_identity @codesign_identity end |
#files ⇒ Object
List of files/bundles to be packaged into the DMG
73 74 75 |
# File 'lib/choctop.rb', line 73 def files @files end |
#generate_index_php ⇒ Object
goddamn nuisance
94 95 96 |
# File 'lib/choctop.rb', line 94 def generate_index_php @generate_index_php end |
#host ⇒ Object
The host name, e.g. some-domain.com Default: host from base_url
54 55 56 |
# File 'lib/choctop.rb', line 54 def host @host end |
#icon_size ⇒ Object
Size of icons, in pixels, within custom DMG (between 16 and 128) Default: 104 - this is nice and big
187 188 189 |
# File 'lib/choctop.rb', line 187 def icon_size @icon_size end |
#icon_text_size ⇒ Object
Icon text size Can pass integer (12) or string (“12” or “12 px”) Default: 12 (px)
192 193 194 |
# File 'lib/choctop.rb', line 192 def icon_text_size @icon_text_size end |
#info_plist_path ⇒ Object
Path to the Info.plist Default: “Info.plist”
23 24 25 |
# File 'lib/choctop.rb', line 23 def info_plist_path @info_plist_path end |
#name ⇒ Object
The name of the Cocoa application Default: info_plist or project folder name if “$EXECUTABLE_NAME”
27 28 29 |
# File 'lib/choctop.rb', line 27 def name @name end |
#readme ⇒ Object
The file name for the project readme file Default: README.txt
70 71 72 |
# File 'lib/choctop.rb', line 70 def readme @readme end |
#release_notes ⇒ Object
The file name for generated release notes for the latest release Default: release_notes.html
66 67 68 |
# File 'lib/choctop.rb', line 66 def release_notes @release_notes end |
#release_notes_template ⇒ Object
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
84 85 86 |
# File 'lib/choctop.rb', line 84 def release_notes_template @release_notes_template end |
#remote_dir ⇒ Object
The remote directory where the xml + dmg files will be uploaded
91 92 93 |
# File 'lib/choctop.rb', line 91 def remote_dir @remote_dir end |
#rsync_args ⇒ Object
The argument flags passed to rsync Default: -aCv
107 108 109 |
# File 'lib/choctop.rb', line 107 def rsync_args @rsync_args end |
#scp_args ⇒ Object
Additional arguments to pass to scp e.g. -P 11222
111 112 113 |
# File 'lib/choctop.rb', line 111 def scp_args @scp_args end |
#src_folder ⇒ Object
Folder from where all files will be copied into the DMG Files are copied here if specified with add_file before DMG creation
120 121 122 |
# File 'lib/choctop.rb', line 120 def src_folder @src_folder end |
#su_feed_url ⇒ Object
The Sparkle feed URL Default: info_plist
50 51 52 |
# File 'lib/choctop.rb', line 50 def su_feed_url @su_feed_url end |
#target ⇒ Object
The target name of the distributed DMG file Default: ##name.app
35 36 37 |
# File 'lib/choctop.rb', line 35 def target @target end |
#transport ⇒ Object
Defines the transport to use for upload, default is :rsync, :scp is also available
100 101 102 |
# File 'lib/choctop.rb', line 100 def transport @transport end |
#user ⇒ Object
The user to log in on the remote server. Default: empty
58 59 60 |
# File 'lib/choctop.rb', line 58 def user @user end |
#version ⇒ Object
The version of the Cocoa application Default: info_plist
31 32 33 |
# File 'lib/choctop.rb', line 31 def version @version end |
#volume_icon ⇒ Object
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
179 180 181 |
# File 'lib/choctop.rb', line 179 def volume_icon @volume_icon end |
Instance Method Details
#build_path ⇒ Object
Path to built DMG, sparkle’s xml file and other assets to be uploaded to remote server
143 144 145 |
# File 'lib/choctop.rb', line 143 def build_path "appcast/build" end |
#define_tasks ⇒ Object
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
# File 'lib/choctop.rb', line 267 def define_tasks return unless Object.const_defined?("Rake") desc "Build Xcode #{build_type}" task :build => "build/#{build_type}/#{target}/Contents/Info.plist" task "build/#{build_type}/#{target}/Contents/Info.plist" do make_build end desc "Create the dmg file for appcasting" task :dmg => :build do detach_dmg make_dmg detach_dmg convert_dmg_readonly add_eula end desc "Create/update the appcast file" task :feed do make_appcast make_dmg_symlink make_index_redirect if generate_index_php == true make_release_notes end desc "Upload the appcast file to the host" task :upload => :feed do upload_appcast end task :detach_dmg do detach_dmg end task :size do puts configure_dmg_window end 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
223 224 225 226 227 228 |
# File 'lib/choctop.rb', line 223 def file(*args, &block) path_or_helper, = 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 [:position] self.files ||= {} files[path_or_helper] = end |
#info_plist ⇒ Object
211 212 213 |
# File 'lib/choctop.rb', line 211 def info_plist @info_plist ||= OSX::NSDictionary.dictionaryWithContentsOfFile(File.(info_plist_path)) || {} end |
#mountpoint ⇒ Object
147 148 149 150 |
# File 'lib/choctop.rb', line 147 def mountpoint # @mountpoint ||= "/tmp/build/mountpoint#{rand(10000000)}" @mountpoint ||= "/Volumes" end |
#pkg ⇒ Object
Path to generated package DMG
138 139 140 |
# File 'lib/choctop.rb', line 138 def pkg "#{build_path}/#{pkg_name}" end |
#pkg_name ⇒ Object
Generated filename for a distribution, from name, version and .dmg e.g. MyApp-1.0.0.dmg
127 128 129 |
# File 'lib/choctop.rb', line 127 def pkg_name version ? "#{name}-#{version}.dmg" : versionless_pkg_name end |
#pkg_relative_url ⇒ Object
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
206 207 208 209 |
# File 'lib/choctop.rb', line 206 def pkg_relative_url _base_url = base_url.gsub(%r{/$}, '') "#{_base_url}/#{pkg_name}".gsub(%r{^.*#{host}}, '') end |
#target_bundle ⇒ Object
40 41 42 |
# File 'lib/choctop.rb', line 40 def target_bundle @target_bundle ||= Dir["#{build_products}/#{name}.*"].first end |
#versionless_pkg_name ⇒ Object
Version-less generated filename for a distribution, from name and .dmg e.g. MyApp.dmg
133 134 135 |
# File 'lib/choctop.rb', line 133 def versionless_pkg_name "#{name}.dmg" end |
#volume_path ⇒ Object
Path to Volume when DMG is mounted
153 154 155 |
# File 'lib/choctop.rb', line 153 def volume_path "#{mountpoint}/#{name}" end |