choctop 0.13.0 → 0.13.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -196,10 +196,10 @@ module Bundler
196
196
  {:loaded_from=>"/Users/drnic/.bundle/ruby/1.8/specifications/rubigen-1.5.5.gemspec", :name=>"rubigen", :load_paths=>["/Users/drnic/.bundle/ruby/1.8/gems/rubigen-1.5.5/lib"]},
197
197
  {:loaded_from=>"/Library/Ruby/Gems/1.8/specifications/syntax-1.0.0.gemspec", :name=>"syntax", :load_paths=>["/Library/Ruby/Gems/1.8/gems/syntax-1.0.0/lib"]},
198
198
  {:loaded_from=>"/Library/Ruby/Gems/1.8/specifications/newgem-1.5.3.gemspec", :name=>"newgem", :load_paths=>["/Library/Ruby/Gems/1.8/gems/newgem-1.5.3/lib"]},
199
- {:loaded_from=>"/Users/drnic/.bundle/ruby/1.8/specifications/rspec-core-2.0.0.beta.15.gemspec", :name=>"rspec-core", :load_paths=>["/Users/drnic/.bundle/ruby/1.8/gems/rspec-core-2.0.0.beta.15/lib"]},
200
- {:loaded_from=>"/Users/drnic/.bundle/ruby/1.8/specifications/rspec-expectations-2.0.0.beta.15.gemspec", :name=>"rspec-expectations", :load_paths=>["/Users/drnic/.bundle/ruby/1.8/gems/rspec-expectations-2.0.0.beta.15/lib"]},
201
- {:loaded_from=>"/Users/drnic/.bundle/ruby/1.8/specifications/rspec-mocks-2.0.0.beta.15.gemspec", :name=>"rspec-mocks", :load_paths=>["/Users/drnic/.bundle/ruby/1.8/gems/rspec-mocks-2.0.0.beta.15/lib"]},
202
- {:loaded_from=>"/Users/drnic/.bundle/ruby/1.8/specifications/rspec-2.0.0.beta.15.gemspec", :name=>"rspec", :load_paths=>["/Users/drnic/.bundle/ruby/1.8/gems/rspec-2.0.0.beta.15/lib"]},
199
+ {:loaded_from=>"/Library/Ruby/Gems/1.8/specifications/rspec-core-2.0.0.beta.16.gemspec", :name=>"rspec-core", :load_paths=>["/Library/Ruby/Gems/1.8/gems/rspec-core-2.0.0.beta.16/lib"]},
200
+ {:loaded_from=>"/Library/Ruby/Gems/1.8/specifications/rspec-expectations-2.0.0.beta.16.gemspec", :name=>"rspec-expectations", :load_paths=>["/Library/Ruby/Gems/1.8/gems/rspec-expectations-2.0.0.beta.16/lib"]},
201
+ {:loaded_from=>"/Library/Ruby/Gems/1.8/specifications/rspec-mocks-2.0.0.beta.16.gemspec", :name=>"rspec-mocks", :load_paths=>["/Library/Ruby/Gems/1.8/gems/rspec-mocks-2.0.0.beta.16/lib"]},
202
+ {:loaded_from=>"/Library/Ruby/Gems/1.8/specifications/rspec-2.0.0.beta.16.gemspec", :name=>"rspec", :load_paths=>["/Library/Ruby/Gems/1.8/gems/rspec-2.0.0.beta.16/lib"]},
203
203
  ].map do |hash|
204
204
  if hash[:virtual_spec]
205
205
  spec = eval(hash[:virtual_spec], TOPLEVEL_BINDING, "<virtual spec for '#{hash[:name]}'>")
@@ -76,13 +76,13 @@ specs:
76
76
  - newgem:
77
77
  version: 1.5.3
78
78
  - rspec-core:
79
- version: 2.0.0.beta.15
79
+ version: 2.0.0.beta.16
80
80
  - rspec-expectations:
81
- version: 2.0.0.beta.15
81
+ version: 2.0.0.beta.16
82
82
  - rspec-mocks:
