<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet href='http://feed.feedsky.com/styles/temp01.xsl' type='text/xsl' ?><!--这是一个由Feedsy提供技术支持的Feed，为了提高读者阅读的体验，以及满足用户美化自己Feed的需要，我们设计了多种精美的Feed模板，提供给大家选择，所有最终呈现出来的样式，皆由用户自愿选择使用，未经许可，任何团体和个人，请不要擅自修改样式或者盗用，这是对于用户选择权的尊重。--><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:fs="http://www.feedsky.com/namespace/feed" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link href="http://feed.feedsky.com/moonfox" type="application/rss+xml" rel="self"></atom:link><fs:self_link href="http://feed.feedsky.com/moonfox" type="application/rss+xml"></fs:self_link><lastBuildDate>Tue, 21 Feb 2012 15:26:20 GMT</lastBuildDate><title>漂自己的移</title><description>Life is what? Get busy living or get busy dying</description><link>http://www.gagahappy.com</link><sy:updatePeriod>hourly</sy:updatePeriod><sy:updateFrequency>1</sy:updateFrequency><language>en</language><pubDate>Tue, 21 Feb 2012 15:28:28 GMT</pubDate><item><title>resque Priorities and Queue Lists</title><link>http://www.gagahappy.com/resque-priorities-and-queue-lists/</link><content:encoded>&lt;p&gt;Priorities and Queue Lists&lt;/p&gt;
&lt;p&gt;Resque doesn&amp;#8217;t support numeric priorities but instead uses the order of queues you give it. We call this list of queues the &amp;#8220;queue list.&amp;#8221;&lt;/p&gt;
&lt;p&gt;Let&amp;#8217;s say we add a warm_cache queue in addition to our file_serve queue. We&amp;#8217;d now start a worker like so:&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;ruby&quot; style=&quot;font-family:monospace;&quot;&gt;$ QUEUES=file_serve,warm_cache rake resque:work&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;When the worker looks for new jobs, it will first check file_serve. If it finds a job, it&amp;#8217;ll process it then check file_serve again. It will keep checking file_serve until no more jobs are available. At that point, it will check warm_cache. If it finds a job it&amp;#8217;ll process it then check file_serve (repeating the whole process).&lt;br /&gt;
Resque doesn&amp;#8217;t support numeric priorities but instead uses the order of queues you give it. We call this list of queues the &amp;#8220;queue list.&amp;#8221;&lt;/p&gt;
&lt;p&gt;您可能感兴趣的文章&lt;ol&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/make-resque-work/' rel='bookmark' title='Resque生效的必要条件'&gt;Resque生效的必要条件&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/608330708/moonfox/feedsky/s.gif?r=http://www.gagahappy.com/resque-priorities-and-queue-lists/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://www.gagahappy.com/resque-priorities-and-queue-lists/feed/</wfw:commentRss><slash:comments>0</slash:comments><description>Priorities and Queue Lists Resque doesn&amp;#8217;t support numeric priorities but instead uses the order of queues you give it. We call this list of queues the &amp;#8220;queue list.&amp;#8221; Let&amp;#8217;s say we add a warm_cache queue in addition to our file_serve queue. We&amp;#8217;d now start a worker like so: $ QUEUES=file_serve,warm_cache rake resque:work When the worker [...]&lt;img src=&quot;http://www1.feedsky.com/t1/608330708/moonfox/feedsky/s.gif?r=http://www.gagahappy.com/resque-priorities-and-queue-lists/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>程序开发</category><category>resque</category><pubDate>Tue, 21 Feb 2012 23:26:20 +0800</pubDate><author>moonfox</author><comments>http://www.gagahappy.com/resque-priorities-and-queue-lists/#comments</comments><guid isPermaLink="false">http://www.gagahappy.com/?p=3995</guid><dc:creator>moonfox</dc:creator><fs:srclink>http://www.gagahappy.com/resque-priorities-and-queue-lists/</fs:srclink><fs:srcfeed>http://www.gagahappy.com/feed/</fs:srcfeed><fs:itemid>feedsky/moonfox/~8433309/608330708/6537203</fs:itemid></item><item><title>ruby 正则表达式中的全局变量</title><link>http://www.gagahappy.com/ruby-regular-expression-in-sub-gsub/</link><content:encoded>&lt;p&gt;在使用sub,gsub 时，正则表达式不中不能使用全局变量&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;ruby&quot; style=&quot;font-family:monospace;&quot;&gt;str = &lt;span style=&quot;color:#996600;&quot;&gt;&amp;quot;a123b456c789&amp;quot;&lt;/span&gt;
str.&lt;span style=&quot;color:#CC0066; font-weight:bold;&quot;&gt;sub&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#40;&lt;/span&gt;a\d&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#40;&lt;/span&gt;b\d&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#40;&lt;/span&gt;c\d&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;/&lt;/span&gt;,&lt;span style=&quot;color:#996600;&quot;&gt;&amp;quot;a=#{$1}, b=#{$2}, c=#{$3}&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;=&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color:#996600;&quot;&gt;&amp;quot;a=, b=, c=&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;可以使用&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;ruby&quot; style=&quot;font-family:monospace;&quot;&gt;str = &lt;span style=&quot;color:#996600;&quot;&gt;&amp;quot;a123b456c789&amp;quot;&lt;/span&gt;
str.&lt;span style=&quot;color:#CC0066; font-weight:bold;&quot;&gt;sub&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#40;&lt;/span&gt;a\d&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#40;&lt;/span&gt;b\d&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#40;&lt;/span&gt;c\d&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;/&lt;/span&gt;,&lt;span style=&quot;color:#996600;&quot;&gt;'a=&lt;span style=&quot;color:#000099;&quot;&gt;\1&lt;/span&gt;, b=&lt;span style=&quot;color:#000099;&quot;&gt;\2&lt;/span&gt;, c=&lt;span style=&quot;color:#000099;&quot;&gt;\3&lt;/span&gt;'&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;=&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color:#996600;&quot;&gt;&amp;quot;a=123, b=456, c=789&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;或&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;ruby&quot; style=&quot;font-family:monospace;&quot;&gt;str = &lt;span style=&quot;color:#996600;&quot;&gt;&amp;quot;a123b456c789&amp;quot;&lt;/span&gt;
str.&lt;span style=&quot;color:#CC0066; font-weight:bold;&quot;&gt;sub&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#40;&lt;/span&gt;a\d&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#40;&lt;/span&gt;b\d&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#40;&lt;/span&gt;c\d&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#996600;&quot;&gt;&amp;quot;a=#{$1}, b=#{$2}, c=#{$3}&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;=&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color:#996600;&quot;&gt;&amp;quot;a=123, b=456, c=789&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;您可能感兴趣的文章&lt;ol&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/error-loading-gem-paths-on-load-path-in-gem_prelude/' rel='bookmark' title='Error loading gem paths on load path in gem_prelude'&gt;Error loading gem paths on load path in gem_prelude&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/ruby-file-name-file/' rel='bookmark' title='如何理解ruby中的__FILE__？'&gt;如何理解ruby中的__FILE__？&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/what-is-dup/' rel='bookmark' title='what is dup'&gt;what is dup&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/python-tiobe-award/' rel='bookmark' title='Python赢得Tiobe 2010年度语言大奖'&gt;Python赢得Tiobe 2010年度语言大奖&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/puts-back-value/' rel='bookmark' title='puts 返回值'&gt;puts 返回值&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/ruby-install-rmagick/' rel='bookmark' title='ruby 安装 rmagick'&gt;ruby 安装 rmagick&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/rails-redirect_to/' rel='bookmark' title='rails redirect_to'&gt;rails redirect_to&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/try-reconstruction/' rel='bookmark' title='小试重构'&gt;小试重构&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/xpath/' rel='bookmark' title='XPath'&gt;XPath&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/render-partial/' rel='bookmark' title='render partial'&gt;render partial&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/607980938/moonfox/feedsky/s.gif?r=http://www.gagahappy.com/ruby-regular-expression-in-sub-gsub/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://www.gagahappy.com/ruby-regular-expression-in-sub-gsub/feed/</wfw:commentRss><slash:comments>0</slash:comments><description>在使用sub,gsub 时，正则表达式不中不能使用全局变量 str = &amp;#34;a123b456c789&amp;#34; str.sub&amp;#40;/&amp;#40;a\d+&amp;#41;&amp;#40;b\d+&amp;#41;&amp;#40;c\d+&amp;#41;/,&amp;#34;a=#{$1}, b=#{$2}, c=#{$3}&amp;#34;&amp;#41; =&amp;#62; &amp;#34;a=, b=, c=&amp;#34; 可以使用 str = &amp;#34;a123b456c789&amp;#34; str.sub&amp;#40;/&amp;#40;a\d+&amp;#41;&amp;#40;b\d+&amp;#41;&amp;#40;c\d+&amp;#41;/,'a=\1, b=\2, c=\3'&amp;#41; =&amp;#62; &amp;#34;a=123, b=456, c=789&amp;#34; 或 str = &amp;#34;a123b456c789&amp;#34; str.sub&amp;#40;/&amp;#40;a\d+&amp;#41;&amp;#40;b\d+&amp;#41;&amp;#40;c\d+&amp;#41;/&amp;#41; &amp;#123;&amp;#34;a=#{$1}, b=#{$2}, c=#{$3}&amp;#34;&amp;#125; =&amp;#62; &amp;#34;a=123, b=456, c=789&amp;#34; 您可能感兴趣的文章 Error loading gem paths on load path in gem_prelude 如何理解ruby中的__FILE__？ what is dup Python赢得Tiobe 2010年度语言大奖 puts 返回值 ruby 安装 [...]&lt;img src=&quot;http://www1.feedsky.com/t1/607980938/moonfox/feedsky/s.gif?r=http://www.gagahappy.com/ruby-regular-expression-in-sub-gsub/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>程序开发</category><category>Ruby</category><pubDate>Mon, 20 Feb 2012 22:19:38 +0800</pubDate><author>moonfox</author><comments>http://www.gagahappy.com/ruby-regular-expression-in-sub-gsub/#comments</comments><guid isPermaLink="false">http://www.gagahappy.com/?p=3978</guid><dc:creator>moonfox</dc:creator><fs:srclink>http://www.gagahappy.com/ruby-regular-expression-in-sub-gsub/</fs:srclink><fs:srcfeed>http://www.gagahappy.com/feed/</fs:srcfeed><fs:itemid>feedsky/moonfox/~8433309/607980938/6537203</fs:itemid></item><item><title>rvm gemset</title><link>http://www.gagahappy.com/rvm-gemset-pic/</link><content:encoded>&lt;p&gt;rvm gemset&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.gagahappy.com/wp-content/uploads/2012/02/Screenshot-at-2012-02-20-222952.png&quot;&gt;&lt;img src=&quot;http://www.gagahappy.com/wp-content/uploads/2012/02/Screenshot-at-2012-02-20-222952.png&quot; alt=&quot;&quot; title=&quot;Screenshot at 2012-02-20 22:29:52&quot; width=&quot;485&quot; height=&quot;356&quot; class=&quot;alignnone size-full wp-image-3981&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;您可能感兴趣的文章&lt;ol&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/ubuntu-11-10-rvm-%e5%ae%89%e8%a3%85%e7%89%88ruby-openssl%e8%a7%a3%e5%86%b3/' rel='bookmark' title='ubuntu 11.10 rvm 安装版ruby openssl解决'&gt;ubuntu 11.10 rvm 安装版ruby openssl解决&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/607980939/moonfox/feedsky/s.gif?r=http://www.gagahappy.com/rvm-gemset-pic/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://www.gagahappy.com/rvm-gemset-pic/feed/</wfw:commentRss><slash:comments>0</slash:comments><description>rvm gemset 您可能感兴趣的文章 ubuntu 11.10 rvm 安装版ruby openssl解决&lt;img src=&quot;http://www1.feedsky.com/t1/607980939/moonfox/feedsky/s.gif?r=http://www.gagahappy.com/rvm-gemset-pic/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>rvm</category><category>程序开发</category><pubDate>Thu, 16 Feb 2012 22:30:17 +0800</pubDate><author>moonfox</author><comments>http://www.gagahappy.com/rvm-gemset-pic/#comments</comments><guid isPermaLink="false">http://www.gagahappy.com/?p=3980</guid><dc:creator>moonfox</dc:creator><fs:srclink>http://www.gagahappy.com/rvm-gemset-pic/</fs:srclink><fs:srcfeed>http://www.gagahappy.com/feed/</fs:srcfeed><fs:itemid>feedsky/moonfox/~8433309/607980939/6537203</fs:itemid></item><item><title>ruby 正则表达式脱字符</title><link>http://www.gagahappy.com/ruby-character-class-up/</link><content:encoded>&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;ruby&quot; style=&quot;font-family:monospace;&quot;&gt;re = &lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#91;&lt;/span&gt;^aeiou&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;/&lt;/span&gt;
&lt;span style=&quot;color:#008000; font-style:italic;&quot;&gt;# Match any character except a, e, i, o, u&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;您可能感兴趣的文章&lt;ol&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/ruby-regular-expression-in-sub-gsub/' rel='bookmark' title='ruby 正则表达式中的全局变量'&gt;ruby 正则表达式中的全局变量&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/error-loading-gem-paths-on-load-path-in-gem_prelude/' rel='bookmark' title='Error loading gem paths on load path in gem_prelude'&gt;Error loading gem paths on load path in gem_prelude&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/ruby-file-name-file/' rel='bookmark' title='如何理解ruby中的__FILE__？'&gt;如何理解ruby中的__FILE__？&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/what-is-dup/' rel='bookmark' title='what is dup'&gt;what is dup&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/python-tiobe-award/' rel='bookmark' title='Python赢得Tiobe 2010年度语言大奖'&gt;Python赢得Tiobe 2010年度语言大奖&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/puts-back-value/' rel='bookmark' title='puts 返回值'&gt;puts 返回值&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/ruby-install-rmagick/' rel='bookmark' title='ruby 安装 rmagick'&gt;ruby 安装 rmagick&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/try-reconstruction/' rel='bookmark' title='小试重构'&gt;小试重构&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/xpath/' rel='bookmark' title='XPath'&gt;XPath&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/render-partial/' rel='bookmark' title='render partial'&gt;render partial&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/607980940/moonfox/feedsky/s.gif?r=http://www.gagahappy.com/ruby-character-class-up/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://www.gagahappy.com/ruby-character-class-up/feed/</wfw:commentRss><slash:comments>0</slash:comments><description>re = /&amp;#91;^aeiou&amp;#93;/ # Match any character except a, e, i, o, u 您可能感兴趣的文章 ruby 正则表达式中的全局变量 Error loading gem paths on load path in gem_prelude 如何理解ruby中的__FILE__？ what is dup Python赢得Tiobe 2010年度语言大奖 puts 返回值 ruby 安装 rmagick 小试重构 XPath render partial&lt;img src=&quot;http://www1.feedsky.com/t1/607980940/moonfox/feedsky/s.gif?r=http://www.gagahappy.com/ruby-character-class-up/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>程序开发</category><category>Ruby</category><pubDate>Wed, 15 Feb 2012 22:49:27 +0800</pubDate><author>moonfox</author><comments>http://www.gagahappy.com/ruby-character-class-up/#comments</comments><guid isPermaLink="false">http://www.gagahappy.com/?p=3990</guid><dc:creator>moonfox</dc:creator><fs:srclink>http://www.gagahappy.com/ruby-character-class-up/</fs:srclink><fs:srcfeed>http://www.gagahappy.com/feed/</fs:srcfeed><fs:itemid>feedsky/moonfox/~8433309/607980940/6537203</fs:itemid></item><item><title>ruby 正则表达式获取匹配字符串前后部分</title><link>http://www.gagahappy.com/ruby-match-pre-post-match/</link><content:encoded>&lt;p&gt; ruby 正则表达式获取匹配字符串前后部分&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;ruby&quot; style=&quot;font-family:monospace;&quot;&gt;a = &lt;span style=&quot;color:#996600;&quot;&gt;&amp;quot;Hello gagahappy Hi&amp;quot;&lt;/span&gt;
refs = a.&lt;span style=&quot;color:#9900CC;&quot;&gt;match&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;/&lt;/span&gt;gagahappy&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#41;&lt;/span&gt;
refs.&lt;span style=&quot;color:#9900CC;&quot;&gt;pre_match&lt;/span&gt;  &lt;span style=&quot;color:#008000; font-style:italic;&quot;&gt;# =&amp;gt; &amp;quot;Hello &amp;quot; &lt;/span&gt;
refs.&lt;span style=&quot;color:#9900CC;&quot;&gt;post_match&lt;/span&gt; &lt;span style=&quot;color:#008000; font-style:italic;&quot;&gt;# =&amp;gt; &amp;quot; Hi&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;您可能感兴趣的文章&lt;ol&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/ruby-regular-expression-in-sub-gsub/' rel='bookmark' title='ruby 正则表达式中的全局变量'&gt;ruby 正则表达式中的全局变量&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/error-loading-gem-paths-on-load-path-in-gem_prelude/' rel='bookmark' title='Error loading gem paths on load path in gem_prelude'&gt;Error loading gem paths on load path in gem_prelude&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/ruby-file-name-file/' rel='bookmark' title='如何理解ruby中的__FILE__？'&gt;如何理解ruby中的__FILE__？&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/what-is-dup/' rel='bookmark' title='what is dup'&gt;what is dup&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/python-tiobe-award/' rel='bookmark' title='Python赢得Tiobe 2010年度语言大奖'&gt;Python赢得Tiobe 2010年度语言大奖&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/puts-back-value/' rel='bookmark' title='puts 返回值'&gt;puts 返回值&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/ruby-install-rmagick/' rel='bookmark' title='ruby 安装 rmagick'&gt;ruby 安装 rmagick&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/try-reconstruction/' rel='bookmark' title='小试重构'&gt;小试重构&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/xpath/' rel='bookmark' title='XPath'&gt;XPath&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/render-partial/' rel='bookmark' title='render partial'&gt;render partial&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/607980941/moonfox/feedsky/s.gif?r=http://www.gagahappy.com/ruby-match-pre-post-match/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://www.gagahappy.com/ruby-match-pre-post-match/feed/</wfw:commentRss><slash:comments>0</slash:comments><description>ruby 正则表达式获取匹配字符串前后部分 a = &amp;#34;Hello gagahappy Hi&amp;#34; refs = a.match&amp;#40;/gagahappy/&amp;#41; refs.pre_match # =&amp;#62; &amp;#34;Hello &amp;#34; refs.post_match # =&amp;#62; &amp;#34; Hi&amp;#34; 您可能感兴趣的文章 ruby 正则表达式中的全局变量 Error loading gem paths on load path in gem_prelude 如何理解ruby中的__FILE__？ what is dup Python赢得Tiobe 2010年度语言大奖 puts 返回值 ruby 安装 rmagick 小试重构 XPath render partial&lt;img src=&quot;http://www1.feedsky.com/t1/607980941/moonfox/feedsky/s.gif?r=http://www.gagahappy.com/ruby-match-pre-post-match/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>程序开发</category><category>Ruby</category><pubDate>Mon, 13 Feb 2012 22:41:11 +0800</pubDate><author>moonfox</author><comments>http://www.gagahappy.com/ruby-match-pre-post-match/#comments</comments><guid isPermaLink="false">http://www.gagahappy.com/?p=3986</guid><dc:creator>moonfox</dc:creator><fs:srclink>http://www.gagahappy.com/ruby-match-pre-post-match/</fs:srclink><fs:srcfeed>http://www.gagahappy.com/feed/</fs:srcfeed><fs:itemid>feedsky/moonfox/~8433309/607980941/6537203</fs:itemid></item><item><title>ubuntu 11.10 rvm 安装版ruby openssl解决</title><link>http://www.gagahappy.com/ubuntu-11-10-rvm-%e5%ae%89%e8%a3%85%e7%89%88ruby-openssl%e8%a7%a3%e5%86%b3/</link><content:encoded>&lt;p&gt;用rvm 安装ruby1.9.1时，需要openssl的版本为0.98，而系统自带为1.0，造成RUNERR,解决方法如下&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;bash&quot; style=&quot;font-family:monospace;&quot;&gt;rvm pkg &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;install&lt;/span&gt; openssl
rvm remove 1.9.2
rvm &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;install&lt;/span&gt; 1.9.2 &lt;span style=&quot;color: #660033;&quot;&gt;--with-openssl-dir&lt;/span&gt;=&lt;span style=&quot;color: #007800;&quot;&gt;$rvm_path&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;usr&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;您可能感兴趣的文章&lt;ol&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/ruby-regular-expression-in-sub-gsub/' rel='bookmark' title='ruby 正则表达式中的全局变量'&gt;ruby 正则表达式中的全局变量&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/rvm-gemset-pic/' rel='bookmark' title='rvm gemset'&gt;rvm gemset&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/ruby-file-name-file/' rel='bookmark' title='如何理解ruby中的__FILE__？'&gt;如何理解ruby中的__FILE__？&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/what-is-dup/' rel='bookmark' title='what is dup'&gt;what is dup&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/python-tiobe-award/' rel='bookmark' title='Python赢得Tiobe 2010年度语言大奖'&gt;Python赢得Tiobe 2010年度语言大奖&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/puts-back-value/' rel='bookmark' title='puts 返回值'&gt;puts 返回值&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/ruby-install-rmagick/' rel='bookmark' title='ruby 安装 rmagick'&gt;ruby 安装 rmagick&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/try-reconstruction/' rel='bookmark' title='小试重构'&gt;小试重构&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/xpath/' rel='bookmark' title='XPath'&gt;XPath&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/render-partial/' rel='bookmark' title='render partial'&gt;render partial&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/607980942/moonfox/feedsky/s.gif?r=http://www.gagahappy.com/ubuntu-11-10-rvm-%e5%ae%89%e8%a3%85%e7%89%88ruby-openssl%e8%a7%a3%e5%86%b3/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://www.gagahappy.com/ubuntu-11-10-rvm-%e5%ae%89%e8%a3%85%e7%89%88ruby-openssl%e8%a7%a3%e5%86%b3/feed/</wfw:commentRss><slash:comments>0</slash:comments><description>用rvm 安装ruby1.9.1时，需要openssl的版本为0.98，而系统自带为1.0，造成RUNERR,解决方法如下 rvm pkg install openssl rvm remove 1.9.2 rvm install 1.9.2 --with-openssl-dir=$rvm_path/usr 您可能感兴趣的文章 ruby 正则表达式中的全局变量 rvm gemset 如何理解ruby中的__FILE__？ what is dup Python赢得Tiobe 2010年度语言大奖 puts 返回值 ruby 安装 rmagick 小试重构 XPath render partial&lt;img src=&quot;http://www1.feedsky.com/t1/607980942/moonfox/feedsky/s.gif?r=http://www.gagahappy.com/ubuntu-11-10-rvm-%e5%ae%89%e8%a3%85%e7%89%88ruby-openssl%e8%a7%a3%e5%86%b3/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>rvm</category><category>程序开发</category><category>Ruby</category><pubDate>Sun, 12 Feb 2012 13:54:28 +0800</pubDate><author>moonfox</author><comments>http://www.gagahappy.com/ubuntu-11-10-rvm-%e5%ae%89%e8%a3%85%e7%89%88ruby-openssl%e8%a7%a3%e5%86%b3/#comments</comments><guid isPermaLink="false">http://www.gagahappy.com/?p=3973</guid><dc:creator>moonfox</dc:creator><fs:srclink>http://www.gagahappy.com/ubuntu-11-10-rvm-%e5%ae%89%e8%a3%85%e7%89%88ruby-openssl%e8%a7%a3%e5%86%b3/</fs:srclink><fs:srcfeed>http://www.gagahappy.com/feed/</fs:srcfeed><fs:itemid>feedsky/moonfox/~8433309/607980942/6537203</fs:itemid></item><item><title>Error loading gem paths on load path in gem_prelude</title><link>http://www.gagahappy.com/error-loading-gem-paths-on-load-path-in-gem_prelude/</link><content:encoded>&lt;p&gt;在用rvm安装ruby后运行gem，出现&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Error loading gem paths on load path in gem_prelude&lt;br /&gt;
can&amp;#8217;t modify frozen string&lt;br /&gt;
&lt;internal:gem_prelude&gt;:69:in `force_encoding&amp;#8217;&lt;br /&gt;
&lt;internal:gem_prelude&gt;:69:in `set_home&amp;#8217;&lt;br /&gt;
&lt;internal:gem_prelude&gt;:38:in `dir&amp;#8217;&lt;br /&gt;
&lt;internal:gem_prelude&gt;:76:in `set_paths&amp;#8217;&lt;br /&gt;
&lt;internal:gem_prelude&gt;:47:in `path&amp;#8217;&lt;br /&gt;
&lt;internal:gem_prelude&gt;:286:in `push_all_highest_version_gems_on_load_path&amp;#8217;&lt;br /&gt;
&lt;internal:gem_prelude&gt;:355:in `&lt;compiled&gt;&amp;#8216;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;解决方法：找到 your/home/.rvm/src/ruby-your-version/gem_prelude.rb文件 编辑&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;ruby&quot; style=&quot;font-family:monospace;&quot;&gt;     &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color:#0000FF; font-weight:bold;&quot;&gt;self&lt;/span&gt;.&lt;span style=&quot;color:#9900CC;&quot;&gt;set_home&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#40;&lt;/span&gt;home&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#41;&lt;/span&gt;
       home = home.&lt;span style=&quot;color:#CC0066; font-weight:bold;&quot;&gt;gsub&lt;/span&gt; &lt;span style=&quot;color:#CC00FF; font-weight:bold;&quot;&gt;File&lt;/span&gt;::ALT_SEPARATOR, &lt;span style=&quot;color:#CC00FF; font-weight:bold;&quot;&gt;File&lt;/span&gt;::SEPARATOR &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color:#CC00FF; font-weight:bold;&quot;&gt;File&lt;/span&gt;::ALT_SEPARATOR	
&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;-&lt;/span&gt;      &lt;span style=&quot;color:#0066ff; font-weight:bold;&quot;&gt;@gem_home&lt;/span&gt; = home.&lt;span style=&quot;color:#9900CC;&quot;&gt;force_encoding&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#40;&lt;/span&gt;Encoding.&lt;span style=&quot;color:#9900CC;&quot;&gt;find&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color:#996600;&quot;&gt;'filesystem'&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#41;&lt;/span&gt;	
&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;+&lt;/span&gt;      &lt;span style=&quot;color:#0066ff; font-weight:bold;&quot;&gt;@gem_home&lt;/span&gt; = home.&lt;span style=&quot;color:#9900CC;&quot;&gt;dup&lt;/span&gt;.&lt;span style=&quot;color:#9900CC;&quot;&gt;force_encoding&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#40;&lt;/span&gt;Encoding.&lt;span style=&quot;color:#9900CC;&quot;&gt;find&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color:#996600;&quot;&gt;'filesystem'&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#41;&lt;/span&gt;
     &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;您可能感兴趣的文章&lt;ol&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/ruby-regular-expression-in-sub-gsub/' rel='bookmark' title='ruby 正则表达式中的全局变量'&gt;ruby 正则表达式中的全局变量&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/ruby-file-name-file/' rel='bookmark' title='如何理解ruby中的__FILE__？'&gt;如何理解ruby中的__FILE__？&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/what-is-dup/' rel='bookmark' title='what is dup'&gt;what is dup&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/python-tiobe-award/' rel='bookmark' title='Python赢得Tiobe 2010年度语言大奖'&gt;Python赢得Tiobe 2010年度语言大奖&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/puts-back-value/' rel='bookmark' title='puts 返回值'&gt;puts 返回值&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/ruby-install-rmagick/' rel='bookmark' title='ruby 安装 rmagick'&gt;ruby 安装 rmagick&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/rails-redirect_to/' rel='bookmark' title='rails redirect_to'&gt;rails redirect_to&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/try-reconstruction/' rel='bookmark' title='小试重构'&gt;小试重构&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/xpath/' rel='bookmark' title='XPath'&gt;XPath&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/render-partial/' rel='bookmark' title='render partial'&gt;render partial&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/607980943/moonfox/feedsky/s.gif?r=http://www.gagahappy.com/error-loading-gem-paths-on-load-path-in-gem_prelude/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://www.gagahappy.com/error-loading-gem-paths-on-load-path-in-gem_prelude/feed/</wfw:commentRss><slash:comments>0</slash:comments><description>在用rvm安装ruby后运行gem，出现 Error loading gem paths on load path in gem_prelude can&amp;#8217;t modify frozen string :69:in `force_encoding&amp;#8217; :69:in `set_home&amp;#8217; :38:in `dir&amp;#8217; :76:in `set_paths&amp;#8217; :47:in `path&amp;#8217; :286:in `push_all_highest_version_gems_on_load_path&amp;#8217; :355:in `&amp;#8216; 解决方法：找到 your/home/.rvm/src/ruby-your-version/gem_prelude.rb文件 编辑 def self.set_home&amp;#40;home&amp;#41; home = home.gsub File::ALT_SEPARATOR, File::SEPARATOR if File::ALT_SEPARATOR - @gem_home = home.force_encoding&amp;#40;Encoding.find&amp;#40;'filesystem'&amp;#41;&amp;#41; + @gem_home = home.dup.force_encoding&amp;#40;Encoding.find&amp;#40;'filesystem'&amp;#41; end 您可能感兴趣的文章 ruby 正则表达式中的全局变量 如何理解ruby中的__FILE__？ what is [...]&lt;img src=&quot;http://www1.feedsky.com/t1/607980943/moonfox/feedsky/s.gif?r=http://www.gagahappy.com/error-loading-gem-paths-on-load-path-in-gem_prelude/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>程序开发</category><category>Ruby</category><pubDate>Sat, 11 Feb 2012 17:03:16 +0800</pubDate><author>moonfox</author><comments>http://www.gagahappy.com/error-loading-gem-paths-on-load-path-in-gem_prelude/#comments</comments><guid isPermaLink="false">http://www.gagahappy.com/?p=3975</guid><dc:creator>moonfox</dc:creator><fs:srclink>http://www.gagahappy.com/error-loading-gem-paths-on-load-path-in-gem_prelude/</fs:srclink><fs:srcfeed>http://www.gagahappy.com/feed/</fs:srcfeed><fs:itemid>feedsky/moonfox/~8433309/607980943/6537203</fs:itemid></item><item><title>Rack::Builder  rackup</title><link>http://www.gagahappy.com/rackbuilder-rackup/</link><content:encoded>&lt;p&gt;rackup converts the supplied rack config file to an instance of Rack::Builder. This is how is happens under the hood ( just so you get an idea ) :&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;ruby&quot; style=&quot;font-family:monospace;&quot;&gt;config_file = &lt;span style=&quot;color:#CC00FF; font-weight:bold;&quot;&gt;File&lt;/span&gt;.&lt;span style=&quot;color:#9900CC;&quot;&gt;read&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#40;&lt;/span&gt;config&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#41;&lt;/span&gt;
