ruby-filemagic 0.2.1 → 0.2.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/README CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  == VERSION
4
4
 
5
- This documentation refers to filemagic version 0.2.1
5
+ This documentation refers to filemagic version 0.2.2
6
6
 
7
7
 
8
8
  == DESCRIPTION
@@ -15,7 +15,11 @@ Similar to Ricardo[http://github.com/ricardochimal/ruby-filemagic]
15
15
  I wanted this project to make some progress. My needs went a bit
16
16
  farther than his, though ;-) Enjoy anyway!
17
17
 
18
- Install the gem from github[http://github.com]:
18
+ Install the gem from Rubyforge[http://rubyforge.org]:
19
+
20
+ sudo gem install ruby-filemagic
21
+
22
+ or from Github[http://github.com]:
19
23
 
20
24
  sudo gem install blackwinter-ruby-filemagic --source http://gems.github.com
21
25
 
@@ -42,10 +46,11 @@ Travis
42
46
 
43
47
  == LINKS
44
48
 
45
- * <http://grub.ath.cx/filemagic/>
46
- * <http://github.com/blackwinter/ruby-filemagic>
47
- * <http://ruby-filemagic.rubyforge.org/>
48
- * <http://rubyforge.org/projects/ruby-filemagic>
49
+ <b></b>
50
+ Homepage:: <http://grub.ath.cx/filemagic/>
51
+ Documentation:: <http://ruby-filemagic.rubyforge.org/>
52
+ Source code:: <http://github.com/blackwinter/ruby-filemagic>
53
+ Rubyforge project:: <http://rubyforge.org/projects/ruby-filemagic>
49
54
 
50
55
 
51
56
  == AUTHORS
data/lib/filemagic.rb CHANGED
@@ -171,7 +171,7 @@ class FileMagic
171
171
  private
172
172
 
173
173
  def simplify_mime(mime, simplified = true)
174
- simplified ? mime[/([\w\/-]+)/, 1].downcase : mime
174
+ simplified ? mime[/([.\w\/-]+)/, 1].downcase : mime
175
175
  end
176
176
 
177
177
  end
data/lib/filemagic/ext.rb CHANGED
@@ -2,6 +2,13 @@ require 'filemagic'
2
2
 
3
3
  module FileMagic::Ext
4
4
 
5
+ def self.included(base)
6
+ base.class_eval {
7
+ extend ClassMethods
8
+ include InstanceMethods
9
+ }
10
+ end
11
+
5
12
  module ClassMethods
6
13
 
7
14
  def file_type(file, *flags)
@@ -47,8 +54,7 @@ end
47
54
 
48
55
  class File
49
56
 
50
- include FileMagic::Ext::InstanceMethods
51
- extend FileMagic::Ext::ClassMethods
57
+ include FileMagic::Ext
52
58
 
53
59
  def self.file_type(file, *flags)
54
60
  FileMagic.fm(*flags).file(file.respond_to?(:path) ? file.path : file)
@@ -60,8 +66,7 @@ end
60
66
 
61
67
  class String
62
68
 
63
- include FileMagic::Ext::InstanceMethods
64
- extend FileMagic::Ext::ClassMethods
69
+ include FileMagic::Ext
65
70
 
66
71
  def self.file_type(string, *flags)
67
72
  FileMagic.fm(*flags).buffer(string)
@@ -4,7 +4,7 @@ class FileMagic
4
4
 
5
5
  MAJOR = 0
6
6
  MINOR = 2
7
- TINY = 1
7
+ TINY = 2
8
8
 
9
9
  class << self
10
10
 
Binary file
@@ -26,7 +26,7 @@ class TestFileMagic < Test::Unit::TestCase
26
26
  fm = FileMagic.new(FileMagic::MAGIC_SYMLINK | FileMagic::MAGIC_MIME)
27
27
 
28
28
  res = fm.file(path_to('pylink'))
29
- assert_equal('text/plain; charset=us-ascii', res)
29
+ assert_equal('text/plain', res)
30
30
 
31
31
  fm.close
32
32
  fm = FileMagic.new(FileMagic::MAGIC_COMPRESS)
@@ -95,7 +95,7 @@ class TestFileMagic < Test::Unit::TestCase
95
95
  def test_mahoro_mime_file
96
96
  fm = FileMagic.new
97
97
  fm.flags = FileMagic::MAGIC_MIME
98
- assert_equal('text/x-c; charset=us-ascii', fm.file(path_to('mahoro.c')))
98
+ assert_equal('text/x-c', fm.file(path_to('mahoro.c')))
99
99
  end
100
100
 
101
101
  def test_mahoro_buffer
@@ -107,7 +107,7 @@ class TestFileMagic < Test::Unit::TestCase
107
107
  def test_mahoro_mime_buffer
108
108
  fm = FileMagic.new
109
109
  fm.flags = FileMagic::MAGIC_MIME
110
- assert_equal('text/x-c; charset=us-ascii', fm.buffer(File.read(path_to('mahoro.c'))))
110
+ assert_equal('text/x-c', fm.buffer(File.read(path_to('mahoro.c'))))
111
111
  end
112
112
 
113
113
  def test_mahoro_valid
@@ -115,6 +115,13 @@ class TestFileMagic < Test::Unit::TestCase
115
115
  assert(fm.valid?, 'Default database was not valid.')
116
116
  end
117
117
 
118
+ # test abbreviating mime types
119
+
120
+ def test_abbrev_mime_type
121
+ fm = FileMagic.mime
122
+ assert_match(/\Aapplication\/vnd.ms-/, fm.file(path_to('excel-example.xls')))
123
+ end
124
+
118
125
  # utility methods:
119
126
 
120
127
  def path_to(file, dir = File.dirname(__FILE__))
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-filemagic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 2
8
+ - 2
9
+ version: 0.2.2
5
10
  platform: ruby
6
11
  authors:
7
12
  - Travis Whitton
@@ -10,7 +15,7 @@ autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2008-09-18 00:00:00 +02:00
18
+ date: 2010-03-02 00:00:00 +01:00
14
19
  default_executable:
15
20
  dependencies: []
16
21
 
@@ -30,29 +35,32 @@ files:
30
35
  - lib/filemagic.rb
31
36
  - ext/filemagic.c
32
37
  - test/pyfile
38
+ - test/mahoro.c
39
+ - test/pylink
33
40
  - test/pyfile-compressed.gz
34
41
  - test/perl
35
42
  - test/leaktest.rb
36
- - test/mahoro.c
37
43
  - test/filemagic_test.rb
38
- - test/pylink
44
+ - test/excel-example.xls
39
45
  - README
40
46
  - CHANGELOG
41
- - TODO
42
47
  - Rakefile
48
+ - TODO
43
49
  - info/filemagic.rd
44
50
  - info/example.rb
45
51
  has_rdoc: true
46
52
  homepage: http://ruby-filemagic.rubyforge.org/
53
+ licenses: []
54
+
47
55
  post_install_message:
48
56
  rdoc_options:
49
- - --line-numbers
57
+ - --title
58
+ - ruby-filemagic Application documentation
50
59
  - --main
51
60
  - README
52
- - --all
61
+ - --line-numbers
53
62
  - --inline-source
54
- - --title
55
- - ruby-filemagic Application documentation
63
+ - --all
56
64
  - --charset
57
65
  - UTF-8
58
66
  require_paths:
@@ -61,20 +69,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
61
69
  requirements:
62
70
  - - ">="
63
71
  - !ruby/object:Gem::Version
72
+ segments:
73
+ - 0
64
74
  version: "0"
65
- version:
66
75
  required_rubygems_version: !ruby/object:Gem::Requirement
67
76
  requirements:
68
77
  - - ">="
69
78
  - !ruby/object:Gem::Version
79
+ segments:
80
+ - 0
70
81
  version: "0"
71
- version:
72
82
  requirements: []
73
83
 
74
84
  rubyforge_project: ruby-filemagic
75
- rubygems_version: 1.2.0
85
+ rubygems_version: 1.3.6
76
86
  signing_key:
77
- specification_version: 2
87
+ specification_version: 3
78
88
  summary: Ruby bindings to the magic(4) library
79
89
  test_files: []
80
90