wrapp 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/features/wrap_app.feature +1 -0
- data/lib/wrapp/dmg_builder.rb +25 -1
- data/lib/wrapp/version.rb +1 -1
- data/spec/wrapp/app_info_spec.rb +6 -19
- data/spec/wrapp/dmg_builder_spec.rb +55 -6
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff8d66befa9b271ee02eff82024ff41eeb886a4d
|
4
|
+
data.tar.gz: 03c0df25217a78d8d88410a516b2b567f33a445f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0b10338cb16cfd88e73dbc87c7a1067855d95477c4cf5a2496f070c7d1f4bc812f0be9f9baaee58622746fae46e34e132c46bf497448a9ea533701670f1d43f
|
7
|
+
data.tar.gz: b5031ceb50be7fcc37cb3f49e75686c4bb07fb87b0c1b29b5068a44b55d69c28c61af5b051de4f74c1b9269b51ecab15f53f226c457ea3da97fbdff768af83c3
|
data/features/wrap_app.feature
CHANGED
data/lib/wrapp/dmg_builder.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Wrapp
|
2
2
|
class DMGBuilder
|
3
|
+
BIG_SOURCE_FOLDER_SIZE = 100
|
4
|
+
|
3
5
|
attr_reader :app_path
|
4
6
|
|
5
7
|
def initialize(app_path, opts = {})
|
@@ -8,7 +10,14 @@ module Wrapp
|
|
8
10
|
end
|
9
11
|
|
10
12
|
def create
|
11
|
-
|
13
|
+
cmd = %w(hdiutil create)
|
14
|
+
cmd << "-srcfolder '#{source_path}'"
|
15
|
+
# NOTE: There is a known bug in hdiutil that causes the image creation
|
16
|
+
# to fail, see: https://discussions.apple.com/thread/5667409
|
17
|
+
# Therefore we have to explicitely set the dmg size for bigger sources.
|
18
|
+
cmd << "-megabytes #{dmg_size}" if big_source_folder?
|
19
|
+
cmd << "'#{dmg_filename}'"
|
20
|
+
system(cmd.join(' '))
|
12
21
|
end
|
13
22
|
|
14
23
|
private
|
@@ -17,6 +26,21 @@ module Wrapp
|
|
17
26
|
@opts[:include_parent_dir] ? File.dirname(app_path) : app_path
|
18
27
|
end
|
19
28
|
|
29
|
+
# @returns [Boolean] true if source folder is bigger or equal then 100MB.
|
30
|
+
def big_source_folder?
|
31
|
+
folder_size >= BIG_SOURCE_FOLDER_SIZE
|
32
|
+
end
|
33
|
+
|
34
|
+
# @returns [Integer] Size of dmg in megabytes.
|
35
|
+
def dmg_size
|
36
|
+
(folder_size * 1.1).to_i # Source folder + 10% buffer.
|
37
|
+
end
|
38
|
+
|
39
|
+
# @returns [Integer] Size of source folder in megabytes.
|
40
|
+
def folder_size
|
41
|
+
`du -ms '#{source_path}'`[/^(\d+)\s+/,1].to_i
|
42
|
+
end
|
43
|
+
|
20
44
|
def dmg_filename
|
21
45
|
"#{app.full_name}.dmg"
|
22
46
|
end
|
data/lib/wrapp/version.rb
CHANGED
data/spec/wrapp/app_info_spec.rb
CHANGED
@@ -35,29 +35,16 @@ module Wrapp
|
|
35
35
|
end
|
36
36
|
|
37
37
|
describe '#get_property' do
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
Cocaine::CommandLine.stub(:new).and_return(command_line)
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'builds a new command line object' do
|
45
|
-
Cocaine::CommandLine.should_receive(:new).
|
46
|
-
with('/usr/libexec/PlistBuddy', '-c :cmd :plist').
|
47
|
-
and_return(command_line)
|
48
|
-
app.get_property('Foo')
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'runs the command line with the property' do
|
52
|
-
command_line.should_receive(:run).
|
53
|
-
with(:cmd => 'Print Foo', :plist => 'Info.plist').
|
38
|
+
it 'retrieves the property by PlistBuddy' do
|
39
|
+
app.should_receive(:`).
|
40
|
+
with("/usr/libexec/PlistBuddy -c 'Print :foo' 'Info.plist'").
|
54
41
|
and_return('')
|
55
|
-
app.get_property('
|
42
|
+
app.get_property('foo')
|
56
43
|
end
|
57
44
|
|
58
45
|
it 'strips the output' do
|
59
|
-
|
60
|
-
expect(app.get_property(
|
46
|
+
app.stub(:`).and_return("Chunky\n")
|
47
|
+
expect(app.get_property(nil)).to eq('Chunky')
|
61
48
|
end
|
62
49
|
|
63
50
|
it 'raises when plistbuddy exists non-zero' do
|
@@ -10,12 +10,28 @@ module Wrapp
|
|
10
10
|
end
|
11
11
|
|
12
12
|
describe '#create' do
|
13
|
-
|
14
|
-
dmg.
|
15
|
-
dmg.
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
before do
|
14
|
+
dmg.stub(:source_path).and_return('Chunky.app')
|
15
|
+
dmg.stub(:dmg_filename).and_return('bacon.dmg')
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'with big source folder' do
|
19
|
+
it 'creates a dmg with predefined size' do
|
20
|
+
dmg.stub(:big_source_folder?).and_return(true)
|
21
|
+
dmg.stub(:dmg_size).and_return(123)
|
22
|
+
dmg.should_receive(:system).
|
23
|
+
with("hdiutil create -srcfolder 'Chunky.app' -megabytes 123 'bacon.dmg'")
|
24
|
+
dmg.create
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'with small source folder' do
|
29
|
+
it 'creates a dmg with automatic size' do
|
30
|
+
dmg.stub(:big_source_folder?).and_return(false)
|
31
|
+
dmg.should_receive(:system).
|
32
|
+
with("hdiutil create -srcfolder 'Chunky.app' 'bacon.dmg'")
|
33
|
+
dmg.create
|
34
|
+
end
|
19
35
|
end
|
20
36
|
end
|
21
37
|
|
@@ -43,6 +59,39 @@ module Wrapp
|
|
43
59
|
end
|
44
60
|
end
|
45
61
|
|
62
|
+
describe '#big_source_folder?' do
|
63
|
+
it 'is true with source folder >= 100MB' do
|
64
|
+
dmg.stub(:folder_size).and_return(100)
|
65
|
+
expect(dmg.send(:big_source_folder?)).to be true
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'is false with source folder < 100MB' do
|
69
|
+
dmg.stub(:folder_size).and_return(99)
|
70
|
+
expect(dmg.send(:big_source_folder?)).to be false
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe '#dmg_size' do
|
75
|
+
it 'returns the folder size + 10% buffer' do
|
76
|
+
dmg.stub(:folder_size).and_return(100)
|
77
|
+
expect(dmg.send(:dmg_size)).to eq(110)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '#folder_size' do
|
82
|
+
it 'gets the folder size by du command' do
|
83
|
+
dmg.stub(:source_path).and_return('/chunky/bacon')
|
84
|
+
dmg.should_receive(:`).with("du -ms '/chunky/bacon'").and_return('')
|
85
|
+
dmg.send(:folder_size)
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'returns the folder size plus 10%' do
|
89
|
+
dmg.stub(:source_path).and_return('/chunky/bacon')
|
90
|
+
dmg.stub(:`).and_return('100 /chunky/bacon')
|
91
|
+
expect(dmg.send(:folder_size)).to eq(100)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
46
95
|
describe '#dmg_filename' do
|
47
96
|
it 'includes the full app name' do
|
48
97
|
app.should_receive(:full_name).and_return('chunky_bacon_0.4.2')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wrapp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Björn Albers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-cli
|
@@ -160,7 +160,7 @@ rubyforge_project:
|
|
160
160
|
rubygems_version: 2.0.3
|
161
161
|
signing_key:
|
162
162
|
specification_version: 4
|
163
|
-
summary: wrapp-0.
|
163
|
+
summary: wrapp-0.6.0
|
164
164
|
test_files:
|
165
165
|
- features/step_definitions/wrapp_steps.rb
|
166
166
|
- features/support/app.rb
|