117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
# File 'lib/file_type.rb', line 117
def self.included ( aClass )
aClass.class_inheritable_accessor :extract_command
aClass.module_eval do
def
true
end
def mk_cmd ( out )
extract_command < @path > out
end
def
base, ext = @base.extsplit
@tmp = TempPath.new(base.path.basename, ext)
cmd = mk_cmd(@tmp)
data = cmd.run(self.class.runner)
if data.status != 0
@tmp.rmtree if @tmp.exist?
raise ExtractError, "Cannot extract a file:
| path: #{to_s}
| type: #{self.class}
| command: #{cmd}
| exit status: #{data.status.exitstatus}".head_cut!
end
FileType.guess(@tmp)
end
alias :default :extract
end
end
|