wand 0.2.1 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -19,3 +19,4 @@ rdoc
19
19
  pkg
20
20
 
21
21
  ## PROJECT::SPECIFIC
22
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "http://rubygems.org"
2
+ gemspec
@@ -0,0 +1,23 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ wand (0.2.1)
5
+ mime-types
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ mime-types (1.16)
11
+ mocha (0.9.10)
12
+ rake
13
+ rake (0.8.7)
14
+ shoulda (2.11.3)
15
+
16
+ PLATFORMS
17
+ ruby
18
+
19
+ DEPENDENCIES
20
+ mime-types
21
+ mocha
22
+ shoulda
23
+ wand!
data/Rakefile CHANGED
@@ -1,27 +1,5 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- require File.dirname(__FILE__) + '/lib/wand'
5
-
6
- begin
7
- require 'jeweler'
8
- Jeweler::Tasks.new do |gem|
9
- gem.name = 'wand'
10
- gem.summary = gem.description = 'Mime-Type gem with fallback to unix file command'
11
- gem.email = 'nunemaker@gmail.com'
12
- gem.homepage = 'http://github.com/jnunemaker/wand'
13
- gem.authors = ['John Nunemaker']
14
- gem.version = Wand::Version
15
-
16
- gem.add_dependency 'mime-types'
17
- gem.add_development_dependency 'shoulda'
18
- gem.add_development_dependency 'yard'
19
- gem.add_development_dependency 'mocha'
20
- end
21
- Jeweler::GemcutterTasks.new
22
- rescue LoadError
23
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
24
- end
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
25
3
 
26
4
  require 'rake/testtask'
27
5
  Rake::TestTask.new(:test) do |test|
@@ -31,14 +9,4 @@ Rake::TestTask.new(:test) do |test|
31
9
  test.verbose = true
32
10
  end
33
11
 
34
- task :test => :check_dependencies
35
- task :default => :test
36
-
37
- begin
38
- require 'yard'
39
- YARD::Rake::YardocTask.new
40
- rescue LoadError
41
- task :yardoc do
42
- abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
43
- end
44
- end
12
+ task :default => :test
@@ -1,12 +1,10 @@
1
1
  require 'mime/types'
2
2
 
3
3
  module Wand
4
- Version = '0.2.1'
5
-
6
- def self.wave(path)
7
- type = MIME::Types.type_for(path)[0].to_s
4
+ def self.wave(path, options={})
5
+ type = MIME::Types.type_for(options[:original_filename] || path)[0].to_s
8
6
  type = execute_file_cmd(path).split(';')[0].strip if type.nil? || type == ''
9
- type = nil if type =~ /cannot\sopen/
7
+ type = nil if type =~ /^cannot/i
10
8
  type
11
9
  end
12
10
 
@@ -17,8 +15,8 @@ module Wand
17
15
  def self.executable=(path)
18
16
  @executable = path
19
17
  end
20
-
18
+
21
19
  def self.execute_file_cmd(path)
22
20
  `#{executable} --mime --brief #{path}`
23
21
  end
24
- end
22
+ end
@@ -0,0 +1,3 @@
1
+ module Wand
2
+ VERSION = "0.3"
3
+ end
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 John Nunemaker
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -15,6 +15,7 @@ class TestWand < Test::Unit::TestCase
15
15
  'ol_tiny.jpg' => 'image/jpeg',
16
16
  'ol_tiny.png' => 'image/png',
17
17
  'styles.css' => 'text/css',
18
+ 'LICENSE' => 'text/plain',
18
19
  }.each_pair do |name, type|
19
20
  should "use mime type gem if it returns type #{name}" do
20
21
  assert_equal type, Wand.wave(FilePath.join(name).expand_path.to_s)
@@ -32,6 +33,10 @@ class TestWand < Test::Unit::TestCase
32
33
  end
33
34
  end
34
35
 
36
+ should "return value from mime type when original_filename provided" do
37
+ assert_equal 'audio/mpeg', Wand.wave('some_temp_file', :original_filename => 'test.mp3')
38
+ end
39
+
35
40
  should "return nil when mime type and file fail" do
