firefox_zip 0.0.1 → 0.0.2
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/Gemfile +1 -2
- data/Gemfile.lock +2 -2
- data/README.md +12 -7
- data/example/example.rb +5 -0
- data/example/hello.zip +0 -0
- data/lib/firefox_zip/files/project.rb +2 -1
- data/lib/firefox_zip/parses/manifest.rb +24 -2
- data/lib/firefox_zip/version.rb +1 -1
- data/lib/firefox_zip.rb +9 -1
- data/spec/firefox_zip/files/project_spec.rb +5 -0
- data/spec/firefox_zip/parses/manifest_spec.rb +19 -1
- data/spec/firefox_zip_spec.rb +20 -0
- data/spec/test_files/hello.zip +0 -0
- data/spec/test_files/manifest.webapp +17 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12014b63f84d9c251b72bbe49c7693b50c2effaf
|
4
|
+
data.tar.gz: 3e4daccc09733fdce63d67f7e1946664ae936585
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a27b91ade5f648d670fae0b0320e5f3c7d890f3d0ce9cbe33d5f6db42a9aec7404a9e993dd1f27ed304550df8153181b2df3cea4a6390d9ce7ed3b5ce2523cf9
|
7
|
+
data.tar.gz: 3c30e3959b070667eed8073a1f5824bbc2506dedc37edc66ac03a18bc4fc12a4d2ca72f61a0ff3251ac2b78250899ff47764f61f438cc06089f854550b3c2276
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -21,13 +21,18 @@ require 'firefox_zip'
|
|
21
21
|
|
22
22
|
app = FirefoxZip.analyze('/path/to/firefox_app.zip')
|
23
23
|
|
24
|
-
app.name
|
25
|
-
app.description
|
26
|
-
app.launch_path
|
27
|
-
app.icon
|
28
|
-
app.icons
|
29
|
-
app.
|
30
|
-
app.
|
24
|
+
app.name # [String] app name
|
25
|
+
app.description # [String] app description
|
26
|
+
app.launch_path # [String] app launch path
|
27
|
+
app.icon # [File] app default icon
|
28
|
+
app.icons # [Array] app icons
|
29
|
+
app.developer # [Hash] app developer info
|
30
|
+
app.default_locale # [String] app default locale
|
31
|
+
app.locales # [Hash] app locales
|
32
|
+
app.type # [String] app type
|
33
|
+
app.permissions # [Array] app permissions
|
34
|
+
app.version # [String] app version
|
35
|
+
app.size # [Fixnum] app zip file size
|
31
36
|
```
|
32
37
|
|
33
38
|
## License
|
data/example/example.rb
CHANGED
@@ -9,4 +9,9 @@ p app.icon # [File] app default icon
|
|
9
9
|
p app.icons # [Array] app icons
|
10
10
|
p app.type # [String] app type
|
11
11
|
p app.permissions # [Array] app permissons
|
12
|
+
p app.developer # [Hash] app developer info
|
13
|
+
p app.default_locale # [String] app default locale
|
14
|
+
p app.locales # [Hash] app locales
|
15
|
+
p app.version # [String] app version
|
16
|
+
p app.size # [Fixnum] app zip file size
|
12
17
|
|
data/example/hello.zip
CHANGED
Binary file
|
@@ -4,13 +4,14 @@ require 'zip'
|
|
4
4
|
module FirefoxZip
|
5
5
|
module Files
|
6
6
|
class Project
|
7
|
-
attr_reader :manifest_data, :icon, :icons
|
7
|
+
attr_reader :manifest_data, :icon, :icons, :size
|
8
8
|
MANIFEST_FILE_NAME = 'manifest.webapp'
|
9
9
|
|
10
10
|
def initialize(zip_file_path)
|
11
11
|
return raise 'not zip file' unless File.exists? zip_file_path
|
12
12
|
|
13
13
|
@zip_file_path = zip_file_path
|
14
|
+
@size = File.size(@zip_file_path)
|
14
15
|
|
15
16
|
Dir.mktmpdir do |dir|
|
16
17
|
project_dir_name = get_root_dir_name(@zip_file_path)
|
@@ -3,7 +3,13 @@ require 'json'
|
|
3
3
|
module FirefoxZip
|
4
4
|
module Parses
|
5
5
|
class Manifest
|
6
|
-
attr_reader :name, :description, :launch_path,
|
6
|
+
attr_reader :name, :description, :launch_path,
|
7
|
+
:icons, :icon, :type, :permissions,
|
8
|
+
:developer, :locales, :default_locale,
|
9
|
+
:version
|
10
|
+
|
11
|
+
# 推奨するサイズ順に並んでる
|
12
|
+
SUPPORT_DEFAULT_ICON_SIZE = [512, 128, 60, 48, 16]
|
7
13
|
|
8
14
|
def initialize(manifest_data)
|
9
15
|
data = JSON.parse(manifest_data)
|
@@ -12,9 +18,25 @@ module FirefoxZip
|
|
12
18
|
@description = data['description']
|
13
19
|
@launch_path = data['launch_path']
|
14
20
|
@icons = data['icons']
|
15
|
-
@icon = data['icons']
|
21
|
+
@icon = get_default_icon(data['icons'])
|
16
22
|
@type = data['type']
|
17
23
|
@permissions = data['permissions']
|
24
|
+
@developer = data['developer']
|
25
|
+
@locales = data['locales']
|
26
|
+
@default_locale = data['default_locale']
|
27
|
+
@version = data['version'].to_f
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def get_default_icon(icons)
|
33
|
+
return nil if icons == nil
|
34
|
+
|
35
|
+
SUPPORT_DEFAULT_ICON_SIZE.each do |size|
|
36
|
+
return icons[size.to_s] if icons[size.to_s] != nil
|
37
|
+
end
|
38
|
+
|
39
|
+
nil
|
18
40
|
end
|
19
41
|
end
|
20
42
|
end
|
data/lib/firefox_zip/version.rb
CHANGED
data/lib/firefox_zip.rb
CHANGED
@@ -3,7 +3,10 @@ require 'firefox_zip/files/project'
|
|
3
3
|
|
4
4
|
module FirefoxZip
|
5
5
|
class << self
|
6
|
-
attr_reader :name, :description, :launch_path,
|
6
|
+
attr_reader :name, :description, :launch_path,
|
7
|
+
:icons, :icon, :type, :permissions,
|
8
|
+
:developer, :locales, :default_locale,
|
9
|
+
:version, :size
|
7
10
|
|
8
11
|
def analyze(file_path)
|
9
12
|
project = Files::Project.new(file_path)
|
@@ -14,6 +17,11 @@ module FirefoxZip
|
|
14
17
|
@icon = project.icon
|
15
18
|
@type = project.manifest_data.type
|
16
19
|
@permissions = project.manifest_data.permissions
|
20
|
+
@developer = project.manifest_data.developer
|
21
|
+
@locales = project.manifest_data.locales
|
22
|
+
@default_locale = project.manifest_data.default_locale
|
23
|
+
@version = project.manifest_data.version
|
24
|
+
@size = project.size
|
17
25
|
|
18
26
|
self
|
19
27
|
end
|
@@ -21,6 +21,11 @@ describe FirefoxZip::Files::Project do
|
|
21
21
|
expect(@project.icons.class).to eq Array
|
22
22
|
end
|
23
23
|
|
24
|
+
it 'get size' do
|
25
|
+
expect(@project.size).not_to be_nil
|
26
|
+
expect(@project.size.class).to eq Fixnum
|
27
|
+
end
|
28
|
+
|
24
29
|
it 'nil' do
|
25
30
|
expect{ FirefoxZip::Files::Project.new(File.expand_path('nil', __FILE__)) }.to raise_error
|
26
31
|
end
|
@@ -29,7 +29,7 @@ describe FirefoxZip::Parses::Manifest do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'get icon' do
|
32
|
-
expect(@manifest.icon).to eq "/icons/
|
32
|
+
expect(@manifest.icon).to eq "/icons/icon128x128.png"
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'get type' do
|
@@ -40,6 +40,24 @@ describe FirefoxZip::Parses::Manifest do
|
|
40
40
|
expect(@manifest.permissions).to match []
|
41
41
|
end
|
42
42
|
|
43
|
+
it 'get developer' do
|
44
|
+
expect(@manifest.developer).to include("name" => "henteko",
|
45
|
+
"url" => "http://henteko07.com")
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'get locales' do
|
49
|
+
expect(@manifest.locales).to include("ja" => {"name" => "test", "description" => "test"})
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'get default_locale' do
|
53
|
+
expect(@manifest.default_locale).to eq 'ja'
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'get version' do
|
57
|
+
expect(@manifest.version).to eq 1.0
|
58
|
+
expect(@manifest.version.class).to eq Float
|
59
|
+
end
|
60
|
+
|
43
61
|
it 'blank' do
|
44
62
|
expect{ FirefoxZip::Parses::Manifest.new('') }.to raise_error
|
45
63
|
end
|
data/spec/firefox_zip_spec.rb
CHANGED
@@ -33,6 +33,26 @@ describe FirefoxZip do
|
|
33
33
|
it 'get permissions' do
|
34
34
|
expect(@app.permissions).to match []
|
35
35
|
end
|
36
|
+
|
37
|
+
it 'get developer' do
|
38
|
+
expect(@app.developer).not_to be_nil
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'get locales' do
|
42
|
+
expect(@app.locales).not_to be_nil
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'get default_locale' do
|
46
|
+
expect(@app.default_locale).not_to be_nil
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'get version' do
|
50
|
+
expect(@app.version).not_to be_nil
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'get size' do
|
54
|
+
expect(@app.size).not_to be_nil
|
55
|
+
end
|
36
56
|
|
37
57
|
it 'raise' do
|
38
58
|
expect{ FirefoxZip.analyze('') }.to raise_error
|
data/spec/test_files/hello.zip
CHANGED
Binary file
|
@@ -8,6 +8,22 @@
|
|
8
8
|
"60": "/icons/icon60x60.png",
|
9
9
|
"128": "/icons/icon128x128.png"
|
10
10
|
},
|
11
|
+
"developer": {
|
12
|
+
"name": "henteko",
|
13
|
+
"url": "http://henteko07.com"
|
14
|
+
},
|
11
15
|
"type": "privileged",
|
12
|
-
"permissions": {}
|
16
|
+
"permissions": {},
|
17
|
+
"default_locale": "ja",
|
18
|
+
"locales": {
|
19
|
+
"it": {
|
20
|
+
"name": "L'Open Web",
|
21
|
+
"description": "Eccitante azione di sviluppo web open!"
|
22
|
+
},
|
23
|
+
"ja": {
|
24
|
+
"name": "test",
|
25
|
+
"description": "test"
|
26
|
+
}
|
27
|
+
},
|
28
|
+
"version": "1.0"
|
13
29
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: firefox_zip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- henteko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|