choctop 0.9.5 → 0.9.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt CHANGED
@@ -1,3 +1,11 @@
1
+ == 0.9.6 2009-02-10
2
+
3
+ * Custom Applications Icons!!!
4
+ * New config option: s.application_icon = "xxx.png"
5
+ * New config option: s.icon_text_size = 12
6
+ * rake dmg NO_BUILD=1 will skip the build step
7
+ * The background image no longer appears in the "real time" design of the DMG as its in .background folder
8
+
1
9
  == 0.9.5 2009-02-03
2
10
 
3
11
  * Fixed whitespace in project names bug
data/Manifest.txt CHANGED
@@ -42,14 +42,14 @@ features/fixtures/SampleApp/SampleApp.xcodeproj/TemplateIcon.icns
42
42
  features/fixtures/SampleApp/SampleApp.xcodeproj/project.pbxproj
43
43
  features/fixtures/SampleApp/SampleApp_Prefix.pch
44
44
  features/fixtures/SampleApp/main.m
45
- features/fixtures/design/background.jpg
46
- features/fixtures/design/ds_store
45
+ features/fixtures/custom_assets/appicon.icns
47
46
  features/initial_generator.feature
48
47
  features/rake_tasks.feature
49
48
  features/sparkle_feed.feature
50
49
  features/steps/common.rb
51
50
  features/steps/dmg_steps.rb
52
51
  features/steps/env.rb
52
+ features/steps/file_attribute_steps.rb
53
53
  features/steps/generator.rb
54
54
  features/steps/remote.rb
55
55
  features/steps/xcode_steps.rb
data/README.rdoc CHANGED
@@ -106,7 +106,7 @@ its set to Debug for development) and then Build. The "rake appcast" task should
106
106
 
107
107
  == SPONSORED BY:
108
108
 
109
- http//mocra.com - Mocra - the premier Rails/iPhone consultancy
109
+ http://mocra.com - Mocra - the premier Rails/iPhone consultancy
110
110
 
111
111
  == LICENSE:
112
112
 
@@ -14,4 +14,5 @@ ChocTop.new do |s|
14
14
  # s.app_icon_position = [100, 90]
15
15
  # s.applications_icon_position = [400, 90]
16
16
  # s.volume_icon = "dmg.icns"
17
+ # s.applications_icon = "appicon.icns" # or "appicon.png"
17
18
  end
data/features/dmg.feature CHANGED
@@ -10,8 +10,8 @@ Feature: Can build a customised DMG image from application build
10
10
  When dmg 'appcast/build/SampleApp-0.1.0.dmg' is mounted as 'SampleApp'
11
11
  Then folder 'SampleApp.app' in mounted volume is created
12
12
  And file 'Applications' in mounted volume is created
13
- And file 'background.jpg' in mounted volume is created
14
- And file 'background.jpg' in mounted volume is invisible
13
+ And file '.background/background.jpg' in mounted volume is created
14
+ And file '.background/background.jpg' in mounted volume is invisible
15
15
  And file '.VolumeIcon.icns' in mounted volume is created
16
16
 
17
17
  Scenario: Build a DMG with a whitespace name
@@ -21,6 +21,19 @@ Feature: Can build a customised DMG image from application build
21
21
  When dmg 'appcast/build/App With Whitespace-1.0.dmg' is mounted as 'App With Whitespace'
22
22
  Then folder 'App With Whitespace.app' in mounted volume is created
23
23
  And file 'Applications' in mounted volume is created
24
- And file 'background.jpg' in mounted volume is created
25
- And file 'background.jpg' in mounted volume is invisible
24
+ And file '.background/background.jpg' in mounted volume is created
25
+ And file '.background/background.jpg' in mounted volume is invisible
26
26
  And file '.VolumeIcon.icns' in mounted volume is created