rack_application = &lt;span style=&quot;color:#CC0066; font-weight:bold;&quot;&gt;eval&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color:#996600;&quot;&gt;&amp;quot;Rack::Builder.new { #{config_file} }&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And then rackup supplies rack_application to the respective webserver :&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;ruby&quot; style=&quot;font-family:monospace;&quot;&gt;server.&lt;span style=&quot;color:#9900CC;&quot;&gt;run&lt;/span&gt; rack_application, options&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Very straight forward! In short, rack config files are evaluated within the context of a Rack::Builder object. So if we convert infinity to a rack config file which rackup can understand :&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;ruby&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color:#008000; font-style:italic;&quot;&gt;# infinity.ru&lt;/span&gt;
&amp;nbsp;
infinity = &lt;span style=&quot;color:#CC0066; font-weight:bold;&quot;&gt;Proc&lt;/span&gt;.&lt;span style=&quot;color:#9900CC;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;|&lt;/span&gt;env&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;|&lt;/span&gt; &lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color:#006666;&quot;&gt;200&lt;/span&gt;, &lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#996600;&quot;&gt;&amp;quot;Content-Type&amp;quot;&lt;/span&gt; &lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span style=&quot;color:#996600;&quot;&gt;&amp;quot;text/html&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#125;&lt;/span&gt;, env.&lt;span style=&quot;color:#9900CC;&quot;&gt;inspect&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
use &lt;span style=&quot;color:#6666ff; font-weight:bold;&quot;&gt;Rack::CommonLogger&lt;/span&gt;
&amp;nbsp;
map &lt;span style=&quot;color:#996600;&quot;&gt;'/'&lt;/span&gt; &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;do&lt;/span&gt;
  run infinity
&lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;end&lt;/span&gt;
&amp;nbsp;
map &lt;span style=&quot;color:#996600;&quot;&gt;'/version'&lt;/span&gt; &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;do&lt;/span&gt;
  map &lt;span style=&quot;color:#996600;&quot;&gt;'/'&lt;/span&gt; &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;do&lt;/span&gt;
    run &lt;span style=&quot;color:#CC0066; font-weight:bold;&quot;&gt;Proc&lt;/span&gt;.&lt;span style=&quot;color:#9900CC;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;|&lt;/span&gt;env&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;|&lt;/span&gt; &lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color:#006666;&quot;&gt;200&lt;/span&gt;, &lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#996600;&quot;&gt;&amp;quot;Content-Type&amp;quot;&lt;/span&gt; &lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span style=&quot;color:#996600;&quot;&gt;&amp;quot;text/html&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#125;&lt;/span&gt;, &lt;span style=&quot;color:#996600;&quot;&gt;&amp;quot;infinity 0.1&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#125;&lt;/span&gt;
  &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;end&lt;/span&gt;
&amp;nbsp;
  map &lt;span style=&quot;color:#996600;&quot;&gt;'/last'&lt;/span&gt; &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;do&lt;/span&gt;
    run &lt;span style=&quot;color:#CC0066; font-weight:bold;&quot;&gt;Proc&lt;/span&gt;.&lt;span style=&quot;color:#9900CC;&quot;&gt;new&lt;/span&gt; &lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;|&lt;/span&gt;env&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;|&lt;/span&gt; &lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color:#006666;&quot;&gt;200&lt;/span&gt;, &lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color:#996600;&quot;&gt;&amp;quot;Content-Type&amp;quot;&lt;/span&gt; &lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span style=&quot;color:#996600;&quot;&gt;&amp;quot;text/html&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#125;&lt;/span&gt;, &lt;span style=&quot;color:#996600;&quot;&gt;&amp;quot;infinity beta 0.0&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#125;&lt;/span&gt;
  &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;end&lt;/span&gt;
&lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And now run it :&lt;br /&gt;
$ rackup infinity.ru&lt;/p&gt;
&lt;p&gt;您可能感兴趣的文章&lt;ol&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/rails-railsorderedoptions/' rel='bookmark' title='rails Rails::OrderedOptions'&gt;rails Rails::OrderedOptions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/the-different-between-include-and-extend-in-ruby/' rel='bookmark' title='ruby 中 include 与 extend 区别'&gt;ruby 中 include 与 extend 区别&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/ruby-initialize-back-class-self/' rel='bookmark' title='ruby initialize 返回对象'&gt;ruby initialize 返回对象&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/rails-redirect_to/' rel='bookmark' title='rails redirect_to'&gt;rails redirect_to&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/render-partial/' rel='bookmark' title='render partial'&gt;render partial&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/validates_inclusion_of/' rel='bookmark' title='validates_inclusion_of'&gt;validates_inclusion_of&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/ruby-connect-string-method/' rel='bookmark' title='ruby 连接字符串'&gt;ruby 连接字符串&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/ri-rails-api/' rel='bookmark' title='使用ri查看Rails的API'&gt;使用ri查看Rails的API&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/belongs-to-primary-key/' rel='bookmark' title='belongs_to 选项中的:primary_key'&gt;belongs_to 选项中的:primary_key&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/add-gem-sources/' rel='bookmark' title='为gem添加源'&gt;为gem添加源&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/607980944/moonfox/feedsky/s.gif?r=http://www.gagahappy.com/rackbuilder-rackup/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://www.gagahappy.com/rackbuilder-rackup/feed/</wfw:commentRss><slash:comments>0</slash:comments><description>rackup converts the supplied rack config file to an instance of Rack::Builder. This is how is happens under the hood ( just so you get an idea ) : config_file = File.read&amp;#40;config&amp;#41; rack_application = eval&amp;#40;&amp;#34;Rack::Builder.new { #{config_file} }&amp;#34;&amp;#41; And then rackup supplies rack_application to the respective webserver : server.run rack_application, options Very straight forward! In [...]&lt;img src=&quot;http://www1.feedsky.com/t1/607980944/moonfox/feedsky/s.gif?r=http://www.gagahappy.com/rackbuilder-rackup/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>rack</category><category>程序开发</category><category>Ruby</category><pubDate>Thu, 09 Feb 2012 17:29:27 +0800</pubDate><author>moonfox</author><comments>http://www.gagahappy.com/rackbuilder-rackup/#comments</comments><guid isPermaLink="false">http://www.gagahappy.com/?p=3971</guid><dc:creator>moonfox</dc:creator><fs:srclink>http://www.gagahappy.com/rackbuilder-rackup/</fs:srclink><fs:srcfeed>http://www.gagahappy.com/feed/</fs:srcfeed><fs:itemid>feedsky/moonfox/~8433309/607980944/6537203</fs:itemid></item><item><title>Eager load application classes</title><link>http://www.gagahappy.com/eager-load-application-classes/</link><content:encoded>&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;ruby&quot; style=&quot;font-family:monospace;&quot;&gt;    &lt;span style=&quot;color:#008000; font-style:italic;&quot;&gt;# Eager load application classes&lt;/span&gt;
    &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;def&lt;/span&gt; load_application_classes
      &lt;span style=&quot;color:#0000FF; font-weight:bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color:#ff6633; font-weight:bold;&quot;&gt;$rails_rake_task&lt;/span&gt;
      &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;if&lt;/span&gt; configuration.&lt;span style=&quot;color:#9900CC;&quot;&gt;cache_classes&lt;/span&gt;
        configuration.&lt;span style=&quot;color:#9900CC;&quot;&gt;eager_load_paths&lt;/span&gt;.&lt;span style=&quot;color:#9900CC;&quot;&gt;each&lt;/span&gt; &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;do&lt;/span&gt; &lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;|&lt;/span&gt;load_path&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;|&lt;/span&gt;
          matcher = &lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;/&lt;/span&gt;\A&lt;span style=&quot;color:#008000; font-style:italic;&quot;&gt;#{Regexp.escape(load_path)}(.*)\.rb\Z/&lt;/span&gt;
          &lt;span style=&quot;color:#CC00FF; font-weight:bold;&quot;&gt;Dir&lt;/span&gt;.&lt;span style=&quot;color:#9900CC;&quot;&gt;glob&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color:#996600;&quot;&gt;&amp;quot;#{load_path}/**/*.rb&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color:#9900CC;&quot;&gt;sort&lt;/span&gt;.&lt;span style=&quot;color:#9900CC;&quot;&gt;each&lt;/span&gt; &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;do&lt;/span&gt; &lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;|&lt;/span&gt;file&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;|&lt;/span&gt;
            require_dependency file.&lt;span style=&quot;color:#CC0066; font-weight:bold;&quot;&gt;sub&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#40;&lt;/span&gt;matcher, &lt;span style=&quot;color:#996600;&quot;&gt;'&lt;span style=&quot;color:#000099;&quot;&gt;\1&lt;/span&gt;'&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#41;&lt;/span&gt;
          &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;end&lt;/span&gt;
        &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;end&lt;/span&gt;
      &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;end&lt;/span&gt;
    &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;您可能感兴趣的文章&lt;ol&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/rails-railsorderedoptions/' rel='bookmark' title='rails Rails::OrderedOptions'&gt;rails Rails::OrderedOptions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/the-different-between-include-and-extend-in-ruby/' rel='bookmark' title='ruby 中 include 与 extend 区别'&gt;ruby 中 include 与 extend 区别&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/ruby-initialize-back-class-self/' rel='bookmark' title='ruby initialize 返回对象'&gt;ruby initialize 返回对象&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/rails-redirect_to/' rel='bookmark' title='rails redirect_to'&gt;rails redirect_to&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/render-partial/' rel='bookmark' title='render partial'&gt;render partial&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/validates_inclusion_of/' rel='bookmark' title='validates_inclusion_of'&gt;validates_inclusion_of&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/ruby-connect-string-method/' rel='bookmark' title='ruby 连接字符串'&gt;ruby 连接字符串&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/ri-rails-api/' rel='bookmark' title='使用ri查看Rails的API'&gt;使用ri查看Rails的API&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/belongs-to-primary-key/' rel='bookmark' title='belongs_to 选项中的:primary_key'&gt;belongs_to 选项中的:primary_key&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/add-gem-sources/' rel='bookmark' title='为gem添加源'&gt;为gem添加源&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/607980945/moonfox/feedsky/s.gif?r=http://www.gagahappy.com/eager-load-application-classes/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://www.gagahappy.com/eager-load-application-classes/feed/</wfw:commentRss><slash:comments>0</slash:comments><description># Eager load application classes def load_application_classes return if $rails_rake_task if configuration.cache_classes configuration.eager_load_paths.each do &amp;#124;load_path&amp;#124; matcher = /\A#{Regexp.escape(load_path)}(.*)\.rb\Z/ Dir.glob&amp;#40;&amp;#34;#{load_path}/**/*.rb&amp;#34;&amp;#41;.sort.each do &amp;#124;file&amp;#124; require_dependency file.sub&amp;#40;matcher, '\1'&amp;#41; end end end end 您可能感兴趣的文章 rails Rails::OrderedOptions ruby 中 include 与 extend 区别 ruby initialize 返回对象 rails redirect_to render partial validates_inclusion_of ruby 连接字符串 使用ri查看Rails的API belongs_to 选项中的:primary_key 为gem添加源&lt;img src=&quot;http://www1.feedsky.com/t1/607980945/moonfox/feedsky/s.gif?r=http://www.gagahappy.com/eager-load-application-classes/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>程序开发</category><category>Ruby</category><pubDate>Wed, 08 Feb 2012 11:22:28 +0800</pubDate><author>moonfox</author><comments>http://www.gagahappy.com/eager-load-application-classes/#comments</comments><guid isPermaLink="false">http://www.gagahappy.com/?p=3969</guid><dc:creator>moonfox</dc:creator><fs:srclink>http://www.gagahappy.com/eager-load-application-classes/</fs:srclink><fs:srcfeed>http://www.gagahappy.com/feed/</fs:srcfeed><fs:itemid>feedsky/moonfox/~8433309/607980945/6537203</fs:itemid></item><item><title>rails Rails::OrderedOptions</title><link>http://www.gagahappy.com/rails-railsorderedoptions/</link><content:encoded>&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;ruby&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color:#6666ff; font-weight:bold;&quot;&gt;Rails::OrderedOptions&lt;/span&gt; &lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color:#CC0066; font-weight:bold;&quot;&gt;Array&lt;/span&gt; &lt;span style=&quot;color:#008000; font-style:italic;&quot;&gt;#:nodoc:&lt;/span&gt;
  &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#93;&lt;/span&gt;=&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#40;&lt;/span&gt;key, value&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#41;&lt;/span&gt;
    key = key.&lt;span style=&quot;color:#9900CC;&quot;&gt;to_sym&lt;/span&gt;
