furoshiki 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/furoshiki/{jar_app.rb → base_app.rb} +73 -97
- data/lib/furoshiki/linux_app.rb +45 -0
- data/lib/furoshiki/mac_app.rb +66 -0
- data/lib/furoshiki/version.rb +1 -1
- data/lib/furoshiki/windows_app.rb +36 -0
- data/lib/furoshiki.rb +3 -1
- metadata +9 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9c6df7eae5f4b6178c062b65d94f982f9aa5424741b33199bcd31be3be2e2f77
|
4
|
+
data.tar.gz: c7f26f4ce029aaf87a3cb43a9477df216bcec4feee432bd4da0362e9ede296e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a92923698d16efa5299953828bdb93cd8d99e951a677ff21b0a38a93877b1e8c4945a2597d557a7d7fa7cabd30c66a27454159080c6a41c8d40a1a77b128f427
|
7
|
+
data.tar.gz: 5089838464681db8b4e196da72c730cbea89e76058373369181bca21121b90304765f5f0d4ba859bfb97d6a34b8b6115d6c4421783e21487c288d86e7d85f6b7
|
@@ -1,13 +1,13 @@
|
|
1
|
+
require 'furoshiki/configuration'
|
1
2
|
require 'furoshiki/exceptions'
|
2
3
|
require 'furoshiki/zip/directory'
|
3
4
|
require 'furoshiki/jar'
|
4
5
|
require 'fileutils'
|
5
|
-
require 'plist'
|
6
6
|
require 'open-uri'
|
7
7
|
require 'net/http'
|
8
8
|
|
9
9
|
module Furoshiki
|
10
|
-
class
|
10
|
+
class BaseApp
|
11
11
|
include FileUtils
|
12
12
|
|
13
13
|
# @param [Furoshiki::Shoes::Configuration] config user configuration
|
@@ -27,58 +27,61 @@ module Furoshiki
|
|
27
27
|
@tmp = @package_dir.join('tmp')
|
28
28
|
end
|
29
29
|
|
30
|
+
def package
|
31
|
+
remove_tmp
|
32
|
+
create_tmp
|
33
|
+
|
34
|
+
cache_template
|
35
|
+
extract_template
|
36
|
+
|
37
|
+
inject_files
|
38
|
+
inject_jar
|
39
|
+
after_built
|
40
|
+
|
41
|
+
move_to_package_dir tmp_app_path
|
42
|
+
after_moved
|
43
|
+
ensure
|
44
|
+
remove_tmp
|
45
|
+
end
|
46
|
+
|
30
47
|
# @return [Pathname] default package directory: ./pkg
|
31
48
|
attr_reader :default_package_dir
|
32
49
|
|
33
50
|
# @return [Pathname] package directory
|
34
51
|
attr_accessor :package_dir
|
35
52
|
|
36
|
-
# @return [Pathname] default path to
|
53
|
+
# @return [Pathname] default path to app template
|
37
54
|
attr_reader :default_template_path
|
38
55
|
|
39
|
-
# @return [Pathname] path to
|
56
|
+
# @return [Pathname] path to app template
|
40
57
|
attr_accessor :template_path
|
41
58
|
|
42
59
|
# @return [Pathname] cache directory
|
43
60
|
attr_reader :cache_dir
|
44
61
|
|
62
|
+
# @param [Furoshiki::Shoes::Configuration] config user configuration
|
45
63
|
attr_reader :config
|
46
64
|
|
65
|
+
# @return [Pathname] app building temp directory
|
47
66
|
attr_reader :tmp
|
48
67
|
|
49
|
-
def package
|
50
|
-
remove_tmp
|
51
|
-
create_tmp
|
52
|
-
cache_template
|
53
|
-
extract_template
|
54
|
-
inject_icon
|
55
|
-
inject_config
|
56
|
-
jar_path = ensure_jar_exists
|
57
|
-
inject_jar jar_path
|
58
|
-
move_to_package_dir tmp_app_path
|
59
|
-
tweak_permissions
|
60
|
-
rescue => e
|
61
|
-
raise e
|
62
|
-
ensure
|
63
|
-
remove_tmp
|
64
|
-
end
|
65
|
-
|
66
68
|
private
|
67
|
-
|
68
|
-
|
69
|
+
|
70
|
+
# Locations and names
|
71
|
+
def app_name
|
72
|
+
raise NotImplementedError
|
69
73
|
end
|
70
74
|
|
71
|
-
def
|
72
|
-
|
75
|
+
def template_basename
|
76
|
+
raise NotImplementedError
|
73
77
|
end
|
74
78
|
|
75
|
-
def
|
76
|
-
|
77
|
-
download_template unless template_path.size?
|
79
|
+
def latest_template_version
|
80
|
+
raise NotImplementedError
|
78
81
|
end
|
79
82
|
|
80
|
-
def
|
81
|
-
|
83
|
+
def remote_template_url
|
84
|
+
raise NotImplementedError
|
82
85
|
end
|
83
86
|
|
84
87
|
def template_extension
|
@@ -89,10 +92,28 @@ module Furoshiki
|
|
89
92
|
"#{template_basename}-#{latest_template_version}#{template_extension}"
|
90
93
|
end
|
91
94
|
|
92
|
-
def
|
93
|
-
|
95
|
+
def tmp_app_path
|
96
|
+
tmp.join app_name
|
97
|
+
end
|
98
|
+
|
99
|
+
def app_path
|
100
|
+
package_dir.join app_name
|
101
|
+
end
|
102
|
+
|
103
|
+
def working_dir
|
104
|
+
config.working_dir
|
105
|
+
end
|
106
|
+
|
107
|
+
# Temp helpers
|
108
|
+
def create_tmp
|
109
|
+
tmp.mkpath
|
94
110
|
end
|
95
111
|
|
112
|
+
def remove_tmp
|
113
|
+
tmp.rmtree if tmp.exist?
|
114
|
+
end
|
115
|
+
|
116
|
+
# Downloading
|
96
117
|
def download_template
|
97
118
|
download remote_template_url, template_path
|
98
119
|
end
|
@@ -130,37 +151,10 @@ module Furoshiki
|
|
130
151
|
end
|
131
152
|
end
|
132
153
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
def remote_template_url
|
138
|
-
config.template_urls.fetch(:jar_app)
|
139
|
-
end
|
140
|
-
|
141
|
-
def move_to_package_dir(path)
|
142
|
-
dest = package_dir.join(path.basename)
|
143
|
-
dest.rmtree if dest.exist?
|
144
|
-
mv path.to_s, dest
|
145
|
-
end
|
146
|
-
|
147
|
-
def ensure_jar_exists
|
148
|
-
jar = Jar.new(@config)
|
149
|
-
path = tmp.join(jar.filename)
|
150
|
-
jar.package(tmp) unless File.exist?(path)
|
151
|
-
path
|
152
|
-
end
|
153
|
-
|
154
|
-
# Injects JAR into APP. The JAR should be the only item in the
|
155
|
-
# Contents/Java directory. If this directory contains more than one
|
156
|
-
# JAR, the "first" one gets run, which may not be what we want.
|
157
|
-
#
|
158
|
-
# @param [Pathname, String] jar_path the location of the JAR to inject
|
159
|
-
def inject_jar(jar_path)
|
160
|
-
jar_dir = tmp_app_path.join('Contents/Java')
|
161
|
-
jar_dir.rmtree if File.exist?(jar_dir)
|
162
|
-
jar_dir.mkdir
|
163
|
-
cp Pathname.new(jar_path), jar_dir
|
154
|
+
# Template helpers
|
155
|
+
def cache_template
|
156
|
+
cache_dir.mkpath unless cache_dir.exist?
|
157
|
+
download_template unless template_path.size?
|
164
158
|
end
|
165
159
|
|
166
160
|
def extract_template
|
@@ -169,57 +163,39 @@ module Furoshiki
|
|
169
163
|
|
170
164
|
::Zip::File.open(template_path) do |zip_file|
|
171
165
|
zip_file.each do |entry|
|
172
|
-
extracted_app = template_path.join(entry.name) if Pathname.new(entry.name).extname == '.app'
|
173
166
|
p = tmp.join(entry.name)
|
174
167
|
p.dirname.mkpath
|
175
168
|
entry.extract(p)
|
176
169
|
end
|
177
170
|
end
|
178
|
-
mv tmp.join(extracted_app.basename.to_s), tmp_app_path
|
179
|
-
end
|
180
|
-
|
181
|
-
def inject_config
|
182
|
-
plist = tmp_app_path.join 'Contents/Info.plist'
|
183
|
-
template = Plist.parse_xml(plist)
|
184
|
-
template['CFBundleIdentifier'] = "com.hackety.shoes.#{config.shortname}"
|
185
|
-
template['CFBundleDisplayName'] = config.name
|
186
|
-
template['CFBundleName'] = config.name
|
187
|
-
template['CFBundleVersion'] = config.version
|
188
|
-
template['CFBundleIconFile'] = Pathname.new(config.icons[:osx]).basename.to_s if config.icons[:osx]
|
189
|
-
File.open(plist, 'w') { |f| f.write template.to_plist }
|
190
|
-
end
|
191
|
-
|
192
|
-
def inject_icon
|
193
|
-
if config.icons[:osx]
|
194
|
-
icon_path = working_dir.join(config.icons[:osx])
|
195
|
-
raise IOError, "Couldn't find app icon at #{icon_path}" unless icon_path.exist?
|
196
|
-
resources_dir = tmp_app_path.join('Contents/Resources')
|
197
|
-
cp icon_path, resources_dir.join(icon_path.basename)
|
198
|
-
end
|
199
171
|
end
|
200
172
|
|
201
|
-
|
202
|
-
|
173
|
+
# Packaging helpers
|
174
|
+
def inject_files
|
175
|
+
# Hook for allowing different app types to put there files in
|
203
176
|
end
|
204
177
|
|
205
|
-
def
|
206
|
-
"
|
178
|
+
def inject_jar
|
179
|
+
raise NotImplementedError("Tell us where the jar is")
|
207
180
|
end
|
208
181
|
|
209
|
-
def
|
210
|
-
tmp.join app_name
|
182
|
+
def after_built
|
211
183
|
end
|
212
184
|
|
213
|
-
def
|
214
|
-
package_dir.join app_name
|
185
|
+
def after_moved
|
215
186
|
end
|
216
187
|
|
217
|
-
def
|
218
|
-
|
188
|
+
def move_to_package_dir(path)
|
189
|
+
dest = package_dir.join(app_name)
|
190
|
+
dest.rmtree if dest.exist?
|
191
|
+
mv path.to_s, dest
|
219
192
|
end
|
220
193
|
|
221
|
-
def
|
222
|
-
config
|
194
|
+
def ensure_jar_exists
|
195
|
+
jar = Jar.new(@config)
|
196
|
+
path = tmp.join(jar.filename)
|
197
|
+
jar.package(tmp) unless File.exist?(path)
|
198
|
+
path
|
223
199
|
end
|
224
200
|
end
|
225
201
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'furoshiki/base_app'
|
2
|
+
require 'plist'
|
3
|
+
|
4
|
+
module Furoshiki
|
5
|
+
class LinuxApp < BaseApp
|
6
|
+
private
|
7
|
+
|
8
|
+
def app_name
|
9
|
+
"#{config.name}-linux"
|
10
|
+
end
|
11
|
+
|
12
|
+
def template_basename
|
13
|
+
'linux-app-template'
|
14
|
+
end
|
15
|
+
|
16
|
+
def latest_template_version
|
17
|
+
'0.0.1'
|
18
|
+
end
|
19
|
+
|
20
|
+
def remote_template_url
|
21
|
+
"https://github.com/shoes/linux-app-templates/releases/download/v#{latest_template_version}/linux-app-template-#{latest_template_version}.zip"
|
22
|
+
end
|
23
|
+
|
24
|
+
def inject_jar
|
25
|
+
jar_path = ensure_jar_exists
|
26
|
+
cp Pathname.new(jar_path), File.join(tmp_app_path, "app.jar")
|
27
|
+
end
|
28
|
+
|
29
|
+
def after_built
|
30
|
+
mv File.join(tmp_app_path, "app"), File.join(tmp_app_path, config.name)
|
31
|
+
end
|
32
|
+
|
33
|
+
def after_moved
|
34
|
+
executable_path.chmod 0755
|
35
|
+
end
|
36
|
+
|
37
|
+
def executable_path
|
38
|
+
app_path.join(config.name)
|
39
|
+
end
|
40
|
+
|
41
|
+
def tmp_app_path
|
42
|
+
tmp.join "#{template_basename}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'furoshiki/base_app'
|
2
|
+
require 'plist'
|
3
|
+
|
4
|
+
module Furoshiki
|
5
|
+
class MacApp < BaseApp
|
6
|
+
private
|
7
|
+
|
8
|
+
def app_name
|
9
|
+
"#{config.name}.app"
|
10
|
+
end
|
11
|
+
|
12
|
+
def template_basename
|
13
|
+
'mac-app-template'
|
14
|
+
end
|
15
|
+
|
16
|
+
def latest_template_version
|
17
|
+
'0.0.3'
|
18
|
+
end
|
19
|
+
|
20
|
+
def remote_template_url
|
21
|
+
"https://github.com/shoes/mac-app-templates/releases/download/v#{latest_template_version}/mac-app-template-#{latest_template_version}.zip"
|
22
|
+
end
|
23
|
+
|
24
|
+
def inject_jar
|
25
|
+
jar_path = ensure_jar_exists
|
26
|
+
cp Pathname.new(jar_path), File.join(tmp_app_path, "Contents", "Java", "app.jar")
|
27
|
+
end
|
28
|
+
|
29
|
+
def inject_files
|
30
|
+
inject_icon
|
31
|
+
inject_config
|
32
|
+
end
|
33
|
+
|
34
|
+
def inject_config
|
35
|
+
plist = tmp_app_path.join 'Contents/Info.plist'
|
36
|
+
template = Plist.parse_xml(plist)
|
37
|
+
template['CFBundleIdentifier'] = "com.hackety.shoes.#{config.shortname}"
|
38
|
+
template['CFBundleDisplayName'] = config.name
|
39
|
+
template['CFBundleName'] = config.name
|
40
|
+
template['CFBundleVersion'] = config.version
|
41
|
+
template['CFBundleIconFile'] = Pathname.new(config.icons[:osx]).basename.to_s if config.icons[:osx]
|
42
|
+
File.open(plist, 'w') { |f| f.write template.to_plist }
|
43
|
+
end
|
44
|
+
|
45
|
+
def inject_icon
|
46
|
+
if config.icons[:osx]
|
47
|
+
icon_path = working_dir.join(config.icons[:osx])
|
48
|
+
raise IOError, "Couldn't find app icon at #{icon_path}" unless icon_path.exist?
|
49
|
+
resources_dir = tmp_app_path.join('Contents/Resources')
|
50
|
+
cp icon_path, resources_dir.join(icon_path.basename)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def after_moved
|
55
|
+
executable_path.chmod 0755
|
56
|
+
end
|
57
|
+
|
58
|
+
def executable_path
|
59
|
+
app_path.join('Contents/MacOS/app')
|
60
|
+
end
|
61
|
+
|
62
|
+
def tmp_app_path
|
63
|
+
tmp.join "#{template_basename}"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/lib/furoshiki/version.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'furoshiki/base_app'
|
2
|
+
|
3
|
+
module Furoshiki
|
4
|
+
class WindowsApp < BaseApp
|
5
|
+
private
|
6
|
+
|
7
|
+
def app_name
|
8
|
+
"#{config.name}-windows"
|
9
|
+
end
|
10
|
+
|
11
|
+
def template_basename
|
12
|
+
'windows-app-template'
|
13
|
+
end
|
14
|
+
|
15
|
+
def latest_template_version
|
16
|
+
'0.0.1'
|
17
|
+
end
|
18
|
+
|
19
|
+
def remote_template_url
|
20
|
+
"https://github.com/shoes/windows-app-templates/releases/download/v#{latest_template_version}/windows-app-template-#{latest_template_version}.zip"
|
21
|
+
end
|
22
|
+
|
23
|
+
def inject_jar
|
24
|
+
jar_path = ensure_jar_exists
|
25
|
+
cp Pathname.new(jar_path), File.join(tmp_app_path, "app.jar")
|
26
|
+
end
|
27
|
+
|
28
|
+
def after_built
|
29
|
+
mv File.join(tmp_app_path, "app.bat"), File.join(tmp_app_path, "#{config.name}.bat")
|
30
|
+
end
|
31
|
+
|
32
|
+
def tmp_app_path
|
33
|
+
tmp.join "#{template_basename}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/furoshiki.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: furoshiki
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Team Shoes
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-06-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,7 +109,8 @@ dependencies:
|
|
109
109
|
- - ">="
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
|
-
description: Create .app, .exe, and $LINUX_PACKAGE versions of your application, with
|
112
|
+
description: Create .app, .exe, and $LINUX_PACKAGE versions of your application, with
|
113
|
+
its own embedded Ruby.
|
113
114
|
email: shoes@lists.mvmanila.com
|
114
115
|
executables: []
|
115
116
|
extensions: []
|
@@ -117,14 +118,17 @@ extra_rdoc_files: []
|
|
117
118
|
files:
|
118
119
|
- LICENSE
|
119
120
|
- lib/furoshiki.rb
|
121
|
+
- lib/furoshiki/base_app.rb
|
120
122
|
- lib/furoshiki/configuration.rb
|
121
123
|
- lib/furoshiki/exceptions.rb
|
122
124
|
- lib/furoshiki/jar.rb
|
123
|
-
- lib/furoshiki/
|
125
|
+
- lib/furoshiki/linux_app.rb
|
126
|
+
- lib/furoshiki/mac_app.rb
|
124
127
|
- lib/furoshiki/util.rb
|
125
128
|
- lib/furoshiki/validator.rb
|
126
129
|
- lib/furoshiki/version.rb
|
127
130
|
- lib/furoshiki/warbler_extensions.rb
|
131
|
+
- lib/furoshiki/windows_app.rb
|
128
132
|
- lib/furoshiki/zip.rb
|
129
133
|
- lib/furoshiki/zip/directory.rb
|
130
134
|
- lib/furoshiki/zip/directory_contents.rb
|
@@ -150,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
154
|
version: '0'
|
151
155
|
requirements: []
|
152
156
|
rubyforge_project:
|
153
|
-
rubygems_version: 2.6.
|
157
|
+
rubygems_version: 2.6.11
|
154
158
|
signing_key:
|
155
159
|
specification_version: 4
|
156
160
|
summary: Package and distribute applications with Ruby.
|