27
+
28
+ Scenario: Build a DMG with custom Applications symlink icon
29
+ Given a Cocoa app with choctop installed called 'SampleApp'
30
+ And is configured for custom Applications icon
31
+ When task 'rake dmg' is invoked
32
+ And dmg 'appcast/build/SampleApp-0.1.0.dmg' is mounted as 'SampleApp'
33
+ Then file 'Applications' in mounted volume is created
34
+ And file 'Applications' in mounted volume has GetFileInfo type '"fdrp"'
35
+ And file 'Applications' in mounted volume has GetFileInfo alias '1'
36
+ And file 'Applications' in mounted volume has GetFileInfo custom icon '1'
37
+ And file 'Applications' in mounted volume is aliased to '/Applications'
38
+
39
+
@@ -1,3 +1,13 @@
1
+ Given /is configured for custom Applications icon$/ do
2
+ appicon = File.expand_path(File.dirname(__FILE__) + "/../fixtures/custom_assets/appicon.icns")
3
+ in_project_folder do
4
+ append_to_file "Rakefile", <<-RUBY.gsub(/^ /, '')
5
+ $sparkle.applications_icon = "appicon.icns"
6
+ RUBY
7
+ FileUtils.cp(appicon, "appicon.icns")
8
+ end
9
+ end
10
+
1
11
  When /^dmg '(.*)' is mounted as '(.*)'$/ do |dmg, name|
2
12
  @stdout = File.expand_path(File.join(@tmp_root, "hdiutil.out"))
3
13
  in_project_folder do
@@ -29,3 +39,4 @@ Then /^file '(.*)' in mounted volume (is|is not) invisible$/ do |file, is|
29
39
  `GetFileInfo -aV '#{@volume_path}/#{file}'`.to_i.should_not == (is == 'is' ? 0 : 1)
30
40
  end
31
41
  end
42
+
@@ -0,0 +1,16 @@
1
+ Then /^file '(.*)' in mounted volume has GetFileInfo (.*) '(.*)'/ do |file, file_info_type, value|
2
+ flags = case file_info_type.to_sym
3
+ when :type; "-t"
4
+ when :alias; "-aa"
5
+ when :"custom icon"; "-ac"
6
+ end
7
+ in_mounted_volume do
8
+ `GetFileInfo #{flags} '#{file}'`.strip.should == value
9
+ end
10
+ end
11
+
12
+ Then /^file '(.*)' in mounted volume is aliased to '(.*)'/ do |file, target|
13
+ in_mounted_volume do
14
+ puts "TODO - how to get applescript to test this?"
15
+ end
16
+ end
data/lib/choctop.rb CHANGED
@@ -10,7 +10,7 @@ require "active_support"
10
10
  require "RedCloth"
11
11
 
12
12
  class ChocTop
13
- VERSION = '0.9.5'
13
+ VERSION = '0.9.6'
14
14
 
15
15
  # The name of the Cocoa application
16
16
  # Default: info_plist['CFBundleExecutable'] or project folder name if "${EXECUTABLE_NAME}"
@@ -110,10 +110,23 @@ class ChocTop
110
110
  # To get default, boring blank DMG volume icon, set value to +nil+
111
111
  attr_accessor :volume_icon
112
112
 
113
+ # Custom icon for the Applications symlink icon
114
+ # Default: none
115
+ attr_accessor :applications_icon
116
+
113
117
  # Size of icons, in pixels, within custom DMG (between 16 and 128)
114
118
  # Default: 104 - this is nice and big
115
119
  attr_accessor :icon_size
116
120
 
121
+ # Icon text size
122
+ # Can pass integer (12) or string ("12" or "12 px")
123
+ # Default: 12 (px)
124
+ attr_reader :icon_text_size
125
+
126
+ def icon_text_size=(size)
127
+ @icon_text_size = size.to_i
128
+ end
129
+
117
130
  # The url for the remote package, without the protocol + host
118
131
  # e.g. if absolute url is http://mydomain.com/downloads/MyApp-1.0.dmg
119
132
  # then pkg_relative_url is /downloads/MyApp-1.0.dmg
@@ -144,6 +157,7 @@ class ChocTop
144
157
  @applications_icon_position = [347, 270]
145
158
  @volume_icon = File.dirname(__FILE__) + "/../assets/DefaultVolumeIcon.icns"
