miteru 0.14.4 → 0.14.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/miteru/configuration.rb +3 -0
- data/lib/miteru/kit.rb +7 -5
- data/lib/miteru/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cf6445b9388cdcfb797cdb8c91615a288757508874d0550bab8c6b052c375d6
|
4
|
+
data.tar.gz: dd9f428317a0f325c2c467234dda21f05bb7cd616114f49adeec9374a4680451
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f740f27cacdb1020a49bc787aa8486cbe6b6ac6fe5e4ad3093af0601928dcd12c78895c39c548a28de18fc35766dbb89507687c81e2bb162d6e69e111242fbd
|
7
|
+
data.tar.gz: a110c028b6129a2d0bc903962d1f945be96426b8c909ae6e34bb1955d3ca657b1c9ef5a48bc1e147c54f992517cc86c0ca18047a79cdcb2b2a95bda5c5148caa
|
data/lib/miteru/configuration.rb
CHANGED
@@ -30,6 +30,8 @@ module Miteru
|
|
30
30
|
|
31
31
|
attr_reader :valid_extensions
|
32
32
|
|
33
|
+
attr_reader :valid_mime_types
|
34
|
+
|
33
35
|
def initialize
|
34
36
|
@auto_download = false
|
35
37
|
@ayashige = false
|
@@ -41,6 +43,7 @@ module Miteru
|
|
41
43
|
@verbose = false
|
42
44
|
|
43
45
|
@valid_extensions = [".zip", ".rar", ".7z", ".tar", ".gz"].freeze
|
46
|
+
@valid_mime_types = ["application/zip", "application/vnd.rar", "application/x-7z-compressed", "application/x-tar", "application/gzip"]
|
44
47
|
end
|
45
48
|
|
46
49
|
def auto_download?
|
data/lib/miteru/kit.rb
CHANGED
@@ -6,6 +6,7 @@ require "securerandom"
|
|
6
6
|
module Miteru
|
7
7
|
class Kit
|
8
8
|
VALID_EXTENSIONS = Miteru.configuration.valid_extensions
|
9
|
+
VALID_MIME_TYPES = Miteru.configuration.valid_mime_types
|
9
10
|
|
10
11
|
attr_reader :url
|
11
12
|
|
@@ -14,7 +15,7 @@ module Miteru
|
|
14
15
|
end
|
15
16
|
|
16
17
|
def valid?;
|
17
|
-
valid_ext? &&
|
18
|
+
valid_ext? && reachable_and_valid_mime_type?
|
18
19
|
end
|
19
20
|
|
20
21
|
def extname
|
@@ -73,13 +74,14 @@ module Miteru
|
|
73
74
|
response.status.success?
|
74
75
|
end
|
75
76
|
|
76
|
-
def
|
77
|
-
|
77
|
+
def valid_mime_type?(response)
|
78
|
+
mime_type = response.content_type.mime_type.to_s
|
79
|
+
VALID_MIME_TYPES.include? mime_type
|
78
80
|
end
|
79
81
|
|
80
|
-
def
|
82
|
+
def reachable_and_valid_mime_type?
|
81
83
|
res = HTTPClient.head(url)
|
82
|
-
reachable?(res) &&
|
84
|
+
reachable?(res) && valid_mime_type?(res)
|
83
85
|
rescue StandardError
|
84
86
|
false
|
85
87
|
end
|
data/lib/miteru/version.rb
CHANGED