~uwelk/drossellog/drossellog

« back to all changes in this revision

Viewing changes to drossellog-generate-daily-reports.rb

  • Committer: Uwe L. Korn
  • Date: 2007-06-10 10:23:07 UTC
  • Revision ID: uwe@hansdieter.xhochy.org-20070610102307-gq3oxvreyswtjvc3
IPCounter now working

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
#############################################################################
6
6
 
7
7
require 'getoptlong'
8
 
require 'xhochy/drossellog/logfileparser.rb'
 
8
require 'rake'
 
9
require 'yaml'
 
10
require 'xhochy/drossellog/dailyreport.rb'
9
11
 
10
12
## Functions ##
11
13
 
67
69
# make it!
68
70
 
69
71
puts '-> Generating daily reports'
70
 
rxp = File.join($tmp_path, File.basename($file), '*', '*', '*.xml')
 
72
rxp = File.join($indir, File.basename($file), '*', '*', '*.yml')
71
73
files = FileList[rxp]
72
 
files.each do |f|
73
 
  date = /(\d+)\/([A-Za-z]+)\/(\d+)\.xml$/.match(f)
 
74
files.each do |file|
 
75
  date = /(\d+)\/([A-Za-z]+)\/(\d+)\.yml$/.match file
74
76
  puts '--> ' + date[3] + ' ' + date[2] + ' ' + date[1]
75
 
  xml = XML::Document.file(f)
76
 
  report = XhochY::Drossellog::DailyReport.new(xml.root)
 
77
  data = YAML::load_file file
 
78
  report = XhochY::Drossellog::DailyReport.new data 
 
79
  data = report.get_data
 
80
  File.open(File.join($outdir, File.basename($file), 'daily', date[1], date[2], date[3] + '.yml'), 'w') do |f|
 
81
    f.write data.to_yaml
 
82
  end           
77
83
end