IBM Developer is your one-stop location for getting hands-on training and learning in-demand skills on relevant technologies such as generative AI, data science, AI, and open source.
Warning. (2019.1) REXML ã¯, æ¨æºæ·»ä»ã§ãã, å質ã»é度ã®ä¸¡é¢ã§ãã¾ãããããã¾ãããNokogiri (é¸) ãã¡ã¸ã£ã¼ã§ãé·ããæ¨æºã®å°ä½ã§ä½¿ããã¦ãã¾ããREXML ã®3åéãã æè¿ã¯, å¤§é¸ (ãã) ã®äººæ°ãé«ããã¹ã¬ããã»ã¼ããé«éãæ©è½æ§ããããYorick Peterse / oga · GitLab REXMLã®ç¹å¾´ REXMLã¯ã XML 1.0ã«æºæ ãããé«éãªXMLãã¼ãµã§ãDOMããªã¼ãçæããããXMLææ¸ãèªã¿ãªããã³ã¼ã«ããã¯ããã (SAX2ã¹ããªã¼ã ãã¼ãµ) ãã¨ãã§ããã XPathã®å®è£ ãå«ã¿ãæ¤ç´¢å¼ã«ãã£ã¦DOMããªã¼ã®å¥½ããªè¦ç´ ãåãåºããã¨ãã§ããã Ruby 1.8.5ã«ã¯REXML 3.1.4ãæ·»ä»ããã¦ããããã¥ã¼ããªã¢ã«ãAPIãªãã¡ã¬ã³ã¹ã¯ä¸è¨ã§è¦ããããããAPIãªãã¡ã¬ã³ã¹ã®ã»ãã¯ä¸ååãã¤èª¤ããããã
æ¥å¹´ãä½ãããï¼ãµãã®ã¨ãæçãæºå«ããã2024å¹´æ¥ã®è¨é² æ¥ã¯èªçã楽ããå£ç¯ 1å¹´ã®ä¸ã§æãèªçã楽ããå£ç¯ã¯æ¥ã ã¨æããã¹ã¼ãã¼ã®æ£ã«ãããããªè²åãã®éèã並ã¶ã¨èªç¶ã¨ããããå¼¾ãã ä¸ã§ãã¨ãããã®ã¯å±±èã ãæ©ãã¨2æä¸æ¬ãããã並ã³å§ããããã¯ãã¿ã©ã®è½ããµãã®ã¨ãã¨ç¶ããæ¡ã®é ã«ã¯ããããã¦ãããâ¦
ãããããã®æ å ±ã³ãã¥ãã±ã¼ã·ã§ã³ã¯RSSã ãã¨ãããã¨ã§RSSãä½æãã¦ã¿ã¾ããã ãã¾ãããªããã¨ãã声ãèããã¦ãããã§ããã»ã»ã»(ç¬) ããããããã«ããããããªé¢ã§å©ç¨ãããããã«ãªã£ã¦ããã¨æãã¾ãã RSSã®çæã«ã¯ãRubyããå©ç¨ãã¾ãã ä»åã®è¨äºã®å 容ã¯ã以ä¸ã®ã¨ããã§ãã (A)ãRubyãã§RSSãçæãã (B)çæããRSSã«ã¹ã¿ã¤ã«ã·ã¼ããé©ç¨ãã¦è¡¨ç¤ºãã ããã§ã¯ãæ©éãåãæããã¾ãããã (A)ãRubyãã§RSSãçæãã ã³ã¼ã(ãtest.rbã)ã示ãã¾ãã -------------------------- ãããã(test.rb) # ãrss/makerãã©ã¤ãã©ãªãå©ç¨ãã¾ã require 'rss/maker' # RSSã®ãã¼ã¸ã§ã³ãæå®ãã¦RSSãªãã¸ã§ã¯ããçæãã¾ã rss = RSS::Maker.make("1.0"
第4åç®ã®ãã¼ãã¯ãéè¤ããRSSãã¾ã¨ãããã¨é¡ãã¾ãã¦ãRubyã§è¤æ°ã®RSSããéè¤ããã¨ã³ããªãé¤å»ããåé¡ãåºãã¾ãã åé¡ æè¿ãã¯ã¦ãªããã¯ãã¼ã¯ãlivedoor ã¯ãªãããªã©ãã¦ã¼ã¶ã¼ãå¤é¨ã®ãµã¤ããéãã¦ããã®çµæãåºåãããµã¼ãã¹ãå¢ãã¦ãã¾ããã ãã ãä¸é¨ã®ãµã¤ããè¦ã¦ããã ãã§è©±é¡ã追ããã¨ãã§ããã®ã§ä¾¿å©ãªã®ã§ãããåãURLãè¤æ°ã®RSSã«ãããããããã¯è¦ãã®ã«â¦â¦ãã¨ããäºãå¤ãã§ãããã ããã§ä»åã¯ãè¤æ°ã®RSSãä¸ã¤ã®RSSã¨ãã¦åºåããããã°ã©ã ãåé¡ã«ãã¾ãã ä»æ§ RSSã®URLã¯ãã³ãã³ãã©ã¤ã³ããå¼æ°ã¨ãã¦1å以ä¸ä¸ããããã çµåããçµæã®RSSã®ã¿ã¤ãã«ããã³èª¬æã¯ãåå¼æ°ã®ã¿ã¤ãã«ãã¤ãªãããã®ã¨ããã çµåããçµæã®RSSã®URLã¯ç¬¬ä¸å¼æ°ã®URLã¨ããã ãã£ã¼ãã®ãªã³ã¯å ãåä¸ã®ãã®ãåããã£ã¼ãã¨ãã¦æ±ãã åºåé ã¯ç¬¬ä¸å¼æ°
require "cgi" require "template" class Feeder def self.get(tmpl_path, options = {}) cgi = CGI.new mime_type = options[:mime_type] || "application/xml" encoding = options[:encoding] || "utf-8" language = options[:language] || "ja" v = Template.get(tmpl_path, {"type" => mime_type, "charset" => encoding}) v.encoding = encoding v.language = language v.site_url = "http://" + cgi.server_name v.feed_url
ä»å¹´ã®1æã«ããã¨ã«ããä½é¨ãã¦ã¿ãªãã¨åãããªããã¨ããçç±ã§å§ããTwitterããã®ãããã®è©±ã¯ãã¤ã¶ããã¦ãä½ãé¢ç½ãââããã°ãæ¸ããªã40代ç·æ§ãããã¾Twitterãå§ãããããã«è©³ããã®ã§ããã¡ããåç §ãã¦ã»ããã®ã ããã¨ããããç¾æç¹ã§ãããã°ã£ã¦ç¶ãã¦ããã èªåã®Twitterã®ä½¿ãæ¹ã解æã§ããWebãµã¼ãã¹ãTwilogãã«ããã°ããããã®å¹³åçãªã¤ã¶ããæ°ã¯1æ¥ããã5.8件ãä»ã¾ã§356件ã»ã©ã¤ã¶ããã¦ãããä»äºã«ä½¿ãã便å©ãã¼ã«ãæ¥çé¢ç½ãã¥ã¼ã¹ãç§äºã®ãç¥ãããªã©ã@nagatameisterã§ã¤ã¶ããã¦ããï¼follow meï¼ï¼ã Twitterã¯ãä»ããå±ãããµã¼ãã¹ã ãä¸æ¹ãèªåã®çºä¿¡ããæ å ±ã§åºå®çãªãã®ãä¾ãã°ãããã£ã¼ã«ãå·çå±¥æ´ãéå¶ãã¦ããä¼æ¥ã«é¢ããæ å ±ããªã³ã¯ä¸è¦§ãªã©ã¯ãã¹ããã¯åã®æ å ±ã¨ãã¦ã¾ã¨ãã¦ãããããTwilogã®ããã«ãã¤
require 'rubygems' require_gem 'builder' xmlobj= Builder::XmlMarkup.new(:target=>STDOUT, :indent=>2) xmlobj.person { |b| b.name("Jim"); b.phone("555-1234") } # # Prints: # <person> # <name>Jim</name> # <phone>555-1234</phone> # </person> require 'rubygems' require_gem 'builder', '~> 2.0' xml = Builder::XmlMarkup.new xmlobj = xml.person { |b| b.name("Jim"); b.phone("555-1234") } xmlobj #=> <person>
ããã«ã¡ã¯ãTæ°ã§ããä»æ¥ã¯rubyã§RSSãåå¾ããæ¹æ³ããç´¹ä»ãã¾ãã rubyã«ã¯RSSãåå¾ããããã®ã¯ã©ã¹ãç¨æããã¦ãããããããã使ã£ããµã³ãã«ãä½æãã¾ãããã¯ã©ã¹ã¯ [RUBY_HOME]/rss/**.rb ã«è²ã ã¨ç¨æããã¦ãã¾ãã â»rubyã¯1.8.7 ã使ã£ã¦ãã¾ãã   # sample.rb class Sample  require 'rss'  require 'uri'  attr_accessor :title, :description, :link, :published_at  def initialize    @title = nil    @description = nil    @link = nil    @published_at = nil  end  def self.get_rss(rss_url) b
âä½ãããããã®ã Railsã¢ããªã±ã¼ã·ã§ã³ã§ãä¸å®ééã§å¦çãå®è¡ãããã âãã©ã°ã¤ã³ãrails_cronãã使ã£ã¦ã¿ã ãªããªã£ã¦ãã£ã½ã(404)ã»ã»ã»orz http://svn.kylemaxwell.com/rails_plugins/rails_cron/trunk/ ä½ã§ãªããªã£ããã ããã»ã»ã âLinuxã®cronã使ã ã»cronè¨å® ï¼ï¼cronè¨å®ãã¡ã¤ã«ã®ç·¨é crontab -eï¼ï¼vi ãéãã®ã§ä»¥ä¸ãè¨è¿° RAILS_ENV=production 0 5 * * * /path/to/ruby /path/to/app/script/runner 'Hoge.create_log'â»æ¯æ¥5æ0åã«å®è¡ã¨ããä¾ã§ãã â»ä¸è¨ã®ä¾ã¯ãHogeã¯ã©ã¹(ã¢ãã«)ã®create_log(ã¯ã©ã¹ã¡ã½ãã)ãå¼ã³åºããä¾ã§ãã â»ãããã¯ã·ã§ã³ã¢ã¼ãã§ãã âåè
äºã®çºç«¯ã¯ãããããå®è£ ãã¦ããã³ã³ããã¼ã©ã®ã¡ã½ãããã¯ã¼ãã³ãããå®è¡ãããã¨ããæãã ããã¤ã調ã¹ã¦ã¿ãã¨railscronã¨ããããã¤ãã®æ¹æ³ã§modelã¯å©ããã ãã©controllerã¯ãwgetããã°ï¼ãã¨ããæãï¼ãªã®ãããã ããã¯ãªããã¤ã¤ã ããmodelã«ç§»ãã®ããã ã§ãè²ã ã¨èª¿ã¹ã¦ã¿ãã¨ãããªãçãä¸ãã£ã¦ãè¨äºãçºè¦ï¼ http://matthall.wordpress.com/2006/12/06/how-to-execute-a-rails-controller-action-via-cron/ èªãã§ã¿ãã¨ãªãã»ã©ç°¡åã§ãrunnerã«ActionControllerãæå®ãã¦å©ãã¦ãããã°ããã¿ããã $ script/runner -e development "app = ActionController::Integration::Sessio
ã©ã³ãã³ã°
ã¡ã³ããã³ã¹
ãç¥ãã
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}