firefox_zip 0.0.3 → 0.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 516943200c8917c49eb8c6dc51bbaf8d745bf857
4
- data.tar.gz: 482cf1def220752ef19d0b769d6f188309030808
3
+ metadata.gz: 528aef293150b87023a6d499cd08a33f7e67c9c6
4
+ data.tar.gz: 9e3c271a67b3205e196b1f3895f54c0bc6389f02
5
5
  SHA512:
6
- metadata.gz: 773086705a80d6be7f4f9ab086932c8f1ee4f8e8698dfbf881fe67b633ee5164e42672feeda1a871184ae63c05138d02435fa0a9f11d7f0326addf4a26fbbc37
7
- data.tar.gz: 99fd46ee0f2671884a73fe047e649b7c03e58be74191b4668545c132f34ecdcac6304125f18ee42c53078c7f2f290a52ccbf6664f0df454548d66560029b719d
6
+ metadata.gz: 8bb52e59cd61ef65165a35b554530d1fd21cc3ab44d4b410ca37e4fa849864ef887f577aa2b4080af16c58e80c23dbba07300eeb01223cf3ae738b4d6eb3b587
7
+ data.tar.gz: 3e63ba9ff1a46b6d39d257a81c252ad123653c3a4f27422870a7470555436ea7e6821d307e23faea36eb6c112d6eeb13edd0616d3a12c29f9feedfd3e926b528
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- firefox_zip (0.0.3)
4
+ firefox_zip (0.1.0)
5
5
  rubyzip (~> 1.1)
6
6
 
7
7
  GEM
data/example/example.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'firefox_zip'
2
2
 
3
- app = FirefoxZip.analyze(File.expand_path('../hello.zip', __FILE__))
3
+ app = FirefoxZip.analyze(File.expand_path('../package.zip', __FILE__))
4
4
 
5
5
  p app.name # [String] app name
6
6
  p app.description # [String] app description
Binary file
@@ -14,25 +14,18 @@ module FirefoxZip
14
14
  @size = File.size(@zip_file_path)
15
15
 
16
16
  Dir.mktmpdir do |dir|
17
- project_dir_name = get_root_dir_name(@zip_file_path)
18
17
  make_zip_files(@zip_file_path, dir)
19
18
 
20
- manifest_file = get_manifest_file(dir, project_dir_name)
19
+ manifest_file = get_manifest_file(dir)
21
20
  @manifest_data = FirefoxZip::Parses::Manifest.new(manifest_file.read)
22
21
  manifest_file.close
23
- @icons = get_icons_file(@manifest_data, dir, project_dir_name)
24
- @icon = get_icon_file(@manifest_data, dir, project_dir_name)
22
+ @icons = get_icons_file(@manifest_data, dir)
23
+ @icon = get_icon_file(@manifest_data, dir)
25
24
  end
26
25
  end
27
26
 
28
27
  private
29
28
 
30
- def get_root_dir_name(file_path)
31
- Zip::File.open(file_path) do |zip_file|
32
- return zip_file.first.name
33
- end
34
- end
35
-
36
29
  def make_zip_files(file_path, dir)
37
30
  Zip::File.open(file_path) do |zip_file|
38
31
  zip_file.each do |entry|
@@ -55,15 +48,15 @@ module FirefoxZip
55
48
  entry_name.match(/.+\/$/) != nil
56
49
  end
57
50
 
58
- def get_manifest_file(dir, project_dir_name)
59
- File.open("#{dir}/#{project_dir_name}/#{MANIFEST_FILE_NAME}", 'r')
51
+ def get_manifest_file(dir)
52
+ File.open("#{dir}/#{MANIFEST_FILE_NAME}", 'r')
60
53
  end
61
54
 
62
- def get_icon_file(manifest_data, dir, project_dir_name)
63
- get_file(dir, project_dir_name, manifest_data.icon)
55
+ def get_icon_file(manifest_data, dir)
56
+ get_file(dir, manifest_data.icon)
64
57
  end