83
- version: 2.0.0.beta.15
83
+ version: 2.0.0.beta.16
84
84
  - rspec:
85
- version: 2.0.0.beta.15
85
+ version: 2.0.0.beta.16
86
86
  hash: 2fa03535b60734ba6b435e984c1a4f65377fddae
87
87
  sources:
88
88
  - Rubygems:
@@ -1,3 +1,7 @@
1
+ == 0.13.1 2010-07-07
2
+
3
+ * Can add URL .webloc files into DMG via #add_link/#link helper
4
+
1
5
  == 0.13.0 2010-07-06
2
6
 
3
7
  * Can now package up entire project (such as a TextMate bundle) as an item (#root or #add_root helper)
@@ -76,6 +76,10 @@ to the end:
76
76
  s.file proc { 'README.txt' }, :position => [50, 100]
77
77
  s.file :position => [50, 100] { 'README.txt' }
78
78
 
79
+ # Link to external URLs
80
+ s.add_link 'http://github.com/drnic/choctop', 'Choctop', :position => [50, 100]
81
+ s.link 'http://github.com/drnic/choctop', :name => 'Choctop', :position => [50, 100]
82
+
79
83
  # Even add the entire project (like a TextMate bundle)
80
84
  s.root :position => [100, 100]
81
85
  s.add_root :position => [100, 100]
@@ -48,5 +48,14 @@ Feature: Can build a customised DMG image from application build
48
48
  And file "MyBundle.tmbundle" in mounted volume is created
49
49
  And file "Applications" in mounted volume is not created
50
50
 
51
+ Scenario: Build a DMG with a URL webloc file
52
+ Given a TextMate bundle project "MyBundle.tmbundle"
53
+ And I want a link "GitHub.webloc" to "http://github.com/drnic/choctop" in the DMG
54
+ When I invoke task "rake dmg"
55
+ And dmg "appcast/build/MyBundle.tmbundle.dmg" is mounted as "MyBundle.tmbundle"
56
+ And file "MyBundle.tmbundle" in mounted volume is created
57
+ And file "Applications" in mounted volume is not created
58
+ And webloc file "GitHub.webloc" links to "http://github.com/drnic/choctop"
59
+
51
60
 
52
61
 
@@ -44,3 +44,13 @@ Then /^file "(.*)" in mounted volume (is|is not) invisible$/ do |file, is|
44
44
  end
45
45
  end
46
46
 
47
+ When /^webloc file "([^"]*)" links to "([^"]*)"$/ do |name, url|
48
+ in_mounted_volume do
49
+ File.exists?(name).should be_true
50
+
51
+ `cp '#{name}' /tmp/link.plist`
52
+ webloc_url = `defaults read /tmp/link URL`.strip
53
+ webloc_url.should == url
54
+ end
55
+ end
56
+
@@ -63,3 +63,8 @@ Given /^a TextMate bundle project "([^"]*)"$/ do |name|
63
63
  choctop_add_root
64
64
  end
65
65
 
