ruby-magic 0.0.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/AUTHORS +1 -1
- data/CHANGELOG.md +60 -0
- data/CONTRIBUTORS.md +17 -0
- data/COPYRIGHT +1 -1
- data/NOTICE +505 -0
- data/README.md +49 -0
- data/dependencies.yml +93 -0
- data/ext/magic/common.h +130 -59
- data/ext/magic/extconf.rb +404 -64
- data/ext/magic/functions.c +265 -187
- data/ext/magic/functions.h +46 -79
- data/ext/magic/ruby-magic.c +1288 -641
- data/ext/magic/ruby-magic.h +383 -173
- data/kwilczynski-public.pem +25 -0
- data/lib/magic.rb +86 -87
- data/lib/magic/core/file.rb +8 -66
- data/lib/magic/core/string.rb +4 -47
- data/lib/magic/version.rb +14 -48
- data/patches/libmagic/0001-Don-t-attempt-to-build-tests-documentation-and-Python-bindings.patch +44 -0
- data/ports/archives/file-5.39.tar.gz +0 -0
- metadata +36 -99
- data/CHANGES +0 -5
- data/CHANGES.rdoc +0 -5
- data/README +0 -1
- data/README.rdoc +0 -7
- data/Rakefile +0 -78
- data/TODO +0 -21
- data/VERSION +0 -1
- data/bin/magic +0 -33
- data/ruby-magic.gemspec +0 -68
- data/test/test_constants.rb +0 -47
- data/test/test_magic.rb +0 -260
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.0.1
|
data/bin/magic
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# -*- encoding: utf-8 -*-
|
4
|
-
|
5
|
-
# :enddoc:
|
6
|
-
|
7
|
-
#
|
8
|
-
# magic
|
9
|
-
#
|
10
|
-
# Copyright 2013-2014 Krzysztof Wilczynski
|
11
|
-
#
|
12
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
13
|
-
# you may not use this file except in compliance with the License.
|
14
|
-
# You may obtain a copy of the License at
|
15
|
-
#
|
16
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
17
|
-
#
|
18
|
-
# Unless required by applicable law or agreed to in writing, software
|
19
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
20
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
21
|
-
# See the License for the specific language governing permissions and
|
22
|
-
# limitations under the License.
|
23
|
-
#
|
24
|
-
|
25
|
-
begin
|
26
|
-
require 'magic'
|
27
|
-
rescue LoadError
|
28
|
-
require 'rubygems'
|
29
|
-
require 'magic'
|
30
|
-
end
|
31
|
-
|
32
|
-
# vim: set ts=2 sw=2 sts=2 et :
|
33
|
-
# encoding: utf-8
|
data/ruby-magic.gemspec
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
# :enddoc:
|
4
|
-
|
5
|
-
#
|
6
|
-
# ruby-magic.gemspec
|
7
|
-
#
|
8
|
-
# Copyright 2013-2014 Krzysztof Wilczynski
|
9
|
-
#
|
10
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
11
|
-
# you may not use this file except in compliance with the License.
|
12
|
-
# You may obtain a copy of the License at
|
13
|
-
#
|
14
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
15
|
-
#
|
16
|
-
# Unless required by applicable law or agreed to in writing, software
|
17
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
18
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
19
|
-
# See the License for the specific language governing permissions and
|
20
|
-
# limitations under the License.
|
21
|
-
#
|
22
|
-
|
23
|
-
signing_key = File.expand_path('~/.gem/kwilczynski-private.pem')
|
24
|
-
|
25
|
-
Gem::Specification.new do |s|
|
26
|
-
s.name = 'ruby-magic'
|
27
|
-
|
28
|
-
s.description = <<-EOS
|
29
|
-
File Magic in Ruby.
|
30
|
-
|
31
|
-
Simple interface to libmagic for Ruby Programming Language.
|
32
|
-
EOS
|
33
|
-
|
34
|
-
s.platform = Gem::Platform::RUBY
|
35
|
-
s.version = File.read('VERSION').strip
|
36
|
-
s.license = 'Apache License, Version 2.0'
|
37
|
-
s.author = 'Krzysztof Wilczynski'
|
38
|
-
s.email = 'krzysztof.wilczynski@linux.com'
|
39
|
-
s.homepage = 'http://about.me/kwilczynski'
|
40
|
-
|
41
|
-
s.rubyforge_project = 'ruby-magic'
|
42
|
-
s.rubygems_version = '~> 2.2.0'
|
43
|
-
s.has_rdoc = true
|
44
|
-
|
45
|
-
s.summary = 'File Magic in Ruby'
|
46
|
-
|
47
|
-
s.files = Dir['ext/**/*.{c,h,rb}'] +
|
48
|
-
Dir['lib/**/*.rb'] +
|
49
|
-
Dir['benchmark/**/*.rb'] +
|
50
|
-
Dir['test/**/*.rb'] +
|
51
|
-
%w(Rakefile ruby-magic.gemspec AUTHORS
|
52
|
-
CHANGES CHANGES.rdoc COPYRIGHT LICENSE
|
53
|
-
README README.rdoc TODO VERSION)
|
54
|
-
|
55
|
-
s.executables << 'magic'
|
56
|
-
s.require_paths << 'lib'
|
57
|
-
s.extensions << 'ext/magic/extconf.rb'
|
58
|
-
|
59
|
-
s.add_development_dependency 'rake', '~> 10.1', '>= 10.1.1'
|
60
|
-
s.add_development_dependency 'rdoc', '~> 4.1', '>= 4.1.1'
|
61
|
-
s.add_development_dependency 'test-unit', '~> 2.5', '>= 2.5.5'
|
62
|
-
s.add_development_dependency 'rake-compiler', '~> 0.9', '>= 0.9.2'
|
63
|
-
|
64
|
-
s.signing_key = signing_key if File.exists?(signing_key)
|
65
|
-
end
|
66
|
-
|
67
|
-
# vim: set ts=2 sw=2 sts=2 et :
|
68
|
-
# encoding: utf-8
|
data/test/test_constants.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
# :enddoc:
|
4
|
-
|
5
|
-
#
|
6
|
-
# test_constants.rb
|
7
|
-
#
|
8
|
-
# Copyright 2013-2014 Krzysztof Wilczynski
|
9
|
-
#
|
10
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
11
|
-
# you may not use this file except in compliance with the License.
|
12
|
-
# You may obtain a copy of the License at
|
13
|
-
#
|
14
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
15
|
-
#
|
16
|
-
# Unless required by applicable law or agreed to in writing, software
|
17
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
18
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
19
|
-
# See the License for the specific language governing permissions and
|
20
|
-
# limitations under the License.
|
21
|
-
#
|
22
|
-
|
23
|
-
begin
|
24
|
-
require 'coveralls'
|
25
|
-
Coveralls.wear!
|
26
|
-
rescue LoadError
|
27
|
-
STDERR.puts 'The Coveralls gem is not installed, skipping ...'
|
28
|
-
end
|
29
|
-
|
30
|
-
gem 'test-unit', '>= 2.5.2'
|
31
|
-
|
32
|
-
require 'test/unit'
|
33
|
-
require 'magic'
|
34
|
-
|
35
|
-
class MagicConstantsTest < Test::Unit::TestCase
|
36
|
-
def setup
|
37
|
-
end
|
38
|
-
|
39
|
-
def teardown
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_constants
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
# vim: set ts=2 sw=2 sts=2 et :
|
47
|
-
# encoding: utf-8
|
data/test/test_magic.rb
DELETED
@@ -1,260 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
# :enddoc:
|
4
|
-
|
5
|
-
#
|
6
|
-
# test_magic.rb
|
7
|
-
#
|
8
|
-
# Copyright 2013-2014 Krzysztof Wilczynski
|
9
|
-
#
|
10
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
11
|
-
# you may not use this file except in compliance with the License.
|
12
|
-
# You may obtain a copy of the License at
|
13
|
-
#
|
14
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
15
|
-
#
|
16
|
-
# Unless required by applicable law or agreed to in writing, software
|
17
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
18
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
19
|
-
# See the License for the specific language governing permissions and
|
20
|
-
# limitations under the License.
|
21
|
-
#
|
22
|
-
|
23
|
-
begin
|
24
|
-
require 'coveralls'
|
25
|
-
Coveralls.wear!
|
26
|
-
rescue LoadError
|
27
|
-
STDERR.puts 'The Coveralls gem is not installed, skipping ...'
|
28
|
-
end
|
29
|
-
|
30
|
-
gem 'test-unit', '>= 2.5.2'
|
31
|
-
|
32
|
-
require 'test/unit'
|
33
|
-
require 'magic'
|
34
|
-
|
35
|
-
DEFAULT_SINGLETON_METHODS = [
|
36
|
-
:open,
|
37
|
-
:mime,
|
38
|
-
:type,
|
39
|
-
:encoding,
|
40
|
-
:compile,
|
41
|
-
:check,
|
42
|
-
:version,
|
43
|
-
:version_to_a,
|
44
|
-
:version_to_s
|
45
|
-
]
|
46
|
-
|
47
|
-
DEFAULT_INSTANCE_METHODS = [
|
48
|
-
:close,
|
49
|
-
:closed?,
|
50
|
-
:path,
|
51
|
-
:flags,
|
52
|
-
:flags_array,
|
53
|
-
:file,
|
54
|
-
:buffer,
|
55
|
-
:descriptor,
|
56
|
-
:load,
|
57
|
-
:compile,
|
58
|
-
:check
|
59
|
-
]
|
60
|
-
|
61
|
-
DEFAULT_INTEGRATION_METHODS = [
|
62
|
-
:magic,
|
63
|
-
:mime,
|
64
|
-
:type
|
65
|
-
]
|
66
|
-
|
67
|
-
class MagicTest < Test::Unit::TestCase
|
68
|
-
def setup
|
69
|
-
@magic = Magic.new
|
70
|
-
end
|
71
|
-
|
72
|
-
def teardown
|
73
|
-
@magic.close
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_magic_alias
|
77
|
-
assert(FileMagic == Magic)
|
78
|
-
end
|
79
|
-
|
80
|
-
def test_magic_singleton_methods
|
81
|
-
assert_block do
|
82
|
-
DEFAULT_SINGLETON_METHODS.all? {|i| Magic.respond_to?(i) }
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def test_magic_new_instance
|
87
|
-
assert(@magic.class == Magic)
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_magic_instance_methods
|
91
|
-
assert_block do
|
92
|
-
DEFAULT_INSTANCE_METHODS.all? {|i| @magic.respond_to?(i) }
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def test_magic_close
|
97
|
-
@magic.close
|
98
|
-
|
99
|
-
assert(@magic.closed?)
|
100
|
-
assert_raise Magic::LibraryError do
|
101
|
-
@magic.file('')
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
def test_magic_closed?
|
106
|
-
assert_equal(@magic.closed?, false)
|
107
|
-
@magic.close
|
108
|
-
assert_equal(@magic.closed?, true)
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_magic_inspect
|
112
|
-
assert(@magic.inspect.match(%r{^#<Magic:0x.+>$}))
|
113
|
-
@magic.close
|
114
|
-
assert(@magic.inspect.match(%r{^#<Magic:0x.+ \(closed\)>$}))
|
115
|
-
end
|
116
|
-
|
117
|
-
def test_magic_path
|
118
|
-
end
|
119
|
-
|
120
|
-
def test_magic_path_MAGIC_environment_variable
|
121
|
-
end
|
122
|
-
|
123
|
-
def test_magic_flags
|
124
|
-
end
|
125
|
-
|
126
|
-
def test_magic_flags_to_a
|
127
|
-
end
|
128
|
-
|
129
|
-
def test_magic_file
|
130
|
-
end
|
131
|
-
|
132
|
-
def test_magic_file_with_MAGIC_CONTINUE_flag
|
133
|
-
end
|
134
|
-
|
135
|
-
def test_magic_buffer
|
136
|
-
end
|
137
|
-
|
138
|
-
def test_magic_buffer_with_MAGIC_CONTINUE_flag
|
139
|
-
end
|
140
|
-
|
141
|
-
def test_magic_descriptor
|
142
|
-
end
|
143
|
-
|
144
|
-
def test_magic_descriptor_with_MAGIC_CONTINUE_flag
|
145
|
-
end
|
146
|
-
|
147
|
-
def test_magic_load
|
148
|
-
end
|
149
|
-
|
150
|
-
def test_magic_load_MAGIC_environment_variable
|
151
|
-
end
|
152
|
-
|
153
|
-
def test_magic_check
|
154
|
-
end
|
155
|
-
|
156
|
-
def test_magic_valid?
|
157
|
-
end
|
158
|
-
|
159
|
-
def test_magic_compile
|
160
|
-
end
|
161
|
-
|
162
|
-
def test_magic_version
|
163
|
-
end
|
164
|
-
|
165
|
-
def test_magic_singleton_open
|
166
|
-
end
|
167
|
-
|
168
|
-
def test_magic_singleton_open_custom_flag
|
169
|
-
end
|
170
|
-
|
171
|
-
def test_magic_singleton_open_block
|
172
|
-
end
|
173
|
-
|
174
|
-
def test_magic_singleton_open_block_custom_flag
|
175
|
-
end
|
176
|
-
|
177
|
-
def test_magic_singleton_mime
|
178
|
-
end
|
179
|
-
|
180
|
-
def test_magic_singleton_mime_block
|
181
|
-
end
|
182
|
-
|
183
|
-
def test_magic_singleton_type
|
184
|
-
end
|
185
|
-
|
186
|
-
def test_magic_singleton_type_block
|
187
|
-
end
|
188
|
-
|
189
|
-
def test_magic_singleton_encoding
|
190
|
-
end
|
191
|
-
|
192
|
-
def test_magic_singleton_encoding_block
|
193
|
-
end
|
194
|
-
|
195
|
-
def test_magic_singleton_compile
|
196
|
-
end
|
197
|
-
|
198
|
-
def test_magic_singleton_check
|
199
|
-
end
|
200
|
-
|
201
|
-
def test_magic_flags_error
|
202
|
-
end
|
203
|
-
|
204
|
-
def test_magic_magic_error
|
205
|
-
end
|
206
|
-
|
207
|
-
def test_magic_library_error
|
208
|
-
end
|
209
|
-
|
210
|
-
def test_magic_new_instance_with_arguments
|
211
|
-
end
|
212
|
-
|
213
|
-
def test_file_integration
|
214
|
-
end
|
215
|
-
|
216
|
-
def test_file_integration_magic
|
217
|
-
end
|
218
|
-
|
219
|
-
def test_file_integration_magic_custom_flag
|
220
|
-
end
|
221
|
-
|
222
|
-
def test_file_integration_mime
|
223
|
-
end
|
224
|
-
|
225
|
-
def test_file_integration_type
|
226
|
-
end
|
227
|
-
|
228
|
-
def test_file_integration_singleton_magic
|
229
|
-
end
|
230
|
-
|
231
|
-
def test_file_integration_singleton_magic_custom_flag
|
232
|
-
end
|
233
|
-
|
234
|
-
def test_file_integration_singleton_mime
|
235
|
-
end
|
236
|
-
|
237
|
-
def test_file_integration_singleton_type
|
238
|
-
end
|
239
|
-
|
240
|
-
def test_string_integration
|
241
|
-
end
|
242
|
-
|
243
|
-
def test_string_integration_magic
|
244
|
-
end
|
245
|
-
|
246
|
-
def test_string_integration_magic_custom_flag
|
247
|
-
end
|
248
|
-
|
249
|
-
def test_string_integration_mime
|
250
|
-
end
|
251
|
-
|
252
|
-
def test_string_integration_type
|
253
|
-
end
|
254
|
-
|
255
|
-
def test_magic_mutex_unlocked
|
256
|
-
end
|
257
|
-
end
|
258
|
-
|
259
|
-
# vim: set ts=2 sw=2 sts=2 et :
|
260
|
-
# encoding: utf-8
|