65
58
 
66
- def get_icons_file(manifest_data, dir, project_dir_name)
59
+ def get_icons_file(manifest_data, dir)
67
60
  icons = manifest_data.icons
68
61
 
69
62
  icons_file = []
@@ -74,15 +67,15 @@ module FirefoxZip
74
67
 
75
68
  icons_file.push({
76
69
  :size => icon_size,
77
- :file => get_file(dir, project_dir_name, icon_file_name)
70
+ :file => get_file(dir, icon_file_name)
78
71
  })
79
72
  end
80
73
 
81
74
  icons_file
82
75
  end
83
76
 
84
- def get_file(dir, project_dir_name, target_file_name)
85
- File.open("#{dir}/#{project_dir_name}#{target_file_name}", 'r')
77
+ def get_file(dir, target_file_name)
78
+ File.open("#{dir}/#{target_file_name}", 'r')
86
79
  end
87
80
  end
88
81
  end
@@ -1,3 +1,3 @@
1
1
  module FirefoxZip
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe FirefoxZip::Files::Project do
4
4
  context 'initialize' do
5
5
  before do
6
- @project = FirefoxZip::Files::Project.new(File.expand_path('../../../test_files/hello.zip', __FILE__))
6
+ @project = FirefoxZip::Files::Project.new(File.expand_path('../../../test_files/package.zip', __FILE__))
7
7
  end
8
8
 
9
9
  it 'get manifest data' do
@@ -33,7 +33,7 @@ describe FirefoxZip::Parses::Manifest do
33
33
  end
34
34
 
35
35
  it 'get type' do
36
- expect(@manifest.type).to eq 'privileged'
36
+ expect(@manifest.type).to eq 'web'
37
37
  end
38
38
 
39
39
  it 'get permissions' do
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe FirefoxZip do
4
4
  context 'self.analyze' do
5
5
  before do
6
- @app = FirefoxZip.analyze(File.expand_path('../test_files/hello.zip', __FILE__))
6
+ @app = FirefoxZip.analyze(File.expand_path('../test_files/package.zip', __FILE__))
7
7
  end
8
8
 
9
9
  it 'get name' do
@@ -27,7 +27,7 @@ describe FirefoxZip do
27
27
  end
28
28
 
29
29
  it 'get type' do
30
- expect(@app.type).to eq 'privileged'
30
+ expect(@app.type).to eq 'web'
31
31
  end
32
32
 
33
33
  it 'get permissions' do
@@ -12,7 +12,7 @@
12
12
  "name": "henteko",
13
13
  "url": "http://henteko07.com"
14
14
  },
15
- "type": "privileged",
15
+ "type": "web",
16
16
  "permissions": {},
17
17
  "default_locale": "ja",
18
18
  "locales": {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: firefox_zip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - henteko
@@ -65,7 +65,7 @@ files:
65
65
  - README.md
66
66
  - Rakefile
67
67
  - example/example.rb
68
- - example/hello.zip
68
+ - example/package.zip
69
69
  - firefox_zip.gemspec
70
70
  - lib/firefox_zip.rb
71
71
  - lib/firefox_zip/files/project.rb
@@ -75,8 +75,8 @@ files:
75
75
  - spec/firefox_zip/parses/manifest_spec.rb
76
76
  - spec/firefox_zip_spec.rb
77
77
  - spec/spec_helper.rb
78
- - spec/test_files/hello.zip
79
78
  - spec/test_files/manifest.webapp
79
+ - spec/test_files/package.zip
80
80
  homepage: https://github.com/henteko/firefox_zip
81
81
  licenses:
82
82
  - MIT
@@ -106,5 +106,5 @@ test_files:
106
106
  - spec/firefox_zip/parses/manifest_spec.rb
107
107
  - spec/firefox_zip_spec.rb
108
108
  - spec/spec_helper.rb
109
- - spec/test_files/hello.zip
110
109
  - spec/test_files/manifest.webapp
110
+ - spec/test_files/package.zip