root/platform/pragger/Publish/nicorank_save_daily.rb @ 30870

Revision 30870, 1.3 kB (checked in by yasuyuki, 5 years ago)

コメント密度ランキングを追加

Line 
1## publish nicovideo mylisted avarage ranking
2##
3## - module Publish::nicorank_save_daily
4##   config:
5##     base_path: save html files base path
6##
7## Copyright (C) 2007-2008, INOUE Yasuyuki <inoue.yasuyuki0@gmail.com>
8## Original version is written by TADA Tadashi <sho@spc.gr.jp>
9## You can redistribute it and/or modify it under GPL3 or any later version.
10
11def nicorank_save_daily(config, data)
12        now = Time::now
13        begin
14    open( "#{config['fetch_date']}" ) {|f| now = YAML.load( f ) }
15        rescue Errno::ENOENT
16        end
17        today_root = config['root_dir'] + now.strftime("/%Y/%m/%d/")
18       
19        data.keys.each do |index|
20                File.open(today_root + "#{index + 1}.html", "w") do |f|
21                        f.write(data[index])
22                end
23                begin
24                  FileUtils.symlink(today_root + "#{index + 1}.html", "#{config['root_dir']}/#{index + 1}.html", :force => true)
25                rescue
26                end
27        end
28        begin
29    FileUtils.symlink(today_root + "1.html", "#{config['root_dir']}/index.html", :force => true) if File.exist? today_root + "1.html"
30    FileUtils.symlink(today_root + "4.html", "#{config['root_dir']}/comment.html", :force => true) if File.exist? today_root + "4.html"
31    FileUtils.symlink(today_root + "7.html", "#{config['root_dir']}/comment_density.html", :force => true) if File.exist? today_root + "7.html"
32  rescue
33  end
34  []
35end
Note: See TracBrowser for help on using the browser.