<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>по стопам webkill&#039;а &#187; case-when</title>
	<atom:link href="http://blog.lukmus.ru/tag/case-when/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.lukmus.ru</link>
	<description>это наш химический дом для печальных жителей Земли</description>
	<lastBuildDate>Sat, 21 Oct 2023 19:10:13 +0000</lastBuildDate>
	<language>ru-RU</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
		<item>
		<title>xmpp4r-simple на ruby 1.9.2</title>
		<link>http://blog.lukmus.ru/2011/08/12/xmpp4r-simple-na-ruby-1-9-2/</link>
		<comments>http://blog.lukmus.ru/2011/08/12/xmpp4r-simple-na-ruby-1-9-2/#comments</comments>
		<pubDate>Fri, 12 Aug 2011 00:07:51 +0000</pubDate>
		<dc:creator>lukmus</dc:creator>
				<category><![CDATA[ruby & ruby on rails]]></category>
		<category><![CDATA[case-when]]></category>
		<category><![CDATA[ruby 1.9]]></category>
		<category><![CDATA[xmpp4r-simple]]></category>

		<guid isPermaLink="false">http://blog.lukmus.ru/?p=1048</guid>
		<description><![CDATA[Не знаю почему такую панику вызвала ошибка гема xmpp4r-simple в ruby 1.9.2 у матерых пользователей Хабра. Собственно сама ошибка выглядит так: 1 2 3 4 5 6 7 8 9 10 11 12 /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:58:in `require': /usr/localrvm/gems/ruby-1.9.2-p180/gems/xmpp4r-simple-0.8.8 /lib/xmpp4r-simple.rb:441: syntax error, unexpected ':', expecting keyword_then or ',' or ';' or '\n' (SyntaxError) when nil: new_presence.show &#124;&#124; :online [...]]]></description>
			<content:encoded><![CDATA[<p>Не знаю почему такую панику вызвала ошибка гема xmpp4r-simple в ruby 1.9.2 у матерых пользователей <a rel="nofollow" href="http://habrahabr.ru/blogs/ror/119567/" target="_blank">Хабра</a>.<br />
<a href="http://blog.lukmus.ru/wp-content/uploads/2011/08/snimok-3.png"><img class="aligncenter size-full wp-image-1049" title="Снимок-3" src="http://blog.lukmus.ru/wp-content/uploads/2011/08/snimok-3.png" alt="" width="501" height="425" /></a><span id="more-1048"></span><br />
Собственно сама ошибка выглядит так:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>rvm<span style="color: #000000; font-weight: bold;">/</span>rubies<span style="color: #000000; font-weight: bold;">/</span>ruby-1.9.2-p180<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>site_ruby<span style="color: #000000; font-weight: bold;">/</span>1.9.1<span style="color: #000000; font-weight: bold;">/</span>rubygems<span style="color: #000000; font-weight: bold;">/</span>custom_require.rb:<span style="color: #000000;">58</span>:in <span style="color: #000000; font-weight: bold;">`</span>require<span style="color: #ff0000;">': /usr/localrvm/gems/ruby-1.9.2-p180/gems/xmpp4r-simple-0.8.8
/lib/xmpp4r-simple.rb:441: syntax error, unexpected '</span>:<span style="color: #ff0000;">', expecting  keyword_then or '</span>,<span style="color: #ff0000;">' or '</span>;<span style="color: #ff0000;">' or '</span>\n<span style="color: #ff0000;">' (SyntaxError)
                   when nil: new_presence.show || :online
                            ^
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/xmpp4r-simple-0.8.8/lib/xmpp4r-simple.rb:442: syntax error, unexpected keyword_when, expecting keyword_end
                   when :unavailable: :unavailable
                       ^
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/xmpp4r-simple-0.8.8/lib/xmpp4r-simple.rb:443: syntax error, unexpected keyword_else, expecting keyword_end
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/xmpp4r-simple-0.8.8/lib/xmpp4r-simple.rb:490: syntax error, unexpected keyword_end, expecting $end
	from /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:58:in  `rescue in require'</span>
	from <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>rvm<span style="color: #000000; font-weight: bold;">/</span>rubies<span style="color: #000000; font-weight: bold;">/</span>ruby-1.9.2-p180<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>site_ruby<span style="color: #000000; font-weight: bold;">/</span>1.9.1<span style="color: #000000; font-weight: bold;">/</span>rubygems<span style="color: #000000; font-weight: bold;">/</span>custom_require.rb:<span style="color: #000000;">35</span>:in <span style="color: #000000; font-weight: bold;">`</span>require<span style="color: #ff0000;">'
	from xmpp.rb:3:in `&lt;main&gt;'</span></pre></td></tr></table></div>

<p>Странно, что никому в голову не пришло проверить ту самую злополучную 441 строку в <code>/usr/local/rvm/gems/ruby-1.9.2-p180/gems/xmpp4r-simple-0.8.8/lib/xmpp4r-simple.rb</code>.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>441
442
443
444
445
446
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">presence = <span style="color:#9966CC; font-weight:bold;">case</span> new_presence.<span style="color:#9900CC;">type</span>
<span style="color:#9966CC; font-weight:bold;">when</span> <span style="color:#0000FF; font-weight:bold;">nil</span>: new_presence.<span style="color:#9900CC;">show</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#ff3333; font-weight:bold;">:online</span>
<span style="color:#9966CC; font-weight:bold;">when</span> <span style="color:#ff3333; font-weight:bold;">:unavailable</span>: <span style="color:#ff3333; font-weight:bold;">:unavailable</span>
<span style="color:#9966CC; font-weight:bold;">else</span>
  <span style="color:#0000FF; font-weight:bold;">nil</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>Ruby 1.9 не понимает case-when, где после условия идет двоеточие. Все что нужно, чтобы исправить этот баг и запустить xmpp4r-simple на Ruby 1.9.x это убрать <code>:</code> и перенести действие за условием на следующую строку.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>441
442
443
444
445
446
447
448
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">presence = <span style="color:#9966CC; font-weight:bold;">case</span> new_presence.<span style="color:#9900CC;">type</span>
<span style="color:#9966CC; font-weight:bold;">when</span> <span style="color:#0000FF; font-weight:bold;">nil</span>
  new_presence.<span style="color:#9900CC;">show</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#ff3333; font-weight:bold;">:online</span>
<span style="color:#9966CC; font-weight:bold;">when</span> <span style="color:#ff3333; font-weight:bold;">:unavailable</span>
  <span style="color:#ff3333; font-weight:bold;">:unavailable</span>
<span style="color:#9966CC; font-weight:bold;">else</span>
  <span style="color:#0000FF; font-weight:bold;">nil</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>И теперь, по крайней мере у меня, xmpp4r-simple завелся как литой.<br />
<meta property="og:image" content="http://blog.lukmus.ru/wp-content/uploads/2011/08/Снимок-3.png" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lukmus.ru/2011/08/12/xmpp4r-simple-na-ruby-1-9-2/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