36
41
  assert_nil Wand.wave('AVGARDD.eot')
37
42
  end
@@ -49,5 +54,15 @@ class TestWand < Test::Unit::TestCase
49
54
  Wand.expects(:execute_file_cmd).returns("image/jpeg\n")
50
55
  assert_equal "image/jpeg", Wand.wave(FilePath.join(name).expand_path.to_s)
51
56
  end
57
+
58
+ should "support old file output format" do
59
+ Wand.expects(:execute_file_cmd).returns("text/plain; charset=us-ascii\n")
60
+ assert_equal "text/plain", Wand.wave('')
61
+ end
62
+
63
+ should "return nil if file output matches cannot" do
64
+ Wand.expects(:execute_file_cmd).returns("cannot open file")
65
+ assert_equal nil, Wand.wave('')
66
+ end
52
67
  end
53
68
  end
@@ -1,74 +1,24 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "wand/version"
5
4
 
6
5
  Gem::Specification.new do |s|
7
- s.name = %q{wand}
8
- s.version = "0.2.1"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["John Nunemaker"]
12
- s.date = %q{2010-03-10}
6
+ s.name = "wand"
7
+ s.version = Wand::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["John Nunemaker"]
10
+ s.email = ["nunemaker@gmail.com"]
11
+ s.homepage = "http://github.com/jnunemaker/wand"
12
+ s.summary = %q{Mime-Type gem with fallback to unix file command}
13
13
  s.description = %q{Mime-Type gem with fallback to unix file command}
