marcel 0.3.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module Marcel
2
- VERSION = "0.3.3"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,86 +1,100 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marcel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Ward
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-15 00:00:00.000000000 Z
11
+ date: 2021-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: mimemagic
14
+ name: minitest
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.3.2
20
- type: :runtime
19
+ version: '5.11'
20
+ type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.3.2
26
+ version: '5.11'
27
27
  - !ruby/object:Gem::Dependency
28
- name: minitest
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: '5.11'
47
+ version: '13.0'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: '5.11'
54
+ version: '13.0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: bundler
56
+ name: rack
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: '1.7'
61
+ version: '2.0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: '1.7'
68
+ version: '2.0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: rake
70
+ name: nokogiri
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: '10.0'
75
+ version: 1.9.1
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: '10.0'
82
+ version: 1.9.1
69
83
  - !ruby/object:Gem::Dependency
70
- name: rack
84
+ name: byebug
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: '2.0'
89
+ version: 10.0.2
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: '2.0'
83
- description:
96
+ version: 10.0.2
97
+ description:
84
98
  email:
85
99
  - tom@basecamp.com
86
100
  executables: []
@@ -88,16 +102,18 @@ extensions: []
88
102
  extra_rdoc_files: []
89
103
  files:
90
104
  - MIT-LICENSE
91
- - README.md
92
105
  - lib/marcel.rb
106
+ - lib/marcel/magic.rb
93
107
  - lib/marcel/mime_type.rb
94
108
  - lib/marcel/mime_type/definitions.rb
109
+ - lib/marcel/tables.rb
95
110
  - lib/marcel/version.rb
96
111
  homepage: https://github.com/basecamp/marcel
97
112
  licenses:
98
113
  - MIT
114
+ - Apache-2.0
99
115
  metadata: {}
100
- post_install_message:
116
+ post_install_message:
101
117
  rdoc_options: []
102
118
  require_paths:
103
119
  - lib
@@ -112,9 +128,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
128
  - !ruby/object:Gem::Version
113
129
  version: '0'
114
130
  requirements: []
115
- rubyforge_project:
116
- rubygems_version: 2.7.3
117
- signing_key:
131
+ rubygems_version: 3.2.3
132
+ signing_key:
118
133
  specification_version: 4
119
134
  summary: Simple mime type detection using magic numbers, filenames, and extensions
120
135
  test_files: []
data/README.md DELETED
@@ -1,50 +0,0 @@
1
- # Marcel
2
-
3
- Marcel attempts to choose the most appropriate content type for a given file by looking at the binary data, the filename, and any declared type (perhaps passed as a request header):
4
-
5
- It's used like this:
6
-
7
- Marcel::MimeType.for Pathname.new("example.gif")
8
- => "image/gif"
9
-
10
- File.open "example.gif" do |file|
11
- Marcel::MimeType.for file
12
- end
13
- => "image/gif"
14
-
15
- Marcel::MimeType.for Pathname.new("unrecognisable-data"), name: "example.pdf"
16
- => "application/pdf"
17
-
18
- Marcel::MimeType.for extension: ".pdf"
19
- => "application/pdf"
20
-
21
- Marcel::MimeType.for Pathname.new("unrecognisable-data"), name: "example", declared_type: "image/png"
22
- => "image/png"
23
-
24
- Marcel::MimeType.for StringIO.new(File.read "unrecognisable-data")
25
- => "application/octet-stream"
26
-
27
- By preference, the magic number data in any passed in file is used to determine the type. If this doesn't work, it uses the type gleaned from the filename, extension, and finally the declared type. If no valid type is found in any of these, "application/octet-stream" is returned.
28
-
29
- Some types aren't easily recognised solely by magic number data. For example Adobe Illustrator files have the same magic number as PDFs (and can usually even be viewed in PDF viewers!). For these types, Marcel uses both the magic number data and the file name to work out the type:
30
-
31
- Marcel::MimeType.for Pathname.new("example.ai"), name: "example.ai"
32
- => "application/illustrator"
33
-
34
- This only happens when the type from the filename is a more specific type of that from the magic number. If it isn't the magic number alone is used.
35
-
36
- Marcel::MimeType.for Pathname.new("example.png"), name: "example.ai"
37
- => "image/png"
38
- # As "application/illustrator" is not a more specific type of "image/png", the filename is ignored
39
-
40
- ## Motivation
41
-
42
- Marcel was extracted from Basecamp 3, in order to make our file detection logic both easily reusable but more importantly, easily testable. Test fixtures have been added for all of the most common file types uploaded to Basecamp, and other common file types too. We hope to expand this test coverage with other file types as and when problems are identified.
43
-
44
- ## Implementation
45
-
46
- At present, marcel is mainly a thin wrapper around the mimemagic gem. It adds priority logic (preferring magic over name when given both), some extra type definitions, and common type subclasses (including Keynote, Pages, etc).
47
-
48
- ## Testing
49
-
50
- The main test fixture files are split into two folders, those that can be recognised by magic numbers, and those that can only be recognised by name. Even though strictly unnecessary, the fixtures in both folders should all be valid files of the type they represent.