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 +1 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +23 -0
- data/Rakefile +3 -35
- data/lib/wand.rb +5 -7
- data/lib/wand/version.rb +3 -0
- data/test/files/LICENSE +20 -0
- data/test/test_wand.rb +15 -0
- data/wand.gemspec +17 -67
- metadata +62 -32
data/.gitignore
CHANGED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -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 '
|
2
|
-
|
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 :
|
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
|
data/lib/wand.rb
CHANGED
@@ -1,12 +1,10 @@
|
|
1
1
|
require 'mime/types'
|
2
2
|
|
3
3
|
module Wand
|
4
|
-
|
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 =~
|
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
|
data/lib/wand/version.rb
ADDED
data/test/files/LICENSE
ADDED
@@ -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.
|
data/test/test_wand.rb
CHANGED
@@ -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
|
data/wand.gemspec
CHANGED
@@ -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
|
8
|
-
s.version
|
9
|
-
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
s.
|
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
|
-
|
53
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
54
|
-
s.specification_version = 3
|
15
|
+
s.add_dependency 'mime-types'
|
55
16
|
|
56
|
-
|
57
|
-
|
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
|
-
|
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-
|
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
|
-
|
18
|
-
|
19
|
-
|
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
|
-
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
25
34
|
- !ruby/object:Gem::Dependency
|
26
35
|
name: shoulda
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
-
|
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
|
-
|
48
|
-
|
49
|
-
|
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
|
-
|
60
|
+
type: :development
|
61
|
+
version_requirements: *id003
|
55
62
|
description: Mime-Type gem with fallback to unix file command
|
56
|
-
email:
|
63
|
+
email:
|
64
|
+
- nunemaker@gmail.com
|
57
65
|
executables: []
|
58
66
|
|
59
67
|
extensions: []
|
60
68
|
|
61
|
-
extra_rdoc_files:
|
62
|
-
|
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
|
-
|
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.
|
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
|