Module: EpubBook
- Extended by:
- Loggable
- Defined in:
- lib/epub_book/book.rb,
lib/epub_book.rb,
lib/epub_book/mailer.rb,
lib/epub_book/version.rb,
lib/epub_book/loggable.rb
Overview
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 ignore_txt 忽略字符,带有ignore_txt的行将被删除
Defined Under Namespace
Modules: Loggable Classes: Book, Config, Mailer
Constant Summary collapse
- VERSION =
"0.1.32"
Class Method Summary collapse
- .config ⇒ Object
- .configure {|config| ... } ⇒ Object
-
.create_book(url, bookname = nil, des_url = nil) {|epub_book| ... } ⇒ Object
book initialize, and the block will prior the yml setting.
-
.default_config ⇒ Object
you can set in configure block or default_setting.yml,and configure block prior the yml setting.
Methods included from Loggable
Class Method Details
.config ⇒ Object
43 44 45 |
# File 'lib/epub_book.rb', line 43 def self.config Config.instance end |
.configure {|config| ... } ⇒ Object
47 48 49 |
# File 'lib/epub_book.rb', line 47 def self.configure yield config end |
.create_book(url, bookname = nil, des_url = nil) {|epub_book| ... } ⇒ Object
book initialize, and the block will prior the yml setting
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# 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 ⇒ Object
you can set in configure block or default_setting.yml,and configure block prior the yml setting
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# 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 |