<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Latest posts for the topic "MentaOnRuby: Porting Mentawai to Ruby"]]></title>
		<link>http://blogs.mentaframework.org/posts/list/2.page</link>
		<description><![CDATA[Latest messages posted in the topic "MentaOnRuby: Porting Mentawai to Ruby"]]></description>
		<generator>JForum - http://www.jforum.net</generator>
			<item>
				<title>MentaOnRuby: Porting Mentawai to Ruby</title>
				<description><![CDATA[ I have just released the first version of MentaOnRuby, a port of Mentawai for Ruby:<br /> <br /> http://rubyforge.org/projects/mentawai/<br /> <br /> Here I will walk you through the first MentaOnRuby sample application so you can get a feel for Ruby, Merb and Mentawai.<br /> <br /> The first thing you need to know is that Mentawai runs on top of [url="http://merbivore.com/"]Merb[/url], which is a kind of [i]Servet Container[/i] for the Ruby world built on top of [url="http://mongrel.rubyforge.org/"]Mongrel[/url]. Below I will show the major steps to get Merb up and running:<br /> <br /> If you installed Ruby, chances are that it already came with [url="http://www.rubygems.org/"]RubyGems[/url]. If not, go here: http://www.rubygems.org/ and install RubyGems.<br /> <br /> After installing, just type gem -v to see its version:<br /> [code]<br /> C:\&gt;gem -v<br /> 1.0.1<br /> [/code]<br /> If you don't see version 1.0.1 or above, you need to upgrade your RubyGems. Just do:<br /> [code]<br /> C:\&gt;gem update --system<br /> Updating RubyGems...<br /> Updating metadata for 175 gems from http://gems.rubyforge.org<br /> ............<br /> [/code]<br /> With your RubyGems up-to-date, you can now install Merb:<br /> [code]<br /> c:\&gt;gem instal merb<br /> [/code]<br /> After the installation you should now be able to run Merb from the command line:<br /> [code]<br /> c:\&gt;merb -v<br /> merb 0.5.3<br /> [/code]<br /> Now go to a directory where you want to create your application and execute the command below:<br /> (OBS: It will create the [i]HelloMenta [/i]directory for you!)<br /> [code]<br /> C:\java\ruby&gt;merb HelloMenta<br />       create<br />       create  app/controllers<br />       create  app/models<br />       create  app/helpers<br />       (...)<br /> [/code]<br /> Go here and download the latest MentaOnRuby files: http://rubyforge.org/projects/mentawai<br /> <br /> (Note: It takes sometime for RubyForge to make the files available for download. Click [url="http://www.mentaframework.org/ruby/MentaOnRuby-0.3b.zip"]here instead[/url] to download the MentaOnRuby.zip file from the Mentawai site)<br /> <br /> Unzip the mentawai.zip file inside your application's [i]lib[/i] folder ([i]HelloMenta/lib[/i]).<br /> <br /> Now we will tell Merb to use the Mentawai controller for all requests ending with [i].mtw[/i]. To do that you should do the following modifications in the config/router.rb file:<br /> <br /> :arrow: Import the controller.rb file:<br /> [code]<br /> require 'Mentawai/core/controller'<br /> [/code]<br /> :arrow: Comment out the merb default routes<br /> [code]<br /> #r.default_routes<br /> [/code]<br /> :arrow: Add the line below to map the Mentawai controller:<br /> [code]<br /> r.match(/\.mtw/).to(:controller =&gt; 'mentawai/core/Controller', :action =&gt;'service')  <br /> [/code]<br /> Now let's create our first Mentawai action: app/controllers/hello.rb<br /> [code]<br /> class Hello &lt; Action<br /> <br />     def execute<br />       username = input.get("username")<br />       output.put("hi", "Hello #{username.upcase}")<br />       :SUCCESS<br />     end<br /> <br /> end<br /> [/code]<br /> Now let's create our ERB file app/views/sayHello.html.erb (you can consider that a Ruby Server Page or RSP):<br /> [code]<br /> &lt;h2&gt;Hello MentaOnRuby&lt;/h2&gt;<br /> &lt;h3&gt;&lt;%= "#{action.output.get('hi')}" %&gt;&lt;/h3&gt;<br /> [/code]<br /> Now our application manager: app/controllers/app_manager.rb<br /> [code]<br /> require 'Mentawai/core/app_manager'<br /> require 'Mentawai/core/forward'<br /> <br /> include Mentawai::Core<br /> <br /> class AppManager &lt; ApplicationManager<br /> <br />   def init<br />     action("Hello").on(:SUCCESS =&gt; Forward.new("sayHello"))<br />   end<br />   <br /> end<br /> [/code]<br /> That's it! Now go inside your application directory and run the merb server:<br /> [code]<br /> c:\java\ruby\HelloMenta&gt;merb<br /> Merb started with these options:<br /> (...)<br /> [/code]<br /> Type the following URL in your browser and you should see your action being executed:<br /> <br /> http://localhost:4000/Hello.mtw?username=Sergio<br /> <br /> The version 0.3b already supports inner actions, filters, global filters, consequences, global consequences, invocation chain, etc. Of course there many other Mentawai features not yet implemented.<br /> ]]></description>
				<guid isPermaLink="true">http://blogs.mentaframework.org/posts/preList/15/24.page</guid>
				<link>http://blogs.mentaframework.org/posts/preList/15/24.page</link>
				<pubDate><![CDATA[Sat, 23 Feb 2008 07:32:32]]> GMT</pubDate>
				<author><![CDATA[ saoj]]></author>
			</item>
			<item>
				<title>Re:MentaOnRuby: Porting Mentawai to Ruby</title>
				<description><![CDATA[ Bom trabalho! Sou programador Ruby e estou estudando Java. Achei interessante a sua idéia de portar algo feito em java para ruby! <img src="http://blogs.mentaframework.org//images/smilies/283a16da79f3aa23fe1025c96295f04f.gif" /> ]]></description>
				<guid isPermaLink="true">http://blogs.mentaframework.org/posts/preList/15/32.page</guid>
				<link>http://blogs.mentaframework.org/posts/preList/15/32.page</link>
				<pubDate><![CDATA[Sat, 5 Apr 2008 15:16:55]]> GMT</pubDate>
				<author><![CDATA[ comechao]]></author>
			</item>
	</channel>
</rss>