module EpubBook

index_url 书目录地址 title_css 书名css路径 index_item_css 目录页列表项目,默认 ul.list3>li>a body_css 内容css, 默认 .articlebody limit 用于测试时使用,得到页面的页数 item_attr 目录页item获取属性 默认为 'href' page_css 分页css路径 page_attr 分页链接地址属性 path 存储目录 user_agent 访问代理 referer 访问原地址 creator 责任人 ext_name 扩展名 epub,txt

Constants

Config
VERSION

Public Class Methods

config() click to toggle source
# File lib/epub_book.rb, line 43
def self.config
  Config.instance
end
configure() { |config| ... } click to toggle source
# File lib/epub_book.rb, line 47
def self.configure
  yield config
end
create_book(url,bookname=nil,des_url=nil) { |epub_book| ... } click to toggle source

book initialize, and the block will prior the yml setting

# File lib/epub_book.rb, line 24
def self.create_book(url,bookname=nil,des_url=nil)

  url_host_key = url[/\/\/(.*?)\//,1].tr(?.,'_')

  epub_book = Book.new(url,des_url) do |book|
    (default_config['book']||{}).merge(default_config[url_host_key]||{}).each_pair do |key,value|
      book.send("#{key}=",value)
    end
  end

  yield epub_book if block_given?

  #epub_book.fetch_index
  epub_book.generate_book(bookname)

  epub_book
end
default_config() click to toggle source

you can set in configure block or default_setting.yml,and configure block prior the yml setting

# File lib/epub_book.rb, line 52
def self.default_config
  unless @default_config
    @default_config= YAML.load(File.open(config.setting_file || "#{`pwd`.strip}/default_setting.yml"))
    configure do |_config|
      @default_config['smtp_config'].each_pair do |key,value|
        _config[key] ||= value
      end
    end
    ::Mail.defaults do
      delivery_method :smtp, {
        :address => EpubBook.config.mail_address,
        :port => EpubBook.config.mail_port,
        :user_name => EpubBook.config.mail_user_name,
        :password => EpubBook.config.mail_password,
        :authentication => :plain,
        :enable_starttls_auto => true
      }
    end
  end
  @default_config
end