rake_dmg 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.rdoc +23 -0
- data/Manifest +9 -0
- data/README.rdoc +120 -0
- data/Rakefile +27 -0
- data/lib/rake/dmg.rb +164 -0
- data/rake_dmg.gemspec +103 -0
- data/spec/dmg_spec.rb +210 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +48 -0
- metadata +106 -0
data/LICENSE.rdoc
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
= LICENSE
|
2
|
+
|
3
|
+
(The MIT License)
|
4
|
+
|
5
|
+
Copyright (c) 2008, 2009 Emanuele Vicentini
|
6
|
+
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
of this software and associated documentation files (the 'Software'), to deal
|
9
|
+
in the Software without restriction, including without limitation the rights
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
12
|
+
furnished to do so, subject to the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
15
|
+
copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23
|
+
SOFTWARE.
|
data/Manifest
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
= Rake DMG library
|
2
|
+
|
3
|
+
DmgTask is a Rake library which aims to ease the building of DMG files for
|
4
|
+
projects, applications and whatever you throw at it.
|
5
|
+
|
6
|
+
== Basic usage
|
7
|
+
|
8
|
+
Firse, install it with:
|
9
|
+
|
10
|
+
$ sudo gem install rake_dmg
|
11
|
+
|
12
|
+
Then, write something like the following code in a Rakefile:
|
13
|
+
|
14
|
+
require 'rake/dmg'
|
15
|
+
|
16
|
+
Rake::DmgTask.new 'pimpernel', '0.1.2' do |dmg|
|
17
|
+
dmg.source_files.include 'build/**/*'
|
18
|
+
dmg.source_files.exclude 'pkg'
|
19
|
+
dmg.strip = 'build'
|
20
|
+
dmg.extra_source_files = {'resources/ds_store' => '/.DS_Store',
|
21
|
+
'resources/background.png' => '/.background/background.png',
|
22
|
+
'doc/quickstart.pdf' => 'guide.pdf'}
|
23
|
+
end
|
24
|
+
|
25
|
+
You can:
|
26
|
+
|
27
|
+
* specify name and optional version string for the DMG file;
|
28
|
+
* specify files to be included using Rake's really flexible FileList;
|
29
|
+
* specify extra files to be added to the final DMG file.
|
30
|
+
|
31
|
+
The last point means you are able to customize the DMG adding documentation,
|
32
|
+
licence file, background images, etc.
|
33
|
+
|
34
|
+
== Motivations
|
35
|
+
|
36
|
+
Building a DMG is rather simple and every library/framework probably has some
|
37
|
+
mechanism to automate the process. For example, RubyCocoa projects and
|
38
|
+
Rucola-based projects (and HotCocoa ones, maybe?) provides Rake tasks like the
|
39
|
+
following ones:
|
40
|
+
|
41
|
+
# RubyCocoa
|
42
|
+
desc "Package the application"
|
43
|
+
task :package => ["xcode:build:#{DEFAULT_TARGET}:#{RELEASE_CONFIGURATION}", "pkg"] do
|
44
|
+
name = "#{APPNAME}.#{APPVERSION}"
|
45
|
+
mkdir "image"
|
46
|
+
sh %{rubycocoa standaloneify "build/#{DEFAULT_CONFIGURATION}/#{APPNAME}.app" "image/#{APPNAME}.app"}
|
47
|
+
puts 'Creating Image...'
|
48
|
+
sh %{
|
49
|
+
hdiutil create -volname '#{name}' -srcfolder image '#{name}'.dmg
|
50
|
+
rm -rf image
|
51
|
+
mv '#{name}.dmg' pkg
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
# Rucola
|
56
|
+
desc "Package the application as a disk image"
|
57
|
+
task :package => :pkg do
|
58
|
+
FileUtils.rm(PKG) if File.exist?(PKG)
|
59
|
+
puts 'Creating Image...'
|
60
|
+
sh "hdiutil create -volname '#{DEPLOY_NAME}' -srcfolder 'build/Release/#{TARGET}' '#{PKG}'"
|
61
|
+
puts ''
|
62
|
+
end
|
63
|
+
|
64
|
+
Both works flowlessly but you cannot customize the final DMG file. Using Rake
|
65
|
+
0.8.2 or later and this library we can change the situation:
|
66
|
+
|
67
|
+
# RubyCocoa
|
68
|
+
Rake::Task[:package].clear_actions
|
69
|
+
task :package => :dmg
|
70
|
+
Rake::DmgTask.new APPNAME, APPVERSION do |p|
|
71
|
+
p.source_files.include "build/#{DEFAULT_CONFIGURATION}/#{APPNAME}.app/**/*"
|
72
|
+
p.strip = "build/#{DEFAULT_CONFIGURATION}"
|
73
|
+
p.extra_source_files = {'extra/LICENCE.rtf' => 'LICENCE.rtf'}
|
74
|
+
end
|
75
|
+
|
76
|
+
# Rucola
|
77
|
+
Rake::Task['deploy:package'].clear_actions
|
78
|
+
namespace :deploy do
|
79
|
+
task :package => :dmg
|
80
|
+
Rake::DmgTask.new APPNAME, APPVERSION do |p|
|
81
|
+
p.source_files.include "build/Release/#{TARGET}/**/*"
|
82
|
+
p.strip = 'build/Release'
|
83
|
+
p.extra_source_files = {'extra/LICENCE.rtf' => 'LICENCE.rtf'}
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
== Some notes about basic DMG building
|
88
|
+
|
89
|
+
The simplest way to programmatically create the smallest DMG file is:
|
90
|
+
|
91
|
+
hdiutil create -srcdir <source directory> \
|
92
|
+
-volname <volume name> \
|
93
|
+
-uid 99 -gid 99 \
|
94
|
+
<image name>
|
95
|
+
|
96
|
+
This command create a zlib-compressed DMG file (UDZO format) using the same
|
97
|
+
filesystem of <em><source directory></em>, if possibile. The final image file
|
98
|
+
is the smallest one able to contain all the content of <em><source
|
99
|
+
directory></em>.
|
100
|
+
|
101
|
+
The user and group id values (99 and 99, respectively) map to the "magic"
|
102
|
+
+unknown+ user and group which, if I understand the system documentation
|
103
|
+
correctly, should be "replaced" at mount time by the disk arbitration with the
|
104
|
+
user who mount the DMG.
|
105
|
+
|
106
|
+
why the lucky stiff, author of Shoes, uses a rather complex, automatic build
|
107
|
+
system written in Ruby, based on Rake with a Perl script called
|
108
|
+
<tt>pkg-dmg</tt> which handles all the details of DMG creation; this wonderful
|
109
|
+
script is complex and makes provision for backward compatibility (which this
|
110
|
+
library does not). why uses it in the following way:
|
111
|
+
|
112
|
+
pkg-dmg --target pkg/#{PKG}.dmg --source dmg --volname '#{APPNAME}' \
|
113
|
+
--copy platform/mac/dmg_ds_store:/.DS_Store --mkdir /.background \
|
114
|
+
--copy static/shoes-dmg.jpg:/.background
|
115
|
+
|
116
|
+
Here the application to package is inside the +dmg+ directory. The first
|
117
|
+
<tt>--copy</tt> puts a handmade ds_store file into the directory used to build
|
118
|
+
the final DMG file; this seems to be the only way to customize DMG's look. The
|
119
|
+
last <tt>--copy</tt> puts the image used as background, referenced by the
|
120
|
+
custom ds_store file.
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'echoe'
|
3
|
+
require 'lib/rake/dmg'
|
4
|
+
|
5
|
+
Echoe.new('rake_dmg', Rake::DmgTask::VERSION) do |s|
|
6
|
+
s.author = 'Emanuele Vicentini'
|
7
|
+
s.email = 'emanuele.vicentini@gmail.com'
|
8
|
+
s.summary = 'Rake library to build DMG files'
|
9
|
+
s.runtime_dependencies = ['rake']
|
10
|
+
s.development_dependencies += ['rake >=0.8.2', 'rspec']
|
11
|
+
s.need_tar_gz = false
|
12
|
+
s.project = 'rakedmg'
|
13
|
+
s.gemspec_format = :yaml
|
14
|
+
s.retain_gemspec = true
|
15
|
+
s.rdoc_pattern = /^README|^LICENSE/
|
16
|
+
s.url = 'http://github.com/baldowl/rake_dmg'
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'spec/rake/spectask'
|
20
|
+
|
21
|
+
Spec::Rake::SpecTask.new do |t|
|
22
|
+
t.spec_opts = %w(-o spec/spec.opts)
|
23
|
+
end
|
24
|
+
|
25
|
+
Rake::Task[:default].clear
|
26
|
+
Rake::Task.tasks.each {|t| t.clear if t.name =~ /test/}
|
27
|
+
task :default => :spec
|
data/lib/rake/dmg.rb
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Define a DMG task library to automate the creation of disk images.
|
4
|
+
|
5
|
+
require 'rake'
|
6
|
+
|
7
|
+
module Rake
|
8
|
+
# Create a packaging task that will package the project into a distributable
|
9
|
+
# disk image.
|
10
|
+
#
|
11
|
+
# The DmgTask will create the following targets:
|
12
|
+
#
|
13
|
+
# [<b>:dmg</b>]
|
14
|
+
# Create the requested DMG file.
|
15
|
+
#
|
16
|
+
# [<b>:clobber_dmg</b>]
|
17
|
+
# Delete the disk image. Automatically added to the main clobber target.
|
18
|
+
#
|
19
|
+
# [<b>:rebuild_dmg</b>]
|
20
|
+
# Rebuild the disk image from scratch.
|
21
|
+
#
|
22
|
+
# Other tasks are created as prerequisites of the main ones and can safely
|
23
|
+
# be ignored.
|
24
|
+
#
|
25
|
+
# Most of the attributes/characteristics of the DmgTask object *must* be set
|
26
|
+
# upon creation via the optional block; altering them afterward has no
|
27
|
+
# effect.
|
28
|
+
#
|
29
|
+
# Example:
|
30
|
+
#
|
31
|
+
# Rake::DmgTask.new("pimpernel", :noversion) do |p|
|
32
|
+
# p.source_files.include("lib/**/*.rb")
|
33
|
+
# p.extra_source_files = {'resources/ds_store' => '/.DS_Store',
|
34
|
+
# 'resources/background.png' => '/.background/background.png'}
|
35
|
+
# end
|
36
|
+
#
|
37
|
+
class DmgTask
|
38
|
+
# This library's version number.
|
39
|
+
VERSION = '0.0.2'
|
40
|
+
|
41
|
+
# Name of the disk image (required).
|
42
|
+
attr_accessor :name
|
43
|
+
|
44
|
+
# Version of the DMG (required; use :noversion for unversioned disk images).
|
45
|
+
attr_accessor :version
|
46
|
+
|
47
|
+
# Directory used to store the disk image (default: 'pkg').
|
48
|
+
attr_accessor :package_dir
|
49
|
+
|
50
|
+
# List of files to be included in the DMG file (default: empty).
|
51
|
+
attr_accessor :source_files
|
52
|
+
|
53
|
+
# List of extra files to be included in the DMG file (default: empty).
|
54
|
+
# Each item is a couple key/value: key is the source, value is the target
|
55
|
+
# inside the DMG.
|
56
|
+
attr_accessor :extra_source_files
|
57
|
+
|
58
|
+
# System utility used to build the DMG file (default: hdiutil).
|
59
|
+
attr_accessor :dmg_command
|
60
|
+
|
61
|
+
# We have administration rights (default: false; this setting is checked
|
62
|
+
# only by the +dmg_options+ method).
|
63
|
+
attr_accessor :admin_rights
|
64
|
+
|
65
|
+
# DMG build options (default tailored to hdiutil; see +dmg_options+
|
66
|
+
# implementation). Assigning any value to this attribute temporarily
|
67
|
+
# switch off the default ones.
|
68
|
+
attr_writer :dmg_options
|
69
|
+
|
70
|
+
# Path prefix to strip from each file name in the final DMG file (default:
|
71
|
+
# nil).
|
72
|
+
attr_accessor :strip
|
73
|
+
|
74
|
+
# Create a Package Task with the given name and version.
|
75
|
+
def initialize(name=nil, version=nil)
|
76
|
+
@name = name
|
77
|
+
@version = version
|
78
|
+
@package_dir = 'pkg'
|
79
|
+
@source_files = Rake::FileList.new
|
80
|
+
@extra_source_files = {}
|
81
|
+
@dmg_command = 'hdiutil'
|
82
|
+
@admin_rights = false
|
83
|
+
@dmg_options = nil
|
84
|
+
@strip = nil
|
85
|
+
yield self if block_given?
|
86
|
+
define_tasks unless name.nil?
|
87
|
+
end
|
88
|
+
|
89
|
+
# Create the tasks defined by this task library.
|
90
|
+
def define_tasks
|
91
|
+
fail "Version required (or :noversion)" if @version.nil?
|
92
|
+
@version = nil if :noversion == @version
|
93
|
+
|
94
|
+
desc "Build the disk image file"
|
95
|
+
task :dmg => "#{package_dir}/#{dmg_file}"
|
96
|
+
|
97
|
+
file "#{package_dir}/#{dmg_file}" => dmg_dir_path do
|
98
|
+
chdir package_dir do
|
99
|
+
sh "#{dmg_command} create #{dmg_options}"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
directory package_dir
|
104
|
+
|
105
|
+
file dmg_dir_path => source_files + extra_source_files.keys do
|
106
|
+
prefix_to_strip = /^#{@strip}/ if @strip
|
107
|
+
mkdir_p package_dir rescue nil
|
108
|
+
source_files.each do |fn|
|
109
|
+
fn_stripped = @strip == nil ? fn : fn.sub(prefix_to_strip, '')
|
110
|
+
f = File.join(dmg_dir_path, fn_stripped)
|
111
|
+
fdir = File.dirname(f)
|
112
|
+
mkdir_p(fdir) if !File.exist?(fdir)
|
113
|
+
if File.directory?(fn)
|
114
|
+
mkdir_p(f)
|
115
|
+
else
|
116
|
+
rm_f f
|
117
|
+
safe_ln(fn, f)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
extra_source_files.each do |k, v|
|
121
|
+
f = File.join(dmg_dir_path, v)
|
122
|
+
mkdir_p(File.dirname(f)) rescue nil
|
123
|
+
rm_f f
|
124
|
+
safe_ln k, f
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
desc "Remove the disk image files"
|
129
|
+
task :clobber_dmg do
|
130
|
+
rm_r package_dir rescue nil
|
131
|
+
end
|
132
|
+
|
133
|
+
task :clobber => :clobber_dmg
|
134
|
+
|
135
|
+
desc "Force a rebuild of the disk image file"
|
136
|
+
task :rebuild_dmg => [:clobber_dmg, :dmg]
|
137
|
+
|
138
|
+
self
|
139
|
+
end
|
140
|
+
|
141
|
+
# DMG volume name.
|
142
|
+
def dmg_name
|
143
|
+
@version ? "#{@name}-#{@version}" : @name
|
144
|
+
end
|
145
|
+
|
146
|
+
# DMG file name.
|
147
|
+
def dmg_file
|
148
|
+
dmg_name + '.dmg'
|
149
|
+
end
|
150
|
+
|
151
|
+
# Build options for +dmg_command+, tailored to hdiutil.
|
152
|
+
def dmg_options
|
153
|
+
@dmg_options || "-srcdir #{dmg_name} -ov -volname #{name} " +
|
154
|
+
"#{admin_rights ? '-uid 99 -gid 99' : '' } " +
|
155
|
+
"#{dmg_file}"
|
156
|
+
end
|
157
|
+
|
158
|
+
# Temporary directory used to gather the DMG's content before actual
|
159
|
+
# building.
|
160
|
+
def dmg_dir_path
|
161
|
+
"#{package_dir}/#{dmg_name}"
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
data/rake_dmg.gemspec
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rake_dmg
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Emanuele Vicentini
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
|
11
|
+
date: 2009-01-05 00:00:00 +01:00
|
12
|
+
default_executable:
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
type: :runtime
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
23
|
+
version:
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: echoe
|
26
|
+
type: :development
|
27
|
+
version_requirement:
|
28
|
+
version_requirements: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: "0"
|
33
|
+
version:
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: rake
|
36
|
+
type: :development
|
37
|
+
version_requirement:
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 0.8.2
|
43
|
+
version:
|
44
|
+
- !ruby/object:Gem::Dependency
|
45
|
+
name: rspec
|
46
|
+
type: :development
|
47
|
+
version_requirement:
|
48
|
+
version_requirements: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: "0"
|
53
|
+
version:
|
54
|
+
description: Rake library to build DMG files
|
55
|
+
email: emanuele.vicentini@gmail.com
|
56
|
+
executables: []
|
57
|
+
|
58
|
+
extensions: []
|
59
|
+
|
60
|
+
extra_rdoc_files:
|
61
|
+
- LICENSE.rdoc
|
62
|
+
- README.rdoc
|
63
|
+
files:
|
64
|
+
- lib/rake/dmg.rb
|
65
|
+
- LICENSE.rdoc
|
66
|
+
- Manifest
|
67
|
+
- rake_dmg.gemspec
|
68
|
+
- Rakefile
|
69
|
+
- README.rdoc
|
70
|
+
- spec/dmg_spec.rb
|
71
|
+
- spec/spec.opts
|
72
|
+
- spec/spec_helper.rb
|
73
|
+
has_rdoc: true
|
74
|
+
homepage: http://github.com/baldowl/rake_dmg
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options:
|
77
|
+
- --line-numbers
|
78
|
+
- --inline-source
|
79
|
+
- --title
|
80
|
+
- Rake_dmg
|
81
|
+
- --main
|
82
|
+
- README.rdoc
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: "0"
|
90
|
+
version:
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: "1.2"
|
96
|
+
version:
|
97
|
+
requirements: []
|
98
|
+
|
99
|
+
rubyforge_project: rakedmg
|
100
|
+
rubygems_version: 1.3.1
|
101
|
+
specification_version: 2
|
102
|
+
summary: Rake library to build DMG files
|
103
|
+
test_files: []
|
data/spec/dmg_spec.rb
ADDED
@@ -0,0 +1,210 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "Rake::DmgTask" do
|
4
|
+
it "should build a DmgTask object" do
|
5
|
+
dmg = Rake::DmgTask.new 'pimpernel', '0.1'
|
6
|
+
dmg.should be_an_instance_of(Rake::DmgTask)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should build a DmgTask object with an optional block" do
|
10
|
+
dmg = Rake::DmgTask.new 'pimpernel', '0.1' do |b|
|
11
|
+
# nothing to do here.
|
12
|
+
end
|
13
|
+
dmg.should be_an_instance_of(Rake::DmgTask)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should require version" do
|
17
|
+
lambda {Rake::DmgTask.new 'pimpernel'}.should raise_error do |err|
|
18
|
+
err =~ /^Version required/
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should accept :noversion" do
|
23
|
+
lambda {Rake::DmgTask.new 'pimpernel', :noversion}.should_not raise_error
|
24
|
+
end
|
25
|
+
|
26
|
+
describe do
|
27
|
+
before do
|
28
|
+
Rake::Task.clear
|
29
|
+
Rake::DmgTask.new 'pimpernel', :noversion
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should define dmg task" do
|
33
|
+
'dmg'.should be_defined
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should define clobber_dmg task" do
|
37
|
+
'clobber_dmg'.should be_defined
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should add clobber_dmg to clobber" do
|
41
|
+
'clobber'.should be_defined
|
42
|
+
'clobber'.should have_prerequisites('clobber_dmg')
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should define rebuild_dmg task" do
|
46
|
+
'rebuild_dmg'.should be_defined
|
47
|
+
'rebuild_dmg'.should have_prerequisites('clobber_dmg', 'dmg')
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "A Rake::DmgTask object" do
|
53
|
+
before do
|
54
|
+
Rake::Task.clear
|
55
|
+
@rose = Rake::DmgTask.new 'rose', :noversion
|
56
|
+
@pimpernel = Rake::DmgTask.new 'pimpernel', '0.1'
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should have a name" do
|
60
|
+
@rose.name.should eql('rose')
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should allow changing name on creation via block" do
|
64
|
+
custom_pkg_dmg = Rake::DmgTask.new 'cyclamen', :noversion do |p|
|
65
|
+
p.name = 'violet'
|
66
|
+
end
|
67
|
+
custom_pkg_dmg.name.should eql('violet')
|
68
|
+
'pkg/violet.dmg'.should be_defined
|
69
|
+
'pkg/cyclamen.dmg'.should_not be_defined
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should ignore changes to name after creation" do
|
73
|
+
@rose.name = 'violet'
|
74
|
+
@rose.name.should eql('violet')
|
75
|
+
'pkg/rose.dmg'.should be_defined
|
76
|
+
'pkg/violet.dmg'.should_not be_defined
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should have a version" do
|
80
|
+
@rose.version.should be_nil
|
81
|
+
@pimpernel.version.should eql('0.1')
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should allow changing version on creation via block" do
|
85
|
+
custom_pkg_dmg = Rake::DmgTask.new 'cyclamen', :noversion do |p|
|
86
|
+
p.version = '0.1'
|
87
|
+
end
|
88
|
+
custom_pkg_dmg.version.should eql('0.1')
|
89
|
+
'pkg/cyclamen-0.1.dmg'.should be_defined
|
90
|
+
'pkg/cyclamen.dmg'.should_not be_defined
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should ignore changes to version after creation" do
|
94
|
+
@rose.version = '0.1'
|
95
|
+
@rose.version.should eql('0.1')
|
96
|
+
'pkg/rose-0.1.dmg'.should_not be_defined
|
97
|
+
'pkg/rose.dmg'.should be_defined
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should default to pkg directory" do
|
101
|
+
@rose.package_dir.should eql('pkg')
|
102
|
+
'pkg'.should be_defined
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should allow custom package directory on creationg" do
|
106
|
+
custom_pkg_dmg = Rake::DmgTask.new 'cyclamen', :noversion do |p|
|
107
|
+
p.package_dir = 'custom_pkg'
|
108
|
+
end
|
109
|
+
custom_pkg_dmg.package_dir.should eql('custom_pkg')
|
110
|
+
'custom_pkg/cyclamen.dmg'.should be_defined
|
111
|
+
'pkg/cyclamen.dmg'.should_not be_defined
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should ignore changes to package dir after creation" do
|
115
|
+
@rose.package_dir = 'custom_pkg'
|
116
|
+
@rose.package_dir.should eql('custom_pkg')
|
117
|
+
'pkg/rose.dmg'.should be_defined
|
118
|
+
'custom_pkg/rose.dmg'.should_not be_defined
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should start with empty source lists" do
|
122
|
+
@rose.source_files.should be_empty
|
123
|
+
@rose.extra_source_files.should be_empty
|
124
|
+
Rake::Task[@rose.dmg_dir_path].prerequisites.should be_empty
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should allow custom source lists on creationg" do
|
128
|
+
custom_pkg_dmg = Rake::DmgTask.new 'cyclamen', :noversion do |p|
|
129
|
+
p.source_files.include 'Rakefile'
|
130
|
+
p.extra_source_files = {'test.rb' => '/a/test_with_another_name.rb'}
|
131
|
+
end
|
132
|
+
custom_pkg_dmg.source_files.should_not be_empty
|
133
|
+
custom_pkg_dmg.extra_source_files.should_not be_empty
|
134
|
+
custom_pkg_dmg.dmg_dir_path.should have_prerequisites('Rakefile', 'test.rb')
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should ignore changes to source lists after creation" do
|
138
|
+
@rose.source_files.include 'Rakefile'
|
139
|
+
@rose.source_files.should_not be_empty
|
140
|
+
@rose.extra_source_files = {'test.rb' => '/a/test_with_another_name.rb'}
|
141
|
+
@rose.extra_source_files.should_not be_empty
|
142
|
+
Rake::Task[@rose.dmg_dir_path].prerequisites.should be_empty
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should default to hdiutil" do
|
146
|
+
@pimpernel.dmg_command.should eql('hdiutil')
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should allow custom dmg command" do
|
150
|
+
@pimpernel.dmg_command = 'whatever_you_want'
|
151
|
+
@pimpernel.dmg_command.should eql('whatever_you_want')
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should default to not have administration rights" do
|
155
|
+
@rose.admin_rights.should be_false
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should allow setting administration rights on creation" do
|
159
|
+
custom_pkg_dmg = Rake::DmgTask.new 'cyclamen', :noversion do |dmg|
|
160
|
+
dmg.admin_rights = true
|
161
|
+
end
|
162
|
+
custom_pkg_dmg.admin_rights.should be_true
|
163
|
+
end
|
164
|
+
|
165
|
+
it "should allow setting administration rights after creation" do
|
166
|
+
@rose.admin_rights.should be_false
|
167
|
+
@rose.admin_rights = true
|
168
|
+
@rose.admin_rights.should be_true
|
169
|
+
end
|
170
|
+
|
171
|
+
it "should change DMG build options based on administration rights presence" do
|
172
|
+
old_options = @rose.dmg_options
|
173
|
+
@rose.admin_rights = true
|
174
|
+
@rose.dmg_options.should_not eql(old_options)
|
175
|
+
@rose.admin_rights = false
|
176
|
+
@rose.dmg_options.should eql(old_options)
|
177
|
+
end
|
178
|
+
|
179
|
+
it "should allow setting totally new DMG build options any time" do
|
180
|
+
old_options = @rose.dmg_options
|
181
|
+
new_options = '-not -really -options'
|
182
|
+
@rose.dmg_options = new_options
|
183
|
+
@rose.dmg_options.should eql(new_options)
|
184
|
+
@rose.dmg_options = nil
|
185
|
+
@rose.dmg_options.should eql(old_options)
|
186
|
+
end
|
187
|
+
|
188
|
+
it "should default to empty strip prefix" do
|
189
|
+
@rose.strip.should be_nil
|
190
|
+
end
|
191
|
+
|
192
|
+
it "should allow setting strip prefix any time" do
|
193
|
+
old_strip = @rose.strip
|
194
|
+
new_strip = 'path/to/stip/out'
|
195
|
+
@rose.strip = new_strip
|
196
|
+
@rose.strip.should eql(new_strip)
|
197
|
+
@rose.strip = old_strip
|
198
|
+
@rose.strip.should eql(old_strip)
|
199
|
+
end
|
200
|
+
|
201
|
+
it "should create the volume name" do
|
202
|
+
@rose.dmg_name.should eql('rose')
|
203
|
+
@pimpernel.dmg_name.should eql('pimpernel-0.1')
|
204
|
+
end
|
205
|
+
|
206
|
+
it "should create the dmg name" do
|
207
|
+
@rose.dmg_file.should eql('rose.dmg')
|
208
|
+
@pimpernel.dmg_file.should eql('pimpernel-0.1.dmg')
|
209
|
+
end
|
210
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'spec'
|
3
|
+
require File.dirname(__FILE__) + '/../lib/rake/dmg'
|
4
|
+
|
5
|
+
module RakeTaskMatchers
|
6
|
+
class BeDefined
|
7
|
+
def matches?(task_name)
|
8
|
+
@task_name = task_name
|
9
|
+
Rake::Task.task_defined?(task_name)
|
10
|
+
end
|
11
|
+
def failure_message
|
12
|
+
"expected #{@task_name.inspect} to be defined"
|
13
|
+
end
|
14
|
+
def negative_failure_message
|
15
|
+
"expected #{@task_name.inspect} not to be define"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def be_defined
|
20
|
+
BeDefined.new
|
21
|
+
end
|
22
|
+
|
23
|
+
class HavePrerequisites
|
24
|
+
def initialize(prereq_tasks)
|
25
|
+
@prereq_tasks = prereq_tasks
|
26
|
+
end
|
27
|
+
def matches?(task_name)
|
28
|
+
@task_name = task_name
|
29
|
+
@prereq_tasks.each do |t|
|
30
|
+
return false if !Rake::Task[@task_name].prerequisites.include?(t)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
def failure_message
|
34
|
+
"expected #{@prereq_tasks.inspect} to be prerequistes of #{@task_name.inspect}"
|
35
|
+
end
|
36
|
+
def negative_failure_message
|
37
|
+
"expected #{@prereq_tasks.inspect} not to be prerequisites of #{@task_name.inspect}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def have_prerequisites(*prereq_tasks)
|
42
|
+
HavePrerequisites.new prereq_tasks
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
Spec::Runner.configure do |conf|
|
47
|
+
conf.include RakeTaskMatchers
|
48
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rake_dmg
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Emanuele Vicentini
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-01-05 00:00:00 +01:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rake
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: echoe
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rake
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.8.2
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: rspec
|
47
|
+
type: :development
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
version:
|
55
|
+
description: Rake library to build DMG files
|
56
|
+
email: emanuele.vicentini@gmail.com
|
57
|
+
executables: []
|
58
|
+
|
59
|
+
extensions: []
|
60
|
+
|
61
|
+
extra_rdoc_files:
|
62
|
+
- LICENSE.rdoc
|
63
|
+
- README.rdoc
|
64
|
+
files:
|
65
|
+
- lib/rake/dmg.rb
|
66
|
+
- LICENSE.rdoc
|
67
|
+
- Manifest
|
68
|
+
- rake_dmg.gemspec
|
69
|
+
- Rakefile
|
70
|
+
- README.rdoc
|
71
|
+
- spec/dmg_spec.rb
|
72
|
+
- spec/spec.opts
|
73
|
+
- spec/spec_helper.rb
|
74
|
+
has_rdoc: true
|
75
|
+
homepage: http://github.com/baldowl/rake_dmg
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options:
|
78
|
+
- --line-numbers
|
79
|
+
- --inline-source
|
80
|
+
- --title
|
81
|
+
- Rake_dmg
|
82
|
+
- --main
|
83
|
+
- README.rdoc
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: "0"
|
91
|
+
version:
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: "1.2"
|
97
|
+
version:
|
98
|
+
requirements: []
|
99
|
+
|
100
|
+
rubyforge_project: rakedmg
|
101
|
+
rubygems_version: 1.3.1
|
102
|
+
signing_key:
|
103
|
+
specification_version: 2
|
104
|
+
summary: Rake library to build DMG files
|
105
|
+
test_files: []
|
106
|
+
|