glongman-ffiruby-filemagic 0.3.4 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -24,6 +24,7 @@ Make sure you have the magic(4) library installed.
24
24
 
25
25
  After Install:
26
26
 
27
+ > sudo ffi_file_magic_setup
27
28
  > irb
28
29
  >> require 'ffi_file_magic'
29
30
  => true
@@ -35,19 +36,18 @@ After Install:
35
36
 
36
37
  Install Problems?
37
38
 
38
- If the gem complains that it can't find the magic library you can run the setup.rb file
39
- in the root of the gem
39
+ If the gem complains that it can't find the magic library you can run this tool:
40
40
 
41
- > sudo ruby /path/to/ffiruby-filemagic/setup.rb (where is the gem? 'gem contents ffiruby-filemagic')
41
+ > sudo ffi_file_magic_setup
42
42
 
43
- Without any arguments setup.rb will look around the filesystem for a magic library and test to see if
43
+ Without any arguments the tool will look around the filesystem for a magic library and test to see if
44
44
  that library is compatible. If so a small modification will be made so the gem will work.
45
45
 
46
- You can run setup.rb more than once.
46
+ You can run the tool more than once.
47
47
 
48
- you can also tell setup.rb exactly where to look for the magic libary
48
+ you can also tell it exactly where to look for the magic libary
49
49
 
50
- > sudo ruby /path/to/ffiruby-filemagic/setup.rb --with-magic-lib=/opt/local/lib
50
+ > sudo ffi_file_magic_setup --with-magic-lib=/opt/local/lib
51
51
 
52
52
  This gem has been tested with the magic library shipped with File 4.26 from ftp://ftp.astron.com/pub/file
53
53
 
@@ -55,7 +55,7 @@ On OSX, and at the time of writing this, you can get file using macports (http:/
55
55
 
56
56
  > sudo port install file
57
57
 
58
- On other Unix variants, download the source, build and install. then run setup.rb
58
+ On other Unix variants, download the source, build and install. then run the tool again
59
59
 
60
60
  COPYRIGHT
61
61
  =========
data/Rakefile CHANGED
@@ -13,7 +13,9 @@ begin
13
13
  s.description = %Q{new implementation of the ancient ruby-filemagic gem. Uses FFI to talk to native library}
14
14
  s.authors = ["Geoff Longman"]
15
15
  s.add_dependency 'ffi'
16
- s.files = FileList["setup.rb", "[A-Z]*", "{lib,test}/**/*"]
16
+ s.executables = ["ffi_file_magic_setup"]
17
+ s.files = FileList["setup.rb", "[A-Z]*", "{lib,bin,test}/**/*"]
18
+ s.post_install_message = "\n\nrun ffi_file_magic_setup to complete the install\n\n\n"
17
19
  end
18
20
  rescue LoadError
19
21
  puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 4
2
+ :patch: 0
3
3
  :major: 0
4
- :minor: 3
4
+ :minor: 4
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env ruby
1
2
  require 'optparse'
2
3
  require "rubygems"
3
4
  require "ffi"
@@ -90,6 +91,12 @@ unless dylib
90
91
  | > port install file |
91
92
  | |
92
93
  | Others - build file from source - ftp://ftp.astron.com/pub/file/ |
94
+ | |
95
+ | Or: |
96
+ | you can run this tool with an option to force the location of the library: |
97
+ | |
98
+ | > ffi_file_magic_setup --with-magic-lib=/opt/local/lib |
99
+ | |
93
100
  +----------------------------------------------------------------------------+
94
101
  END_FAIL
95
102
  end
@@ -100,8 +107,19 @@ class FFIFileMagic
100
107
  module LoadLibrary
101
108
  def self.included(base)
102
109
  base.class_eval do
103
- # setup.rb found this library as suitable
104
- ffi_lib '#{dylib.name}'
110
+ begin
111
+ # the ffi_file_magic_setup tool once found this library as suitable
112
+ ffi_lib '#{dylib.name}'
113
+ rescue LoadError
114
+ puts <<END_LOAD_ERROR
115
+ +--------------------------------------------+
116
+ | I was unable to load the magic library. |
117
+ | |
118
+ | Try running the ffi_file_magic_setup tool |
119
+ +--------------------------------------------+
120
+ END_LOAD_ERROR
121
+ raise
122
+ end
105
123
  end
106
124
  end
107
125
  end
@@ -111,7 +129,7 @@ END_TEMPLATE
111
129
 
112
130
  if dylib
113
131
  print "writing path #{dylib.name} into lib/ffi_file_magic/load_library.rb ...."
114
- load_library = File.expand_path(File.dirname(__FILE__) + '/lib/ffi_file_magic/load_library.rb')
132
+ load_library = File.expand_path(File.dirname(__FILE__) + '/../lib/ffi_file_magic/load_library.rb')
115
133
  File.open(load_library, 'w') do |file|
116
134
  file.write template
117
135
  end
@@ -3,8 +3,18 @@ class FFIFileMagic
3
3
  module LoadLibrary
4
4
  def self.included(base)
5
5
  base.class_eval do
6
- # setup.rb found this library as suitable
7
- ffi_lib '/opt/local/lib/libmagic.dylib'
6
+ begin
7
+ ffi_lib 'magic'
8
+ rescue LoadError
9
+ puts <<END_LOAD_ERROR
10
+ +--------------------------------------------+
11
+ | I was unable to load the magic library. |
12
+ | |
13
+ | Try running the ffi_file_magic_setup tool |
14
+ +--------------------------------------------+
15
+ END_LOAD_ERROR
16
+ raise
17
+ end
8
18
  end
9
19
  end
10
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glongman-ffiruby-filemagic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geoff Longman
@@ -9,8 +9,8 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-21 00:00:00 -08:00
13
- default_executable:
12
+ date: 2009-02-23 00:00:00 -08:00
13
+ default_executable: ffi_file_magic_setup
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ffi
@@ -24,8 +24,8 @@ dependencies:
24
24
  version:
25
25
  description: new implementation of the ancient ruby-filemagic gem. Uses FFI to talk to native library
26
26
  email: glongman@overlay.tv
27
- executables: []
28
-
27
+ executables:
28
+ - ffi_file_magic_setup
29
29
  extensions: []
30
30
 
31
31
  extra_rdoc_files: []
@@ -40,6 +40,7 @@ files:
40
40
  - lib/ffi_file_magic/ffi_file_magic.rb
41
41
  - lib/ffi_file_magic/load_library.rb
42
42
  - lib/ffi_file_magic.rb
43
+ - bin/ffi_file_magic_setup
43
44
  - test/ffiruby_filemagic_test.rb
44
45
  - test/leaktest.rb
45
46
  - test/perl
@@ -48,7 +49,12 @@ files:
48
49
  - test/test_helper.rb
49
50
  has_rdoc: true
50
51
  homepage: http://github.com/glongman/ffiruby-filemagic
51
- post_install_message:
52
+ post_install_message: |+
53
+
54
+
55
+ run ffi_file_magic_setup to complete the install
56
+
57
+
52
58
  rdoc_options:
53
59
  - --inline-source
54
60
  - --charset=UTF-8