blast_off 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +4 -0
- data/blast_off.gemspec +2 -0
- data/lib/blast_off.rb +1 -0
- data/lib/blast_off/services/qiniu.rb +38 -57
- data/lib/blast_off/template.rb +41 -0
- data/lib/blast_off/template/index.html.erb +11 -5
- data/lib/blast_off/version.rb +1 -1
- data/spec/blast_off/template_spec.rb +72 -0
- metadata +33 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a6e9251f16129eb15def3ec26795df792984bec
|
4
|
+
data.tar.gz: 188ebf9f63c74820302fdfeed8aa6ee678ea559f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 063fef30610b2bb1ec3002a57cd122a3a3da1fd3c75bd81669c5e3a4558642ab90c05f7da5120d4855a37aef7043f37b80d7e11a1259dfc2fb979817eb3b4772
|
7
|
+
data.tar.gz: 1f58707ce398a963e7d41217a0ff24b66f0d9a200d0d88d0e664d9cfd155e1456c24682bf3787cb5c7081a3c06f13d6e6e2293c10031bad09b0117f363500efa
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## [v0.3.0](https://github.com/linjunpop/blast_off/tree/v0.3.0)
|
6
|
+
|
7
|
+
* Set correct file mime-types.
|
8
|
+
* Also include App short version on web page.
|
9
|
+
|
5
10
|
## [v0.2.0](https://github.com/linjunpop/blast_off/tree/v0.2.0)
|
6
11
|
|
7
12
|
* Let services' `generate` method return URL address.
|
data/README.md
CHANGED
data/blast_off.gemspec
CHANGED
@@ -21,9 +21,11 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
22
|
spec.add_development_dependency "rake"
|
23
23
|
spec.add_development_dependency "rspec", '~> 2.14'
|
24
|
+
spec.add_development_dependency "nokogiri", '~> 1.6'
|
24
25
|
|
25
26
|
spec.add_runtime_dependency 'gli','~> 2.8.1'
|
26
27
|
spec.add_runtime_dependency 'qiniu-rs', '~> 3.4.6'
|
27
28
|
spec.add_runtime_dependency 'rainbow', '~> 1.1.4'
|
28
29
|
spec.add_runtime_dependency 'ipa_reader', '~> 0.7.1'
|
30
|
+
spec.add_runtime_dependency 'CFPropertyList'
|
29
31
|
end
|
data/lib/blast_off.rb
CHANGED
@@ -9,37 +9,32 @@ module BlastOff
|
|
9
9
|
def initialize(ipa_file_path:nil, access_key:'', secret_key:'', bucket:'')
|
10
10
|
@ipa_file_path = ipa_file_path
|
11
11
|
@ipa_file = ::IpaReader::IpaFile.new(ipa_file_path)
|
12
|
-
@
|
12
|
+
@bucket = bucket
|
13
13
|
|
14
14
|
::Qiniu::RS.establish_connection!(
|
15
15
|
enable_debug: false,
|
16
16
|
access_key: access_key,
|
17
17
|
secret_key: secret_key
|
18
18
|
)
|
19
|
+
@upload_token = ::Qiniu::RS.generate_upload_token(scope: @bucket)
|
19
20
|
end
|
20
21
|
|
21
22
|
def distribute
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
ensure
|
38
|
-
html_file.close
|
39
|
-
html_file.unlink
|
40
|
-
end
|
41
|
-
|
42
|
-
upload(@ipa_file_path, "#{@ipa_file.name}.ipa")
|
23
|
+
upload_string(
|
24
|
+
template.manifest_plist("#{base_url}/#{@ipa_file.name}.ipa"),
|
25
|
+
'manifest.plist',
|
26
|
+
'application/octet-stream'
|
27
|
+
)
|
28
|
+
upload_string(
|
29
|
+
template.html("#{base_url}/manifest.plist"),
|
30
|
+
'index.html',
|
31
|
+
'text/html'
|
32
|
+
)
|
33
|
+
upload_file(
|
34
|
+
@ipa_file_path,
|
35
|
+
"#{@ipa_file.name}.ipa",
|
36
|
+
'application/octet-stream'
|
37
|
+
)
|
43
38
|
|
44
39
|
"#{base_url}/index.html"
|
45
40
|
end
|
@@ -51,48 +46,34 @@ module BlastOff
|
|
51
46
|
end
|
52
47
|
|
53
48
|
def base_url
|
54
|
-
"http://#{@
|
49
|
+
"http://#{@bucket}.qiniudn.com/#{base_path}"
|
55
50
|
end
|
56
51
|
|
57
|
-
def
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
file
|
62
|
-
|
63
|
-
|
52
|
+
def upload_string(string, key, mime_type)
|
53
|
+
file = Tempfile.new(key)
|
54
|
+
begin
|
55
|
+
file.write(string)
|
56
|
+
file.rewind
|
57
|
+
upload_file(file.path, key, mime_type)
|
58
|
+
ensure
|
59
|
+
file.close
|
60
|
+
file.unlink
|
61
|
+
end
|
64
62
|
end
|
65
63
|
|
66
|
-
def
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
],
|
75
|
-
metadata: {
|
76
|
-
'bundle-identifier' => @ipa_file.bundle_identifier,
|
77
|
-
'bundle-version' => @ipa_file.version,
|
78
|
-
kind: 'software',
|
79
|
-
title: @ipa_file.name
|
80
|
-
}
|
81
|
-
]
|
82
|
-
}.to_plist
|
64
|
+
def upload_file(filepath, key, mime_type)
|
65
|
+
::Qiniu::RS.upload_file(
|
66
|
+
uptoken: @upload_token,
|
67
|
+
file: filepath,
|
68
|
+
mime_type: mime_type,
|
69
|
+
bucket: @bucket,
|
70
|
+
key: "#{base_path}/#{key}"
|
71
|
+
)
|
83
72
|
end
|
84
73
|
|
85
|
-
def
|
86
|
-
|
87
|
-
app_name: @ipa_file.name,
|
88
|
-
app_version: @ipa_file.version,
|
89
|
-
base_url: base_url
|
90
|
-
})
|
91
|
-
template_file = File.join(File.dirname(File.expand_path(__FILE__)), '../template/index.html.erb')
|
92
|
-
|
93
|
-
::ERB.new(File.read(template_file)).result(opts.instance_eval {binding})
|
74
|
+
def template
|
75
|
+
@template ||= Template.new(@ipa_file)
|
94
76
|
end
|
95
|
-
|
96
77
|
end
|
97
78
|
end
|
98
79
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'cfpropertylist'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
module BlastOff
|
5
|
+
class Template
|
6
|
+
def initialize(ipa_file)
|
7
|
+
@ipa = ipa_file
|
8
|
+
end
|
9
|
+
|
10
|
+
def manifest_plist(ipa_file_url)
|
11
|
+
{
|
12
|
+
items: [
|
13
|
+
assets: [
|
14
|
+
{
|
15
|
+
kind: 'software-package',
|
16
|
+
url: ipa_file_url
|
17
|
+
}
|
18
|
+
],
|
19
|
+
metadata: {
|
20
|
+
'bundle-identifier' => @ipa.bundle_identifier,
|
21
|
+
'bundle-version' => @ipa.version,
|
22
|
+
kind: 'software',
|
23
|
+
title: @ipa.name
|
24
|
+
}
|
25
|
+
]
|
26
|
+
}.to_plist(plist_format: CFPropertyList::List::FORMAT_XML)
|
27
|
+
end
|
28
|
+
|
29
|
+
def html(manifest_plist_url)
|
30
|
+
opts = OpenStruct.new({
|
31
|
+
ipa: @ipa,
|
32
|
+
install_url: URI.escape(
|
33
|
+
"itms-services://?action=download-manifest&url=#{manifest_plist_url}"
|
34
|
+
)
|
35
|
+
})
|
36
|
+
template_file = File.join(File.dirname(File.expand_path(__FILE__)), 'template/index.html.erb')
|
37
|
+
|
38
|
+
::ERB.new(File.read(template_file)).result(opts.instance_eval {binding})
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -33,18 +33,24 @@
|
|
33
33
|
}
|
34
34
|
</style>
|
35
35
|
|
36
|
-
<title><%=
|
36
|
+
<title><%= ipa.name %> | <%= ipa.short_version %> (<%= ipa.version %>)</title>
|
37
37
|
</head>
|
38
38
|
|
39
39
|
<body>
|
40
40
|
<div class="container">
|
41
|
-
<h1><%=
|
42
|
-
<
|
43
|
-
<h2>Version: <%=
|
41
|
+
<h1><%= ipa.name %></h1>
|
42
|
+
<div class="qr-image"></div>
|
43
|
+
<h2>Version: <%= ipa.short_version %> (<%= ipa.version %>)</h2>
|
44
44
|
<p>
|
45
|
-
<a class="button" href="
|
45
|
+
<a class="button" href="<%= install_url %>">Install</a>
|
46
46
|
</p>
|
47
47
|
</div>
|
48
|
+
<script type="text/javascript" charset="utf-8">
|
49
|
+
var qrImageUrl = "http://api.qrserver.com/v1/create-qr-code/?size=250x250&data=" + document.URL;
|
50
|
+
var qrImageNode = document.createElement("img");
|
51
|
+
qrImageNode.src = qrImageUrl;
|
52
|
+
document.querySelector('.qr-image').appendChild(qrImageNode);
|
53
|
+
</script>
|
48
54
|
</body>
|
49
55
|
</html>
|
50
56
|
|
data/lib/blast_off/version.rb
CHANGED
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'nokogiri'
|
3
|
+
|
4
|
+
describe BlastOff::Template do
|
5
|
+
let(:ipa) {
|
6
|
+
double(
|
7
|
+
'IPA',
|
8
|
+
name: 'Foobar',
|
9
|
+
bundle_identifier: 'com.example.Foobar',
|
10
|
+
version: '2013',
|
11
|
+
short_version: '1.0.0'
|
12
|
+
)
|
13
|
+
}
|
14
|
+
let(:template) {
|
15
|
+
BlastOff::Template.new(ipa)
|
16
|
+
}
|
17
|
+
|
18
|
+
describe '#html' do
|
19
|
+
let(:doc) {
|
20
|
+
Nokogiri::HTML(template.html('http://example.com/manifest.plist'))
|
21
|
+
}
|
22
|
+
let(:expected_install_url) {
|
23
|
+
"itms-services://?action=download-manifest&url=http://example.com/manifest.plist"
|
24
|
+
}
|
25
|
+
|
26
|
+
it 'generate correct install button' do
|
27
|
+
doc.at_css('.button')['href'].should eq expected_install_url
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'generate correct version' do
|
31
|
+
doc.at_css('h2').text.should eq 'Version: 1.0.0 (2013)'
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'generate correct title' do
|
35
|
+
doc.at_css('h1').text.should eq 'Foobar'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#manifest_plist' do
|
40
|
+
let(:doc) {
|
41
|
+
Nokogiri::XML(template.manifest_plist('http://example.com/Foobar.ipa'))
|
42
|
+
}
|
43
|
+
|
44
|
+
it 'generate correct bundle-identifier' do
|
45
|
+
element = doc.
|
46
|
+
at_xpath('//key[contains(text(),"bundle-identifier")]').
|
47
|
+
next_element
|
48
|
+
element.text.should eq 'com.example.Foobar'
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'generate correct url' do
|
52
|
+
element = doc.
|
53
|
+
at_xpath('//key[contains(text(),"url")]').
|
54
|
+
next_element
|
55
|
+
element.text.should eq 'http://example.com/Foobar.ipa'
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'generate correct bundle-version' do
|
59
|
+
element = doc.
|
60
|
+
at_xpath('//key[contains(text(),"bundle-version")]').
|
61
|
+
next_element
|
62
|
+
element.text.should eq '2013'
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'generate correct title' do
|
66
|
+
element = doc.
|
67
|
+
at_xpath('//key[contains(text(),"title")]').
|
68
|
+
next_element
|
69
|
+
element.text.should eq 'Foobar'
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blast_off
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jun Lin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '2.14'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: nokogiri
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.6'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.6'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: gli
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +122,20 @@ dependencies:
|
|
108
122
|
- - ~>
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: 0.7.1
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: CFPropertyList
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
111
139
|
description: An iOS beta distribution tool.
|
112
140
|
email:
|
113
141
|
- linjunpop@gmail.com
|
@@ -129,9 +157,11 @@ files:
|
|
129
157
|
- lib/blast_off.rb
|
130
158
|
- lib/blast_off/services.rb
|
131
159
|
- lib/blast_off/services/qiniu.rb
|
160
|
+
- lib/blast_off/template.rb
|
132
161
|
- lib/blast_off/template/index.html.erb
|
133
162
|
- lib/blast_off/version.rb
|
134
163
|
- spec/blast_off/services/qiniu_spec.rb
|
164
|
+
- spec/blast_off/template_spec.rb
|
135
165
|
- spec/spec_helper.rb
|
136
166
|
homepage: https://github.com/linjunpop/blast_off
|
137
167
|
licenses:
|
@@ -159,5 +189,6 @@ specification_version: 4
|
|
159
189
|
summary: An iOS beta distribution tool.
|
160
190
|
test_files:
|
161
191
|
- spec/blast_off/services/qiniu_spec.rb
|
192
|
+
- spec/blast_off/template_spec.rb
|
162
193
|
- spec/spec_helper.rb
|
163
194
|
has_rdoc:
|