mimer 0.0.1 → 0.0.2

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -33,6 +33,17 @@ class Mimer
33
33
  def mime_type
34
34
  @mime_type
35
35
  end
36
+
37
+ # Suggests an extention to use like .jpg or .png
38
+ def suggested_extension
39
+ case(mime_type)
40
+ when /^image\/jpeg/ : '.jpg'
41
+ when /^image\/gif/ : '.gif'
42
+ when /^image\/png/ : '.png'
43
+ else
44
+ nil
45
+ end
46
+ end
36
47
 
37
48
  # Returns true if the file is a text file.
38
49
  def text?
@@ -1,15 +1,15 @@
1
1
  # Generated by jeweler
2
- # DO NOT EDIT THIS FILE
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mimer}
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ariejan de Vroom"]
12
- s.date = %q{2009-10-12}
12
+ s.date = %q{2010-02-11}
13
13
  s.description = %q{Find the mime-type of a file using unix' `file` command. This does not look at file extension, ever.}
14
14
  s.email = %q{ariejan@ariejan.net}
15
15
  s.extra_rdoc_files = [
@@ -26,6 +26,8 @@ Gem::Specification.new do |s|
26
26
  "lib/mimer.rb",
27
27
  "mimer.gemspec",
28
28
  "spec/fixtures/facepalm.jpg",
29
+ "spec/fixtures/google.gif",
30
+ "spec/fixtures/kirk.png",
29
31
  "spec/fixtures/plain.txt",
30
32
  "spec/mimer_spec.rb",
31
33
  "spec/spec_helper.rb"
@@ -54,3 +56,4 @@ Gem::Specification.new do |s|
54
56
  s.add_dependency(%q<rspec>, [">= 0"])
55
57
  end
56
58
  end
59
+
Binary file
Binary file
@@ -30,6 +30,23 @@ describe "Mimer" do
30
30
  end
31
31
  end
32
32
 
33
+ describe "image extensions" do
34
+ it "should work for jpeg" do
35
+ mimer = Mimer.identify(fixture_path('facepalm.jpg'))
36
+ mimer.suggested_extension.should eql(".jpg")
37
+ end
38
+
39
+ it "should work for gif" do
40
+ mimer = Mimer.identify(fixture_path('google.gif'))
41
+ mimer.suggested_extension.should eql(".gif")
42
+ end
43
+
44
+ it "should work for png" do
45
+ mimer = Mimer.identify(fixture_path('kirk.png'))
46
+ mimer.suggested_extension.should eql(".png")
47
+ end
48
+ end
49
+
33
50
  describe "image" do
34
51
 
35
52
  before(:each) do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mimer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ariejan de Vroom
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-12 00:00:00 +02:00
12
+ date: 2010-02-11 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -41,6 +41,8 @@ files:
41
41
  - lib/mimer.rb
42
42
  - mimer.gemspec
43
43
  - spec/fixtures/facepalm.jpg
44
+ - spec/fixtures/google.gif
45
+ - spec/fixtures/kirk.png
44
46
  - spec/fixtures/plain.txt
45
47
  - spec/mimer_spec.rb
46
48
  - spec/spec_helper.rb