14
- s.email = %q{nunemaker@gmail.com}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- ".document",
21
- ".gitignore",
22
- "LICENSE",
23
- "README.rdoc",
24
- "Rakefile",
25
- "lib/wand.rb",
26
- "test/files/AVGARDD.eot",
27
- "test/files/AVGARDD.svg",
28
- "test/files/AVGARDD.ttf",
29
- "test/files/AVGARDD.woff",
30
- "test/files/compressed.zip",
31
- "test/files/example.m4r",
32
- "test/files/favicon.ico",
33
- "test/files/index.html",
34
- "test/files/jquery.js",
35
- "test/files/ol_tiny.jpg",
36
- "test/files/ol_tiny.png",
37
- "test/files/styles.css",
38
- "test/helper.rb",
39
- "test/test_wand.rb",
40
- "wand.gemspec"
41
- ]
42
- s.homepage = %q{http://github.com/jnunemaker/wand}
43
- s.rdoc_options = ["--charset=UTF-8"]
44
- s.require_paths = ["lib"]
45
- s.rubygems_version = %q{1.3.5}
46
- s.summary = %q{Mime-Type gem with fallback to unix file command}
47
- s.test_files = [
48
- "test/helper.rb",
49
- "test/test_wand.rb"
50
- ]
51
14
 
52
- if s.respond_to? :specification_version then
53
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
54
- s.specification_version = 3
15
+ s.add_dependency 'mime-types'
55
16
 
56
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
57
- s.add_runtime_dependency(%q<mime-types>, [">= 0"])
58
- s.add_development_dependency(%q<shoulda>, [">= 0"])
59
- s.add_development_dependency(%q<yard>, [">= 0"])
60
- s.add_development_dependency(%q<mocha>, [">= 0"])
61
- else
62
- s.add_dependency(%q<mime-types>, [">= 0"])
63
- s.add_dependency(%q<shoulda>, [">= 0"])
64
- s.add_dependency(%q<yard>, [">= 0"])
65
- s.add_dependency(%q<mocha>, [">= 0"])
66
- end
67
- else
68
- s.add_dependency(%q<mime-types>, [">= 0"])
69
- s.add_dependency(%q<shoulda>, [">= 0"])
70
- s.add_dependency(%q<yard>, [">= 0"])
71
- s.add_dependency(%q<mocha>, [">= 0"])
72
- end
73
- end
17
+ s.add_development_dependency 'shoulda'
18
+ s.add_development_dependency 'mocha'
74
19
 
20
+ s.files = `git ls-files`.split("\n")
21
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
23
+ s.require_paths = ["lib"]
24
+ end
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wand
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ hash: 13
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 3
9
+ version: "0.3"
5
10
  platform: ruby
6
11
  authors:
7
12
  - John Nunemaker
@@ -9,69 +14,75 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-03-10 00:00:00 -05:00
17
+ date: 2010-12-20 00:00:00 -05:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: mime-types
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
20
25
  requirements:
21
26
  - - ">="
22
27
  - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
23
31
  version: "0"
24
- version:
32
+ type: :runtime
33
+ version_requirements: *id001
25
34
  - !ruby/object:Gem::Dependency
26
35
  name: shoulda
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
30
39
  requirements:
31
40
  - - ">="
32
41
  - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
33
45
  version: "0"
34
- version:
35
- - !ruby/object:Gem::Dependency
36
- name: yard
37
46
  type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: "0"
44
- version:
47
+ version_requirements: *id002
45
48
  - !ruby/object:Gem::Dependency
46
49
  name: mocha
47
- type: :development
48
- version_requirement:
49
- version_requirements: !ruby/object:Gem::Requirement
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ none: false
50
53
  requirements:
51
54
  - - ">="
52
55
  - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
53
59
  version: "0"
54
- version:
60
+ type: :development
61
+ version_requirements: *id003
55
62
  description: Mime-Type gem with fallback to unix file command
56
- email: nunemaker@gmail.com
63
+ email:
64
+ - nunemaker@gmail.com
57
65
  executables: []
58
66
 
59
67
  extensions: []
60
68
 
61
- extra_rdoc_files:
62
- - LICENSE
63
- - README.rdoc
69
+ extra_rdoc_files: []
70
+
64
71
  files:
65
72
  - .document
66
73
  - .gitignore
74
+ - Gemfile
75
+ - Gemfile.lock
67
76
  - LICENSE
68
77
  - README.rdoc
69
78
  - Rakefile
70
79
  - lib/wand.rb
80
+ - lib/wand/version.rb
71
81
  - test/files/AVGARDD.eot
72
82
  - test/files/AVGARDD.svg
73
83
  - test/files/AVGARDD.ttf
74
84
  - test/files/AVGARDD.woff
85
+ - test/files/LICENSE
75
86
  - test/files/compressed.zip
76
87
  - test/files/example.m4r
77
88
  - test/files/favicon.ico
@@ -88,29 +99,48 @@ homepage: http://github.com/jnunemaker/wand
88
99
  licenses: []
89
100
 
90
101
  post_install_message:
91
- rdoc_options:
92
- - --charset=UTF-8
102
+ rdoc_options: []
103
+
93
104
  require_paths:
94
105
  - lib
95
106
  required_ruby_version: !ruby/object:Gem::Requirement
107
+ none: false
96
108
  requirements:
97
109
  - - ">="
98
110
  - !ruby/object:Gem::Version
111
+ hash: 3
112
+ segments:
113
+ - 0
99
114
  version: "0"
100
- version:
101
115
  required_rubygems_version: !ruby/object:Gem::Requirement
116
+ none: false
102
117
  requirements:
103
118
  - - ">="
104
119
  - !ruby/object:Gem::Version
120
+ hash: 3
121
+ segments:
122
+ - 0
105
123
  version: "0"
106
- version:
107
124
  requirements: []
108
125
 
109
126
  rubyforge_project:
110
- rubygems_version: 1.3.5
127
+ rubygems_version: 1.3.7
111
128
  signing_key:
112
129
  specification_version: 3
113
130
  summary: Mime-Type gem with fallback to unix file command
114
131
  test_files:
132
+ - test/files/AVGARDD.eot
133
+ - test/files/AVGARDD.svg
134
+ - test/files/AVGARDD.ttf
135
+ - test/files/AVGARDD.woff
136
+ - test/files/LICENSE
137
+ - test/files/compressed.zip
138
+ - test/files/example.m4r
139
+ - test/files/favicon.ico
140
+ - test/files/index.html
141
+ - test/files/jquery.js
142
+ - test/files/ol_tiny.jpg
143
+ - test/files/ol_tiny.png
144
+ - test/files/styles.css
115
145
  - test/helper.rb
116
146
  - test/test_wand.rb