ffi-magic 2011.04 → 2011.04.22

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.md CHANGED
@@ -2,11 +2,21 @@
2
2
 
3
3
  ## Usage
4
4
 
5
- require 'ffi-magic'
6
- magic = Magic.new
7
- magic.file('spec/magic.png')
8
- # => "PNG image data, 100 x 67, 8-bit/color RGB, non-interlaced"
9
- magic.flags = Magic::MIME
10
- # => 1040
11
- magic.file('spec/magic.png')
12
- # => "image/png; charset=binary"
5
+ ```ruby
6
+ require 'ffi-magic'
7
+ magic = Magic.new
8
+ magic.file('spec/magic.png')
9
+ # => "PNG image data, 100 x 67, 8-bit/color RGB, non-interlaced"
10
+ magic.flags = Magic::MIME
11
+ # => 1040
12
+ magic.file('spec/magic.png')
13
+ # => "image/png; charset=binary"
14
+ ```
15
+
16
+ ### Getting the MIME Type
17
+
18
+ ```ruby
19
+ magic = Magic.new(Magic::MIME)
20
+ magic.file('spec/magic.png')
21
+ # => "image/png"
22
+ ```
data/doc/AUTHORS CHANGED
@@ -1,4 +1,4 @@
1
1
  Following persons have contributed to ffi-magic.
2
2
  (Sorted by number of submitted patches, then alphabetically)
3
3
 
4
- 3 Michael Fellinger <m.fellinger@gmail.com>
4
+ 7 Michael Fellinger <m.fellinger@gmail.com>
data/doc/CHANGELOG CHANGED
@@ -1,3 +1,19 @@
1
+ [9d387d0 | Fri Apr 22 03:03:02 UTC 2011] Michael Fellinger <m.fellinger@gmail.com>
2
+
3
+ * Version 2011.04.22
4
+
5
+ [faba9e5 | Fri Apr 22 03:02:49 UTC 2011] Michael Fellinger <m.fellinger@gmail.com>
6
+
7
+ * Fix bug in Magic#buffer, makes specs pass
8
+
9
+ [e2e046a | Fri Apr 22 02:41:48 UTC 2011] Michael Fellinger <m.fellinger@gmail.com>
10
+
11
+ * clean up
12
+
13
+ [6ccf92e | Fri Apr 22 02:41:41 UTC 2011] Michael Fellinger <m.fellinger@gmail.com>
14
+
15
+ * Point out that you can pass the flag to Magic.new
16
+
1
17
  [5a53006 | Fri Apr 22 02:04:14 UTC 2011] Michael Fellinger <m.fellinger@gmail.com>
2
18
 
3
19
  * Version 2011.04
data/ffi-magic.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{ffi-magic}
5
- s.version = "2011.04"
5
+ s.version = "2011.04.22"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Michael 'manveru' Fellinger"]
data/lib/ffi-magic.rb CHANGED
@@ -6,15 +6,15 @@ class Magic
6
6
  extend FFI::Library
7
7
  ffi_lib ['magic', 'libmagic.so.1']
8
8
 
9
- attach_function :magic_open, [:int], :pointer
10
- attach_function :magic_error, [:pointer], :string
11
- attach_function :magic_load, [:pointer, :string], :int
12
- attach_function :magic_file, [:pointer, :string], :string
13
- attach_function :magic_setflags, [:pointer, :int], :void
14
- attach_function :magic_buffer, [:pointer, :string, :int], :string
15
- attach_function :magic_check, [:pointer, :string], :int
16
- attach_function :magic_compile, [:pointer, :string], :int
17
- attach_function :magic_close, [:pointer], :void
9
+ attach_function :magic_open, [:int], :pointer
10
+ attach_function :magic_error, [:pointer], :string
11
+ attach_function :magic_load, [:pointer, :string], :int
12
+ attach_function :magic_file, [:pointer, :string], :string
13
+ attach_function :magic_setflags, [:pointer, :int], :void
14
+ attach_function :magic_buffer, [:pointer, :pointer, :int], :string
15
+ attach_function :magic_check, [:pointer, :string], :int
16
+ attach_function :magic_compile, [:pointer, :string], :int
17
+ attach_function :magic_close, [:pointer], :void
18
18
 
19
19
  NONE = 0x000000
20
20
  DEBUG = 0x000001
@@ -82,7 +82,7 @@ class Magic
82
82
 
83
83
  def buffer(input)
84
84
  input.force_encoding(Encoding::BINARY)
85
- magic_buffer(@cookie, input, input.bytesize.to_s)
85
+ magic_buffer(@cookie, input, input.bytesize)
86
86
  end
87
87
 
88
88
  def flags=(flags)
@@ -1,3 +1,3 @@
1
1
  class Magic
2
- VERSION = "2011.04"
2
+ VERSION = "2011.04.22"
3
3
  end
data/spec/ffi-magic.rb CHANGED
@@ -20,12 +20,12 @@ describe 'Magic' do
20
20
 
21
21
  should 'buffer' do
22
22
  @m.flags = Magic::NONE
23
- @m.buffer(File.read(file)).should == "ASCII C++ program text"
23
+ @m.buffer(File.read(file)).should == "PNG image data, 100 x 67, 8-bit/color RGB, non-interlaced"
24
24
  end
25
25
 
26
26
  should 'buffer MIME' do
27
27
  @m.flags = Magic::MIME
28
- @m.buffer(File.read(file)).should == "text/x-c++; charset=us-ascii"
28
+ @m.buffer(File.read(file)).should == "image/png; charset=binary"
29
29
  end
30
30
 
31
31
  should 'have a valid database' do
metadata CHANGED
@@ -5,7 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 2011
7
7
  - 4
8
- version: "2011.04"
8
+ - 22
9
+ version: 2011.04.22
9
10
  platform: ruby
10
11
  authors:
11
12
  - Michael 'manveru' Fellinger