firefox_zip 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 528aef293150b87023a6d499cd08a33f7e67c9c6
4
- data.tar.gz: 9e3c271a67b3205e196b1f3895f54c0bc6389f02
3
+ metadata.gz: ade035f1d03dcbcb9921977812575da95b04f93a
4
+ data.tar.gz: dfab4f23fb0d4fd3d3880b7173fdeb8ba5e1e4e6
5
5
  SHA512:
6
- metadata.gz: 8bb52e59cd61ef65165a35b554530d1fd21cc3ab44d4b410ca37e4fa849864ef887f577aa2b4080af16c58e80c23dbba07300eeb01223cf3ae738b4d6eb3b587
7
- data.tar.gz: 3e63ba9ff1a46b6d39d257a81c252ad123653c3a4f27422870a7470555436ea7e6821d307e23faea36eb6c112d6eeb13edd0616d3a12c29f9feedfd3e926b528
6
+ metadata.gz: 998521c5d0e4f8204f96badb83803fd95cb6c1011f72976dad78c173f6860166171b3d3ae9c68baad487538cfd01570e16c60802b641cc45caacc0ab71f55287
7
+ data.tar.gz: b142c9980a75e7beec137da7ebfbdfee93fbbe04b1c224f919c9564ea36ab06d3ba898657fb5532edbde8effe0bbb769230b06c471992efe263ef1b826d18048
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- firefox_zip (0.1.0)
4
+ firefox_zip (0.2.0)
5
5
  rubyzip (~> 1.1)
6
+ systemu (~> 2.6)
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
@@ -22,6 +23,7 @@ GEM
22
23
  rspec-support (~> 3.1.0)
23
24
  rspec-support (3.1.2)
24
25
  rubyzip (1.1.6)
26
+ systemu (2.6.4)
25
27
 
26
28
  PLATFORMS
27
29
  ruby
data/README.md CHANGED
@@ -19,7 +19,7 @@ $ bundle install
19
19
  ```rb
20
20
  require 'firefox_zip'
21
21
 
22
- app = FirefoxZip.analyze('/path/to/firefox_app.zip')
22
+ app = FirefoxZip.analyze('/path/to/firefox_app.zip', valid: true) # valid default false
23
23
 
24
24
  app.name # [String] app name
25
25
  app.description # [String] app description
@@ -37,5 +37,8 @@ app.size # [Fixnum] app zip file size
37
37
  app.to_hash # [Hash] app info to hash
38
38
  ```
39
39
 
40
+ ## Validation
41
+ Use [app-validator](https://github.com/mozilla/app-validator) tool.
42
+
40
43
  ## License
41
44
  MIT
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.require_paths = ["lib"]
18
18
 
19
19
  s.add_runtime_dependency 'rubyzip', '~> 1.1'
20
+ s.add_runtime_dependency 'systemu', '~> 2.6'
20
21
  s.add_development_dependency 'rake', '~> 10.4'
21
22
  s.add_development_dependency 'rspec', '~> 3.1'
22
23
  end
@@ -1,5 +1,6 @@
1
1
  require 'firefox_zip/parses/manifest'
2
2
  require 'firefox_zip/files/project'
3
+ require 'firefox_zip/valid'
3
4
 
4
5
  module FirefoxZip
5
6
  class << self
@@ -8,7 +9,9 @@ module FirefoxZip
8
9
  :developer, :locales, :default_locale,
9
10
  :version, :size
10
11
 
11
- def analyze(file_path)
12
+ def analyze(file_path, option={})
13
+ valid = option[:valid] != nil ? option[:valid] : false
14
+
12
15
  @project = Files::Project.new(file_path)
13
16
  @name = @project.manifest_data.name
14
17
  @description = @project.manifest_data.description
@@ -23,6 +26,8 @@ module FirefoxZip
23
26
  @version = @project.manifest_data.version
24
27
  @size = @project.size
25
28
 
29
+ FirefoxZip::Valid.run(file_path) if valid
30
+
26
31
  self
27
32
  end
28
33
 
@@ -0,0 +1,17 @@
1
+ require 'systemu'
2
+ require 'json'
3
+
4
+ module FirefoxZip
5
+ class Valid
6
+ def self.run(zip_file_path)
7
+ return raise 'not zip file' unless File.exists? zip_file_path
8
+
9
+ status, stdout, stderr = systemu "app-validator #{zip_file_path} -o json"
10
+
11
+ raise 'Not run validation error' if status.exitstatus != 0
12
+ result = JSON.parse(stdout)
13
+
14
+ raise "Validation error: #{result['message']}" if result['errors'] != 0
15
+ end
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module FirefoxZip
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe FirefoxZip::Valid do
4
+ context 'self.run' do
5
+ before do
6
+ @status, stdout, stderr = systemu 'app-validator --help'
7
+ end
8
+
9
+ it 'success' do
10
+ expect { FirefoxZip::Valid.run(File.expand_path('../../test_files/package.zip', __FILE__)) }.not_to raise_error if @status.exitstatus == 0
11
+ end
12
+
13
+ it 'error' do
14
+ expect { FirefoxZip::Valid.run(File.expand_path('../../test_files/error_package.zip', __FILE__)) }.to raise_error if @status.exitstatus == 0
15
+ end
16
+ end
17
+
18
+ end
@@ -70,4 +70,18 @@ describe FirefoxZip do
70
70
  expect{ FirefoxZip.analyze('') }.to raise_error
71
71
  end
72
72
  end
73
+
74
+ context 'self.analyze valid false' do
75
+ before do
76
+ @status, stdout, stderr = systemu 'app-validator --help'
77
+ end
78
+
79
+ it 'not raise error' do
80
+ expect { FirefoxZip.analyze(File.expand_path('../test_files/error_package.zip', __FILE__)) }.not_to raise_error if @status.exitstatus == 0
81
+ end
82
+
83
+ it 'raise error' do
84
+ expect { FirefoxZip.analyze(File.expand_path('../test_files/error_package.zip', __FILE__), valid: true) }.to raise_error if @status.exitstatus == 0
85
+ end
86
+ end
73
87
  end
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.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - henteko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-02 00:00:00.000000000 Z
11
+ date: 2015-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: systemu
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.6'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.6'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -70,11 +84,14 @@ files:
70
84
  - lib/firefox_zip.rb
71
85
  - lib/firefox_zip/files/project.rb
72
86
  - lib/firefox_zip/parses/manifest.rb
87
+ - lib/firefox_zip/valid.rb
73
88
  - lib/firefox_zip/version.rb
74
89
  - spec/firefox_zip/files/project_spec.rb
75
90
  - spec/firefox_zip/parses/manifest_spec.rb
91
+ - spec/firefox_zip/valid_spec.rb
76
92
  - spec/firefox_zip_spec.rb
77
93
  - spec/spec_helper.rb
94
+ - spec/test_files/error_package.zip
78
95
  - spec/test_files/manifest.webapp
79
96
  - spec/test_files/package.zip
80
97
  homepage: https://github.com/henteko/firefox_zip
@@ -104,7 +121,9 @@ summary: Firefox os app analyzer
104
121
  test_files:
105
122
  - spec/firefox_zip/files/project_spec.rb
106
123
  - spec/firefox_zip/parses/manifest_spec.rb
124
+ - spec/firefox_zip/valid_spec.rb
107
125
  - spec/firefox_zip_spec.rb
108
126
  - spec/spec_helper.rb
127
+ - spec/test_files/error_package.zip
109
128
  - spec/test_files/manifest.webapp
110
129
  - spec/test_files/package.zip