marcel 0.3.0 → 0.3.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 +4 -4
- data/.gitignore +1 -13
- data/.travis.yml +7 -0
- data/Gemfile.lock +2 -2
- data/lib/marcel/mime_type.rb +11 -6
- data/lib/marcel/version.rb +1 -1
- data/marcel.gemspec +1 -1
- data/test/mime_type_test.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 216d21a724ab7262910321bd6556b885fcb1c5dc9f3f19d7e8e0a354b98456e1
|
4
|
+
data.tar.gz: 337b73e40e8d08a89be70b78377cf9d21c63f2dc4889a6eff18aa3b97bcd32af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72b64e06d3ca8cde9145ea39bda39e54ed35e2c9fc06cd0e42e1f1c26c85ed1d46d268b4515cfa8ab222f3259a13abfc988d498d343b94906c5b458febbf902c
|
7
|
+
data.tar.gz: 8e1c2ba8f0f15317d8a7388e7e81c650ff4e52ec5cc311863bd1404655a8b87a164f9f4fcf70d1eb8d8b31bc3661c644eb1d01965b533c853012626baac6df8d
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Gemfile.lock
CHANGED
data/lib/marcel/mime_type.rb
CHANGED
@@ -27,28 +27,34 @@ class Marcel::MimeType
|
|
27
27
|
def for_data(pathname_or_io)
|
28
28
|
if pathname_or_io
|
29
29
|
with_io(pathname_or_io) do |io|
|
30
|
-
MimeMagic.by_magic(io)
|
30
|
+
if magic = MimeMagic.by_magic(io)
|
31
|
+
magic.type.downcase
|
32
|
+
end
|
31
33
|
end
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
35
37
|
def for_name(name)
|
36
38
|
if name
|
37
|
-
MimeMagic.by_path(name)
|
39
|
+
if magic = MimeMagic.by_path(name)
|
40
|
+
magic.type.downcase
|
41
|
+
end
|
38
42
|
end
|
39
43
|
end
|
40
44
|
|
41
45
|
def for_extension(extension)
|
42
46
|
if extension
|
43
|
-
MimeMagic.by_extension(extension)
|
47
|
+
if magic = MimeMagic.by_extension(extension)
|
48
|
+
magic.type.downcase
|
49
|
+
end
|
44
50
|
end
|
45
51
|
end
|
46
52
|
|
47
53
|
def for_declared_type(declared_type)
|
48
54
|
type = parse_media_type(declared_type)
|
49
55
|
|
50
|
-
if type != BINARY
|
51
|
-
type
|
56
|
+
if type != BINARY && !type.nil?
|
57
|
+
type.downcase
|
52
58
|
end
|
53
59
|
end
|
54
60
|
|
@@ -90,4 +96,3 @@ class Marcel::MimeType
|
|
90
96
|
end
|
91
97
|
|
92
98
|
require 'marcel/mime_type/definitions'
|
93
|
-
|
data/lib/marcel/version.rb
CHANGED
data/marcel.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ['lib']
|
19
19
|
|
20
|
-
spec.required_ruby_version = '
|
20
|
+
spec.required_ruby_version = '>= 2.2'
|
21
21
|
|
22
22
|
spec.add_dependency 'mimemagic', '~> 0.3.2'
|
23
23
|
|
data/test/mime_type_test.rb
CHANGED
@@ -25,7 +25,7 @@ class Marcel::MimeTypeTest < Marcel::TestCase
|
|
25
25
|
end
|
26
26
|
|
27
27
|
test "gets content type from Tempfiles" do
|
28
|
-
Tempfile.open do |tempfile|
|
28
|
+
Tempfile.open("Marcel") do |tempfile|
|
29
29
|
tempfile.write(File.read(@path))
|
30
30
|
content_type = Marcel::MimeType.for tempfile
|
31
31
|
assert_equal "image/gif", content_type
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marcel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Ward
|
@@ -88,6 +88,7 @@ extensions: []
|
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
90
|
- ".gitignore"
|
91
|
+
- ".travis.yml"
|
91
92
|
- Gemfile
|
92
93
|
- Gemfile.lock
|
93
94
|
- MIT-LICENSE
|
@@ -208,9 +209,9 @@ require_paths:
|
|
208
209
|
- lib
|
209
210
|
required_ruby_version: !ruby/object:Gem::Requirement
|
210
211
|
requirements:
|
211
|
-
- - "
|
212
|
+
- - ">="
|
212
213
|
- !ruby/object:Gem::Version
|
213
|
-
version: '2.
|
214
|
+
version: '2.2'
|
214
215
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
215
216
|
requirements:
|
216
217
|
- - ">="
|