danger-apkstats 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +19 -1
- data/.travis.yml +18 -5
- data/Dangerfile.sample +15 -0
- data/Gemfile +3 -1
- data/Gemfile.lock +136 -0
- data/Guardfile +4 -2
- data/README.md +25 -4
- data/Rakefile +12 -10
- data/danger-apkstats.gemspec +20 -19
- data/lib/apkstats/command/apk_analyzer.rb +56 -21
- data/lib/apkstats/command/executable.rb +62 -0
- data/lib/apkstats/entity/apk_info.rb +40 -0
- data/lib/apkstats/entity/apk_info_diff.rb +67 -0
- data/lib/apkstats/entity/feature.rb +100 -0
- data/lib/apkstats/entity/permission.rb +86 -0
- data/lib/apkstats/gem_version.rb +3 -1
- data/lib/apkstats/helper/bytes.rb +65 -0
- data/lib/apkstats/plugin.rb +199 -38
- data/lib/danger_apkstats.rb +2 -0
- data/lib/danger_plugin.rb +2 -0
- data/spec/apkstats_spec.rb +4 -24
- data/spec/command/apk_analyzer_spec.rb +130 -0
- data/spec/entity/apk_info_diff_spec.rb +110 -0
- data/spec/entity/apk_info_spec.rb +49 -0
- data/spec/entity/features_spec.rb +42 -0
- data/spec/entity/permissions_spec.rb +37 -0
- data/spec/fixture/app-base.apk +0 -0
- data/spec/fixture/app-other1.apk +0 -0
- data/spec/fixture/app-other2.apk +0 -0
- data/spec/fixture/app-other3.apk +0 -0
- data/spec/fixture/app-other4.apk +0 -0
- data/spec/fixture/app-other5.apk +0 -0
- data/spec/fixture/github_pr.json +345 -0
- data/spec/helper/bytes_spec.rb +95 -0
- data/spec/spec_helper.rb +10 -2
- data/spec/stub/command.rb +20 -0
- metadata +38 -3
- data/lib/apkstats/command/executable_command.rb +0 -24
@@ -0,0 +1,95 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "../spec_helper"
|
4
|
+
|
5
|
+
module Apkstats::Helper
|
6
|
+
describe Apkstats::Helper::Bytes do
|
7
|
+
context "from_b" do
|
8
|
+
let(:byte) { Bytes.from_b(100_000) }
|
9
|
+
let(:negative_byte) { Bytes.from_b(-100_000) }
|
10
|
+
|
11
|
+
it "to_b" do
|
12
|
+
expect(byte.to_b).to be_within(0.01).of(100_000)
|
13
|
+
expect(byte.to_s_b).to eq("+#{byte.to_b}")
|
14
|
+
expect(negative_byte.to_b).to be_within(0.01).of(-100_000)
|
15
|
+
expect(negative_byte.to_s_b).to eq(negative_byte.to_b.to_s)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "to_kb" do
|
19
|
+
expect(byte.to_kb).to be_within(0.01).of((100_000 / 1024.to_f).round(2))
|
20
|
+
expect(byte.to_s_kb).to eq("+#{byte.to_kb}")
|
21
|
+
expect(negative_byte.to_kb).to be_within(0.01).of((-100_000 / 1024.to_f).round(2))
|
22
|
+
expect(negative_byte.to_s_kb).to eq(negative_byte.to_kb.to_s)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "to_mb" do
|
26
|
+
expect(byte.to_mb).to be_within(0.01).of(((100_000 / 1024.to_f).round(2) / 1024.to_f).round(2))
|
27
|
+
expect(byte.to_s_mb).to eq("+#{byte.to_mb}")
|
28
|
+
expect(negative_byte.to_mb).to be_within(0.01).of(((-100_000 / 1024.to_f).round(2) / 1024.to_f).round(2))
|
29
|
+
expect(negative_byte.to_s_mb).to eq(negative_byte.to_mb.to_s)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "from_kb" do
|
34
|
+
let(:byte) { Bytes.from_kb(1234.56) }
|
35
|
+
let(:negative_byte) { Bytes.from_kb(-1234.56) }
|
36
|
+
|
37
|
+
it "to_b" do
|
38
|
+
expect(byte.to_b).to be_within(0.01).of(1234.56 * 1024)
|
39
|
+
expect(byte.to_s_b).to eq("+#{byte.to_b}")
|
40
|
+
expect(negative_byte.to_b).to be_within(0.01).of(-1234.56 * 1024)
|
41
|
+
expect(negative_byte.to_s_b).to eq(negative_byte.to_b.to_s)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "to_kb" do
|
45
|
+
expect(byte.to_kb).to be_within(0.01).of(1234.56)
|
46
|
+
expect(byte.to_s_kb).to eq("+#{byte.to_kb}")
|
47
|
+
expect(negative_byte.to_kb).to be_within(0.01).of(-1234.56)
|
48
|
+
expect(negative_byte.to_s_kb).to eq(negative_byte.to_kb.to_s)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "to_mb" do
|
52
|
+
expect(byte.to_mb).to be_within(0.01).of((1234.56 / 1024.to_f).round(2))
|
53
|
+
expect(byte.to_s_mb).to eq("+#{byte.to_mb}")
|
54
|
+
expect(negative_byte.to_mb).to be_within(0.01).of((-1234.56 / 1024.to_f).round(2))
|
55
|
+
expect(negative_byte.to_s_mb).to eq(negative_byte.to_mb.to_s)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context "from_mb" do
|
60
|
+
let(:byte) { Bytes.from_mb(12.34) }
|
61
|
+
let(:negative_byte) { Bytes.from_mb(-12.34) }
|
62
|
+
|
63
|
+
it "to_b" do
|
64
|
+
expect(byte.to_b).to be_within(0.01).of(12.34 * 1024 * 1024)
|
65
|
+
expect(byte.to_s_b).to eq("+#{byte.to_b}")
|
66
|
+
expect(negative_byte.to_b).to be_within(0.01).of(-12.34 * 1024 * 1024)
|
67
|
+
expect(negative_byte.to_s_b).to eq(negative_byte.to_b.to_s)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "to_kb" do
|
71
|
+
expect(byte.to_kb).to be_within(0.01).of(12.34 * 1024)
|
72
|
+
expect(byte.to_s_kb).to eq("+#{byte.to_kb}")
|
73
|
+
expect(negative_byte.to_kb).to be_within(0.01).of(-12.34 * 1024)
|
74
|
+
expect(negative_byte.to_s_kb).to eq(negative_byte.to_kb.to_s)
|
75
|
+
end
|
76
|
+
|
77
|
+
it "to_mb" do
|
78
|
+
expect(byte.to_mb).to be_within(0.01).of(12.34)
|
79
|
+
expect(byte.to_s_mb).to eq("+#{byte.to_mb}")
|
80
|
+
expect(negative_byte.to_mb).to be_within(0.01).of(-12.34)
|
81
|
+
expect(negative_byte.to_s_mb).to eq(negative_byte.to_mb.to_s)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
it "up_unit" do
|
86
|
+
expect(Bytes.up_unit(100)).to be_within(0.01).of(100.to_f / 1024)
|
87
|
+
expect(Bytes.up_unit(234)).to be_within(0.01).of(234.to_f / 1024)
|
88
|
+
end
|
89
|
+
|
90
|
+
it "down_unit" do
|
91
|
+
expect(Bytes.down_unit(100)).to eq(100 * 1024)
|
92
|
+
expect(Bytes.down_unit(234)).to eq(234 * 1024)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,15 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "pathname"
|
2
|
-
ROOT = Pathname.new(File.expand_path("
|
4
|
+
ROOT = Pathname.new(File.expand_path("..", __dir__))
|
3
5
|
$:.unshift((ROOT + "lib").to_s)
|
4
6
|
$:.unshift((ROOT + "spec").to_s)
|
5
7
|
|
8
|
+
def fixture_path
|
9
|
+
"#{(ROOT + 'spec' + 'fixture')}/"
|
10
|
+
end
|
11
|
+
|
6
12
|
require "bundler/setup"
|
7
13
|
require "pry"
|
8
14
|
|
9
15
|
require "rspec"
|
10
16
|
require "danger"
|
11
17
|
|
12
|
-
if `git remote -v` ==
|
18
|
+
if `git remote -v` == ""
|
13
19
|
puts "You cannot run tests without setting a local git remote on this repo"
|
14
20
|
puts "It's a weird side-effect of Danger's internals."
|
15
21
|
exit(0)
|
@@ -63,3 +69,5 @@ def testing_dangerfile
|
|
63
69
|
env = Danger::EnvironmentManager.new(testing_env)
|
64
70
|
Danger::Dangerfile.new(env, testing_ui)
|
65
71
|
end
|
72
|
+
|
73
|
+
require_relative "stub/command"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Apkstats::Stub
|
4
|
+
class Command
|
5
|
+
include Apkstats::Command::Executable
|
6
|
+
|
7
|
+
def initialize(defaults = {})
|
8
|
+
@command_path = __FILE__
|
9
|
+
@defaults = defaults
|
10
|
+
end
|
11
|
+
|
12
|
+
def method_missing(name, *arguments, &block)
|
13
|
+
Apkstats::Entity::ApkInfo::KEYS.include?(name.to_sym) && !block && arguments.size == 1 && @defaults[name.to_sym] || super
|
14
|
+
end
|
15
|
+
|
16
|
+
def respond_to_missing?(method_name, _include_private = false)
|
17
|
+
Apkstats::Entity::ApkInfo::KEYS.include?(method_name.to_sym) || super
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger-apkstats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jumpei Matsuda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: danger-plugin-api
|
@@ -161,20 +161,41 @@ files:
|
|
161
161
|
- ".gitignore"
|
162
162
|
- ".rubocop.yml"
|
163
163
|
- ".travis.yml"
|
164
|
+
- Dangerfile.sample
|
164
165
|
- Gemfile
|
166
|
+
- Gemfile.lock
|
165
167
|
- Guardfile
|
166
168
|
- LICENSE.txt
|
167
169
|
- README.md
|
168
170
|
- Rakefile
|
169
171
|
- danger-apkstats.gemspec
|
170
172
|
- lib/apkstats/command/apk_analyzer.rb
|
171
|
-
- lib/apkstats/command/
|
173
|
+
- lib/apkstats/command/executable.rb
|
174
|
+
- lib/apkstats/entity/apk_info.rb
|
175
|
+
- lib/apkstats/entity/apk_info_diff.rb
|
176
|
+
- lib/apkstats/entity/feature.rb
|
177
|
+
- lib/apkstats/entity/permission.rb
|
172
178
|
- lib/apkstats/gem_version.rb
|
179
|
+
- lib/apkstats/helper/bytes.rb
|
173
180
|
- lib/apkstats/plugin.rb
|
174
181
|
- lib/danger_apkstats.rb
|
175
182
|
- lib/danger_plugin.rb
|
176
183
|
- spec/apkstats_spec.rb
|
184
|
+
- spec/command/apk_analyzer_spec.rb
|
185
|
+
- spec/entity/apk_info_diff_spec.rb
|
186
|
+
- spec/entity/apk_info_spec.rb
|
187
|
+
- spec/entity/features_spec.rb
|
188
|
+
- spec/entity/permissions_spec.rb
|
189
|
+
- spec/fixture/app-base.apk
|
190
|
+
- spec/fixture/app-other1.apk
|
191
|
+
- spec/fixture/app-other2.apk
|
192
|
+
- spec/fixture/app-other3.apk
|
193
|
+
- spec/fixture/app-other4.apk
|
194
|
+
- spec/fixture/app-other5.apk
|
195
|
+
- spec/fixture/github_pr.json
|
196
|
+
- spec/helper/bytes_spec.rb
|
177
197
|
- spec/spec_helper.rb
|
198
|
+
- spec/stub/command.rb
|
178
199
|
homepage: https://github.com/jmatsu/danger-apkstats
|
179
200
|
licenses:
|
180
201
|
- MIT
|
@@ -201,4 +222,18 @@ specification_version: 4
|
|
201
222
|
summary: This is a danger plugin to inspect android application file.
|
202
223
|
test_files:
|
203
224
|
- spec/apkstats_spec.rb
|
225
|
+
- spec/command/apk_analyzer_spec.rb
|
226
|
+
- spec/entity/apk_info_diff_spec.rb
|
227
|
+
- spec/entity/apk_info_spec.rb
|
228
|
+
- spec/entity/features_spec.rb
|
229
|
+
- spec/entity/permissions_spec.rb
|
230
|
+
- spec/fixture/app-base.apk
|
231
|
+
- spec/fixture/app-other1.apk
|
232
|
+
- spec/fixture/app-other2.apk
|
233
|
+
- spec/fixture/app-other3.apk
|
234
|
+
- spec/fixture/app-other4.apk
|
235
|
+
- spec/fixture/app-other5.apk
|
236
|
+
- spec/fixture/github_pr.json
|
237
|
+
- spec/helper/bytes_spec.rb
|
204
238
|
- spec/spec_helper.rb
|
239
|
+
- spec/stub/command.rb
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module Danger::Apkstats
|
2
|
-
module ExecutableCommand
|
3
|
-
require "open3"
|
4
|
-
|
5
|
-
# @return [String, String] ([ size, old_size, changed_by ].join(' '), err message)
|
6
|
-
def compare_with(apk_filepath, other_apk_filepath)
|
7
|
-
unsupported!
|
8
|
-
end
|
9
|
-
|
10
|
-
def filesize(apk_filepath)
|
11
|
-
unsupported!
|
12
|
-
end
|
13
|
-
|
14
|
-
def downloadsize(apk_filepath)
|
15
|
-
unsupported!
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def unsupported!
|
21
|
-
raise "#{__method__} is not supported by #{self.class}"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|