146
159
  @icon_size = 104
160
+ @icon_text_size = 12
147
161
 
148
162
  yield self if block_given?
149
163
 
@@ -1,6 +1,10 @@
1
1
  module ChocTop::Appcast
2
2
  def make_build
3
- sh "xcodebuild -configuration Release"
3
+ if ENV['NO_BUILD']
4
+ puts "Skipping build task..."
5
+ else
6
+ sh "xcodebuild -configuration Release"
7
+ end
4
8
  end
5
9
 
6
10
  def make_appcast
data/lib/choctop/dmg.rb CHANGED
@@ -6,20 +6,15 @@ module ChocTop::Dmg
6
6
  sh "hdiutil create -format UDRW -quiet -volname '#{name}' -srcfolder 'build/Release/#{target}' '#{pkg}'"
7
7
  sh "hdiutil attach '#{pkg}' -mountpoint '#{volume_path}' -noautoopen -quiet"
8
8
  sh "bless --folder '#{volume_path}' --openfolder '#{volume_path}'"
9
- sh "ln -s /Applications '#{volume_path}/Applications'"
10
9
  sh "sleep 1"
11
- if volume_icon
12
- FileUtils.cp(volume_icon, "#{volume_path}/.VolumeIcon.icns")
13
- sh "SetFile -a C '#{volume_path}'"
14
- end
15
- target_background = "#{volume_path}/#{volume_background}"
16
- FileUtils.cp(background_file, target_background) if background_file
10
+
11
+ configure_volume_icon
12
+ configure_applications_icon
17
13
  configure_dmg_window
18
- sh "SetFile -a V '#{target_background}'" if background_file
19
14
  end
20
15
 
21
16
  def volume_background
22
- "background#{File.extname(background_file)}"
17
+ ".background/background#{File.extname(background_file)}"
23
18
  end
24
19
 
25
20
  def window_position
@@ -37,49 +32,66 @@ module ChocTop::Dmg
37
32
  [background.first, background.last + statusbar_height]
38
33
  end
39
34
 
40
- def statusbar_height
41
- 20
42
- end
35
+ def statusbar_height; 20; end
43
36
 
37
+ def configure_volume_icon
38
+ if volume_icon
39
+ FileUtils.cp(volume_icon, "#{volume_path}/.VolumeIcon.icns")
40
+ sh "SetFile -a C '#{volume_path}'"
41
+ end
42
+ end
43
+
44
44
  def configure_dmg_window
