mime-typer 0.2 → 0.2.1

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: 2854587c48b7973c8f88bfa17d732ab1113fac1c
4
- data.tar.gz: 8072db2297467952ab51ee30989f12e69b862cf9
3
+ metadata.gz: cde2142f2e3b81b5d4cd363bc57d4c26026f744f
4
+ data.tar.gz: 27bec553b6bf4dc984890df92d9365e9dd95197f
5
5
  SHA512:
6
- metadata.gz: 9694fb0a7685436fd57d83dce29710f100a947daa4d76e07cb9c83f32fe96749d6a69ba1cb286b73d1275f66c28df42e4a80e26e14ccd35baa6ed362523dcf0b
7
- data.tar.gz: 3ac3d8ff70d6a6e94b74c3ea3edfb70ac3acd881ae6c9994910277549a48aa744eed23a790015d76d1786d7783090c4ae1b0d442b64fd4f3910f9b32c625786d
6
+ metadata.gz: 3702ce87a2770e9ecd833e1bb61ecdf3dbaa3c29a2a04e1cd62ddbd92b871b369f99131d6cff14cb657f70bf711d9fb85b812f8f9067b6ecb13b06950e0c53f1
7
+ data.tar.gz: 2a15a8daaf138847fcd4220f04c36fcccb84a78c2f1aebf038895b1de4f62675ca578f450a924c35400079b74c7f433e33e4aa463b0bddffd9facbc4e110289c
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2013 Piero Dotti
3
+ Copyright (c) 2014 Piero Dotti
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
@@ -17,4 +17,4 @@ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
17
  FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
18
  COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
19
  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -24,3 +24,12 @@ You can also pass an already opened file:
24
24
 
25
25
  myfile = File.open('path/to/my/image.jpg')
26
26
  MIME::Typer.detect(myfile) # => 'image/jpg'
27
+
28
+
29
+ If you want to detect the MIME Type of a remote file you can use the `remote` method
30
+
31
+ MIME::Typer.remote('http://www.yoursite.com/image.png') # => 'image/png'
32
+
33
+ This will load only the first part of the file, so it's quite fast also with large remote files.
34
+
35
+ **Warning** this feature is quite experimental!
@@ -61,7 +61,8 @@ module MIME
61
61
  def self.load_remote(uri, bytes = 200)
62
62
  result = ''
63
63
  uri = URI(uri)
64
- Net::HTTP.start(uri.host, uri.port) do |http|
64
+ ssl = uri.scheme == 'https'
65
+ Net::HTTP.start(uri.host, uri.port, use_ssl: ssl) do |http|
65
66
  request = Net::HTTP::Get.new(uri.request_uri)
66
67
  http.request(request) do |response|
67
68
  result = response.socket.read(bytes)
@@ -1,7 +1,7 @@
1
1
  lib = 'mime-typer'
2
2
  Gem::Specification.new do |s|
3
3
  s.name = 'mime-typer'
4
- s.version = '0.2'
4
+ s.version = '0.2.1'
5
5
  s.date = '2014-08-04'
6
6
  s.summary = 'MIME Typer'
7
7
  s.description = 'A gem to detect mime type of a file, using libmagic.'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mime-typer
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piero Dotti