&amp;nbsp;
    &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;if&lt;/span&gt; pair = find_pair&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#40;&lt;/span&gt;key&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#41;&lt;/span&gt;
      pair.&lt;span style=&quot;color:#9900CC;&quot;&gt;pop&lt;/span&gt;
      pair &lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; value
    &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;else&lt;/span&gt;
      &lt;span style=&quot;color:#0000FF; font-weight:bold;&quot;&gt;self&lt;/span&gt; &lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#91;&lt;/span&gt;key, value&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#93;&lt;/span&gt;
    &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;end&lt;/span&gt;
  &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;end&lt;/span&gt;
&amp;nbsp;
  &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;def&lt;/span&gt; &lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#40;&lt;/span&gt;key&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#41;&lt;/span&gt;
    pair = find_pair&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#40;&lt;/span&gt;key.&lt;span style=&quot;color:#9900CC;&quot;&gt;to_sym&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#41;&lt;/span&gt;
    pair ? pair.&lt;span style=&quot;color:#9900CC;&quot;&gt;last&lt;/span&gt; : &lt;span style=&quot;color:#0000FF; font-weight:bold;&quot;&gt;nil&lt;/span&gt;
  &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;end&lt;/span&gt;
&amp;nbsp;
  &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;def&lt;/span&gt; method_missing&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#40;&lt;/span&gt;name, &lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;*&lt;/span&gt;args&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;if&lt;/span&gt; name.&lt;span style=&quot;color:#9900CC;&quot;&gt;to_s&lt;/span&gt; =~ &lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#40;&lt;/span&gt;.&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#41;&lt;/span&gt;=$&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;/&lt;/span&gt;
      &lt;span style=&quot;color:#0000FF; font-weight:bold;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#91;&lt;/span&gt;$1.&lt;span style=&quot;color:#9900CC;&quot;&gt;to_sym&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#93;&lt;/span&gt; = args.&lt;span style=&quot;color:#9900CC;&quot;&gt;first&lt;/span&gt;
    &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;else&lt;/span&gt;
      &lt;span style=&quot;color:#0000FF; font-weight:bold;&quot;&gt;self&lt;/span&gt;&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#91;&lt;/span&gt;name&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#93;&lt;/span&gt;
    &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;end&lt;/span&gt;
  &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;end&lt;/span&gt;
