firebrew 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/firebrew.gemspec +1 -0
- data/lib/firebrew/firefox/extension.rb +29 -6
- data/lib/firebrew/version.rb +1 -1
- data/spec/firebrew/firefox/extension_spec.rb +113 -14
- data/spec/fixtures/firefox/extension/extensions.v16.json +2 -2
- data/spec/fixtures/firefox/extension/extensions_added_hoge.v16.json +3 -2
- data/spec/fixtures/firefox/extension/unpack_false.xpi +0 -0
- data/spec/fixtures/firefox/extension/unpack_null.xpi +0 -0
- data/spec/fixtures/firefox/extension/unpack_true.md5 +3 -0
- data/spec/fixtures/firefox/extension/unpack_true.xpi +0 -0
- metadata +24 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64ff3a699d6eb6038ac49fad26c13ea38d20f9b7
|
4
|
+
data.tar.gz: ead1c868230eee2dc80afe8595f17430715978f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4fe6fbb93d9127d839c7917cd44ed6cf688e676d39d98933a2793c9464fc43452785463c3ba85bbcfc53998e530feeb1d6f3bc7d9c34835caa1ef8057c7b550
|
7
|
+
data.tar.gz: 83bd15df6e84aff5f351f2fdfdb9b16956bfcb385eaa5982b7597f204108e4991408973d71b88aecb324414bcc38ae7bc7017efaaca687cfb1703c7c34e409b4
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [0.1.3](https://github.com/mrk21/firebrew/tree/v0.1.3) - 2014-08-19
|
4
|
+
|
5
|
+
* Bugfix [#24](https://github.com/mrk21/firebrew/issues/24): When the `em:unpack` value of the install manifests was true, is unable to normally installing
|
6
|
+
|
3
7
|
## [0.1.2](https://github.com/mrk21/firebrew/tree/v0.1.2) - 2014-08-15
|
4
8
|
|
5
9
|
* Bugfix [#23](https://github.com/mrk21/firebrew/issues/23): If the `install` element of the extension which was got by the generic AMO API was equal or greater than two, then occurs errors
|
data/firebrew.gemspec
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'open-uri'
|
3
3
|
require 'json'
|
4
|
+
require 'zip'
|
5
|
+
require 'rexml/document'
|
4
6
|
require 'firebrew/firefox/basic_extension'
|
5
7
|
|
6
8
|
module Firebrew::Firefox
|
@@ -22,7 +24,7 @@ module Firebrew::Firefox
|
|
22
24
|
name: extension['defaultLocale']['name'],
|
23
25
|
guid: extension['id'],
|
24
26
|
version: extension['version'],
|
25
|
-
uri:
|
27
|
+
uri: extension['descriptor'],
|
26
28
|
}, self)
|
27
29
|
end
|
28
30
|
end
|
@@ -40,11 +42,31 @@ module Firebrew::Firefox
|
|
40
42
|
def install(extension)
|
41
43
|
dir = File.join(self.profile.path, 'extensions')
|
42
44
|
FileUtils.mkdir_p dir
|
43
|
-
install_path = '%s.xpi' % File.join(dir, extension.guid)
|
44
45
|
|
45
|
-
open([extension.uri].flatten.first, 'rb') do |
|
46
|
-
open(
|
47
|
-
|
46
|
+
open([extension.uri].flatten.first, 'rb') do |r|
|
47
|
+
xpi = Zip::File.open(r)
|
48
|
+
install_manifests = xpi.find_entry('install.rdf')
|
49
|
+
install_manifests = install_manifests.get_input_stream.read
|
50
|
+
install_manifests = REXML::Document.new(install_manifests)
|
51
|
+
is_unpacking = REXML::XPath.match(install_manifests, '/RDF/Description/em:unpack/text()').first
|
52
|
+
is_unpacking = is_unpacking.nil? ? false : is_unpacking.value.strip == 'true'
|
53
|
+
|
54
|
+
if is_unpacking then
|
55
|
+
extension.uri = File.join(dir, extension.guid)
|
56
|
+
FileUtils.mkdir_p(extension.uri)
|
57
|
+
xpi.each do |entry|
|
58
|
+
next if entry.ftype == :directory
|
59
|
+
content = entry.get_input_stream.read
|
60
|
+
Dir.chdir(extension.uri) do
|
61
|
+
FileUtils.mkdir_p File.dirname(entry.name)
|
62
|
+
File.write(entry.name, content)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
else
|
66
|
+
extension.uri = '%s.xpi' % File.join(dir, extension.guid)
|
67
|
+
open(extension.uri, 'wb') do |w|
|
68
|
+
w.write r.read
|
69
|
+
end
|
48
70
|
end
|
49
71
|
end
|
50
72
|
|
@@ -53,7 +75,7 @@ module Firebrew::Firefox
|
|
53
75
|
end
|
54
76
|
|
55
77
|
def uninstall(extension)
|
56
|
-
FileUtils.
|
78
|
+
FileUtils.rm_rf extension.uri
|
57
79
|
self.remove(extension)
|
58
80
|
self.push
|
59
81
|
end
|
@@ -83,6 +105,7 @@ module Firebrew::Firefox
|
|
83
105
|
'id'=> extension.guid,
|
84
106
|
'location'=> 'app-profile',
|
85
107
|
'version'=> extension.version,
|
108
|
+
'descriptor'=> extension.uri,
|
86
109
|
'defaultLocale'=> {
|
87
110
|
'name'=> extension.name
|
88
111
|
}
|
data/lib/firebrew/version.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'fileutils'
|
3
|
+
require 'digest/md5'
|
3
4
|
|
4
5
|
module Firebrew::Firefox
|
5
6
|
describe Firebrew::Firefox::Extension do
|
6
7
|
let(:manager) do
|
7
8
|
Extension::Manager.new(
|
8
9
|
profile: Profile.new(
|
9
|
-
path: '
|
10
|
+
path: File.join(Dir.pwd, 'tmp')
|
10
11
|
)
|
11
12
|
)
|
12
13
|
end
|
@@ -16,18 +17,19 @@ module Firebrew::Firefox
|
|
16
17
|
name: 'Japanese Language Pack',
|
17
18
|
guid: 'langpack-ja@firefox.mozilla.org',
|
18
19
|
version: '30.0',
|
19
|
-
uri: '
|
20
|
+
uri: File.join(Dir.pwd, 'tmp/extensions/langpack-ja@firefox.mozilla.org.xpi')
|
20
21
|
}, self.manager),
|
21
22
|
Extension.new({
|
22
23
|
name: 'Vimperator',
|
23
24
|
guid: 'vimperator@mozdev.org',
|
24
25
|
version: '3.8.2',
|
25
|
-
uri: '
|
26
|
+
uri: File.join(Dir.pwd, 'tmp/extensions/vimperator@mozdev.org.xpi')
|
26
27
|
}, self.manager)
|
27
28
|
]}
|
28
29
|
|
29
30
|
before do
|
30
|
-
|
31
|
+
json = File.read('./spec/fixtures/firefox/extension/extensions.v16.json')
|
32
|
+
File.write('./tmp/extensions.json', json % {profile_path: self.manager.profile.path})
|
31
33
|
end
|
32
34
|
|
33
35
|
describe :Manager do
|
@@ -92,21 +94,24 @@ module Firebrew::Firefox
|
|
92
94
|
let(:extension) do
|
93
95
|
Extension.new({
|
94
96
|
guid: 'hoge@example.org',
|
95
|
-
uri: '
|
97
|
+
uri: File.join(Dir.pwd, 'spec/fixtures/firefox/extension/unpack_false.xpi')
|
96
98
|
}, self.manager)
|
97
99
|
end
|
98
100
|
|
99
|
-
|
101
|
+
let(:expected_path) do
|
102
|
+
File.join(self.instance.profile.path, 'extensions/%s.xpi' % self.extension.guid)
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'should copy the `path/to/profile/extensions/<GUID>.xpi`' do
|
100
106
|
subject
|
101
|
-
|
102
|
-
expect(File.exists? path).to be_truthy
|
107
|
+
expect(File.exists? self.expected_path).to be_truthy
|
103
108
|
end
|
104
109
|
|
105
110
|
it 'should add the `extension` extension' do
|
106
111
|
subject
|
107
112
|
all = self.instance.all
|
108
113
|
extension = self.extension
|
109
|
-
extension.uri = '
|
114
|
+
extension.uri = File.join(Dir.pwd, 'tmp/extensions/hoge@example.org.xpi')
|
110
115
|
expect(all.size).to eq(3)
|
111
116
|
expect(all[0]).to eq(self.extensions[0])
|
112
117
|
expect(all[1]).to eq(self.extensions[1])
|
@@ -118,8 +123,8 @@ module Firebrew::Firefox
|
|
118
123
|
Extension.new({
|
119
124
|
guid: 'hoge@example.org',
|
120
125
|
uri: [
|
121
|
-
'
|
122
|
-
'
|
126
|
+
File.join(Dir.pwd, 'spec/fixtures/firefox/extension/unpack_false.xpi'),
|
127
|
+
File.join(Dir.pwd, 'spec/fixtures/firefox/extension/not_exists.xpi'),
|
123
128
|
]
|
124
129
|
}, self.manager)
|
125
130
|
end
|
@@ -128,19 +133,89 @@ module Firebrew::Firefox
|
|
128
133
|
expect{subject}.to_not raise_error
|
129
134
|
end
|
130
135
|
end
|
136
|
+
|
137
|
+
context 'when an `em:unpack` value of the `install.rdf` in the XPI package not exsisted' do
|
138
|
+
let(:extension) do
|
139
|
+
Extension.new({
|
140
|
+
guid: 'hoge@example.org',
|
141
|
+
uri: File.join(Dir.pwd, 'spec/fixtures/firefox/extension/unpack_null.xpi')
|
142
|
+
}, self.manager)
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'should copy the `path/to/profile/extensions/<GUID>.xpi`' do
|
146
|
+
subject
|
147
|
+
expect(File.exists? self.expected_path).to be_truthy
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'should add the `extension` extension' do
|
151
|
+
subject
|
152
|
+
all = self.instance.all
|
153
|
+
extension = self.extension
|
154
|
+
extension.uri = File.join(Dir.pwd, 'tmp/extensions/hoge@example.org.xpi')
|
155
|
+
expect(all.size).to eq(3)
|
156
|
+
expect(all[0]).to eq(self.extensions[0])
|
157
|
+
expect(all[1]).to eq(self.extensions[1])
|
158
|
+
expect(all[2]).to eq(self.extension)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
context 'when an `em:unpack` value of the `install.rdf` in the XPI package was true' do
|
163
|
+
let(:extension) do
|
164
|
+
Extension.new({
|
165
|
+
guid: 'hoge@example.org',
|
166
|
+
uri: './spec/fixtures/firefox/extension/unpack_true.xpi'
|
167
|
+
}, self.manager)
|
168
|
+
end
|
169
|
+
|
170
|
+
let(:expected_path) do
|
171
|
+
File.join(self.instance.profile.path, 'extensions/%s' % self.extension.guid)
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'should copy the `path/to/profile/extensions/<GUID>`' do
|
175
|
+
subject
|
176
|
+
expect(File.exists? self.expected_path).to be_truthy
|
177
|
+
end
|
178
|
+
|
179
|
+
it 'should unzip all files in the XPI package' do
|
180
|
+
subject
|
181
|
+
md5list = File.read('./spec/fixtures/firefox/extension/unpack_true.md5')
|
182
|
+
Dir.chdir(self.expected_path) do
|
183
|
+
md5list.each_line do |item|
|
184
|
+
md5, path = item.split(/\s+/)
|
185
|
+
expect(Digest::MD5.hexdigest(File.read path)).to eq(md5)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
it 'should add the `extension` extension' do
|
191
|
+
subject
|
192
|
+
all = self.instance.all
|
193
|
+
extension = self.extension
|
194
|
+
extension.uri = File.join(Dir.pwd, 'tmp/extensions/hoge@example.org')
|
195
|
+
expect(all.size).to eq(3)
|
196
|
+
expect(all[0]).to eq(self.extensions[0])
|
197
|
+
expect(all[1]).to eq(self.extensions[1])
|
198
|
+
expect(all[2]).to eq(self.extension)
|
199
|
+
end
|
200
|
+
end
|
131
201
|
end
|
132
202
|
|
133
203
|
describe '#uninstall(extension)' do
|
134
204
|
let(:extension) do
|
135
205
|
Extension.new({
|
136
206
|
guid: 'hoge@example.org',
|
137
|
-
uri: '
|
207
|
+
uri: File.join(Dir.pwd, 'tmp/extensions/hoge@example.org.xpi')
|
138
208
|
}, self.manager)
|
139
209
|
end
|
140
210
|
|
141
|
-
|
142
|
-
FileUtils.cp('./spec/fixtures/firefox/extension/extensions_added_hoge.v16.json', './tmp/extensions.json')
|
211
|
+
let(:create_xpi_block){->{
|
143
212
|
File.write self.extension.uri, ''
|
213
|
+
}}
|
214
|
+
|
215
|
+
before do
|
216
|
+
json = File.read('./spec/fixtures/firefox/extension/extensions_added_hoge.v16.json')
|
217
|
+
File.write('./tmp/extensions.json', json % {profile_path: self.manager.profile.path})
|
218
|
+
self.create_xpi_block[]
|
144
219
|
self.manager.uninstall(self.extension)
|
145
220
|
end
|
146
221
|
|
@@ -154,6 +229,30 @@ module Firebrew::Firefox
|
|
154
229
|
expect(all[0]).to eq(self.extensions[0])
|
155
230
|
expect(all[1]).to eq(self.extensions[1])
|
156
231
|
end
|
232
|
+
|
233
|
+
context 'when `em:unpack` value of the `install.rdf` in the `extension` was true' do
|
234
|
+
let(:extension) do
|
235
|
+
Extension.new({
|
236
|
+
guid: 'hoge@example.org',
|
237
|
+
uri: File.join(Dir.pwd, 'tmp/extensions/hoge@example.org')
|
238
|
+
}, self.manager)
|
239
|
+
end
|
240
|
+
|
241
|
+
let(:create_xpi_block){->{
|
242
|
+
FileUtils.mkdir_p self.extension.uri
|
243
|
+
}}
|
244
|
+
|
245
|
+
it 'should remove the `extension` file' do
|
246
|
+
expect(File.exists? self.extension.uri).to be_falsey
|
247
|
+
end
|
248
|
+
|
249
|
+
it 'should remove the `extension` extension' do
|
250
|
+
all = self.instance.all
|
251
|
+
expect(all.size).to eq(2)
|
252
|
+
expect(all[0]).to eq(self.extensions[0])
|
253
|
+
expect(all[1]).to eq(self.extensions[1])
|
254
|
+
end
|
255
|
+
end
|
157
256
|
end
|
158
257
|
end
|
159
258
|
|
@@ -147,7 +147,7 @@
|
|
147
147
|
"active": true,
|
148
148
|
"userDisabled": false,
|
149
149
|
"appDisabled": false,
|
150
|
-
"descriptor": "/
|
150
|
+
"descriptor": "%{profile_path}/extensions/langpack-ja@firefox.mozilla.org.xpi",
|
151
151
|
"installDate": 1404466078000,
|
152
152
|
"updateDate": 1404626257000,
|
153
153
|
"applyBackgroundUpdates": 1,
|
@@ -197,7 +197,7 @@
|
|
197
197
|
"active": true,
|
198
198
|
"userDisabled": false,
|
199
199
|
"appDisabled": false,
|
200
|
-
"descriptor": "/
|
200
|
+
"descriptor": "%{profile_path}/extensions/vimperator@mozdev.org.xpi",
|
201
201
|
"installDate": 1404474084000,
|
202
202
|
"updateDate": 1404617815000,
|
203
203
|
"applyBackgroundUpdates": 1,
|
@@ -147,7 +147,7 @@
|
|
147
147
|
"active": true,
|
148
148
|
"userDisabled": false,
|
149
149
|
"appDisabled": false,
|
150
|
-
"descriptor": "/
|
150
|
+
"descriptor": "%{profile_path}/extensions/langpack-ja@firefox.mozilla.org.xpi",
|
151
151
|
"installDate": 1404466078000,
|
152
152
|
"updateDate": 1404626257000,
|
153
153
|
"applyBackgroundUpdates": 1,
|
@@ -197,7 +197,7 @@
|
|
197
197
|
"active": true,
|
198
198
|
"userDisabled": false,
|
199
199
|
"appDisabled": false,
|
200
|
-
"descriptor": "/
|
200
|
+
"descriptor": "%{profile_path}/extensions/vimperator@mozdev.org.xpi",
|
201
201
|
"installDate": 1404474084000,
|
202
202
|
"updateDate": 1404617815000,
|
203
203
|
"applyBackgroundUpdates": 1,
|
@@ -226,6 +226,7 @@
|
|
226
226
|
{
|
227
227
|
"id": "hoge@example.org",
|
228
228
|
"location": "app-profile",
|
229
|
+
"descriptor": "%{profile_path}/extensions/hoge@example.org.xpi",
|
229
230
|
"version": null,
|
230
231
|
"defaultLocale": {
|
231
232
|
"name": null
|
Binary file
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: firebrew
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuichi Murata
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '2.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubyzip
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.1'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.1'
|
111
125
|
description: Firefox add-ons manager for CUI.
|
112
126
|
email:
|
113
127
|
- mrk21info+rubygems@gmail.com
|
@@ -151,6 +165,10 @@ files:
|
|
151
165
|
- spec/fixtures/amo_api/search/single.xml
|
152
166
|
- spec/fixtures/firefox/extension/extensions.v16.json
|
153
167
|
- spec/fixtures/firefox/extension/extensions_added_hoge.v16.json
|
168
|
+
- spec/fixtures/firefox/extension/unpack_false.xpi
|
169
|
+
- spec/fixtures/firefox/extension/unpack_null.xpi
|
170
|
+
- spec/fixtures/firefox/extension/unpack_true.md5
|
171
|
+
- spec/fixtures/firefox/extension/unpack_true.xpi
|
154
172
|
- spec/fixtures/firefox/profile/base.ini
|
155
173
|
- spec/fixtures/firefox/profile/empty.ini
|
156
174
|
- spec/spec_helper.rb
|
@@ -194,6 +212,10 @@ test_files:
|
|
194
212
|
- spec/fixtures/amo_api/search/single.xml
|
195
213
|
- spec/fixtures/firefox/extension/extensions.v16.json
|
196
214
|
- spec/fixtures/firefox/extension/extensions_added_hoge.v16.json
|
215
|
+
- spec/fixtures/firefox/extension/unpack_false.xpi
|
216
|
+
- spec/fixtures/firefox/extension/unpack_null.xpi
|
217
|
+
- spec/fixtures/firefox/extension/unpack_true.md5
|
218
|
+
- spec/fixtures/firefox/extension/unpack_true.xpi
|
197
219
|
- spec/fixtures/firefox/profile/base.ini
|
198
220
|
- spec/fixtures/firefox/profile/empty.ini
|
199
221
|
- spec/spec_helper.rb
|