dmg 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +2 -0
- data/bin/dmg +5 -0
- data/dmg.gemspec +21 -0
- data/lib/dmg.rb +7 -0
- data/lib/dmg/cli.rb +16 -0
- data/lib/dmg/errors.rb +7 -0
- data/lib/dmg/pkg.rb +62 -0
- data/lib/dmg/pkgs.yml +34 -0
- data/lib/dmg/version.rb +3 -0
- metadata +78 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
data/bin/dmg
ADDED
data/dmg.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "dmg/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "dmg"
|
7
|
+
s.version = Dmg::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Philippe Creux"]
|
10
|
+
s.email = ["pcreux@gmail.com"]
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{Install popular applications provided as dmgs from the command line}
|
13
|
+
s.description = %q{It's like apt-get for Mac}
|
14
|
+
|
15
|
+
s.default_executable = %q{dmg}
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
end
|
data/lib/dmg.rb
ADDED
data/lib/dmg/cli.rb
ADDED
data/lib/dmg/errors.rb
ADDED
data/lib/dmg/pkg.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
module DMG
|
2
|
+
class Pkg
|
3
|
+
def self.list
|
4
|
+
puts all.map(&:name)
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.install(pkg_names)
|
8
|
+
pkgs = pkg_names.map { |pkg_name| find!(pkg_name) }
|
9
|
+
pkgs.each(&:install!)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.all
|
13
|
+
return @@all if defined?(@@all)
|
14
|
+
@@all = []
|
15
|
+
pkgs = YAML.load_file(File.dirname(__FILE__) + '/pkgs.yml')
|
16
|
+
pkgs.each do |key, values|
|
17
|
+
@@all << Pkg.new({'name' => key}.merge(values))
|
18
|
+
end
|
19
|
+
|
20
|
+
@@all
|
21
|
+
end
|
22
|
+
|
23
|
+
attr_reader :name, :package, :url, :volume_dir
|
24
|
+
|
25
|
+
def initialize(args)
|
26
|
+
@name = args['name']
|
27
|
+
@package = args['package']
|
28
|
+
@url = args['url']
|
29
|
+
@volume_dir = args['volume_dir'] || @package
|
30
|
+
end
|
31
|
+
|
32
|
+
def install!
|
33
|
+
dmg_file = "~/Downloads/#{package}.dmg"
|
34
|
+
destination = '/Applications'
|
35
|
+
|
36
|
+
if "hdiutil info"[/image-path.*#{dmg_file}/]
|
37
|
+
puts "#{name} is already installed"
|
38
|
+
return
|
39
|
+
end
|
40
|
+
|
41
|
+
#run_cmd("curl -L #{url} -o #{dmg_file}")
|
42
|
+
run_cmd("hdid #{dmg_file}")
|
43
|
+
run_cmd "sudo cp -r '/Volumes/#{volume_dir}/#{package}.app' #{destination}"
|
44
|
+
run_cmd "hdiutil detach '/Volumes/#{volume_dir}'"
|
45
|
+
run_cmd("sudo chmod 755 #{destination}/#{package}.app/Contents/MacOS/#{package}")
|
46
|
+
end
|
47
|
+
|
48
|
+
protected
|
49
|
+
|
50
|
+
def self.find!(pkg_name)
|
51
|
+
pkg = all.select { |pkg| pkg.name == pkg_name }.first
|
52
|
+
raise PackageNotFound, "Can't find a package called '#{pkg_name}'" unless pkg
|
53
|
+
|
54
|
+
pkg
|
55
|
+
end
|
56
|
+
|
57
|
+
def run_cmd(cmd)
|
58
|
+
puts cmd
|
59
|
+
raise DMGError, "Failed to run a command" unless system(cmd)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/dmg/pkgs.yml
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
dropbox:
|
2
|
+
package: Dropbox
|
3
|
+
volume_dir: Dropbox Installer
|
4
|
+
url: "http://www.dropbox.com/download?plat=mac"
|
5
|
+
|
6
|
+
chrome:
|
7
|
+
package: Google Chrome
|
8
|
+
url: "https://dl-ssl.google.com/chrome/mac/stable/GGRM/googlechrome.dmg"
|
9
|
+
|
10
|
+
skype:
|
11
|
+
package: Skype
|
12
|
+
url: http://www.skype.com/go/getskype-macosx.dmg
|
13
|
+
|
14
|
+
steam:
|
15
|
+
package: Steam
|
16
|
+
url: http://cdn.store.steampowered.com/public/client/installer/steam.dmg
|
17
|
+
|
18
|
+
macirssi:
|
19
|
+
package: MacIrssi
|
20
|
+
url: http://www.sysctl.co.uk/projects/macirssi/downloads/MacIrssi-0.8.6.6.dmg
|
21
|
+
|
22
|
+
picasa:
|
23
|
+
package: Picasa
|
24
|
+
url: http://dl.google.com/photos/picasamac38.dmg
|
25
|
+
|
26
|
+
adium:
|
27
|
+
package: Adium
|
28
|
+
volume_dir: Adium 1.4.1
|
29
|
+
url: http://download.adium.im/Adium_1.4.1.dmg
|
30
|
+
|
31
|
+
emacs:
|
32
|
+
package: Emacs
|
33
|
+
url: http://emacsformacosx.com/emacs-builds/Emacs-23.2-universal-10.6.3.dmg
|
34
|
+
|
data/lib/dmg/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dmg
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Philippe Creux
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-04-06 00:00:00 -07:00
|
19
|
+
default_executable: dmg
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: It's like apt-get for Mac
|
23
|
+
email:
|
24
|
+
- pcreux@gmail.com
|
25
|
+
executables:
|
26
|
+
- dmg
|
27
|
+
extensions: []
|
28
|
+
|
29
|
+
extra_rdoc_files: []
|
30
|
+
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- Gemfile
|
34
|
+
- Rakefile
|
35
|
+
- bin/dmg
|
36
|
+
- dmg.gemspec
|
37
|
+
- lib/dmg.rb
|
38
|
+
- lib/dmg/cli.rb
|
39
|
+
- lib/dmg/errors.rb
|
40
|
+
- lib/dmg/pkg.rb
|
41
|
+
- lib/dmg/pkgs.yml
|
42
|
+
- lib/dmg/version.rb
|
43
|
+
has_rdoc: true
|
44
|
+
homepage: ""
|
45
|
+
licenses: []
|
46
|
+
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
hash: 3
|
67
|
+
segments:
|
68
|
+
- 0
|
69
|
+
version: "0"
|
70
|
+
requirements: []
|
71
|
+
|
72
|
+
rubyforge_project:
|
73
|
+
rubygems_version: 1.3.7
|
74
|
+
signing_key:
|
75
|
+
specification_version: 3
|
76
|
+
summary: Install popular applications provided as dmgs from the command line
|
77
|
+
test_files: []
|
78
|
+
|