66
+ Given /^I want a link "([^"]*)" to "([^"]*)" in the DMG$/ do |name, url|
67
+ choctop_add_link name, url
68
+ end
69
+
70
+
@@ -5,10 +5,16 @@ module DmgHelper
5
5
  end
6
6
  end
7
7
 
8
- def choctop_add_root(position = [347, 65])
8
+ def choctop_add_root(position = [180, 65])
9
9
  in_project_folder do
10
10
  append_to_file "Rakefile", "$choctop.add_root :position=> #{position.inspect}"
11
11
  end
12
12
  end
13
+
14
+ def choctop_add_link(name, url, position = [347, 272])
15
+ in_project_folder do
16
+ append_to_file "Rakefile", "$choctop.add_link #{url.inspect}, :name => #{name.inspect}, :position=> #{position.inspect}"
17
+ end
18
+ end
13
19
  end
14
20
  World(DmgHelper)
@@ -18,7 +18,7 @@ module ChocTop
18
18
  include Dmg
19
19
  include RakeTasks
20
20
 
21
- VERSION = '0.13.0'
21
+ VERSION = '0.13.1'
22
22
 
23
23
  attr_writer :build_opts
24
24
  def build_opts
@@ -276,6 +276,27 @@ module ChocTop
276
276
  files['.'] = options
277
277
  end
278
278
  alias_method :add_root, :root
279
+
280
+ # Add the whole project as a mounted item; e.g. a TextMate bundle
281
+ # Examples:
282
+ # add_link "http://github.com/drnic/choctop", :name => 'Github', :position => [50, 100]
283
+ # add_link "http://github.com/drnic/choctop", 'Github.webloc', :position => [50, 100]
284
+ # Required option:
285
+ # +:position+ - two item array [x, y] window position
286
+ # +:name+ - override the name of the project when mounted in the DMG
287
+ def link(url, *options)
288
+ name = options.first if options.first.is_a?(String)
289
+ options = options.last || {}
290
+ options[:url] = url
291
+ options[:name] = name if name
292
+ throw "add_link :position => [x,y] option is missing" unless options[:position]
293
+ throw "add_link :name => 'Name' option is missing" unless options[:name]
294
+ options[:name].gsub!(/(\.webloc|\.url)$/, '')
295
+ options[:name] += ".webloc"
296
+ self.files ||= {}
297
+ files[options[:name]] = options
298
+ end
299
+ alias_method :add_link, :link
279
300
 
280
301
  def initialize
281
302
  $choctop = $sparkle = self # define a global variable for this object ($sparkle is legacy)
@@ -309,4 +330,4 @@ module ChocTop
309
330
  define_tasks
310
331
  end
311
332
  end
312
- end
333
+ end
@@ -15,21 +15,23 @@ module ChocTop
15
15
  files[path] = options
16
16
  options[:name] ||= File.basename(path)
17
17
  end
18
+ if path =~ %r{\.webloc$}
19
+ files[path] = options
20
+ options[:name] ||= File.basename(path)
21
+ options[:link] = true
22
+ end
18
23
  files
19
24
  end
20
25
  end
21
26
 
22
27
  # Two-phase copy: first to a tmp folder (to prevent recursion); then tmp folder to +dmg_src_folder+
23
28
  def copy_files
24
- require 'tmpdir'
25
- tmp_dmg_src_folder = File.join(Dir.tmpdir, Time.now.to_i.to_s) # probably unique folder
26
29
  FileUtils.mkdir_p(tmp_dmg_src_folder)
27
30
  files.each do |path, options|
28
- target = File.join(tmp_dmg_src_folder, options[:name])
29
- sh ::Escape.shell_command(['cp', '-r', path, target])
30
- if options[:exclude]
31
- exclude_list = options[:exclude].is_a?(Array) ? options[:exclude] : [options[:exclude].to_s]
32
- exclude_list.each { |exclude| sh ::Escape.shell_command(['rm', '-rf', File.join(target, exclude)]) }
31
+ if options[:link]
32
+ add_link_to_dmg_src_folder(path, options)
33
+ else
34
+ add_file_to_dmg_src_folder(path, options)
33
35
  end
34
36
  end
35
37
  FileUtils.rm_r(dmg_src_folder) if File.exists? dmg_src_folder
@@ -188,7 +190,25 @@ module ChocTop
188
190
  # hdiutil flatten $@
189
191
 
190
192
  end
193
+
194
+ def add_file_to_dmg_src_folder(path, options)
195
+ target = File.join(tmp_dmg_src_folder, options[:name])
196
+ sh ::Escape.shell_command(['cp', '-r', path, target])
197
+ if options[:exclude]
198
+ exclude_list = options[:exclude].is_a?(Array) ? options[:exclude] : [options[:exclude].to_s]
199
+ exclude_list.each { |exclude| sh ::Escape.shell_command(['rm', '-rf', File.join(target, exclude)]) }
200
+ end
201
+ end
191
202
 
203
+ def add_link_to_dmg_src_folder(path, options)
204
+ plist_name = options[:name].gsub(/\.webloc$/, '')
205
+ plist_target = File.join(tmp_dmg_src_folder, plist_name)
206
+ target = File.join(tmp_dmg_src_folder, options[:name])
207
+ sh ::Escape.shell_command(['defaults', 'write', plist_target, 'URL', options[:url]])
208
+ sh ::Escape.shell_command(['plutil', '-convert', 'xml1', '-o', target, "#{plist_target}.plist"])
209
+ sh ::Escape.shell_command(['rm', "#{plist_target}.plist"])
210
+ end
211
+
192
212
  def run_applescript(applescript, tmp_file = "choctop-script")
193
213
  File.open(scriptfile = "/tmp/#{tmp_file}", "w") do |f|
194
214
  f << applescript
@@ -202,5 +222,12 @@ module ChocTop
202
222
  end
203
223
  applescript
204
224
  end
225
+
226
+ def tmp_dmg_src_folder
227
+ @tmp_dmg_src_folder ||= begin
228
+ require 'tmpdir'
229
+ File.join(Dir.tmpdir, Time.now.to_i.to_s) # probably unique folder
230
+ end
231
+ end
205
232
  end
206
- end
233
+ end
@@ -14,7 +14,7 @@ describe ChocTop::Dmg do
14
14
  FileUtils.chdir(@project_path) do
15
15
  @choctop.file :readme, :position=>[175, 65]
16
16
  @choctop.prepare_files
17
- @choctop.files['README.txt'].should == {:position=>[175, 65]}
17
+ @choctop.files['README.txt'].should == {:position=>[175, 65], :name => 'README.txt'}
18
18
  end
19
19
  end
20
20
 
@@ -22,7 +22,7 @@ describe ChocTop::Dmg do
22
22
  FileUtils.chdir(@project_path) do
23
23
  @choctop.file proc { 'README.txt' }, :position=>[175, 65]
24
24
  @choctop.prepare_files
25
- @choctop.files['README.txt'].should == {:position=>[175, 65]}
25
+ @choctop.files['README.txt'].should == {:position=>[175, 65], :name => 'README.txt'}
26
26
  end
27
27
  end
28
28
 
@@ -30,7 +30,29 @@ describe ChocTop::Dmg do
30
30
  FileUtils.chdir(@project_path) do
31
31
  @choctop.file(:position => [175, 65]) { 'README.txt' }
32
32
  @choctop.prepare_files
33
- @choctop.files['README.txt'].should == {:position=>[175, 65]}
33
+ @choctop.files['README.txt'].should == {:position=>[175, 65], :name => 'README.txt'}
34
+ end
35
+ end
36
+ end
37
+
38
+ context "#link" do
39
+ it "should take args: .link(url, name, :position => [x,y])" do
40
+ FileUtils.chdir(@project_path) do
41
+ @choctop.link('http://github.com', 'Fork me', :position => [175, 65])
42
+ @choctop.prepare_files
43
+ @choctop.files['Fork me.webloc'].should == {
44
+ :position=>[175, 65], :url => 'http://github.com', :name => 'Fork me.webloc', :link => true
45
+ }
46
+ end
47
+ end
48
+
49
+ it "should take args: .link(url, :name => 'Name.webloc', :position => [x,y])" do
50
+ FileUtils.chdir(@project_path) do
51
+ @choctop.link('http://github.com', :name => 'Fork me.webloc', :position => [175, 65])
52
+ @choctop.prepare_files
53
+ @choctop.files['Fork me.webloc'].should == {
54
+ :position=>[175, 65], :url => 'http://github.com', :name => 'Fork me.webloc', :link => true
55
+ }
34
56
  end
35
57
  end
36
58
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: choctop
3
3
  version: !ruby/object:Gem::Version
4
- hash: 43
4
+ hash: 41
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 13
9
- - 0
10
- version: 0.13.0
9
+ - 1
10
+ version: 0.13.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dr Nic Williams
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-07-06 00:00:00 +10:00
20
+ date: 2010-07-07 00:00:00 +10:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency