ruby-filemagic 0.6.1 → 0.6.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.
- checksums.yaml +4 -4
- data/ChangeLog +6 -2
- data/README +46 -21
- data/Rakefile +21 -15
- data/ext/filemagic/extconf.rb +5 -0
- data/ext/filemagic/filemagic.c +2 -1
- data/lib/filemagic.rb +11 -1
- data/lib/filemagic/magic.mgc +0 -0
- data/lib/filemagic/version.rb +1 -1
- data/test/filemagic_test.rb +12 -1
- data/test/perl.mgc +0 -0
- metadata +18 -33
- data/info/example.rb +0 -31
- data/info/filemagic.rd +0 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d1d279fb547f7aa623c1e88e7f2f47f6e4e1861
|
4
|
+
data.tar.gz: 88e3fbc28fd2ce43f1f7b7669e1ee2655359a619
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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.
|
5
|
+
This documentation refers to filemagic version 0.6.2
|
6
6
|
|
7
7
|
|
8
8
|
== DESCRIPTION
|
9
9
|
|
10
|
-
|
10
|
+
FileMagic extension module. See also libmagic(3), file(1) and magic(4).
|
11
11
|
|
12
|
-
|
12
|
+
=== Constants
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
-
|
23
|
+
=== Methods
|
19
24
|
|
20
|
-
|
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
|
-
|
42
|
+
p FileMagic.new.flags
|
23
43
|
|
24
|
-
|
44
|
+
FileMagic.open(:mime) { |fm|
|
45
|
+
p fm.flags
|
46
|
+
p fm.file(__FILE__)
|
47
|
+
p fm.file(__FILE__, true)
|
25
48
|
|
26
|
-
|
27
|
-
|
49
|
+
fm.flags = [:raw, :continue]
|
50
|
+
p fm.flags
|
51
|
+
}
|
28
52
|
|
29
|
-
|
53
|
+
fm = FileMagic.new
|
54
|
+
p fm.flags
|
30
55
|
|
31
|
-
|
32
|
-
|
33
|
-
su
|
34
|
-
make install
|
56
|
+
mime = FileMagic.mime
|
57
|
+
p mime.flags
|
35
58
|
|
36
|
-
|
37
|
-
|
59
|
+
=== Installation
|
60
|
+
|
61
|
+
Install the gem:
|
62
|
+
|
63
|
+
sudo gem install ruby-filemagic
|
38
64
|
|
39
|
-
|
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
|
-
|
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:
|
9
|
-
version:
|
10
|
-
summary:
|
11
|
-
authors:
|
12
|
-
email:
|
13
|
-
license:
|
14
|
-
homepage:
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
33
|
+
warn "Please install the `hen' gem. (#{err})"
|
28
34
|
end
|
data/ext/filemagic/extconf.rb
CHANGED
@@ -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')
|
data/ext/filemagic/filemagic.c
CHANGED
data/lib/filemagic.rb
CHANGED
@@ -1,8 +1,18 @@
|
|
1
|
-
|
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
|
data/lib/filemagic/version.rb
CHANGED
data/test/filemagic_test.rb
CHANGED
@@ -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
|
-
|
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)
|
data/test/perl.mgc
ADDED
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.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
-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MN87XwexGuU2GCpIMUd6VCTA7zMP2OWuXEcba7jT5OtiI55buO0J4CRtyeX1XF
|
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:
|
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:
|
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.
|
113
|
+
ruby-filemagic-0.6.2 [2015-02-06]:
|
129
114
|
|
130
|
-
*
|
131
|
-
|
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.
|
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.
|
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
|
data/info/example.rb
DELETED
@@ -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
|
-
}
|
data/info/filemagic.rd
DELETED
@@ -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.
|