create_bundle 0.1.0 → 0.1.4
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 +4 -4
- data/README.md +23 -3
- data/exe/cb +1 -1
- data/lib/create_bundle/version.rb +1 -1
- data/lib/create_bundle.rb +11 -14
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f0de999eecf8968d214418bea0d4e63a35f8ee6311605337aaf5207f3fc5709
|
4
|
+
data.tar.gz: 1d69de6e5346e7c141478d839846951fec3d8c9c46441477dc045ecfa736649f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d17d6a141ccf17b1c4039b41633a1e2aa86c1d0569db18071bc9ef325b1b1e40ea4d0583ff516576a64dabe2a2cd93611d559ae910a6488c49283a30d8e688a
|
7
|
+
data.tar.gz: cb5f0db9849b1c85f20aedc32066ac99e474bb046958fdd90636c5c8b9da403030cd756b275ea844ba99a428f26517ebcbdcc7b88f1df3f79b1dc68e74918b41
|
data/README.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
|
-
|
1
|
+
[](https://codeclimate.com/github/aladac/create_bundle/maintainability)
|
2
|
+
# create_bundle
|
2
3
|
|
3
|
-
|
4
|
+
Tool for creating MacOS application bundles containing an icon and launch command copied from the source application.
|
5
|
+
|
6
|
+
## Why?
|
7
|
+
- Can't you just create a link? _Yes I can but I can't add commands to be run before an app is started_
|
8
|
+
- Can't you just do it all using a bash one liner? _Yes I can but I'm lazy and the gem exec provides some basic error handling_
|
9
|
+
- To create bare bundles to edit later
|
4
10
|
|
5
11
|
## Installation
|
6
12
|
|
@@ -9,9 +15,23 @@ A simple tool for creating bare MacOS application bundles containing an icon and
|
|
9
15
|
## Usage
|
10
16
|
|
11
17
|
```
|
12
|
-
Usage: cb SOURCE_APP [
|
18
|
+
Usage: cb [OPTIONS] SOURCE_APP [DESTINATION_APP]
|
19
|
+
Usage: cb -i ICON -s SCRIPT -b DESTINATION_APP
|
20
|
+
-v, --[no-]verbose Run verbosely
|
21
|
+
-i, --icon PATH Use a custom icon
|
22
|
+
-s, --script PATH Use a custom executable
|
23
|
+
-b, --bare Create a bare bundle
|
13
24
|
```
|
14
25
|
|
26
|
+
$ cb -v /Applications/iTerm.app ~/Desktop/iTerm.app
|
27
|
+
$ cb -b -i Icon.icns -s start.sh New.app
|
28
|
+
|
29
|
+
## What does it actually do?
|
30
|
+
The script when run for a source app bundle copies the icon file from the bundle (trying to parse the Info.plist, falling back to AppIcon.icns when failed), creates a new app bundle with this icon and a script to open the original app bundle.
|
31
|
+
You may say the end result is kind of like creating a filesystem link.
|
32
|
+
|
33
|
+
You can create a _"bare"_ bundle with a custom script and icon
|
34
|
+
|
15
35
|
## License
|
16
36
|
|
17
37
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/exe/cb
CHANGED
@@ -43,6 +43,6 @@ if options[:bare]
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
c = CreateBundle::Base.new(ARGV[0], ARGV[1], options[:script], options[:icon], options[:bare])
|
46
|
+
c = CreateBundle::Base.new(source: ARGV[0], target: ARGV[1], script: options[:script], icon: options[:icon], bare: options[:bare])
|
47
47
|
c.verbose = options[:verbose]
|
48
48
|
c.create
|
data/lib/create_bundle.rb
CHANGED
@@ -11,17 +11,13 @@ module CreateBundle
|
|
11
11
|
class Base
|
12
12
|
attr_accessor :logger, :app_path, :target_path, :verbose
|
13
13
|
|
14
|
-
def initialize(
|
14
|
+
def initialize(options)
|
15
15
|
@logger = Logger.new(STDOUT)
|
16
|
-
@app_path = Pathname(
|
17
|
-
@custom_icon =
|
18
|
-
@custom_script =
|
19
|
-
if bare
|
20
|
-
|
21
|
-
else
|
22
|
-
(logger.info("Source doesn't look like an app bundle") && exit) unless plist_path.exist?
|
23
|
-
end
|
24
|
-
@target_path = target_path ? Pathname(target_path) : Pathname(@app_path.basename.to_s)
|
16
|
+
@app_path = Pathname(options[:source])
|
17
|
+
@custom_icon = options[:icon]
|
18
|
+
@custom_script = options[:script]
|
19
|
+
options[:target] = options[:source] if options[:bare]
|
20
|
+
@target_path = options[:target] ? Pathname(options[:target]) : Pathname(@app_path.basename.to_s)
|
25
21
|
end
|
26
22
|
|
27
23
|
def custom_icon_path
|
@@ -35,7 +31,7 @@ module CreateBundle
|
|
35
31
|
end
|
36
32
|
|
37
33
|
def icon_path
|
38
|
-
app_path + 'Contents' + 'Resources' + icon_file
|
34
|
+
custom_icon_path || app_path + 'Contents' + 'Resources' + icon_file
|
39
35
|
rescue ArgumentError
|
40
36
|
logger.warn 'Problem reading source plist file, probably binary format, falling back to default icon name'
|
41
37
|
icon = app_path + 'Contents' + 'Resources' + 'AppIcon.icns'
|
@@ -43,7 +39,8 @@ module CreateBundle
|
|
43
39
|
end
|
44
40
|
|
45
41
|
def plist_path
|
46
|
-
app_path + 'Contents' + 'Info.plist'
|
42
|
+
path = app_path + 'Contents' + 'Info.plist'
|
43
|
+
path.exist? ? path : (logger.info("Source doesn't look like an app bundle") && exit)
|
47
44
|
end
|
48
45
|
|
49
46
|
def plist
|
@@ -87,7 +84,7 @@ module CreateBundle
|
|
87
84
|
end
|
88
85
|
|
89
86
|
def copy_icon
|
90
|
-
File.link(
|
87
|
+
File.link(icon_path, resources_dir + 'applet.icns')
|
91
88
|
logger.debug "Copied icon to: #{(resources_dir + 'applet.icns')}" if verbose
|
92
89
|
end
|
93
90
|
|
@@ -95,7 +92,6 @@ module CreateBundle
|
|
95
92
|
f = File.new(macos_dir + 'applet', 'w')
|
96
93
|
f.puts "#!/bin/sh\nopen -a \"#{ARGV[0]}\""
|
97
94
|
f.close
|
98
|
-
FileUtils.chmod 0o755, macos_dir + 'applet'
|
99
95
|
logger.debug "Created exec: #{(macos_dir + 'applet')}" if verbose
|
100
96
|
end
|
101
97
|
|
@@ -112,6 +108,7 @@ module CreateBundle
|
|
112
108
|
|
113
109
|
def create_exec
|
114
110
|
copy_script || write_script
|
111
|
+
FileUtils.chmod 0o755, macos_dir + 'applet'
|
115
112
|
end
|
116
113
|
|
117
114
|
def create
|