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

Revision 13852, 1.0 kB (checked in by yasuyuki, 6 years ago)

プラグインがFIXNUMを返すと、次のプラグイン実行時にエラーを起こすため、ダミーの配列を返すよう修正

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.each_with_index do |html, index|
20                File.open(today_root + "#{index + 1}.html", "w") do |f|
21                        f.write(html)
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  rescue
31  end
32  []
33end
Note: See TracBrowser for help on using the browser.