sparkle_appcast 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/sparkle_appcast/appcast.rb +5 -5
- data/lib/sparkle_appcast/archive.rb +25 -45
- data/lib/sparkle_appcast/bundle.rb +58 -0
- data/lib/sparkle_appcast/cli.rb +43 -0
- data/lib/sparkle_appcast.rb +1 -0
- metadata +8 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d53602018aca02ede32180faa6f1793ce88007cfe917f0b49dd8ff7569dbad34
|
4
|
+
data.tar.gz: 1cf9b9ac1d6674d4db17ab007da8e3ae9dd37e5ed7bd2d3f13db197358827c37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c06b95f733b14eca7e27b2d7833946758b35c6a83dc3a8200eb062c0b2844d412582b5a86aabe985d3233376348439837a5d6d33e4d947e8ba98d813437b094
|
7
|
+
data.tar.gz: ab6beee04561fc1b42490b7e1b825fcdb3ff0dfe8ae8c4649126761717dbda0d49b9379e61d25026580e421960443547bbab22c5787ad73be9e6e24ddc511041
|
data/README.md
CHANGED
@@ -65,7 +65,7 @@ The application archive file must contain exact one application bundle.
|
|
65
65
|
Default to `"The most recent changes."`.
|
66
66
|
|
67
67
|
### `sign [OPTIONS...] [FILE_PATH]`
|
68
|
-
|
68
|
+
|
69
69
|
Sign data at `FILE_PATH` or reading from the standard input with `DSA_PRIVATE_KEY_PATH`
|
70
70
|
and print signature that can be used in `appcast.xml`.
|
71
71
|
Use this for testing private key.
|
@@ -89,7 +89,7 @@ Use Ruby Gems to install `sparkle_appcast`.
|
|
89
89
|
|
90
90
|
Or use [bundler](http://bundler.io/), add next line to `Gemfile` in your project.
|
91
91
|
|
92
|
-
gem "
|
92
|
+
gem "sparkle_appcast"
|
93
93
|
|
94
94
|
|
95
95
|
SEE ALSO
|
@@ -18,21 +18,21 @@ module SparkleAppcast
|
|
18
18
|
|
19
19
|
def rss_params
|
20
20
|
{
|
21
|
-
channel_link: archive.feed_url,
|
21
|
+
channel_link: archive.bundle_info[:feed_url],
|
22
22
|
title: title,
|
23
23
|
description: release_note.html,
|
24
24
|
publish_date: archive.created_at,
|
25
25
|
url: url,
|
26
26
|
length: archive.size,
|
27
|
-
version: archive.bundle_version,
|
28
|
-
short_version_string: archive.bundle_short_version_string,
|
29
|
-
minimum_system_version: archive.minimum_system_version,
|
27
|
+
version: archive.bundle_info[:bundle_version],
|
28
|
+
short_version_string: archive.bundle_info[:bundle_short_version_string],
|
29
|
+
minimum_system_version: archive.bundle_info[:minimum_system_version],
|
30
30
|
dsa_signature: dsa_signature
|
31
31
|
}.merge(params)
|
32
32
|
end
|
33
33
|
|
34
34
|
def title
|
35
|
-
"#{archive.bundle_name} #{archive.bundle_short_version_string} (#{archive.bundle_version})"
|
35
|
+
"#{archive.bundle_info[:bundle_name]} #{archive.bundle_info[:bundle_short_version_string]} (#{archive.bundle_info[:bundle_version]})"
|
36
36
|
end
|
37
37
|
|
38
38
|
def dsa_signature
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require "tmpdir"
|
2
|
-
require "plist"
|
3
2
|
|
4
3
|
module SparkleAppcast
|
5
4
|
class Archive
|
@@ -9,26 +8,6 @@ module SparkleAppcast
|
|
9
8
|
@path = File.expand_path(path)
|
10
9
|
end
|
11
10
|
|
12
|
-
def bundle_name
|
13
|
-
info_plist["CFBundleDisplayName"] || info_plist["CFBundleName"]
|
14
|
-
end
|
15
|
-
|
16
|
-
def bundle_version
|
17
|
-
info_plist["CFBundleVersion"]
|
18
|
-
end
|
19
|
-
|
20
|
-
def bundle_short_version_string
|
21
|
-
info_plist["CFBundleShortVersionString"]
|
22
|
-
end
|
23
|
-
|
24
|
-
def minimum_system_version
|
25
|
-
info_plist["LSMinimumSystemVersion"]
|
26
|
-
end
|
27
|
-
|
28
|
-
def feed_url
|
29
|
-
info_plist["SUFeedURL"]
|
30
|
-
end
|
31
|
-
|
32
11
|
def created_at
|
33
12
|
File.birthtime(path)
|
34
13
|
end
|
@@ -41,28 +20,9 @@ module SparkleAppcast
|
|
41
20
|
File.binread(path)
|
42
21
|
end
|
43
22
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
def info_plist
|
49
|
-
@info_plist ||= Dir.mktmpdir do |tmpdir_path|
|
50
|
-
case File.basename(path)
|
51
|
-
when /\.zip\z/i
|
52
|
-
Kernel.system("/usr/bin/ditto", "-x", "-k", path, tmpdir_path)
|
53
|
-
when /\.tar\z/i
|
54
|
-
Kernel.system("/usr/bin/tar", "-x", "-f", path, "-C", tmpdir_path)
|
55
|
-
when /\.tar\.gz\z/i, /\.tgz\z/i, /\.tar\.xz\z/i, /\.txz\z/i, /\.tar\.lzma\z/i
|
56
|
-
Kernel.system("/usr/bin/tar", "-x", "-z", "-f", path, "-C", tmpdir_path)
|
57
|
-
when /\.tar\.bz2\z/i, /\.tbz\z/i
|
58
|
-
Kernel.system("/usr/bin/tar", "-x", "-j", "-f", path, "-C", tmpdir_path)
|
59
|
-
else
|
60
|
-
raise NotImplementedError.new("Disk image support is not implemented yet.")
|
61
|
-
end
|
62
|
-
|
63
|
-
unless $?.success?
|
64
|
-
raise RuntimeError.new("Failed to expand archive: #{path}")
|
65
|
-
end
|
23
|
+
def bundle_info
|
24
|
+
@bundle_info ||= Dir.mktmpdir do |tmpdir_path|
|
25
|
+
unarchive!(tmpdir_path)
|
66
26
|
|
67
27
|
app_paths = Dir.glob(File.join(tmpdir_path, "*.app"), File::FNM_CASEFOLD)
|
68
28
|
if app_paths.size == 0
|
@@ -71,10 +31,30 @@ module SparkleAppcast
|
|
71
31
|
raise RuntimeError.new("Found multiple application bundles: #{app_paths.map{|path| File.basename(path)}}")
|
72
32
|
else
|
73
33
|
app_path = app_paths.first
|
74
|
-
|
75
|
-
Plist.parse_xml(info_plist_path)
|
34
|
+
Bundle.new(app_path).info
|
76
35
|
end
|
77
36
|
end
|
78
37
|
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def unarchive!(destination_path)
|
42
|
+
case File.basename(path)
|
43
|
+
when /\.zip\z/i
|
44
|
+
Kernel.system("/usr/bin/ditto", "-x", "-k", path, destination_path)
|
45
|
+
when /\.tar\z/i
|
46
|
+
Kernel.system("/usr/bin/tar", "-x", "-f", path, "-C", destination_path)
|
47
|
+
when /\.tar\.gz\z/i, /\.tgz\z/i, /\.tar\.xz\z/i, /\.txz\z/i, /\.tar\.lzma\z/i
|
48
|
+
Kernel.system("/usr/bin/tar", "-x", "-z", "-f", path, "-C", destination_path)
|
49
|
+
when /\.tar\.bz2\z/i, /\.tbz\z/i
|
50
|
+
Kernel.system("/usr/bin/tar", "-x", "-j", "-f", path, "-C", destination_path)
|
51
|
+
else
|
52
|
+
raise NotImplementedError.new("Disk image support is not implemented yet.")
|
53
|
+
end
|
54
|
+
|
55
|
+
unless $?.success?
|
56
|
+
raise RuntimeError.new("Failed to expand archive: #{path}")
|
57
|
+
end
|
58
|
+
end
|
79
59
|
end
|
80
60
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require "plist"
|
2
|
+
|
3
|
+
module SparkleAppcast
|
4
|
+
class Bundle
|
5
|
+
INFO_KEYS = [
|
6
|
+
:bundle_name,
|
7
|
+
:bundle_version,
|
8
|
+
:bundle_short_version_string,
|
9
|
+
:minimum_system_version,
|
10
|
+
:feed_url
|
11
|
+
]
|
12
|
+
|
13
|
+
attr_reader :path
|
14
|
+
|
15
|
+
def initialize(path)
|
16
|
+
@path = File.expand_path(path)
|
17
|
+
end
|
18
|
+
|
19
|
+
def [](key)
|
20
|
+
info[key]
|
21
|
+
end
|
22
|
+
|
23
|
+
def info
|
24
|
+
@info ||= INFO_KEYS.inject({}) do |info, key|
|
25
|
+
info[key] = self.send(key)
|
26
|
+
info
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
# TODO: Support localizable string.
|
33
|
+
|
34
|
+
def bundle_name
|
35
|
+
info_plist["CFBundleDisplayName"] || info_plist["CFBundleName"]
|
36
|
+
end
|
37
|
+
|
38
|
+
def bundle_version
|
39
|
+
info_plist["CFBundleVersion"]
|
40
|
+
end
|
41
|
+
|
42
|
+
def bundle_short_version_string
|
43
|
+
info_plist["CFBundleShortVersionString"]
|
44
|
+
end
|
45
|
+
|
46
|
+
def minimum_system_version
|
47
|
+
info_plist["LSMinimumSystemVersion"]
|
48
|
+
end
|
49
|
+
|
50
|
+
def feed_url
|
51
|
+
info_plist["SUFeedURL"]
|
52
|
+
end
|
53
|
+
|
54
|
+
def info_plist
|
55
|
+
@info_plist ||= Plist.parse_xml(File.join(path, "Contents", "Info.plist"))
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/lib/sparkle_appcast/cli.rb
CHANGED
@@ -48,6 +48,49 @@ module SparkleAppcast
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
+
desc "info FILE", "Print info about the application bundle."
|
52
|
+
Bundle::INFO_KEYS.each do |key|
|
53
|
+
option key, type: :boolean, desc: "Print #{key}."
|
54
|
+
end
|
55
|
+
def info(file)
|
56
|
+
bundle_info = if File.file?(file)
|
57
|
+
Archive.new(file).bundle_info
|
58
|
+
else
|
59
|
+
Bundle.new(file).info
|
60
|
+
end
|
61
|
+
|
62
|
+
include_keys = []
|
63
|
+
exclude_keys = []
|
64
|
+
Bundle::INFO_KEYS.each do |key|
|
65
|
+
case options[key]
|
66
|
+
when nil
|
67
|
+
when true
|
68
|
+
include_keys << key
|
69
|
+
when false
|
70
|
+
exclude_keys << key
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
keys = if include_keys.empty?
|
75
|
+
Bundle::INFO_KEYS
|
76
|
+
else
|
77
|
+
include_keys
|
78
|
+
end
|
79
|
+
keys = keys - exclude_keys
|
80
|
+
|
81
|
+
if keys.count > 1
|
82
|
+
info = {}
|
83
|
+
keys.each do |key|
|
84
|
+
info[key] = bundle_info[key]
|
85
|
+
end
|
86
|
+
puts info.map{|key, value| "#{key} #{value}"}.join("\n")
|
87
|
+
else
|
88
|
+
keys.each do |key|
|
89
|
+
puts bundle_info[key]
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
51
94
|
desc "sign [FILE]", "Sign a file with a DSA private key."
|
52
95
|
option :key, type: :string, required: true, desc: "Path to a DSA private key."
|
53
96
|
def sign(file = nil)
|
data/lib/sparkle_appcast.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module SparkleAppcast
|
2
2
|
autoload :Appcast, "sparkle_appcast/appcast"
|
3
3
|
autoload :Archive, "sparkle_appcast/archive"
|
4
|
+
autoload :Bundle, "sparkle_appcast/bundle"
|
4
5
|
autoload :Cli, "sparkle_appcast/cli"
|
5
6
|
autoload :ReleaseNote, "sparkle_appcast/release_note"
|
6
7
|
autoload :Rss, "sparkle_appcast/rss"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sparkle_appcast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoshimasa Niwa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -96,13 +96,16 @@ files:
|
|
96
96
|
- lib/sparkle_appcast.rb
|
97
97
|
- lib/sparkle_appcast/appcast.rb
|
98
98
|
- lib/sparkle_appcast/archive.rb
|
99
|
+
- lib/sparkle_appcast/bundle.rb
|
99
100
|
- lib/sparkle_appcast/cli.rb
|
100
101
|
- lib/sparkle_appcast/release_note.rb
|
101
102
|
- lib/sparkle_appcast/rss.rb
|
102
103
|
- lib/sparkle_appcast/signer.rb
|
103
|
-
homepage:
|
104
|
-
licenses:
|
105
|
-
|
104
|
+
homepage: https://github.com/niw/sparkle_appcast
|
105
|
+
licenses:
|
106
|
+
- MIT
|
107
|
+
metadata:
|
108
|
+
source_code_uri: https://github.com/niw/sparkle_appcast
|
106
109
|
post_install_message:
|
107
110
|
rdoc_options: []
|
108
111
|
require_paths:
|