multi_mime 0.0.4 → 1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5e01154ce64a34ce74eaaba1d3179c398644a4af
4
- data.tar.gz: 2141a42a372b020e43b7fb124b0763032bccf209
3
+ metadata.gz: 5efc9d64b3c707b8ae9ce324808872e6c8a3cc85
4
+ data.tar.gz: 8e8f1a3f5316ea7f5e4cf78d07160ab29d1bbbcc
5
5
  SHA512:
6
- metadata.gz: 2fe28b810ec0f71734f3669af238bad606a636da8eaee92863103925ab1de1ddcd4cf1e7cc1d89f8bf8a418ee7f340c43b985119d256570f89c075d3f65ea7b9
7
- data.tar.gz: 7c8a93b0b261ea77212297f035ced8237fec19cbba7f57201b1928198c93b17c43723afe19181e252693ceafdf2db0af06b615d3dfffe84f27feabbd915cbeeb
6
+ metadata.gz: fe30cc3af9523823eeeeaadc1d8ced587d0944479e6d59d020b7dd0c022c6f727c0114042c00a977df440e0ce1e420a48ca18ffd9d34776144b282740a22cec6
7
+ data.tar.gz: 07ecf389df86c3a12e4d0bad9db367bc99a0b3afdf2ff5a1364cae33608830bb522843c63a30725825d48ac9e62b30742c8f23dbd41c1b0810ee3c5c0b874bb7
@@ -1,5 +1,6 @@
1
1
  language: ruby
2
2
  cache: bundler
3
+ bundler_args: --without development
3
4
  rvm:
4
5
  - ruby-head
5
6
  - jruby-head
data/Gemfile CHANGED
@@ -1,3 +1,19 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
+
5
+ gem 'mime-types', '~> 1.5'
6
+ gem 'actionpack', '~> 3.2'
7
+ gem 'rack'
8
+ gem 'mimemagic'
9
+
10
+ group :developement do
11
+ gem 'rubocop', github: 'bbatsov/rubocop'
12
+ end
13
+
14
+ group :test do
15
+ gem 'rake', '~> 10.0'
16
+ gem 'fakefs', '~> 0.4.3'
17
+ gem 'rspec'
18
+ gem 'timecop'
19
+ end
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 Karl Freeman
1
+ Copyright (c) 2013-2014 Karl Freeman
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,13 +1,15 @@
1
1
  # MultiMime
2
2
 
3
- A generic swappable back-end for Mime Type detection
3
+ A generic swappable back-end for MIME type detection
4
4
 
