marcel 0.3.3 → 1.0.1

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.1"
3
3
  end
metadata CHANGED
@@ -1,29 +1,15 @@
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.1
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-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: mimemagic
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 0.3.2
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 0.3.2
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: minitest
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -42,14 +28,14 @@ dependencies:
42
28
  name: bundler
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
- - - "~>"
31
+ - - ">="
46
32
  - !ruby/object:Gem::Version
47
33
  version: '1.7'
48
34
  type: :development
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
- - - "~>"
38
+ - - ">="
53
39
  - !ruby/object:Gem::Version
54
40
  version: '1.7'
55
41
  - !ruby/object:Gem::Dependency
@@ -58,14 +44,14 @@ dependencies:
58
44
  requirements:
59
45
  - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: '10.0'
47
+ version: '13.0'
62
48
  type: :development
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
52
  - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: '10.0'
54
+ version: '13.0'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: rack
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -80,7 +66,35 @@ dependencies:
80
66
  - - "~>"
81
67
  - !ruby/object:Gem::Version
82
68
  version: '2.0'
83
- description:
69
+ - !ruby/object:Gem::Dependency
70
+ name: nokogiri
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 1.9.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 1.9.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: byebug
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 10.0.2
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
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
- homepage: https://github.com/basecamp/marcel
111
+ homepage: https://github.com/rails/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.