顯示具有 rails plugin 標籤的文章。 顯示所有文章
顯示具有 rails plugin 標籤的文章。 顯示所有文章

2014年7月30日 星期三

[rails] scheduler_daemon 執行出現問題.

在 scheduler_daemon.log 下發現錯誤訊息. 
# Logfile created on 2014-07-29 23:49:00 +0800 by logger.rb/31641
*** below you find the most recent exception thrown, this will be likely (but not certainly) the exception that made the application exit abnormally ***
#<NameError: uninitialized constant Rufus::EmScheduler>
*** below you find all exception objects found in memory, some of them may have been thrown in your application, others may just be in memory because they are standard exceptions ***
#<IOError: stream closed>
#<NoMemoryError: failed to allocate memory>
#<SystemStackError: stack level too deep>
#<fatal: exception reentered>
#<Errno::ENOENT: No such file or directory - /home/xxx/log/scheduler_daemon.pid>
#<NameError: uninitialized constant Rufus::Scheduler::EmScheduler>
#<NameError: uninitialized constant Rufus::EmScheduler>
#<NameError: uninitialized constant EmScheduler>
#<NameError: uninitialized constant EmScheduler>
#<NameError: uninitialized constant Rufus::EmScheduler>

主要就是要把 Gemfile.lock
rufus-scheduler (3.0.8)  改成  rufus-scheduler (2.0.24)

來源: https://github.com/ssoroka/scheduler_daemon/commit/72226e915a5b25e5695e6b7017eaefff27c90348

2014年7月18日 星期五

[Rails] 安裝 railroady

Ubuntu
 sudo apt-get install graphviz
CentOs
yum install graphviz

放在 Gemfile 內
group :development, :test do
    gem 'railroady'
end

然後執行
rake diagram:all 
來源: https://github.com/preston/railroady

2012年10月19日 星期五

[引用]hpricot,rails的解析html插件

引用來源

pricot 是快又好用的 Ruby HTML parser,來源 JQuery。它的特點是 1.速度快,因為核心用C改寫了 2.好用的介面,你可以用CSS selectors,element IDs,tag types 等。

其它特點可以解析 XML,可以解析 invaild 的 HTML,甚至可以更改 document 結構。


open-uri中文說明


hpricot官方git地址

  require 'open-uri' doc = open("http://qwantz.com/") { |f| Hpricot(f) }

require 'rubygems' require 'hpricot' document = <<END <ul> <li>first item</li> <li>second item</li> </ul> END doc = Hpricot.parse(document) (doc/'li').each do |item| puts item.inner_html#輸出內容 end

require 'rubygems' require 'hpricot' require 'open-uri' url = "http://www.abc.com/news/news_msg.php" doc = Hpricot(open(url)) doc.search('table tr td div.tbCopy font').each do |item| (item/'a').each do |nav| puts nav.attributes['href']#讀取屬性 puts nav.inner_html end end