5
- Lots of Ruby libraries utilize Mime Type detection in some form. In order to best support multiple Mime Type detection libraries, `multi_mime` is a general-purpose swappable Mime Type detection backend library. eg [MultiJson](https://github.com/intridea/multi_json) for Mime Types.
5
+ Lots of ruby libraries utilize mime type detection in some form. In order to best support multiple mime type detection libraries, `multi_mime` is a general-purpose, swappable, MIME type detection backend library.
6
+
7
+ eg [MultiJson](https://github.com/intridea/multi_json) for MIME types.
6
8
 
7
9
  ## Installation
8
10
 
9
11
  ```ruby
10
- gem 'multi_mime', '~> 0.0.3'
12
+ gem 'multi_mime', '~> 1.0'
11
13
  ```
12
14
 
13
15
  ```ruby
@@ -16,6 +18,8 @@ require 'multi_mime'
16
18
 
17
19
  ## Features / Usage Examples
18
20
 
21
+ Part of utilizing various mime type libraries is the need for a common interface. `MultiMime` provides just that with various methods.
22
+
19
23
  ```ruby
20
24
  MultiMime.type_for('text/html') # 'text/html'
21
25
  # alias :by_type
@@ -30,6 +34,26 @@ MultiMime.type_for_file( File.open('foo.html', 'w') ) # 'text/html'
30
34
  # alias :by_file
31
35
  ```
32
36
 
37
+ `MultiMime` tries to have intelligent defaulting. That is, if you have any of the supported engines already loaded, it will utilize them before attempting to load any. When loading, libraries are ordered in the same order as [Supported Mime Engines](https://github.com/karlfreeman/multi_mime#supported-mime-engines). Lets try using `MultiMime` with `Rack::Mime` loaded, then switch it to `MIME::Types`.
38
+
39
+ ```ruby
40
+ require 'rack/mime' # true
41
+
42
+ MultiMime.default_adapter # ':rack_mime'
43
+
44
+ MultiMime.adapter # MultiMime::Adapters::RackMime
45
+
46
+ MultiMime.reset_adapter # MultiMime::Adapters::RackMime
47
+
48
+ MultiMime.adapter = :mime_types # `:mime_types`
49
+
50
+ require 'mime/types' # false (eg loaded)
51
+
52
+ MultiMime.adapter # MultiMime::Adapters::MimeTypes
53
+
54
+ MultiMime.type_for_extension('.json') # 'application/json'
55
+ ```
56
+
33
57
  ## Badges
34
58
 
35
59
  [![Gem Version](http://img.shields.io/gem/v/multi_mime.svg)][gem]
@@ -65,7 +89,7 @@ Inspiration:
65
89
  Cribbed:
66
90
 
67
91
  - [MultiJSON](https://github.com/intridea/multi_json)
68
- - [Asset_Sync"s MultiMime module](https://github.com/rumblelabs/asset_sync/commit/9333bd01ae1a7cf2ffa046b8390fbc4165c38030)
92
+ - [Asset_Sync's MultiMime module](https://github.com/rumblelabs/asset_sync/commit/9333bd01ae1a7cf2ffa046b8390fbc4165c38030)
69
93
 
70
94
  [gem]: https://rubygems.org/gems/multi_mime
71
95
  [travis]: http://travis-ci.org/karlfreeman/multi_mime
data/Rakefile CHANGED
@@ -2,16 +2,22 @@ require 'bundler'
2
2
  Bundler.setup
3
3
  Bundler::GemHelper.install_tasks
4
4
 
5
- require 'yard'
6
- YARD::Rake::YardocTask.new
7
-
8
5
  require 'rspec/core/rake_task'
9
6
  desc 'Run all examples'
10
7
  RSpec::Core::RakeTask.new(:spec)
11
8
 
12
- require 'rubocop/rake_task'
13
- desc 'Run rubocop'
14
- Rubocop::RakeTask.new(:rubocop)
9
+ begin
10
+ require 'yard'
11
+ YARD::Rake::YardocTask.new
12
+ rescue LoadError
13
+ end
14
+
15
+ begin
16
+ require 'rubocop/rake_task'
17
+ desc 'Run rubocop'
18
+ Rubocop::RakeTask.new(:rubocop)
19
+ rescue LoadError
20
+ end
15
21
 
16
22
  task default: :spec
17
23
  task test: :spec
@@ -125,7 +125,7 @@ module MultiMime
125
125
  REQUIREMENT_MAP.each do |adapter, library, clazz|
126
126
  if new_adapter.to_sym == adapter
127
127
  require library
128
- require "multi_mime/adapters/#{new_adapter.to_s}"
128
+ require "multi_mime/adapters/#{new_adapter}"
129
129
  adapter_clazz = MultiMime::Adapters.const_get(:"#{new_adapter.to_s.split('_').map { |s| s.capitalize }.join('')}")
130
130
  else
131
131
  next
@@ -1,3 +1,3 @@
1
1
  module MultiMime
2
- VERSION = '0.0.4' unless defined?(MultiMime::VERSION)
2
+ VERSION = '1.0' unless defined?(MultiMime::VERSION)
3
3
  end
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = MultiMime::VERSION
9
9
  spec.authors = ['Karl Freeman']
10
10
  spec.email = ['karlfreeman@gmail.com']
11
- spec.summary = %q{A generic swappable back-end for Mime::Type detection}
12
- spec.description = %q{A generic swappable back-end for Mime::Type detection}
11
+ spec.summary = %q{A generic swappable back-end for MIME type detection}
12
+ spec.description = %q{A generic swappable back-end for MIME type detection}
13
13
  spec.homepage = 'https://github.com/karlfreeman/multi_mime'
14
14
  spec.license = 'MIT'
15
15
 
@@ -19,20 +19,10 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ['lib']
20
20
  spec.required_ruby_version = '>= 1.9.3'
21
21
 
22
- spec.add_dependency 'fog', '~> 1.12'
23
-
24
- spec.add_development_dependency 'mime-types', '~> 1.5'
25
- spec.add_development_dependency 'actionpack', '~> 3.2'
26
- spec.add_development_dependency 'rack'
27
- spec.add_development_dependency 'mimemagic'
28
-
29
22
  spec.add_development_dependency 'bundler', '~> 1.5'
30
23
  spec.add_development_dependency 'rake', '~> 10.0'
31
24
  spec.add_development_dependency 'kramdown', '>= 0.14'
32
- spec.add_development_dependency 'fakefs', '~> 0.5'
33
- spec.add_development_dependency 'rspec'
34
25
  spec.add_development_dependency 'rubocop'
35
- spec.add_development_dependency 'timecop'
36
26
  spec.add_development_dependency 'pry'
37
27
  spec.add_development_dependency 'yard'
38
- end
28
+ end
@@ -1,3 +1,6 @@
1
1
  if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ruby'
2
- require 'pry' unless ENV['CI']
2
+ begin
3
+ require 'pry' unless ENV['CI']
4
+ rescue LoadError
5
+ end
3
6
  end
@@ -40,6 +40,11 @@ describe MultiMime do
40
40
  it { should == MultiMime.instance_method(:type_for_path) }
41
41
  end
42
42
 
43
+ describe :by_file do
44
+ subject { MultiMime.instance_method(:by_file) }
45
+ it { should == MultiMime.instance_method(:type_for_file) }
46
+ end
47
+
43
48
  end
44
49
 
45
50
  context :defaults do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multi_mime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: '1.0'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karl Freeman
@@ -10,76 +10,6 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2014-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: fog
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.12'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.12'
27
- - !ruby/object:Gem::Dependency
28
- name: mime-types
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1.5'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1.5'
41
- - !ruby/object:Gem::Dependency
42
- name: actionpack
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '3.2'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '3.2'
55
- - !ruby/object:Gem::Dependency
56
- name: rack
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: mimemagic
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
13
  - !ruby/object:Gem::Dependency
84
14
  name: bundler
85
15
  requirement: !ruby/object:Gem::Requirement
@@ -122,34 +52,6 @@ dependencies:
122
52
  - - ">="
123
53
  - !ruby/object:Gem::Version
124
54
  version: '0.14'
125
- - !ruby/object:Gem::Dependency
126
- name: fakefs
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: '0.5'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: '0.5'
139
- - !ruby/object:Gem::Dependency
140
- name: rspec
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: '0'
153
55
  - !ruby/object:Gem::Dependency
154
56
  name: rubocop
155
57
  requirement: !ruby/object:Gem::Requirement
@@ -164,20 +66,6 @@ dependencies:
164
66
  - - ">="
165
67
  - !ruby/object:Gem::Version
166
68
  version: '0'
167
- - !ruby/object:Gem::Dependency
168
- name: timecop
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - ">="
172
- - !ruby/object:Gem::Version
173
- version: '0'
174
- type: :development
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - ">="
179
- - !ruby/object:Gem::Version
180
- version: '0'
181
69
  - !ruby/object:Gem::Dependency
182
70
  name: pry
183
71
  requirement: !ruby/object:Gem::Requirement
@@ -206,7 +94,7 @@ dependencies:
206
94
  - - ">="
207
95
  - !ruby/object:Gem::Version
208
96
  version: '0'
209
- description: A generic swappable back-end for Mime::Type detection
97
+ description: A generic swappable back-end for MIME type detection
210
98
  email:
211
99
  - karlfreeman@gmail.com
212
100
  executables: []
@@ -262,7 +150,7 @@ rubyforge_project:
262
150
  rubygems_version: 2.2.0
263
151
  signing_key:
264
152
  specification_version: 4
265
- summary: A generic swappable back-end for Mime::Type detection
153
+ summary: A generic swappable back-end for MIME type detection
266
154
  test_files:
267
155
  - spec/shared/adapter.rb
268
156
  - spec/spec_helper.rb