ruby-filemagic 0.6.1 → 0.6.2

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: 8defa2096e9b64ff01af2cb0cdfebfbf25fd8177
4
- data.tar.gz: 6f3018740cf798e2fa4d54d343e8b4942e71f695
3
+ metadata.gz: 6d1d279fb547f7aa623c1e88e7f2f47f6e4e1861
4
+ data.tar.gz: 88e3fbc28fd2ce43f1f7b7669e1ee2655359a619
5
5
  SHA512:
6
- metadata.gz: 8b9ed685e46ac3c6516e95a96cc0ce9eeb1cc07053fa8a697853a6f963cee69e561492cd6e34d1d78b2b310f8eb0d02ea89c523e4da464f80544a21f461169ce
7
- data.tar.gz: 30f8367ed63c08a609119d6fa0d69fcb904de20210cf1eb3fa598ec8d95dcd8c1916fbca6655e663b530ea4ce45e225bb202ee152c7810e78c1e2cb0e0e9704d
6
+ metadata.gz: 3143dd206af80d9e962ce5907cc9b9d24a5ddbee25783f9621970f065b2dcf31427135261c2b09f3c734738a7e0b2f2912d39a400d528d5e12a4e6e1076c4071
7
+ data.tar.gz: 0eb00059e40fd6db78d26a194f1e101b7526e194a0550d2161f90540a7bde0bcae61e3ced9db6e37b59b5226802ee092ca71022f2e7ccf36bdae6f1b7e04bac3
data/ChangeLog CHANGED
@@ -2,10 +2,14 @@
2
2
 
3
3
  = Revision history for ruby-filemagic
4
4
 
