wrapp 0.1.0

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/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .rbenv-version
6
+ .rspec
7
+ .yardoc
8
+ Gemfile.lock
9
+ InstalledFiles
10
+ _yardoc
11
+ coverage
12
+ doc/
13
+ lib/bundler/man
14
+ pkg
15
+ rdoc
16
+ spec/reports
17
+ test/tmp
18
+ test/version_tmp
19
+ tmp
20
+ vendor
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in wrapp.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,14 @@
1
+ guard 'cucumber' do
2
+ watch(%r{^bin/.+$}) { 'features' }
3
+ watch(%r{^features/.+\.feature$})
4
+ watch(%r{^features/support/.+$}) { 'features' }
5
+ watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
6
+ end
7
+
8
+ guard :rspec do
9
+ watch(%r{^spec/.+_spec\.rb$})
10
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
11
+ watch('spec/spec_helper.rb') { "spec" }
12
+ watch('lib/wrapp.rb') { 'spec' }
13
+ end
14
+
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Björn Albers
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # Wrapp
2
+
3
+ Wrap an App... in a disk image (DMG).
4
+
5
+
6
+ ## Prologue
7
+
8
+ Say you wanna put your nice Mac OS X application in a handy disk image
9
+ (DMG) for download / deployment.
10
+ Why not use `wrapp` for this?
11
+ It is even shorter to type then `hdiutil` ;-)
12
+
13
+ **NOTE: This only runs on Mac OS X!**
14
+
15
+
16
+ ## Installation
17
+
18
+ Add this line to your application's Gemfile:
19
+
20
+ gem 'wrapp'
21
+
22
+ And then execute:
23
+
24
+ $ bundle
25
+
26
+ Or install it yourself as:
27
+
28
+ $ gem install wrapp
29
+
30
+
31
+ ## Usage
32
+
33
+ Some examples...
34
+
35
+ Build a dmg from the locally installed 'Chunky Bacon.app':
36
+
37
+ ```
38
+ wrapp /Applications/Chunky\ Bacon.app
39
+ created chunky_bacon_1.2.3.dmg with SHA-1 deadbeef...
40
+ ```
41
+
42
+ **NOTE: Not yet implemented!**
43
+ Build a dmg from the Chunky Bacon app (the one with the weird directory
44
+ layout):
45
+
46
+ ```
47
+ wrapp --plist /Applications/Chunky/Bacon.app /Applications/Chunky
48
+ created bacon_1.2.3.dmg with SHA-1 deadbeef...
49
+ ```
50
+
51
+ **NOTE: Not yet implemented!**
52
+ Build the dmg in a different directory (and create it first if missing):
53
+
54
+ ```
55
+ wrapp --outdir /tmp/dmgs /Applications/Chunky\ Bacon.app
56
+ ...
57
+ created chunky_bacon_1.2.3.dmg with SHA-1 deadbeef...
58
+ ```
59
+
60
+ Thats it.
61
+
62
+
63
+ ## Contributing
64
+
65
+ Thanks for your help! Please contact me via Github or check the open
66
+ issues. Then:
67
+
68
+ 1. Fork it
69
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
70
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
71
+ 4. Push to the branch (`git push origin my-new-feature`)
72
+ 5. Create new Pull Request
73
+
74
+
75
+ ## Copyright
76
+
77
+ Copyright (c) 2013 Björn Albers
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/wrapp ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'wrapp'
4
+
5
+ Wrapp::DMGBuilder.run
@@ -0,0 +1,58 @@
1
+ def create_app
2
+ FileUtils.rm_f(dmg_filename)
3
+ write_file(plist_path, plist_content)
4
+ end
5
+
6
+ def plist_path
7
+ File.join(app_path, 'Contents', 'Info.plist')
8
+ end
9
+
10
+ def plist_content
11
+ %Q{<?xml version="1.0" encoding="UTF-8"?>
12
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
13
+ <plist version="1.0">
14
+ <dict>
15
+ <key>CFBundleName</key>
16
+ <string>#{app_name}</string>
17
+ <key>CFBundleShortVersionString</key>
18
+ <string>#{app_version}</string>
19
+ </dict>
20
+ </plist>
21
+ }
22
+ end
23
+
24
+ def run_wrapp_command
25
+ cmd = "wrapp '#{app_path}'"
26
+ run_simple(unescape(cmd))
27
+ end
28
+
29
+ def dmg_filename
30
+ 'chunky_bacon_1.2.3.dmg'
31
+ end
32
+
33
+ def app_version
34
+ '1.2.3'
35
+ end
36
+
37
+ def app_name
38
+ 'Chunky Bacon'
39
+ end
40
+
41
+ def app_path
42
+ "Applications/#{app_name}.app"
43
+ end
44
+
45
+ Given(/^an App$/) do
46
+ create_app
47
+ end
48
+
49
+ When(/^I run wrapp$/) do
50
+ run_wrapp_command
51
+ end
52
+
53
+ Then(/^the App should be wrapped in a DMG$/) do
54
+ check_file_presence([dmg_filename], true) # assert that dmg exists
55
+ # attach dmg
56
+ # assert that dmg contains the app dir (basedir w/o full path)
57
+ # detach dmg
58
+ end
@@ -0,0 +1,5 @@
1
+ require 'aruba/cucumber'
2
+
3
+ Before do
4
+ @aruba_timeout_seconds = 10
5
+ end
@@ -0,0 +1,13 @@
1
+ Feature: Wrap App
2
+
3
+ In order to simplify distributing Apps
4
+ As as user
5
+ I want wrap my App in a DMG
6
+
7
+ Scenario: Create DMG
8
+ Given an App
9
+ When I run wrapp
10
+ Then the App should be wrapped in a DMG
11
+
12
+ #Scenario: Create DMG with different output directory
13
+ #Scenario: Create DMG with differnt info plist
@@ -0,0 +1,34 @@
1
+ module Wrapp
2
+ class AppInfo
3
+ attr_reader :plist
4
+
5
+ def initialize(plist)
6
+ @plist = plist
7
+ end
8
+
9
+ def full_name
10
+ separator = '_'
11
+ [name.downcase, version].join(separator).gsub(/\s+/, separator)
12
+ end
13
+
14
+ def name
15
+ get_property('CFBundleName')
16
+ end
17
+
18
+ def version
19
+ get_property('CFBundleShortVersionString')
20
+ end
21
+
22
+ def get_property(property)
23
+ raise "No property found: #{property}" unless
24
+ properties.has_key?(property)
25
+ properties[property].strip
26
+ end
27
+
28
+ private
29
+
30
+ def properties
31
+ Plist::parse_xml plist
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,41 @@
1
+ module Wrapp
2
+ class DMGBuilder
3
+ attr_reader :app_path
4
+
5
+ class << self
6
+ def run
7
+ new(ARGV.first).create #TODO: Test this!
8
+ end
9
+ end
10
+
11
+ def initialize(app_path)
12
+ @app_path = app_path
13
+ end
14
+
15
+ def create
16
+ create_dmg
17
+ end
18
+
19
+ private
20
+
21
+ def create_dmg
22
+ system("hdiutil create '#{dmg_path}' -srcfolder '#{app_path}'")
23
+ end
24
+
25
+ def dmg_path
26
+ dmg_filename
27
+ end
28
+
29
+ def dmg_filename
30
+ "#{app.full_name}.dmg"
31
+ end
32
+
33
+ def app
34
+ @app_info ||= AppInfo.new(plist)
35
+ end
36
+
37
+ def plist
38
+ File.join(app_path, 'Contents', 'Info.plist')
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,3 @@
1
+ module Wrapp
2
+ VERSION = '0.1.0'
3
+ end
data/lib/wrapp.rb ADDED
@@ -0,0 +1,4 @@
1
+ require 'plist'
2
+ require 'wrapp/version'
3
+ require 'wrapp/app_info'
4
+ require 'wrapp/dmg_builder'
@@ -0,0 +1 @@
1
+ require 'wrapp'
@@ -0,0 +1,59 @@
1
+ require 'spec_helper'
2
+
3
+ module Wrapp
4
+ describe AppInfo do
5
+ let(:app) { AppInfo.new('Info.plist') }
6
+
7
+ describe '#full_name' do
8
+ it 'includes the downcased name and version without spaces' do
9
+ app.stub(:name).and_return("Chunky\t Bacon")
10
+ app.stub(:version).and_return('1.2.3')
11
+ expect(app.full_name).to eq('chunky_bacon_1.2.3')
12
+ end
13
+ end
14
+
15
+ describe '#name' do
16
+ it 'returns the app name' do
17
+ app.should_receive(:get_property).
18
+ with('CFBundleName').
19
+ and_return('Chunky Bacon')
20
+ expect(app.name).to eq('Chunky Bacon')
21
+ end
22
+ end
23
+
24
+ describe '#version' do
25
+ it 'returns the app version' do
26
+ app.should_receive(:get_property).
27
+ with('CFBundleShortVersionString').
28
+ and_return('0.4.2')
29
+ expect(app.version).to eq('0.4.2')
30
+ end
31
+ end
32
+
33
+ describe '#properties' do
34
+ it 'returns the app properties as hash' do
35
+ Plist.should_receive(:parse_xml).with('Info.plist').
36
+ and_return(:plist_as_hash)
37
+ expect(app.send(:properties)).to eq(:plist_as_hash)
38
+ end
39
+ end
40
+
41
+ describe '#get_property' do
42
+ context 'with existing property' do
43
+ it 'returns the striped property' do
44
+ app.stub(:properties).and_return({})
45
+ expect {
46
+ app.get_property('Chunky')
47
+ }.to raise_error(/no property found: chunky/i)
48
+ end
49
+ end
50
+
51
+ context 'with missing property' do
52
+ it 'raises an error' do
53
+ app.stub(:properties).and_return({ 'Chunky' => ' Bacon ' })
54
+ expect(app.get_property('Chunky')).to eq('Bacon')
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,72 @@
1
+ require 'spec_helper'
2
+
3
+ module Wrapp
4
+ describe DMGBuilder do
5
+ let(:dmg) { DMGBuilder.new('Chunky Bacon.app') }
6
+ let(:app) { double('app') }
7
+
8
+ before do
9
+ DMGBuilder.any_instance.stub(:system)
10
+ end
11
+
12
+ describe '.run' do
13
+ it 'creates the dmg' do
14
+ DMGBuilder.stub(:new).and_return(dmg)
15
+ dmg.should_receive(:create) #TODO: Fix nil warning!
16
+ DMGBuilder.run
17
+ end
18
+ end
19
+
20
+ describe '#create' do
21
+ it 'creates the dmg and directory' do
22
+ dmg.should_receive(:create_dmg)
23
+ dmg.create
24
+ end
25
+ end
26
+
27
+ describe '#create_dmg' do
28
+ it 'creates the dmg by hdiutil' do
29
+ dmg.should_receive(:app_path).and_return('Chunky.app')
30
+ dmg.should_receive(:dmg_path).and_return('bacon.dmg')
31
+ dmg.should_receive(:system).
32
+ with("hdiutil create 'bacon.dmg' -srcfolder 'Chunky.app'")
33
+ dmg.send(:create_dmg)
34
+ end
35
+ end
36
+
37
+ describe '#app_path' do
38
+ it 'returns the path to the app' do
39
+ expect(dmg.app_path).to eq('Chunky Bacon.app')
40
+ end
41
+ end
42
+
43
+ describe '#dmg_path' do
44
+ it 'returns the dmg_filename' do
45
+ dmg.should_receive(:dmg_filename).and_return('chunky_bacon.dmg')
46
+ expect(dmg.send(:dmg_path)).to eq('chunky_bacon.dmg')
47
+ end
48
+ end
49
+
50
+ describe '#dmg_filename' do
51
+ it 'includes the full app name' do
52
+ app.should_receive(:full_name).and_return('chunky_bacon_0.4.2')
53
+ dmg.stub(:app).and_return(app)
54
+ expect(dmg.send(:dmg_filename)).to eq('chunky_bacon_0.4.2.dmg')
55
+ end
56
+ end
57
+
58
+ describe '#app' do
59
+ it 'creates a cached app_info instance' do
60
+ dmg.should_receive(:plist).and_return('Info.plist')
61
+ AppInfo.should_receive(:new).once.with('Info.plist').and_return(app)
62
+ expect(dmg.send(:app)).to eq(app)
63
+ end
64
+ end
65
+
66
+ describe '#plist' do
67
+ it 'returns the app info plist path' do
68
+ expect(dmg.send(:plist)).to eq('Chunky Bacon.app/Contents/Info.plist')
69
+ end
70
+ end
71
+ end
72
+ end
data/wrapp.gemspec ADDED
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'wrapp/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'wrapp'
8
+ spec.version = Wrapp::VERSION
9
+ spec.authors = ["Björn Albers"]
10
+ spec.email = ["bjoernalbers@googlemail.com"]
11
+ spec.description = %q{Wrap an App... in a disk image (DMG)}
12
+ spec.summary = "#{spec.name}-#{spec.version}"
13
+ spec.homepage = 'https://github.com/bjoernalbers/wrapp'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'plist', '~> 3.1'
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.3'
24
+ spec.add_development_dependency 'rake'
25
+ spec.add_development_dependency 'guard', '~> 1.8'
26
+ spec.add_development_dependency 'guard-cucumber'
27
+ spec.add_development_dependency 'guard-rspec'
28
+ spec.add_development_dependency 'aruba'
29
+ end
metadata ADDED
@@ -0,0 +1,189 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wrapp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Björn Albers
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-10-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: plist
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '3.1'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '3.1'
30
+ - !ruby/object:Gem::Dependency
31
+ name: bundler
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '1.3'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '1.3'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: guard
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '1.8'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '1.8'
78
+ - !ruby/object:Gem::Dependency
79
+ name: guard-cucumber
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: guard-rspec
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: aruba
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ description: Wrap an App... in a disk image (DMG)
127
+ email:
128
+ - bjoernalbers@googlemail.com
129
+ executables:
130
+ - wrapp
131
+ extensions: []
132
+ extra_rdoc_files: []
133
+ files:
134
+ - .gitignore
135
+ - Gemfile
136
+ - Guardfile
137
+ - LICENSE.txt
138
+ - README.md
139
+ - Rakefile
140
+ - bin/wrapp
141
+ - features/step_definitions/wrapp_steps.rb
142
+ - features/support/env.rb
143
+ - features/wrap_app.feature
144
+ - lib/wrapp.rb
145
+ - lib/wrapp/app_info.rb
146
+ - lib/wrapp/dmg_builder.rb
147
+ - lib/wrapp/version.rb
148
+ - spec/spec_helper.rb
149
+ - spec/wrapp/app_info_spec.rb
150
+ - spec/wrapp/dmg_builder_spec.rb
151
+ - wrapp.gemspec
152
+ homepage: https://github.com/bjoernalbers/wrapp
153
+ licenses:
154
+ - MIT
155
+ post_install_message:
156
+ rdoc_options: []
157
+ require_paths:
158
+ - lib
159
+ required_ruby_version: !ruby/object:Gem::Requirement
160
+ none: false
161
+ requirements:
162
+ - - ! '>='
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ segments:
166
+ - 0
167
+ hash: -3226553906218150349
168
+ required_rubygems_version: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ segments:
175
+ - 0
176
+ hash: -3226553906218150349
177
+ requirements: []
178
+ rubyforge_project:
179
+ rubygems_version: 1.8.23
180
+ signing_key:
181
+ specification_version: 3
182
+ summary: wrapp-0.1.0
183
+ test_files:
184
+ - features/step_definitions/wrapp_steps.rb
185
+ - features/support/env.rb
186
+ - features/wrap_app.feature
187
+ - spec/spec_helper.rb
188
+ - spec/wrapp/app_info_spec.rb
189
+ - spec/wrapp/dmg_builder_spec.rb