mime-typer 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/README.md +26 -0
- data/Rakefile +18 -0
- data/dipendences/Rakefile +17 -0
- data/dog.jpg +0 -0
- data/lib/mime-typer.rb +8 -0
- data/mime-typer.gemspec +23 -0
- metadata +80 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 19b714b76fb015b1b2c44eb1ffa0288b1135a4bf
|
4
|
+
data.tar.gz: 5e6fb027e2c2224c5014e41cf009e548cd3a8550
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 03b530b087f9a800765ded623b6249c28192043b91b027d653eba8e99c0c45f0205354a4d6957a1d0f1a0686c253e6a8818c5e43e8844ab0ea2978bcfe9b9a4b
|
7
|
+
data.tar.gz: b139ddbfc4322087e0cbb9aaabdcaf7561563c5897eaa0c898874e5d13ac0b0f810d71c41af6c74994a5d385852d7fed885ec4af9da1688c73614e016b98f04e
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013 Piero Dotti
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
MIME Typer
|
2
|
+
==================
|
3
|
+
|
4
|
+
A simple library to detect mime type of a file, using libmagic
|
5
|
+
|
6
|
+
## Installation: ##
|
7
|
+
Add this line in your Gemfile
|
8
|
+
|
9
|
+
gem 'mime-typer'
|
10
|
+
|
11
|
+
## Run tests: ##
|
12
|
+
|
13
|
+
bundle exec rake
|
14
|
+
|
15
|
+
## Requirements: ##
|
16
|
+
It requires both [awk](http://en.wikipedia.org/wiki/AWK) and [file](http://en.wikipedia.org/wiki/File_(command)) to be installed and available in your `PATH`. Installation will fail if you miss them.
|
17
|
+
|
18
|
+
|
19
|
+
## How to use: ##
|
20
|
+
|
21
|
+
MIME::Typer.detect('path/to/my/image.jpg') # => 'image/jpg'
|
22
|
+
|
23
|
+
You can also pass an already opened file:
|
24
|
+
|
25
|
+
myfile = File.open('path/to/my/image.jpg')
|
26
|
+
MIME::Typer.detect(myfile) # => 'image/jpg'
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
require 'rake/testtask'
|
4
|
+
|
5
|
+
task :default => [:test]
|
6
|
+
|
7
|
+
Rake::TestTask.new do |t|
|
8
|
+
t.libs << 'test'
|
9
|
+
t.test_files = FileList['tests/test_*.rb']
|
10
|
+
end
|
11
|
+
|
12
|
+
desc 'Open a pry session preloaded with this library'
|
13
|
+
task :console do
|
14
|
+
require 'pry'
|
15
|
+
require './lib/mime-typer.rb'
|
16
|
+
ARGV.clear
|
17
|
+
Pry.start
|
18
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require 'rake/testtask'
|
3
|
+
|
4
|
+
task :default => [:check]
|
5
|
+
|
6
|
+
desc 'Check if required commands exists'
|
7
|
+
task :check do
|
8
|
+
# Checking availability of file
|
9
|
+
unless system("which file > /dev/null")
|
10
|
+
raise 'Installation failure! Please install libmagic on your system.'
|
11
|
+
end
|
12
|
+
|
13
|
+
unless system("which awk > /dev/null")
|
14
|
+
raise 'Installation failure! Please install awk on your system.'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
data/dog.jpg
ADDED
Binary file
|
data/lib/mime-typer.rb
ADDED
data/mime-typer.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
lib = 'mime-typer'
|
2
|
+
Gem::Specification.new do |s|
|
3
|
+
s.name = 'mime-typer'
|
4
|
+
s.version = '0.1'
|
5
|
+
s.date = '2014-07-31'
|
6
|
+
s.summary = 'MIME Typer'
|
7
|
+
s.description = 'A gem to detect mime type of a file, using libmagic.'
|
8
|
+
s.authors = ['Piero Dotti']
|
9
|
+
s.email = 'progiemmeh@gmail.com'
|
10
|
+
s.homepage = 'https://github.com/ProGM/mime-typer'
|
11
|
+
s.license = 'MIT'
|
12
|
+
s.extensions = %w(dipendences/Rakefile)
|
13
|
+
|
14
|
+
s.files = %w(Gemfile LICENSE README.md Rakefile dog.jpg)
|
15
|
+
s.files << "#{lib}.gemspec"
|
16
|
+
s.files += Dir.glob("lib/**/*.rb")
|
17
|
+
s.files += Dir.glob("test/**/*.rb")
|
18
|
+
s.files += Dir.glob("dipendences/*")
|
19
|
+
|
20
|
+
|
21
|
+
s.add_development_dependency 'minitest', '~> 5.3'
|
22
|
+
s.add_development_dependency 'rake', '~> 10.3'
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mime-typer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Piero Dotti
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: minitest
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.3'
|
41
|
+
description: A gem to detect mime type of a file, using libmagic.
|
42
|
+
email: progiemmeh@gmail.com
|
43
|
+
executables: []
|
44
|
+
extensions:
|
45
|
+
- dipendences/Rakefile
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- Gemfile
|
49
|
+
- LICENSE
|
50
|
+
- README.md
|
51
|
+
- Rakefile
|
52
|
+
- dipendences/Rakefile
|
53
|
+
- dog.jpg
|
54
|
+
- lib/mime-typer.rb
|
55
|
+
- mime-typer.gemspec
|
56
|
+
homepage: https://github.com/ProGM/mime-typer
|
57
|
+
licenses:
|
58
|
+
- MIT
|
59
|
+
metadata: {}
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 2.4.1
|
77
|
+
signing_key:
|
78
|
+
specification_version: 4
|
79
|
+
summary: MIME Typer
|
80
|
+
test_files: []
|