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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 89102143e9e405545e94b50da7b81b90c85ae9612c8c914d4b50b6d09ca2e023
4
- data.tar.gz: 2d6e60e6301425b9ceb8ed7cf103caab144f2ddab4fdd3872ef3f332a6667e37
3
+ metadata.gz: 1cf6445b9388cdcfb797cdb8c91615a288757508874d0550bab8c6b052c375d6
4
+ data.tar.gz: dd9f428317a0f325c2c467234dda21f05bb7cd616114f49adeec9374a4680451
5
5
  SHA512:
6
- metadata.gz: 3df145d910400efc069d07c718943560a064b5d9fff849fb695795bf49b1d30681e6c31946172f2cd0e7508ca46ded7ff93d2935e48fc6dc970e1817d6e6348c
7
- data.tar.gz: 70057c7c2451f4631bfda279431e40dfc86bc4931caa555141e607d0a2d73e5308bd0458ddc9046b1e0ccbe0329829ab8568202e8671c68146e5b6b4b6688705
6
+ metadata.gz: 5f740f27cacdb1020a49bc787aa8486cbe6b6ac6fe5e4ad3093af0601928dcd12c78895c39c548a28de18fc35766dbb89507687c81e2bb162d6e69e111242fbd
7
+ data.tar.gz: a110c028b6129a2d0bc903962d1f945be96426b8c909ae6e34bb1955d3ca657b1c9ef5a48bc1e147c54f992517cc86c0ca18047a79cdcb2b2a95bda5c5148caa
@@ -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?
@@ -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? && reachable_and_archive_file?
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 archive_file?(response)
77
- !response.content_type.mime_type.to_s.start_with? "text/"
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 reachable_and_archive_file?
82
+ def reachable_and_valid_mime_type?
81
83
  res = HTTPClient.head(url)
82
- reachable?(res) && archive_file?(res)
84
+ reachable?(res) && valid_mime_type?(res)
83
85
  rescue StandardError
84
86
  false
85
87
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Miteru
4
- VERSION = "0.14.4"
4
+ VERSION = "0.14.5"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: miteru
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.4
4
+ version: 0.14.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manabu Niseki