file_groups 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6990c650671a753c6ff1853c419835c1b82e570d36614de0c638eeb0355a2896
4
+ data.tar.gz: 97b5c795725de6a9bd057dcb07b7df824fef111e7bacb7a4a26d225e3bc1a1d1
5
+ SHA512:
6
+ metadata.gz: 8da9abde5c23f3edf38f8f471c925c6937b977dd452b76a154cc8d90efadd1c44b03366dd51f693abfc4071818af403d579881c9256666beaf15fc46c040c902
7
+ data.tar.gz: cb7c14be4aaeaa5cf8fdd09f354d5db3ef04b8ce4d71bfc0dc5697ed3fdd557ee4a8ab0d2cc34dbe1a180e9849dfd4e21a3a2480195d87eb58a21fd737eb6e54
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /Gemfile.lock
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in file_types.gemspec
6
+ gemspec
data/README.md ADDED
@@ -0,0 +1,90 @@
1
+ # `FileGroups`
2
+
3
+ Common file extensions and MIME types, grouped by application and type.
4
+ Useful when you need to process or restrict processing to certain types of files.
5
+
6
+ ## Usage
7
+
8
+ Methods on `FileGroups` return an object containing a set of MIME
9
+ types and file extensions. These are accessible via the `.mime_types` and `.extensions`
10
+ methods, which return an `Array` of `String`s. By default only commonly used values are returned.
11
+ To return all know values pass `true` to either method, e.g., `object.mime_types(true)`
12
+
13
+ In some cases additional methods can be called on the object to further restrict the set.
14
+
15
+ Let's look at some examples.
16
+
17
+ ### Images & Video
18
+
19
+ ```rb
20
+ require "file_groups"
21
+
22
+ FileGroups.image.extensions # ["bmp", "gif", "ico", "jpeg", ... ]
23
+ FileGroups.image.mime_types # ["image/bmp", "image/x-ms-bmp", "image/gif", ... ]
24
+ FileGroups.video.extensions # ["asf", "mov", "qt", "movie", ... ]
25
+ FileGroups.video.mime_types # ["video/x-ms-asf", "video/quicktime", ... ]
26
+ ```
27
+
28
+ Images can be filtered on by raster, vector, or web:
29
+ ```rb
30
+ FileGroups.image.web.extensions # ["gif", "jpeg", "jpg", "png", "svg", "webp"]
31
+ FileGroups.image.raster.extensions # ["bmp", "gif", "ico", "jpeg", "jpg", "tif", "tiff", "webp"]
32
+ FileGroups.image.vector.extensions # ["svg"]
33
+ ```
34
+
35
+ For a complete list pass in `true` to any of these methods:
36
+ ```rb
37
+ FileGroups.image.extensions(true) # ["bmp", "dib", "gif", "ico", "jfif", "jpe", "jpeg", ... ]
38
+ ```
39
+
40
+ ### Spreadsheets
41
+
42
+ Retrieve a list of file extensions or MIME types used by spreadsheets
43
+ ```rb
44
+ require "file_groups"
45
+
46
+ FileGroups.spreadsheet.extensions # ["csv", "xls", "xlsx", "xlt", ... ]
47
+ FileGroups.spreadsheet.mime_types # ["text/csv", "application/vnd.ms-excel", ... ]
48
+ ```
49
+
50
+ If you only want values specific to Microsoft Excel:
51
+ ```rb
52
+ FileGroups.spreadsheet.excel.extensions # ["xls", "xlsx", "xlt", "xltx", "xlw"]
53
+ FileGroups.spreadsheet.excel.mime_types # ["application/vnd.ms-excel", ... ]
54
+ ```
55
+
56
+ Or for OpenOffice:
57
+ ```rb
58
+ FileGroups.spreadsheet.openoffice.extensions # ["ods", "ots"]
59
+ ```
60
+
61
+ By default these only return common extensions, to return all:
62
+ ```rb
63
+ FileGroups.spreadsheet.excel.extensions(true) # ["xls", "xlsx", "xlt", "xltx", ... ]
64
+ ```
65
+
66
+ ### Office Productivity Files
67
+
68
+ Retrieve a list of file extensions or MIME types used by common office software
69
+
70
+ ```rb
71
+ require "file_groups"
72
+ FileGroups.document.extensions # ["csv", "key", "key-tef", "xls", "xlsx", "xlt ... ]
73
+ FileGroups.document.mime_types # ["text/csv", "application/vnd.ms-excel", ... ]
74
+ ```
75
+
76
+ ### Other Filters
77
+
78
+ See the documentation for more.
79
+
80
+ ## Contributing
81
+
82
+ See https://github.com/sshaw/file_groups (or ../README.md)
83
+
84
+ ## Author
85
+
86
+ Skye Shaw (skye.shaw -AT- gmail)
87
+
88
+ ## License
89
+
90
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,29 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "file_groups"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "file_groups"
8
+ spec.version = FileGroups::VERSION
9
+ spec.authors = ["Skye Shaw"]
10
+ spec.email = ["skye.shaw@gmail.com"]
11
+
12
+ spec.summary = %q{Common file extensions and MIME types, grouped by application and type}
13
+ spec.description = %q{Common file extensions and MIME types, grouped by application and type. Useful when you need to process or restrict processing to certain types of files.}
14
+ spec.homepage = "https://github.com/sshaw/file_groups/tree/master/ruby"
15
+ spec.license = "MIT"
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|template.erb)/}) }
21
+ end
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.16"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "rspec", "~> 3.0"
29
+ end
@@ -0,0 +1,505 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ********************
4
+ # AUTOGENERATED FILE DO NOT MODIFY
5
+ # ********************
6
+ #
7
+ module FileGroups
8
+ VERSION = "0.0.1"
9
+
10
+
11
+ def self.video
12
+ o = Object.new
13
+
14
+ def o.extensions(all = false)
15
+ (all ? ["asf", "mov", "qt", "movie", "avi", "mpv2", "mp4", "mpe", "mpeg", "mpg", "webm"] : ["asf", "mov", "qt", "movie", "avi", "mp4", "mpeg", "mpg", "webm"]).dup
16
+ end
17
+
18
+ def o.mime_types(all = false)
19
+ (all ? ["video/x-ms-asf", "video/quicktime", "video/x-sgi-movie", "video/x-msvideo", "video/mpeg", "video/mp4", "video/webm"] : ["video/x-ms-asf", "video/quicktime", "video/x-sgi-movie", "video/x-msvideo", "video/mp4", "video/mpeg", "video/webm"]).dup
20
+ end
21
+
22
+
23
+ o
24
+ end
25
+
26
+ def self.audio
27
+ o = Object.new
28
+
29
+ def o.extensions(all = false)
30
+ (all ? ["au", "aif", "aiff", "aifc", "mp3", "rmi", "mid", "ra", "ram", "snd", "wav", "weba"] : ["au", "aif", "aiff", "aifc", "mp3", "rmi", "mid", "wav", "weba"]).dup
31
+ end
32
+
33
+ def o.mime_types(all = false)
34
+ (all ? ["audio/basic", "audio/x-aiff", "audio/mpeg", "audio/mp3", "audio/mid", "audio/midi", "audio/x-pn-realaudio", "audio/x-realaudio", "audio/x-wav", "audio/wav", "audio/wave", "audio/webm"] : ["audio/basic", "audio/x-aiff", "audio/mpeg", "audio/mp3", "audio/mid", "audio/midi", "audio/x-wav", "audio/wav", "audio/wave", "audio/webm"]).dup
35
+ end
36
+
37
+
38
+ o
39
+ end
40
+
41
+ def self.image
42
+ o = Object.new
43
+
44
+ def o.extensions(all = false)
45
+ (all ? ["bmp", "dib", "gif", "ico", "jfif", "jpe", "jpeg", "jpg", "pbm", "pgm", "png", "ppm", "rgb", "svg", "tif", "tiff", "webp", "xbm", "xpm"] : ["bmp", "gif", "ico", "jpeg", "jpg", "png", "svg", "tif", "tiff", "webp"]).dup
46
+ end
47
+
48
+ def o.mime_types(all = false)
49
+ (all ? ["image/bmp", "image/x-ms-bmp", "image/gif", "image/x-icon", "image/vnd.microsoft.icon", "image/pipeg", "image/jpeg", "image/x-portable-bitmap", "image/x-portable-graymap", "image/png", "image/x-portable-pixmap", "image/x-rgb", "image/svg+xml", "image/tiff", "image/webp", "image/x-xbitmap", "image/x-xpixmap"] : ["image/bmp", "image/x-ms-bmp", "image/gif", "image/x-icon", "image/vnd.microsoft.icon", "image/jpeg", "image/png", "image/svg+xml", "image/tiff", "image/webp"]).dup
50
+ end
51
+
52
+ def o.raster
53
+ tag = Object.new
54
+
55
+ def tag.extensions(all = false)
56
+ (all ? ["bmp", "dib", "gif", "ico", "jpe", "jpeg", "jpg", "ppm", "tif", "tiff", "webp"] : ["bmp", "gif", "ico", "jpeg", "jpg", "tif", "tiff", "webp"]).dup
57
+ end
58
+
59
+ def tag.mime_types(all = false)
60
+ (all ? ["image/bmp", "image/x-ms-bmp", "image/gif", "image/x-icon", "image/vnd.microsoft.icon", "image/jpeg", "image/x-portable-pixmap", "image/tiff", "image/webp"] : ["image/bmp", "image/x-ms-bmp", "image/gif", "image/x-icon", "image/vnd.microsoft.icon", "image/jpeg", "image/tiff", "image/webp"]).dup
61
+ end
62
+
63
+ tag
64
+ end
65
+ def o.web
66
+ tag = Object.new
67
+
68
+ def tag.extensions(all = false)
69
+ (all ? ["gif", "jpe", "jpeg", "jpg", "png", "svg"] : ["gif", "jpeg", "jpg", "png", "svg"]).dup
70
+ end
71
+
72
+ def tag.mime_types(all = false)
73
+ (all ? ["image/gif", "image/jpeg", "image/png", "image/svg+xml"] : ["image/gif", "image/jpeg", "image/png", "image/svg+xml"]).dup
74
+ end
75
+
76
+ tag
77
+ end
78
+ def o.vector
79
+ tag = Object.new
80
+
81
+ def tag.extensions(all = false)
82
+ (all ? ["svg"] : ["svg"]).dup
83
+ end
84
+
85
+ def tag.mime_types(all = false)
86
+ (all ? ["image/svg+xml"] : ["image/svg+xml"]).dup
87
+ end
88
+
89
+ tag
90
+ end
91
+
92
+ o
93
+ end
94
+
95
+ def self.spreadsheet
96
+ o = Object.new
97
+
98
+ def o.extensions(all = false)
99
+ (all ? ["csv", "xls", "xlsx", "xlt", "xltx", "xlw", "xla", "xlsm", "xlsb", "xltm", "xlam", "numbers", "ods", "ots", "tsv", "tab"] : ["csv", "xls", "xlsx", "xlt", "xltx", "xlw", "numbers", "ods", "ots", "tsv"]).dup
100
+ end
101
+
102
+ def o.mime_types(all = false)
103
+ (all ? ["text/csv", "application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.openxmlformats-officedocument.spreadsheetml.template", "application/vnd.ms-excel.sheet.macroenabled.12", "application/vnd.ms-excel.sheet.binary.macroenabled.12", "application/vnd.ms-excel.template.macroenabled.12", "application/vnd.ms-excel.addin.macroenabled.12", "application/vnd.apple.numbers", "application/vnd.oasis.opendocument.spreadsheet", "application/vnd.oasis.opendocument.spreadsheet-template", "text/tab-separated-values"] : ["text/csv", "application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.openxmlformats-officedocument.spreadsheetml.template", "application/vnd.apple.numbers", "application/vnd.oasis.opendocument.spreadsheet", "application/vnd.oasis.opendocument.spreadsheet-template", "text/tab-separated-values"]).dup
104
+ end
105
+
106
+ def o.excel
107
+ tag = Object.new
108
+
109
+ def tag.extensions(all = false)
110
+ (all ? ["xls", "xlsx", "xlt", "xltx", "xlw", "xla", "xlsm", "xlsb", "xltm", "xlam"] : ["xls", "xlsx", "xlt", "xltx", "xlw"]).dup
111
+ end
112
+
113
+ def tag.mime_types(all = false)
114
+ (all ? ["application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.openxmlformats-officedocument.spreadsheetml.template", "application/vnd.ms-excel.sheet.macroenabled.12", "application/vnd.ms-excel.sheet.binary.macroenabled.12", "application/vnd.ms-excel.template.macroenabled.12", "application/vnd.ms-excel.addin.macroenabled.12"] : ["application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.openxmlformats-officedocument.spreadsheetml.template"]).dup
115
+ end
116
+
117
+ tag
118
+ end
119
+ def o.apple
120
+ tag = Object.new
121
+
122
+ def tag.extensions(all = false)
123
+ (all ? ["numbers"] : ["numbers"]).dup
124
+ end
125
+
126
+ def tag.mime_types(all = false)
127
+ (all ? ["application/vnd.apple.numbers"] : ["application/vnd.apple.numbers"]).dup
128
+ end
129
+
130
+ tag
131
+ end
132
+ def o.numbers
133
+ tag = Object.new
134
+
135
+ def tag.extensions(all = false)
136
+ (all ? ["numbers"] : ["numbers"]).dup
137
+ end
138
+
139
+ def tag.mime_types(all = false)
140
+ (all ? ["application/vnd.apple.numbers"] : ["application/vnd.apple.numbers"]).dup
141
+ end
142
+
143
+ tag
144
+ end
145
+ def o.openoffice
146
+ tag = Object.new
147
+
148
+ def tag.extensions(all = false)
149
+ (all ? ["ods", "ots"] : ["ods", "ots"]).dup
150
+ end
151
+
152
+ def tag.mime_types(all = false)
153
+ (all ? ["application/vnd.oasis.opendocument.spreadsheet", "application/vnd.oasis.opendocument.spreadsheet-template"] : ["application/vnd.oasis.opendocument.spreadsheet", "application/vnd.oasis.opendocument.spreadsheet-template"]).dup
154
+ end
155
+
156
+ tag
157
+ end
158
+ def o.calc
159
+ tag = Object.new
160
+
161
+ def tag.extensions(all = false)
162
+ (all ? ["ods", "ots"] : ["ods", "ots"]).dup
163
+ end
164
+
165
+ def tag.mime_types(all = false)
166
+ (all ? ["application/vnd.oasis.opendocument.spreadsheet", "application/vnd.oasis.opendocument.spreadsheet-template"] : ["application/vnd.oasis.opendocument.spreadsheet", "application/vnd.oasis.opendocument.spreadsheet-template"]).dup
167
+ end
168
+
169
+ tag
170
+ end
171
+
172
+ o
173
+ end
174
+
175
+ def self.document
176
+ o = Object.new
177
+
178
+ def o.extensions(all = false)
179
+ (all ? ["csv", "key", "key-tef", "kth", "apxl", "xls", "xlsx", "xlt", "xltx", "xlw", "xla", "xlsm", "xlsb", "xltm", "xlam", "ppt", "pptx", "pps", "ppsx", "ppa", "ppam", "pptm", "ppsm", "potm", "doc", "docx", "dot", "dotx", "dotm", "docm", "word", "w6w", "numbers", "ods", "ots", "odp", "odt", "ott", "oth", "odm", "page", "pdf", "rtf", "tsv", "tab", "txt", "text"] : ["csv", "key", "key-tef", "xls", "xlsx", "xlt", "xltx", "xlw", "ppt", "pptx", "pps", "ppsx", "doc", "docx", "dot", "dotx", "numbers", "ods", "ots", "odp", "odt", "ott", "page", "pdf", "rtf", "tsv", "txt", "text"]).dup
180
+ end
181
+
182
+ def o.mime_types(all = false)
183
+ (all ? ["text/csv", "application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.openxmlformats-officedocument.spreadsheetml.template", "application/vnd.ms-excel.sheet.macroenabled.12", "application/vnd.ms-excel.sheet.binary.macroenabled.12", "application/vnd.ms-excel.template.macroenabled.12", "application/vnd.ms-excel.addin.macroenabled.12", "application/vnd.ms-powerpoint", "application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.openxmlformats-officedocument.presentationml.slideshow", "application/vnd.ms-powerpoint.addin.macroenabled.12", "application/vnd.ms-powerpoint.presentation.macroenabled.12", "application/vnd.ms-powerpoint.slideshow.macroenabled.12", "application/vnd.ms-powerpoint.template.macroenabled.12", "application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.openxmlformats-officedocument.wordprocessingml.template", "application/vnd.ms-word.template.macroenabled.12", "application/vnd.ms-word.document.macroenabled.12", "application/vnd.apple.numbers", "application/vnd.oasis.opendocument.spreadsheet", "application/vnd.oasis.opendocument.spreadsheet-template", "application/vnd.oasis.opendocument.presentation", "application/vnd.oasis.opendocument.text", "application/vnd.oasis.opendocument.text-template", "application/vnd.oasis.opendocument.text-web", "application/vnd.oasis.opendocument.text-master", "application/pdf", "application/rtf", "text/rtf", "text/tab-separated-values", "text/plain"] : ["text/csv", "application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.openxmlformats-officedocument.spreadsheetml.template", "application/vnd.ms-powerpoint", "application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.openxmlformats-officedocument.presentationml.slideshow", "application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.openxmlformats-officedocument.wordprocessingml.template", "application/vnd.apple.numbers", "application/vnd.oasis.opendocument.spreadsheet", "application/vnd.oasis.opendocument.spreadsheet-template", "application/vnd.oasis.opendocument.presentation", "application/vnd.oasis.opendocument.text", "application/vnd.oasis.opendocument.text-template", "application/pdf", "application/rtf", "text/rtf", "text/tab-separated-values", "text/plain"]).dup
184
+ end
185
+
186
+ def o.apple
187
+ tag = Object.new
188
+
189
+ def tag.extensions(all = false)
190
+ (all ? ["key", "key-tef", "kth", "apxl", "numbers", "page"] : ["key", "key-tef", "numbers", "page"]).dup
191
+ end
192
+
193
+ def tag.mime_types(all = false)
194
+ (all ? ["application/vnd.apple.numbers"] : ["application/vnd.apple.numbers"]).dup
195
+ end
196
+
197
+ tag
198
+ end
199
+ def o.keynote
200
+ tag = Object.new
201
+
202
+ def tag.extensions(all = false)
203
+ (all ? ["key", "key-tef", "kth", "apxl"] : ["key", "key-tef"]).dup
204
+ end
205
+
206
+ def tag.mime_types(all = false)
207
+ (all ? [] : []).dup
208
+ end
209
+
210
+ tag
211
+ end
212
+ def o.excel
213
+ tag = Object.new
214
+
215
+ def tag.extensions(all = false)
216
+ (all ? ["xls", "xlsx", "xlt", "xltx", "xlw", "xla", "xlsm", "xlsb", "xltm", "xlam"] : ["xls", "xlsx", "xlt", "xltx", "xlw"]).dup
217
+ end
218
+
219
+ def tag.mime_types(all = false)
220
+ (all ? ["application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.openxmlformats-officedocument.spreadsheetml.template", "application/vnd.ms-excel.sheet.macroenabled.12", "application/vnd.ms-excel.sheet.binary.macroenabled.12", "application/vnd.ms-excel.template.macroenabled.12", "application/vnd.ms-excel.addin.macroenabled.12"] : ["application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.openxmlformats-officedocument.spreadsheetml.template"]).dup
221
+ end
222
+
223
+ tag
224
+ end
225
+ def o.powerpoint
226
+ tag = Object.new
227
+
228
+ def tag.extensions(all = false)
229
+ (all ? ["ppt", "pptx", "pps", "ppsx", "ppa", "ppam", "pptm", "ppsm", "potm"] : ["ppt", "pptx", "pps", "ppsx"]).dup
230
+ end
231
+
232
+ def tag.mime_types(all = false)
233
+ (all ? ["application/vnd.ms-powerpoint", "application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.openxmlformats-officedocument.presentationml.slideshow", "application/vnd.ms-powerpoint.addin.macroenabled.12", "application/vnd.ms-powerpoint.presentation.macroenabled.12", "application/vnd.ms-powerpoint.slideshow.macroenabled.12", "application/vnd.ms-powerpoint.template.macroenabled.12"] : ["application/vnd.ms-powerpoint", "application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.openxmlformats-officedocument.presentationml.slideshow"]).dup
234
+ end
235
+
236
+ tag
237
+ end
238
+ def o.word
239
+ tag = Object.new
240
+
241
+ def tag.extensions(all = false)
242
+ (all ? ["doc", "docx", "dot", "dotx", "dotm", "docm", "word", "w6w"] : ["doc", "docx", "dot", "dotx"]).dup
243
+ end
244
+
245
+ def tag.mime_types(all = false)
246
+ (all ? ["application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.openxmlformats-officedocument.wordprocessingml.template", "application/vnd.ms-word.template.macroenabled.12", "application/vnd.ms-word.document.macroenabled.12"] : ["application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.openxmlformats-officedocument.wordprocessingml.template"]).dup
247
+ end
248
+
249
+ tag
250
+ end
251
+ def o.numbers
252
+ tag = Object.new
253
+
254
+ def tag.extensions(all = false)
255
+ (all ? ["numbers"] : ["numbers"]).dup
256
+ end
257
+
258
+ def tag.mime_types(all = false)
259
+ (all ? ["application/vnd.apple.numbers"] : ["application/vnd.apple.numbers"]).dup
260
+ end
261
+
262
+ tag
263
+ end
264
+ def o.openoffice
265
+ tag = Object.new
266
+
267
+ def tag.extensions(all = false)
268
+ (all ? ["ods", "ots", "odp", "odt", "ott", "oth", "odm"] : ["ods", "ots", "odp", "odt", "ott"]).dup
269
+ end
270
+
271
+ def tag.mime_types(all = false)
272
+ (all ? ["application/vnd.oasis.opendocument.spreadsheet", "application/vnd.oasis.opendocument.spreadsheet-template", "application/vnd.oasis.opendocument.presentation", "application/vnd.oasis.opendocument.text", "application/vnd.oasis.opendocument.text-template", "application/vnd.oasis.opendocument.text-web", "application/vnd.oasis.opendocument.text-master"] : ["application/vnd.oasis.opendocument.spreadsheet", "application/vnd.oasis.opendocument.spreadsheet-template", "application/vnd.oasis.opendocument.presentation", "application/vnd.oasis.opendocument.text", "application/vnd.oasis.opendocument.text-template"]).dup
273
+ end
274
+
275
+ tag
276
+ end
277
+ def o.calc
278
+ tag = Object.new
279
+
280
+ def tag.extensions(all = false)
281
+ (all ? ["ods", "ots"] : ["ods", "ots"]).dup
282
+ end
283
+
284
+ def tag.mime_types(all = false)
285
+ (all ? ["application/vnd.oasis.opendocument.spreadsheet", "application/vnd.oasis.opendocument.spreadsheet-template"] : ["application/vnd.oasis.opendocument.spreadsheet", "application/vnd.oasis.opendocument.spreadsheet-template"]).dup
286
+ end
287
+
288
+ tag
289
+ end
290
+ def o.impress
291
+ tag = Object.new
292
+
293
+ def tag.extensions(all = false)
294
+ (all ? ["odp"] : ["odp"]).dup
295
+ end
296
+
297
+ def tag.mime_types(all = false)
298
+ (all ? ["application/vnd.oasis.opendocument.presentation"] : ["application/vnd.oasis.opendocument.presentation"]).dup
299
+ end
300
+
301
+ tag
302
+ end
303
+ def o.writer
304
+ tag = Object.new
305
+
306
+ def tag.extensions(all = false)
307
+ (all ? ["odt", "ott", "oth", "odm"] : ["odt", "ott"]).dup
308
+ end
309
+
310
+ def tag.mime_types(all = false)
311
+ (all ? ["application/vnd.oasis.opendocument.text", "application/vnd.oasis.opendocument.text-template", "application/vnd.oasis.opendocument.text-web", "application/vnd.oasis.opendocument.text-master"] : ["application/vnd.oasis.opendocument.text", "application/vnd.oasis.opendocument.text-template"]).dup
312
+ end
313
+
314
+ tag
315
+ end
316
+ def o.pages
317
+ tag = Object.new
318
+
319
+ def tag.extensions(all = false)
320
+ (all ? ["page"] : ["page"]).dup
321
+ end
322
+
323
+ def tag.mime_types(all = false)
324
+ (all ? [] : []).dup
325
+ end
326
+
327
+ tag
328
+ end
329
+ def o.pdf
330
+ tag = Object.new
331
+
332
+ def tag.extensions(all = false)
333
+ (all ? ["pdf"] : ["pdf"]).dup
334
+ end
335
+
336
+ def tag.mime_types(all = false)
337
+ (all ? ["application/pdf"] : ["application/pdf"]).dup
338
+ end
339
+
340
+ tag
341
+ end
342
+
343
+ o
344
+ end
345
+
346
+ def self.presentation
347
+ o = Object.new
348
+
349
+ def o.extensions(all = false)
350
+ (all ? ["key", "key-tef", "kth", "apxl", "ppt", "pptx", "pps", "ppsx", "ppa", "ppam", "pptm", "ppsm", "potm", "odp"] : ["key", "key-tef", "ppt", "pptx", "pps", "ppsx", "odp"]).dup
351
+ end
352
+
353
+ def o.mime_types(all = false)
354
+ (all ? ["application/vnd.ms-powerpoint", "application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.openxmlformats-officedocument.presentationml.slideshow", "application/vnd.ms-powerpoint.addin.macroenabled.12", "application/vnd.ms-powerpoint.presentation.macroenabled.12", "application/vnd.ms-powerpoint.slideshow.macroenabled.12", "application/vnd.ms-powerpoint.template.macroenabled.12", "application/vnd.oasis.opendocument.presentation"] : ["application/vnd.ms-powerpoint", "application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.openxmlformats-officedocument.presentationml.slideshow", "application/vnd.oasis.opendocument.presentation"]).dup
355
+ end
356
+
357
+ def o.apple
358
+ tag = Object.new
359
+
360
+ def tag.extensions(all = false)
361
+ (all ? ["key", "key-tef", "kth", "apxl"] : ["key", "key-tef"]).dup
362
+ end
363
+
364
+ def tag.mime_types(all = false)
365
+ (all ? [] : []).dup
366
+ end
367
+
368
+ tag
369
+ end
370
+ def o.keynote
371
+ tag = Object.new
372
+
373
+ def tag.extensions(all = false)
374
+ (all ? ["key", "key-tef", "kth", "apxl"] : ["key", "key-tef"]).dup
375
+ end
376
+
377
+ def tag.mime_types(all = false)
378
+ (all ? [] : []).dup
379
+ end
380
+
381
+ tag
382
+ end
383
+ def o.powerpoint
384
+ tag = Object.new
385
+
386
+ def tag.extensions(all = false)
387
+ (all ? ["ppt", "pptx", "pps", "ppsx", "ppa", "ppam", "pptm", "ppsm", "potm"] : ["ppt", "pptx", "pps", "ppsx"]).dup
388
+ end
389
+
390
+ def tag.mime_types(all = false)
391
+ (all ? ["application/vnd.ms-powerpoint", "application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.openxmlformats-officedocument.presentationml.slideshow", "application/vnd.ms-powerpoint.addin.macroenabled.12", "application/vnd.ms-powerpoint.presentation.macroenabled.12", "application/vnd.ms-powerpoint.slideshow.macroenabled.12", "application/vnd.ms-powerpoint.template.macroenabled.12"] : ["application/vnd.ms-powerpoint", "application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.openxmlformats-officedocument.presentationml.slideshow"]).dup
392
+ end
393
+
394
+ tag
395
+ end
396
+ def o.openoffice
397
+ tag = Object.new
398
+
399
+ def tag.extensions(all = false)
400
+ (all ? ["odp"] : ["odp"]).dup
401
+ end
402
+
403
+ def tag.mime_types(all = false)
404
+ (all ? ["application/vnd.oasis.opendocument.presentation"] : ["application/vnd.oasis.opendocument.presentation"]).dup
405
+ end
406
+
407
+ tag
408
+ end
409
+ def o.impress
410
+ tag = Object.new
411
+
412
+ def tag.extensions(all = false)
413
+ (all ? ["odp"] : ["odp"]).dup
414
+ end
415
+
416
+ def tag.mime_types(all = false)
417
+ (all ? ["application/vnd.oasis.opendocument.presentation"] : ["application/vnd.oasis.opendocument.presentation"]).dup
418
+ end
419
+
420
+ tag
421
+ end
422
+
423
+ o
424
+ end
425
+
426
+ def self.word_processing
427
+ o = Object.new
428
+
429
+ def o.extensions(all = false)
430
+ (all ? ["doc", "docx", "dot", "dotx", "dotm", "docm", "word", "w6w", "odt", "ott", "oth", "odm", "page", "rtf", "txt", "text"] : ["doc", "docx", "dot", "dotx", "odt", "ott", "page", "rtf", "txt", "text"]).dup
431
+ end
432
+
433
+ def o.mime_types(all = false)
434
+ (all ? ["application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.openxmlformats-officedocument.wordprocessingml.template", "application/vnd.ms-word.template.macroenabled.12", "application/vnd.ms-word.document.macroenabled.12", "application/vnd.oasis.opendocument.text", "application/vnd.oasis.opendocument.text-template", "application/vnd.oasis.opendocument.text-web", "application/vnd.oasis.opendocument.text-master", "application/rtf", "text/rtf", "text/plain"] : ["application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.openxmlformats-officedocument.wordprocessingml.template", "application/vnd.oasis.opendocument.text", "application/vnd.oasis.opendocument.text-template", "application/rtf", "text/rtf", "text/plain"]).dup
435
+ end
436
+
437
+ def o.word
438
+ tag = Object.new
439
+
440
+ def tag.extensions(all = false)
441
+ (all ? ["doc", "docx", "dot", "dotx", "dotm", "docm", "word", "w6w"] : ["doc", "docx", "dot", "dotx"]).dup
442
+ end
443
+
444
+ def tag.mime_types(all = false)
445
+ (all ? ["application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.openxmlformats-officedocument.wordprocessingml.template", "application/vnd.ms-word.template.macroenabled.12", "application/vnd.ms-word.document.macroenabled.12"] : ["application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.openxmlformats-officedocument.wordprocessingml.template"]).dup
446
+ end
447
+
448
+ tag
449
+ end
450
+ def o.openoffice
451
+ tag = Object.new
452
+
453
+ def tag.extensions(all = false)
454
+ (all ? ["odt", "ott", "oth", "odm"] : ["odt", "ott"]).dup
455
+ end
456
+
457
+ def tag.mime_types(all = false)
458
+ (all ? ["application/vnd.oasis.opendocument.text", "application/vnd.oasis.opendocument.text-template", "application/vnd.oasis.opendocument.text-web", "application/vnd.oasis.opendocument.text-master"] : ["application/vnd.oasis.opendocument.text", "application/vnd.oasis.opendocument.text-template"]).dup
459
+ end
460
+
461
+ tag
462
+ end
463
+ def o.writer
464
+ tag = Object.new
465
+
466
+ def tag.extensions(all = false)
467
+ (all ? ["odt", "ott", "oth", "odm"] : ["odt", "ott"]).dup
468
+ end
469
+
470
+ def tag.mime_types(all = false)
471
+ (all ? ["application/vnd.oasis.opendocument.text", "application/vnd.oasis.opendocument.text-template", "application/vnd.oasis.opendocument.text-web", "application/vnd.oasis.opendocument.text-master"] : ["application/vnd.oasis.opendocument.text", "application/vnd.oasis.opendocument.text-template"]).dup
472
+ end
473
+
474
+ tag
475
+ end
476
+ def o.apple
477
+ tag = Object.new
478
+
479
+ def tag.extensions(all = false)
480
+ (all ? ["page"] : ["page"]).dup
481
+ end
482
+
483
+ def tag.mime_types(all = false)
484
+ (all ? [] : []).dup
485
+ end
486
+
487
+ tag
488
+ end
489
+ def o.pages
490
+ tag = Object.new
491
+
492
+ def tag.extensions(all = false)
493
+ (all ? ["page"] : ["page"]).dup
494
+ end
495
+
496
+ def tag.mime_types(all = false)
497
+ (all ? [] : []).dup
498
+ end
499
+
500
+ tag
501
+ end
502
+
503
+ o
504
+ end
505
+ end
data/template.erb ADDED
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ********************
4
+ # AUTOGENERATED FILE DO NOT MODIFY
5
+ # ********************
6
+ #
7
+ module FileGroups
8
+ VERSION = "0.0.1"
9
+
10
+ <%- Util.groups(json).each do |method, record| %>
11
+ def self.<%= method %>
12
+ o = Object.new
13
+
14
+ def o.extensions(all = false)
15
+ (all ? <%= Util.extensions(record["files"], false) %> : <%= Util.extensions(record["files"], true) %>).dup
16
+ end
17
+
18
+ def o.mime_types(all = false)
19
+ (all ? <%= Util.mime_types(record["files"], false) %> : <%= Util.mime_types(record["files"], true) %>).dup
20
+ end
21
+
22
+ <% record["tags"] && record["tags"].each do |tag, files| -%>
23
+ def o.<%= tag %>
24
+ tag = Object.new
25
+
26
+ def tag.extensions(all = false)
27
+ (all ? <%= Util.extensions(files, false) %> : <%= Util.extensions(files, true) %>).dup
28
+ end
29
+
30
+ def tag.mime_types(all = false)
31
+ (all ? <%= Util.mime_types(files, false) %> : <%= Util.mime_types(files, true) %>).dup
32
+ end
33
+
34
+ tag
35
+ end
36
+ <%- end -%>
37
+
38
+ o
39
+ end
40
+ <%- end -%>
41
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: file_groups
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Skye Shaw
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-05-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
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.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description: Common file extensions and MIME types, grouped by application and type.
56
+ Useful when you need to process or restrict processing to certain types of files.
57
+ email:
58
+ - skye.shaw@gmail.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - Gemfile
65
+ - README.md
66
+ - Rakefile
67
+ - file_groups.gemspec
68
+ - lib/file_groups.rb
69
+ - template.erb
70
+ homepage: https://github.com/sshaw/file_groups/tree/master/ruby
71
+ licenses:
72
+ - MIT
73
+ metadata: {}
74
+ post_install_message:
75
+ rdoc_options: []
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubyforge_project:
90
+ rubygems_version: 2.7.6
91
+ signing_key:
92
+ specification_version: 4
93
+ summary: Common file extensions and MIME types, grouped by application and type
94
+ test_files: []