aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/lib/action_mailer/vendor/tmail-1.2.2/tmail/require_arch.rb
blob: b4fffb8abbd9ce5b071ea4d6b13b88801869ba4b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#:stopdoc:
require 'rbconfig'

# Attempts to require anative extension.
# Falls back to pure-ruby version, if it fails.
#
# This uses Config::CONFIG['arch'] from rbconfig.

def require_arch(fname)
  arch = Config::CONFIG['arch']
  begin
    path = File.join("tmail", arch, fname)
    require path
  rescue LoadError => e
    # try pre-built Windows binaries
    if arch =~ /mswin/
      require File.join("tmail", 'mswin32', fname)
    else
      raise e
    end
  end
end


# def require_arch(fname)
#   dext = Config::CONFIG['DLEXT']
#   begin
#     if File.extname(fname) == dext
#       path = fname
#     else
#       path = File.join("tmail","#{fname}.#{dext}")
#     end
#     require path
#   rescue LoadError => e
#     begin
#       arch = Config::CONFIG['arch']
#       path = File.join("tmail", arch, "#{fname}.#{dext}")
#       require path
#     rescue LoadError
#       case path
#       when /i686/
#         path.sub!('i686', 'i586')
#       when /i586/
#         path.sub!('i586', 'i486')
#       when /i486/
#         path.sub!('i486', 'i386')
#       else
#         begin
#           require fname + '.rb'
#         rescue LoadError
#           raise e
#         end
#       end
#       retry
#     end
#   end
# end
#:startdoc: