Ruby - RSS 作成 - メインモジュール

クラウディア 
1. 概要
2. モジュール

1. 概要

 まずは、メインモジュールからかな。  とは、言うものの、構成を考えながらなので少しずつ。

2. モジュール

 内容は徐々に変わっていくと思います。
#!/usr/bin/env ruby
=begin

=end

$LOAD_PATH << File.dirname(File.expand_path(__FILE__))

require('pry')
require('openssl')
require('Contents')
require('ExceptLog')
require('DBaccess')
require('ReadConf')
require('CheckParent')

begin
  OpenSSL::SSL.module_eval{ remove_const(:VERIFY_PEER) }
  OpenSSL::SSL.const_set( :VERIFY_PEER, OpenSSL::SSL::VERIFY_NONE )

  readconf = ReadConf.new
  $parameter = readconf.execute(File.dirname(File.expand_path(__FILE__))) # コンフィグレーションファイルの読込

  database = DBaccess.new()
  database.connect($parameter[:database])                                 # 接続
  feed = database.feed                                                    # フィードテーブルの読込

  parent = CheckParent.new(feed['home']);

  tree     = { feed['home'] => 'UNKNOWN' }
  checked  = {}

  contents = Contents.new
  contents.feed=(feed)

  start = Time::now()
  puts("開始時刻               "+start.strftime("%Y年%m月%d日 %H:%M:%S"))

  parent.execute(feed['home'], tree, checked, contents)                   # コンテンツ収集

  collectend = Time::now()
  puts("コンテンツ収集完了時刻 "+collectend.strftime("%Y年%m月%d日 %H:%M:%S"))

  database.content=(contents.detail)                                      # コンテンツテーブル更新

  contenttend = Time::now()

  puts("コンテンツ登録完了時刻 "+contenttend.strftime("%Y年%m月%d日 %H:%M:%S"))

  #binding.pry

  Pathname.new(File.dirname(File.expand_path(__FILE__))+'/tree.dmp').open('wb') do | file |
    Marshal.dump(tree, file)
  end

  Pathname.new(File.dirname(File.expand_path(__FILE__))+'/contents.dmp').open('wb') do | file |
    Marshal.dump(contents.detail, file)
  end

rescue => error
  exeptlog = ExceptLog.new
  exeptlog.execute(self, error)
  exit 1
ensure

end

 このサイトを読んでいる方より、「.html」形式のサイトマップが欲しいという要望がありましたので、これで取得している「tree」構造のコンテンツを「.html」形式で出力する仕組みも作ろうかと考えています(2018年11月08日)。  末尾の方に「Marshal.dump」で2つのオブジェクトを出力する処理を加えました(2018年11月09日)。  サイトのツリー構造のオブジェクトと各コンテンツの情報を持つオブジェクトを出力しています。  これを html 形式のサイトマップを作成するのに流用します。  一連の流れで、サイトマップを作成することも可能ですが、本処理で、3000ページほどの内容を処理するのに 10分程度かかるので、サイトマップを作成するプログラムのデバッグに影響が出るため、切り離しました。
earthcar(アースカー)