&amp;nbsp;
  private
    &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;def&lt;/span&gt; find_pair&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#40;&lt;/span&gt;key&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#41;&lt;/span&gt;
      &lt;span style=&quot;color:#0000FF; font-weight:bold;&quot;&gt;self&lt;/span&gt;.&lt;span style=&quot;color:#9900CC;&quot;&gt;each&lt;/span&gt; &lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;|&lt;/span&gt;i&lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;|&lt;/span&gt; &lt;span style=&quot;color:#0000FF; font-weight:bold;&quot;&gt;return&lt;/span&gt; i &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;if&lt;/span&gt; i.&lt;span style=&quot;color:#9900CC;&quot;&gt;first&lt;/span&gt; == key &lt;span style=&quot;color:#006600; font-weight:bold;&quot;&gt;&amp;#125;&lt;/span&gt;
      &lt;span style=&quot;color:#0000FF; font-weight:bold;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color:#0000FF; font-weight:bold;&quot;&gt;false&lt;/span&gt;
    &lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;end&lt;/span&gt;
&lt;span style=&quot;color:#9966CC; font-weight:bold;&quot;&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;您可能感兴趣的文章&lt;ol&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/what-is-dup/' rel='bookmark' title='what is dup'&gt;what is dup&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/the-different-between-include-and-extend-in-ruby/' rel='bookmark' title='ruby 中 include 与 extend 区别'&gt;ruby 中 include 与 extend 区别&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/ruby-initialize-back-class-self/' rel='bookmark' title='ruby initialize 返回对象'&gt;ruby initialize 返回对象&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/ruby-install-rmagick/' rel='bookmark' title='ruby 安装 rmagick'&gt;ruby 安装 rmagick&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/rails-redirect_to/' rel='bookmark' title='rails redirect_to'&gt;rails redirect_to&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/try-reconstruction/' rel='bookmark' title='小试重构'&gt;小试重构&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/render-partial/' rel='bookmark' title='render partial'&gt;render partial&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/ri-rails-api/' rel='bookmark' title='使用ri查看Rails的API'&gt;使用ri查看Rails的API&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/belongs-to-primary-key/' rel='bookmark' title='belongs_to 选项中的:primary_key'&gt;belongs_to 选项中的:primary_key&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href='http://www.gagahappy.com/add-gem-sources/' rel='bookmark' title='为gem添加源'&gt;为gem添加源&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/607980946/moonfox/feedsky/s.gif?r=http://www.gagahappy.com/rails-railsorderedoptions/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://www.gagahappy.com/rails-railsorderedoptions/feed/</wfw:commentRss><slash:comments>0</slash:comments><description>class Rails::OrderedOptions &amp;#60; Array #:nodoc: def &amp;#91;&amp;#93;=&amp;#40;key, value&amp;#41; key = key.to_sym &amp;#160; if pair = find_pair&amp;#40;key&amp;#41; pair.pop pair &amp;#60;&amp;#60; value else self &amp;#60;&amp;#60; &amp;#91;key, value&amp;#93; end end &amp;#160; def &amp;#91;&amp;#93;&amp;#40;key&amp;#41; pair = find_pair&amp;#40;key.to_sym&amp;#41; pair ? pair.last : nil end &amp;#160; def method_missing&amp;#40;name, *args&amp;#41; if name.to_s =~ /&amp;#40;.*&amp;#41;=$/ self&amp;#91;$1.to_sym&amp;#93; = args.first else self&amp;#91;name&amp;#93; end end &amp;#160; [...]&lt;img src=&quot;http://www1.feedsky.com/t1/607980946/moonfox/feedsky/s.gif?r=http://www.gagahappy.com/rails-railsorderedoptions/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>程序开发</category><category>Ruby</category><pubDate>Tue, 07 Feb 2012 18:19:21 +0800</pubDate><author>moonfox</author><comments>http://www.gagahappy.com/rails-railsorderedoptions/#comments</comments><guid isPermaLink="false">http://www.gagahappy.com/?p=3967</guid><dc:creator>moonfox</dc:creator><fs:srclink>http://www.gagahappy.com/rails-railsorderedoptions/</fs:srclink><fs:srcfeed>http://www.gagahappy.com/feed/</fs:srcfeed><fs:itemid>feedsky/moonfox/~8433309/607980946/6537203</fs:itemid></item></channel></rss>
