bring some sanity into output_data
This commit is contained in:
parent
45257627f3
commit
7c354b7ba7
1 changed files with 18 additions and 15 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/local/bin/ruby -w
|
#!/usr/local/bin/ruby -w
|
||||||
|
|
||||||
# $Dwarf: ripnews.rb,v 1.40 2003/03/21 12:51:21 ward Exp $
|
# $Dwarf: ripnews.rb,v 1.41 2003/04/18 21:06:51 ward Exp $
|
||||||
# $Source$
|
# $Source$
|
||||||
|
|
||||||
require 'date'
|
require 'date'
|
||||||
|
|
@ -290,26 +290,23 @@ def output_data(subject, mode, filename="", body="")
|
||||||
group = @articles.get_groupname
|
group = @articles.get_groupname
|
||||||
print " mode: #{mode}\n" if Debuglevel > 0
|
print " mode: #{mode}\n" if Debuglevel > 0
|
||||||
print " Filename: '#{filename}'\n" if Debuglevel > 0
|
print " Filename: '#{filename}'\n" if Debuglevel > 0
|
||||||
|
|
||||||
|
# de-crap subject...
|
||||||
|
subject.sub!(/\s*$/, "")
|
||||||
|
subject.sub!(/^[\s\.!-]*/, "")
|
||||||
|
|
||||||
|
# decide on a filename
|
||||||
if @config[group].has_key?("-L") and @config[group]["-L"]
|
if @config[group].has_key?("-L") and @config[group]["-L"]
|
||||||
print "longname\n" if Debuglevel > 1
|
print "longname\n" if Debuglevel > 1
|
||||||
outfile = subject
|
outfile = subject
|
||||||
while outfile.length > @maxfilelength
|
outfile = outfile[0...@maxfilelength]
|
||||||
outfile = outfile[0...-1]
|
|
||||||
end
|
|
||||||
elsif @config[group].has_key?("-C") and @config[group]["-C"]
|
elsif @config[group].has_key?("-C") and @config[group]["-C"]
|
||||||
print "combinedname\n" if Debuglevel > 1
|
print "combinedname\n" if Debuglevel > 1
|
||||||
|
outfile = outfile[0...@maxfilelength-filename.length-3]
|
||||||
outfile = "#{subject} [#{filename}]"
|
outfile = "#{subject} [#{filename}]"
|
||||||
sub2 = subject
|
if outfile.length > @maxfilelength
|
||||||
while outfile.length > @maxfilelength
|
outfile = filename
|
||||||
lastlength = outfile.length
|
outfile = outfile[0...@maxfilelength]
|
||||||
sub2 = sub2[0...-1]
|
|
||||||
outfile = "#{sub2} [#{filename}]" # this is going to loop if the #{filename} is too long :(
|
|
||||||
if outfile.length == lastlength
|
|
||||||
outfile = filename
|
|
||||||
while outfile.length > @maxfilelength
|
|
||||||
outfile = outfile[0...-1]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
print "shortname\n" if Debuglevel > 1
|
print "shortname\n" if Debuglevel > 1
|
||||||
|
|
@ -318,6 +315,8 @@ def output_data(subject, mode, filename="", body="")
|
||||||
outfile = outfile[0...-1]
|
outfile = outfile[0...-1]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# do the actual saving
|
||||||
if save_file("#{@config[group]["DATADIR"]}/#{group}", outfile, body)
|
if save_file("#{@config[group]["DATADIR"]}/#{group}", outfile, body)
|
||||||
@articles.group_update_newsrc(subject)
|
@articles.group_update_newsrc(subject)
|
||||||
@articles.save_newsrc unless @config[group].has_key?("-T") and @config[group]["-T"]
|
@articles.save_newsrc unless @config[group].has_key?("-T") and @config[group]["-T"]
|
||||||
|
|
@ -328,20 +327,24 @@ def check_ext(group, filename, mode)
|
||||||
print " filename: #{filename}\n";
|
print " filename: #{filename}\n";
|
||||||
case mode
|
case mode
|
||||||
when "s"
|
when "s"
|
||||||
|
######## debuging
|
||||||
print " sould have extension: #{@config[group]["-S"]}\n";
|
print " sould have extension: #{@config[group]["-S"]}\n";
|
||||||
if ( @config[group].has_key?("-S") && filename =~ /\.(#{@config[group]["-S"]})$/ )
|
if ( @config[group].has_key?("-S") && filename =~ /\.(#{@config[group]["-S"]})$/ )
|
||||||
print " extension matches\n"
|
print " extension matches\n"
|
||||||
else
|
else
|
||||||
print " extension doesn't match\n"
|
print " extension doesn't match\n"
|
||||||
end
|
end
|
||||||
|
######## /debuging
|
||||||
return @config[group].has_key?("-S") ? ( filename =~ /\.(#{@config[group]["-S"]})$/ ) : true
|
return @config[group].has_key?("-S") ? ( filename =~ /\.(#{@config[group]["-S"]})$/ ) : true
|
||||||
when "m"
|
when "m"
|
||||||
|
######## debuging
|
||||||
print " sould have extension: #{@config[group]["-M"]}\n";
|
print " sould have extension: #{@config[group]["-M"]}\n";
|
||||||
if ( @config[group].has_key?("-S") && filename =~ /\.(#{@config[group]["-M"]})$/ )
|
if ( @config[group].has_key?("-S") && filename =~ /\.(#{@config[group]["-M"]})$/ )
|
||||||
print " extension matches\n"
|
print " extension matches\n"
|
||||||
else
|
else
|
||||||
print " extension doesn't match\n"
|
print " extension doesn't match\n"
|
||||||
end
|
end
|
||||||
|
######## /debuging
|
||||||
return @config[group].has_key?("-M") ? ( filename =~ /\.(#{@config[group]["-M"]})$/ ) : true
|
return @config[group].has_key?("-M") ? ( filename =~ /\.(#{@config[group]["-M"]})$/ ) : true
|
||||||
else
|
else
|
||||||
print "Illegal mode \"#{mode}\" in check_ext\n"
|
print "Illegal mode \"#{mode}\" in check_ext\n"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue