lib/shutter/iptables.rb in shutter-0.2.0 vs lib/shutter/iptables.rb in shutter-0.2.2
- old
+ new
@@ -46,11 +46,13 @@
@base
end
def clean
@base = @base.gsub(/^#.*$/, "")
- @base = @base.gsub(/^$\n/, "")
+ @base = @base.gsub(/^$\n/, "")
+ # Add a newline at the end
+ @base + "\n"
end
def read(file, filter=true)
#puts "Reading: #{@path}/#{file}"
lines = File.read("#{@path}/#{file}").split("\n")
@@ -229,10 +231,10 @@
###
def filter_and_sort(content)
filtered = content.scan(/^[:-].*$/).sort
# Make sure that we remove (gsub) the counts on the chains and remove any
# trailing whitespace and newlines
- filtered.map {|x| x.gsub(/\ \[.*\]/,"").strip}
+ filtered.map {|x| x.gsub(/\ \[.*\]/,"").split(' ').sort.join.strip}
end
end
end
end
\ No newline at end of file