5
+ == 0.6.2 [2015-02-06]
6
+
7
+ * Improved Windows support (issue #10 by Matt Hoyle).
8
+ * Fixed FileMagic.path to account for missing magic file.
9
+
5
10
  == 0.6.1 [2014-08-19]
6
11
 
7
- * Account for options passed to FileMagic.fm (issue #7 reported by Adam
8
- Wróbel).
12
+ * Account for options passed to FileMagic.fm (issue #7 by Adam Wróbel).
9
13
 
10
14
  == 0.6.0 [2014-05-16]
11
15
 
data/README CHANGED
@@ -2,42 +2,67 @@
2
2
 
3
3
  == VERSION
4
4
 
5
- This documentation refers to filemagic version 0.6.1
5
+ This documentation refers to filemagic version 0.6.2
6
6
 
7
7
 
8
8
  == DESCRIPTION
9
9
 
10
- === Revised version
10
+ FileMagic extension module. See also libmagic(3), file(1) and magic(4).
11
11
 
12
- September 12, 2008 Jens Wille <jens.wille@gmail.com>
12
+ === Constants
13
13
 
14
- Similar to Ricardo[http://github.com/ricardochimal/ruby-filemagic]
15
- I wanted this project to make some progress. My needs went a bit
16
- farther than his, though ;-) Enjoy anyway!
14
+ <tt>MAGIC_NONE</tt>:: No flags
15
+ <tt>MAGIC_DEBUG</tt>:: Turn on debugging
16
+ <tt>MAGIC_SYMLINK</tt>:: Follow symlinks
17
+ <tt>MAGIC_COMPRESS</tt>:: Check inside compressed files
18
+ <tt>MAGIC_DEVICES</tt>:: Look at the contents of devices
19
+ <tt>MAGIC_MIME</tt>:: Return a mime string
20
+ <tt>MAGIC_CONTINUE</tt>:: Return all matches, not just the first
21
+ <tt>MAGIC_CHECK</tt>:: Print warnings to stderr
17
22
 
18
- Install the gem:
23
+ === Methods
19
24
 
20
- sudo gem install ruby-filemagic
25
+ <tt>file(filename)</tt>:: Returns a textual description of the contents
26
+ of the filename argument
27
+ <tt>buffer(string)</tt>:: Returns a textual description of the contents
28
+ of the string argument
29
+ <tt>check(filename)</tt>:: Checks the validity of entries in the database
30
+ file passed in as filename
31
+ <tt>compile(filename)</tt>:: Compiles the database file passed in as filename
32
+ <tt>close()</tt>:: Closes the magic database and frees any memory
33
+ allocated
34
+
35
+ === Synospis
36
+
37
+ require 'filemagic'
38
+
39
+ p FileMagic::VERSION
40
+ p FileMagic::MAGIC_VERSION
21
41
 
22
- === Original package
42
+ p FileMagic.new.flags
23
43
 
24
- July 28, 2003 Travis Whitton <tinymountain@gmail.com>
44
+ FileMagic.open(:mime) { |fm|
45
+ p fm.flags
46
+ p fm.file(__FILE__)
47
+ p fm.file(__FILE__, true)
25
48
 
26
- This is one of my first ruby bindings, so suggestions are welcome. See
27
- filemagic.rd and test.rb for usage.
49
+ fm.flags = [:raw, :continue]
50
+ p fm.flags
51
+ }
28
52
 
29
- to install, run these commands:
53
+ fm = FileMagic.new
54
+ p fm.flags
30
55
 
31
- ruby extconf.rb
32
- make
33
- su
34
- make install
56
+ mime = FileMagic.mime
57
+ p mime.flags
35
58
 
36
- the file(1) library and headers are required.
37
- I have file 0.4.3.
59
+ === Installation
60
+
61
+ Install the gem:
62
+
63
+ sudo gem install ruby-filemagic
38
64
 
39
- Enjoy!
40
- Travis
65
+ The file(1) library and headers are required.
41
66
 
42
67
 
43
68
  == LINKS
data/Rakefile CHANGED
@@ -1,28 +1,34 @@
1
- require File.expand_path(%q{../lib/filemagic/version}, __FILE__)
1
+ require_relative 'lib/filemagic/version'
2
2
 
3
3
  begin
4
4
  require 'hen'
5
5
 
6
+ file mgc = 'lib/filemagic/magic.mgc' do
7
+ dir = ENV['WITH_CROSS_MAGIC']
8
+
9
+ dir && File.exist?(src = File.join(dir, 'magic', File.basename(mgc))) ?
10
+ cp(src, mgc) : File.binwrite(mgc, "\x1C\x04\x1E\xF1\x0C".ljust(248, "\0"))
11
+ end
12
+
6
13
  Hen.lay! {{
7
14
  gem: {
8
- name: %q{ruby-filemagic},
9
- version: FileMagic::VERSION,
10
- summary: 'Ruby bindings to the magic(4) library',
11
- authors: ['Travis Whitton', 'Jens Wille'],
12
- email: 'jens.wille@gmail.com',
13
- license: %q{Ruby},
14
- homepage: :blackwinter,
15
- extra_files: FileList['info/*'].to_a,
16
- dependencies: %w[],
17
- extension: {
18
- name: 'ruby_filemagic',
19
- ext_name: 'filemagic',
20
- cross_compile: false
15
+ name: %q{ruby-filemagic},
16
+ version: FileMagic::VERSION,
17
+ summary: 'Ruby bindings to the magic(4) library',
18
+ authors: ['Travis Whitton', 'Jens Wille'],
19
+ email: 'jens.wille@gmail.com',
20
+ license: %q{Ruby},
21
+ homepage: :blackwinter,
22
+ local_files: [mgc],
23
+ extension: {
24
+ with_cross_gnurx: lambda { |dir| [dir] },
25
+ with_cross_magic: lambda { |dir| [src =
26
+ File.join(dir, 'src'), File.join(src, '.libs')] }
21
27
  },
22
28
 
23
29
  required_ruby_version: '>= 1.9.3'
24
30
  }
25
31
  }}
26
32
  rescue LoadError => err
27
- warn "Please install the `hen' gem first. (#{err})"
33
+ warn "Please install the `hen' gem. (#{err})"
28
34
  end
@@ -1,7 +1,12 @@
1
1
  require 'mkmf'
2
2
 
3
3
  $CFLAGS << ' -Wall' if ENV['WALL']
4
+ $LDFLAGS << ' -static-libgcc'
5
+
4
6
  dir_config('magic')
7
+ dir_config('gnurx')
8
+
9
+ have_library('gnurx')
5
10
 
6
11
  if have_library('magic', 'magic_open') && have_header('magic.h')
7
12
  have_header('file/patchlevel.h')
@@ -3,7 +3,8 @@
3
3
  /* Returns the magic path */
4
4
  static VALUE
5
5
  rb_magic_getpath(VALUE klass) {
6
- return rb_str_new2(magic_getpath(NULL, 0));
6
+ const char *path = magic_getpath(NULL, 0);
7
+ return path != NULL ? rb_str_new2(path) : Qnil;
7
8
  }
8
9
 
9
10
  /* Converts flags to integer */
@@ -1,8 +1,18 @@
1
- require 'filemagic/ruby_filemagic'
1
+ begin
2
+ require "filemagic/#{RUBY_VERSION[/\d+.\d+/]}/ruby_filemagic"
3
+ rescue LoadError => err
4
+ raise if err.respond_to?(:path) && !err.path
5
+ require 'filemagic/ruby_filemagic'
6
+ end
7
+
2
8
  require 'filemagic/version'
3
9
 
4
10
  class FileMagic
5
11
 
12
+ DEFAULT_MAGIC = __FILE__.sub(/\.rb\z/, '/magic.mgc')
13
+
14
+ ENV['MAGIC'] ||= DEFAULT_MAGIC unless path
15
+
6
16
  # Map flag names to their values (:name => Integer).
7
17
  FLAGS_BY_SYM = [
8
18
  :none, # No flags
Binary file
@@ -4,7 +4,7 @@ class FileMagic
4
4
 
5
5
  MAJOR = 0
6
6
  MINOR = 6
7
- TINY = 1
7
+ TINY = 2
8
8
 
9
9
  class << self
10
10
 
@@ -45,7 +45,9 @@ magic file from #{FileMagic.path}
45
45
  fm = FileMagic.new(FileMagic::MAGIC_COMPRESS)
46
46
 
47
47
  res = fm.file(path_to('pyfile-compressed.gz'))
48
- assert_match(/^#{python_script} \(gzip compressed data, was "pyfile-compressed", from Unix/, res)
48
+ gzip_compressed = 'gzip compressed data, was "pyfile-compressed"'
49
+ assert_match(Gem.win_platform? ? /^#{gzip_compressed}/ :
50
+ /^#{python_script} \(#{gzip_compressed}/, res)
49
51
 
50
52
  fm.close
51
53
  end
@@ -58,12 +60,21 @@ magic file from #{FileMagic.path}
58
60
  end
59
61
 
60
62
  def test_check
63
+ return if Gem.win_platform?
61
64
  fm = FileMagic.new(FileMagic::MAGIC_NONE)
62
65
  res = silence_stderr { fm.check(path_to('perl')) }
63
66
  fm.close
64
67
  assert(res)
65
68
  end
66
69
 
70
+ def test_check_compiled
71
+ return if MAGIC_VERSION <= 5.09
72
+ fm = FileMagic.new(FileMagic::MAGIC_NONE)
73
+ res = silence_stderr { fm.check(path_to('perl.mgc')) }
74
+ fm.close
75
+ assert(res)
76
+ end
77
+
67
78
  def test_compile
68
79
  assert(File.writable?('.'), "can't write to current directory")
69
80
  fm = FileMagic.new(FileMagic::MAGIC_NONE)
Binary file
metadata CHANGED
@@ -1,51 +1,36 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-filemagic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Travis Whitton
8
8
  - Jens Wille
9
9
  autorequire:
10
10
  bindir: bin
11
- cert_chain:
12
- - |
13
- -----BEGIN CERTIFICATE-----
14
- MIIDMDCCAhigAwIBAgIBADANBgkqhkiG9w0BAQUFADA+MQswCQYDVQQDDAJ3dzEb
15
- MBkGCgmSJomT8ixkARkWC2JsYWNrd2ludGVyMRIwEAYKCZImiZPyLGQBGRYCZGUw
16
- HhcNMTMwMTMxMDkyMjIyWhcNMTQwMTMxMDkyMjIyWjA+MQswCQYDVQQDDAJ3dzEb
17
- MBkGCgmSJomT8ixkARkWC2JsYWNrd2ludGVyMRIwEAYKCZImiZPyLGQBGRYCZGUw
18
- ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDVXmfa6rbTwKOvtuGoROc1
19
- I4qZjgLX0BA4WecYB97PjwLJmJ1hRvf9JulVCJYYmt5ZEPPXbgi9xLbcp6ofGmnC
20
- i68/kbhcz20/fRUtIJ2phU3ypQTEd2pFddpL7SR2FxLkzvvg5E6nslGn7o2erDpO
21
- 8sm610A3xsgT/eNIr9QA7k4pHh18X1KvZKmmQR4/AjVyKmKawzauKUoHHepjvjVs
22
- s0pVoM7UmOmrS4SafQ3OwUo37f19CVdN2/FW7z3e5+iYhKxdIFdhniX9iDWtA3Jn
23
- 7oUOtiolhCRK4P/c30UjTCDkRkOldsWciFUasROJ5VAV2SVv7FtGHoQLDZ/++tRr
24
- AgMBAAGjOTA3MAkGA1UdEwQCMAAwHQYDVR0OBBYEFIAPWU4BEoYUe82hY/0EkoGd
25
- Oo/WMAsGA1UdDwQEAwIEsDANBgkqhkiG9w0BAQUFAAOCAQEAf2YnB0mj42of22dA
26
- MimgJCAEgB3H5aHbZ6B5WVnFvrC2UUnhP+/kLj/6UgOfqcasy4Xh62NVGuNrf7rF
27
- 7NMN87XwexGuU2GCpIMUd6VCTA7zMP2OWuXEcba7jT5OtiI55buO0J4CRtyeX1XF
28
- qwlGgx4ItcGhMTlDFXj3IkpeVtjD8O7yWE21bHf9lLURmqK/r9KjoxrrVi7+cESJ
29
- H19TDW3R9p594jCl1ykPs3dz/0Bk+r1HTd35Yw+yBbyprSJb4S7OcRRHCryuo09l
30
- NBGyZvOBuqUp0xostWSk0dfxyn/YQ7eqvQRGBhK1VGa7Tg/KYqnemDE57+VOXrua
31
- 59wzaA==
32
- -----END CERTIFICATE-----
33
- date: 2014-08-19 00:00:00.000000000 Z
11
+ cert_chain: []
12
+ date: 2015-02-06 00:00:00.000000000 Z
34
13
  dependencies:
35
14
  - !ruby/object:Gem::Dependency
36
15
  name: hen
37
16
  requirement: !ruby/object:Gem::Requirement
38
17
  requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '0.8'
39
21
  - - ">="
40
22
  - !ruby/object:Gem::Version
41
- version: '0'
23
+ version: 0.8.1
42
24
  type: :development
43
25
  prerelease: false
44
26
  version_requirements: !ruby/object:Gem::Requirement
45
27
  requirements:
28
+ - - "~>"
29
+ - !ruby/object:Gem::Version
30
+ version: '0.8'
46
31
  - - ">="
47
32
  - !ruby/object:Gem::Version
48
- version: '0'
33
+ version: 0.8.1
49
34
  - !ruby/object:Gem::Dependency
50
35
  name: rake
51
36
  requirement: !ruby/object:Gem::Requirement
@@ -105,10 +90,9 @@ files:
105
90
  - ext/filemagic/extconf.rb
106
91
  - ext/filemagic/filemagic.c
107
92
  - ext/filemagic/filemagic.h
108
- - info/example.rb
109
- - info/filemagic.rd
110
93
  - lib/filemagic.rb
111
94
  - lib/filemagic/ext.rb
95
+ - lib/filemagic/magic.mgc
112
96
  - lib/filemagic/version.rb
113
97
  - lib/ruby-filemagic.rb
114
98
  - test/excel-example.xls
@@ -116,6 +100,7 @@ files:
116
100
  - test/leaktest.rb
117
101
  - test/mahoro.c
118
102
  - test/perl
103
+ - test/perl.mgc
119
104
  - test/pyfile
120
105
  - test/pyfile-compressed.gz
121
106
  - test/pylink
@@ -125,14 +110,14 @@ licenses:
125
110
  metadata: {}
126
111
  post_install_message: |2+
127
112
 
128
- ruby-filemagic-0.6.1 [2014-08-19]:
113
+ ruby-filemagic-0.6.2 [2015-02-06]:
129
114
 
130
- * Account for options passed to FileMagic.fm (issue #7 reported by Adam
131
- Wróbel).
115
+ * Improved Windows support (issue #10 by Matt Hoyle).
116
+ * Fixed FileMagic.path to account for missing magic file.
132
117
 
133
118
  rdoc_options:
134
119
  - "--title"
135
- - ruby-filemagic Application documentation (v0.6.1)
120
+ - ruby-filemagic Application documentation (v0.6.2)
136
121
  - "--charset"
137
122
  - UTF-8
138
123
  - "--line-numbers"
@@ -153,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
138
  version: '0'
154
139
  requirements: []
155
140
  rubyforge_project:
156
- rubygems_version: 2.4.1
141
+ rubygems_version: 2.4.5
157
142
  signing_key:
158
143
  specification_version: 4
159
144
  summary: Ruby bindings to the magic(4) library
@@ -1,31 +0,0 @@
1
- #! /usr/bin/ruby
2
-
3
- $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
- require 'filemagic'
5
-
6
- p FileMagic::VERSION
7
- p FileMagic::MAGIC_VERSION
8
-
9
- p FileMagic.new.flags
10
-
11
- FileMagic.open(:mime) { |fm|
12
- p fm.flags
13
- p fm.file(__FILE__)
14
-
15
- fm.flags = [:raw, :continue]
16
- p fm.flags
17
- }
18
-
19
- fm = FileMagic.new
20
- p fm.flags
21
-
22
- mime = FileMagic.mime
23
- p mime.flags
24
-
25
- ARGV.each { |file|
26
- p fm.file(file)
27
- p fm.file(file, true)
28
-
29
- p mime.file(file)
30
- p mime.file(file, true)
31
- }
@@ -1,36 +0,0 @@
1
- =begin
2
-
3
- = FileMagic extension module SEE ALSO libmagic(3), file(1) and magic(4)
4
- == FileMagic
5
- === Constants
6
- : MAGIC_NONE
7
- No flags
8
- : MAGIC_DEBUG
9
- Turn on debuggin
10
- : MAGIC_SYMLINK
11
- Follow symlinks
12
- : MAGIC_COMPRESS
13
- Check inside compressed files
14
- : MAGIC_DEVICES
15
- Look at the contents of devices
16
- : MAGIC_MIME
17
- Return a mime string
18
- : MAGIC_CONTINUE
19
- Return all matches, not just the first
20
- : MAGIC_CHECK
21
- Print warnings to stderr
22
-
23
- === Methods
24
- : file(filename)
25
- returns a textual description of the contents of the filename argument
26
- : buffer(string)
27
- returns a textual description of the contents of the string argument
28
- : check(filename)
29
- checks the validity of entries in the colon separated database files
30
- passed in as filename
31
- : compile(filename)
32
- compile the the colon separated list of database files passed in as
33
- filename
34
- : close()
35
- closes the magic database and frees any memory allocated. if memory
36
- is a concern, use this.