45
- applescript = <<-SCRIPT
46
- tell application "Finder"
47
- set mountpoint to POSIX file ("#{volume_path}" as string) as alias
48
- tell folder mountpoint
49
- open
50
- tell container window
51
- set toolbar visible to false
52
- set statusbar visible to false -- doesn't do anything at DMG open time
53
- set current view to icon view
54
- delay 1 -- Sync
55
- set the bounds to {#{window_bounds.join(", ")}}
56
- end tell
57
- delay 1 -- Sync
58
- set icon size of the icon view options of container window to #{icon_size}
59
- set arrangement of the icon view options of container window to not arranged
60
- set position of item "#{target}" to {#{app_icon_position.join(", ")}}
61
- set position of item "Applications" to {#{applications_icon_position.join(", ")}}
62
- set the bounds of the container window to {#{window_bounds.join(", ")}}
63
- set background picture of the icon view options of container window to file "#{File.basename volume_background}"
64
- update without registering applications
65
- delay 5 -- Sync
66
- close
67
- end tell
68
- -- Sync
69
- delay 5
70
- end tell
71
- SCRIPT
72
- File.open(scriptfile = "/tmp/choctop-script", "w") do |f|
73
- f << applescript
45
+ if background_file
46
+ target_background = "#{volume_path}/#{volume_background}"
47
+ FileUtils.mkdir_p(File.dirname(target_background))
48
+ FileUtils.cp(background_file, target_background)
74
49
  end
75
- sh("osascript #{scriptfile}") do |ok, res|
76
- if ! ok
77
- p res
78
- puts volume_path
79
- exit 1
80
- end
50
+ run_applescript <<-SCRIPT.gsub(/^ /, '')
51
+ tell application "Finder"
52
+ set mountpoint to POSIX file ("#{volume_path}" as string) as alias
53
+ tell folder mountpoint
54
+ open
55
+ tell container window
56
+ set toolbar visible to false
57
+ set statusbar visible to false -- doesn't do anything at DMG open time
58
+ set current view to icon view
59
+ delay 1 -- Sync
60
+ set the bounds to {#{window_bounds.join(", ")}}
61
+ end tell
62
+ delay 1 -- Sync
63
+ set icon size of the icon view options of container window to #{icon_size}
64
+ set text size of the icon view options of container window to #{icon_text_size}
65
+ set arrangement of the icon view options of container window to not arranged
66
+ set position of item "#{target}" to {#{app_icon_position.join(", ")}}
67
+ set position of item "Applications" to {#{applications_icon_position.join(", ")}}
68
+ set the bounds of the container window to {#{window_bounds.join(", ")}}
69
+ set background picture of the icon view options of container window to file "#{volume_background.gsub(/\//,':')}"
70
+ update without registering applications
71
+ delay 5 -- Sync
72
+ close
73
+ end tell
74
+ -- Sync
75
+ delay 5
76
+ end tell
77
+ SCRIPT
78
+ sh "SetFile -a V '#{target_background}'" if background_file
79
+ end
80
+
81
+ def configure_applications_icon
82
+ run_applescript <<-SCRIPT.gsub(/^ /, ''), "apps_icon_script"
83
+ tell application "Finder"
84
+ set dest to disk "#{name}"
85
+ set src to folder "Applications" of startup disk
86
+ make new alias at dest to src
87
+ end tell
88
+ SCRIPT
89
+ if applications_icon
90
+ applications_path = "#{volume_path}/Applications"
91
+ OSX::NSApplicationLoad()
92
+ image = OSX::NSImage.alloc.initWithContentsOfFile(applications_icon)
93
+ OSX::NSWorkspace.sharedWorkspace.setIcon_forFile_options(image, applications_path, nil)
81
94
  end
82
- applescript
83
95
  end
84
96
 
85
97
  def detach_dmg
@@ -107,6 +119,20 @@ module ChocTop::Dmg
107
119
  # hdiutil flatten $@
108
120
 
109
121
  end
122
+
123
+ def run_applescript(applescript, tmp_file = "choctop-script")
124
+ File.open(scriptfile = "/tmp/#{tmp_file}", "w") do |f|
125
+ f << applescript
126
+ end
127
+ sh("osascript #{scriptfile}") do |ok, res|
128
+ if ! ok
129
+ p res
130
+ puts volume_path
131
+ exit 1
132
+ end
133
+ end
134
+ applescript
135
+ end
110
136
  end
111
137
  ChocTop.send(:include, ChocTop::Dmg)
112
138
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: choctop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5
4
+ version: 0.9.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dr Nic Williams
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-02-03 00:00:00 +10:00
13
+ date: 2009-02-10 00:00:00 +10:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -120,14 +120,14 @@ files:
120
120
  - features/fixtures/SampleApp/SampleApp.xcodeproj/project.pbxproj
121
121
  - features/fixtures/SampleApp/SampleApp_Prefix.pch
122
122
  - features/fixtures/SampleApp/main.m
123
- - features/fixtures/design/background.jpg
124
- - features/fixtures/design/ds_store
123
+ - features/fixtures/custom_assets/appicon.icns
125
124
  - features/initial_generator.feature
126
125
  - features/rake_tasks.feature
127
126
  - features/sparkle_feed.feature
128
127
  - features/steps/common.rb
129
128
  - features/steps/dmg_steps.rb
130
129
  - features/steps/env.rb
130
+ - features/steps/file_attribute_steps.rb
131
131
  - features/steps/generator.rb
132
132
  - features/steps/remote.rb
133
133
  - features/steps/xcode_steps.rb
Binary file