wrapp 0.5.1 → 0.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 25cf9c09bb6bbae211ecb408887c7f2f3882fc39
4
- data.tar.gz: a9e3f7c9e819f9b365066910cd6c66c90c2ff558
3
+ metadata.gz: ff8d66befa9b271ee02eff82024ff41eeb886a4d
4
+ data.tar.gz: 03c0df25217a78d8d88410a516b2b567f33a445f
5
5
  SHA512:
6
- metadata.gz: 831b4c45087952ca1189ed35562c308d2e71f42c8a99ccd0f19c0def101133821f85db039fd9a1875f04b2a33ef091009d8ce30a24c2dd0fe97c6baca2307003
7
- data.tar.gz: 6a72b9cb7672b4954cc54f124832d67219eddfd7eb686834ef7b38a5bae9fdb02b43308614d43e47322fc6654925247e26cbcb6729a9ebbc5adf80f82bcc6f72
6
+ metadata.gz: b0b10338cb16cfd88e73dbc87c7a1067855d95477c4cf5a2496f070c7d1f4bc812f0be9f9baaee58622746fae46e34e132c46bf497448a9ea533701670f1d43f
7
+ data.tar.gz: b5031ceb50be7fcc37cb3f49e75686c4bb07fb87b0c1b29b5068a44b55d69c28c61af5b051de4f74c1b9269b51ecab15f53f226c457ea3da97fbdff768af83c3
@@ -4,6 +4,7 @@ Feature: Wrap App
4
4
  As as user
5
5
  I want wrap my App in a DMG
6
6
 
7
+ @announce
7
8
  Scenario: Wrap App
8
9
  Given an App
9
10
  When I wrap the App
@@ -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
- system("hdiutil create '#{dmg_filename}' -srcfolder '#{source_path}'")
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
@@ -1,3 +1,3 @@
1
1
  module Wrapp
2
- VERSION = '0.5.1'
2
+ VERSION = '0.6.0'
3
3
  end
@@ -35,29 +35,16 @@ module Wrapp
35
35
  end
36
36
 
37
37
  describe '#get_property' do
38
- let(:command_line) { double('command_line', :run => '') }
39
-
40
- before do
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('Foo')
42
+ app.get_property('foo')
56
43
  end
57
44
 
58
45
  it 'strips the output' do
59
- command_line.stub(:run).and_return("Chunky\n")
60
- expect(app.get_property('')).to eq('Chunky')
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
- it 'creates the dmg by hdiutil' do
14
- dmg.should_receive(:source_path).and_return('Chunky.app')
15
- dmg.should_receive(:dmg_filename).and_return('bacon.dmg')
16
- dmg.should_receive(:system).
17
- with("hdiutil create 'bacon.dmg' -srcfolder 'Chunky.app'")
18
- dmg.create
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.5.1
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-01-16 00:00:00.000000000 Z
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.5.1
163
+ summary: wrapp-0.6.0
164
164
  test_files:
165
165
  - features/step_definitions/wrapp_steps.rb
166
166
  - features/support/app.rb