Hello, we just researched a Php to Ruby compilation software, because our client has some Php Project, and that can accelarates their transition to rails, and there are a lot of php projects out there, both open sourced and close sourced, so this software may be helpful to accelarates the changes from php world to ruby''s world. (Besides, some clouds, like VMWare cloudfoundry supports rails now, you can compile your php''s project into rails and runs ontop of it). This project compiles php code to ruby code as close as possbile, so the following php code would compile to this code, $instanceName = ''db''; $config = $sugar_config[''dbconfig'']; if(!isset($dbinstances)){ $dbinstances = array(); } //fall back to the default instance name if(empty($sugar_config[''db''][$instanceName])){ $instanceName = ''''; } if(!isset($dbinstances[$instanceName])){ $my_db_manager = ''MysqlManager''; if( $config[''db_type''] == "mysql" ) { if ((!isset($sugar_config[''mysqli_disabled'']) || $sugar_config[''mysqli_disabled''] == false) && function_exists(''mysqli_connect'')) { $my_db_manager = ''MysqliManager''; } } if( $config[''db_type''] == "oci8" ){ } elseif( $config[''db_type''] == "mssql" ){ if ( function_exists(''sqlsrv_connect'') && (empty($config[''db_mssql_force_driver'']) || $config[''db_mssql_force_driver''] == ''sqlsrv'' )) $my_db_manager = ''SqlsrvManager''; elseif (is_freetds() && (empty($config[''db_mssql_force_driver'']) || $config[''db_mssql_force_driver''] == ''freetds'' )) $my_db_manager = ''FreeTDSManager''; else $my_db_manager = ''MssqlManager''; } $GLOBALS[''log'']->info("using $my_db_manager DBManager backend"); if(!empty($config[''db_manager''])){ $my_db_manager = $config[''db_manager'']; } require_once("include/database/{$my_db_manager}.php"); $dbinstances[$instanceName] = new $my_db_manager(); $dbinstances[$instanceName]->getHelper(); $dbinstances[$instanceName]->connect($config, true); $dbinstances[$instanceName]->count_id = $count; $dbinstances[$instanceName]->references = 0; $dbinstances[$instanceName]->getHelper()->db $dbinstances[$instanceName]; } else { $old_count++; $dbinstances[$instanceName]->references = $old_count; } #to this ruby code _VARS["instanceName"] = "db" _VARS["config"] = ((_VARS["sugar_config"] ||= { }))["dbconfig"] if (not isset(_VARS["dbinstances"]).php_true_value).php_true_value then _VARS["dbinstances"] = PhpArray.new end if empty((((_VARS["sugar_config"] ||= { })["db"] ||= { }))[_VARS["instanceName"]]).php_true_value then _VARS["instanceName"] = "" end if (not isset(((_VARS["dbinstances"] ||= { }))[_VARS["instanceName"]]).php_true_value).php_true_value then _VARS["my_db_manager"] = "MysqlManager" if (((_VARS["config"] ||= { }))["db_type"] == "mysql").php_true_value then if (((not isset(((_VARS["sugar_config"] ||= { }))["mysqli_disabled"]).php_true_value).php_true_value or (((_VARS["sugar_config"] ||= { }))["mysqli_disabled"] =false).php_true_value).php_true_value and self.function_exists(binding, "mysqli_connect").php_true_value).php_true_value then _VARS["my_db_manager"] = "MysqliManager" end end if (((_VARS["config"] ||= { }))["db_type"] == "oci8").php_true_value then nil else if (((_VARS["config"] ||= { }))["db_type"] == "mssql") then if (self.function_exists(binding, "sqlsrv_connect").php_true_value and (empty(((_VARS["config"] ||= { }))["db_mssql_force_driver"]).php_true_value or (((_VARS["config"] ||= { }))["db_mssql_force_driver"] ="sqlsrv").php_true_value).php_true_value).php_true_value then _VARS["my_db_manager"] = "SqlsrvManager" else if (self.is_freetds(binding).php_true_value and (empty(((_VARS["config"] ||= { }))["db_mssql_force_driver"]).php_true_value or (((_VARS["config"] ||= { }))["db_mssql_force_driver"] ="freetds").php_true_value).php_true_value) then _VARS["my_db_manager"] = "FreeTDSManager" else _VARS["my_db_manager"] = "MssqlManager" end end end end _GLOBALS["log"].info(binding, "using #{_VARS["my_db_manager"]} DBManager backend") if (not empty(((_VARS["config"] ||= { }))["db_manager"]).php_true_value).php_true_value then _VARS["my_db_manager"] = ((_VARS["config"] ||= { }))["db_manager"] end _require_once("include/database/#{_VARS["my_db_manager"]}.php", binding) (_VARS["dbinstances"] ||= { })[_VARS["instanceName"]] HomeController.const_get(_VARS["my_db_manager"]).new(binding) ((_VARS["dbinstances"] ||= { }))[_VARS["instanceName"]].getHelper(binding) ((_VARS["dbinstances"] ||= { }))[_VARS["instanceName"]].connect(binding, _VARS["config"], true) ((_VARS["dbinstances"] ||= { }))[_VARS["instanceName"]].count_id _VARS["count"] ((_VARS["dbinstances"] ||= { }))[_VARS["instanceName"]].references 0 ((_VARS["dbinstances"] ||= { }))[_VARS["instanceName"]].getHelper(binding).db = ((_VARS["dbinstances"] ||= { }))[_VARS["instanceName"]] else _VARS["old_count"] = _VARS["old_count"].+(1) ((_VARS["dbinstances"] ||= { }))[_VARS["instanceName"]].references _VARS["old_count"] end So we are going to release this to public. $2500, one license ,up to 5 people''s use. Anybody Interested? Talk to me. my gmail is just this. Best Regards. femto -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
That''s probably the ugliest ruby code I''ve ever seen. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Yes,it''s self compiled, why using _VARS, and not directly local_variables? because php has some weird var logic, like say $a =1; echo $GLOBALS["a"]; //this is 1, it automaticly affects entry in $GLOBALS, and in the opposite direction, $GLOBALS["a"]=1; echo $a; //now $a is 1, which is really unfornate. not to mention some indirect variable access. like $a=1; $c="a"; echo $$c; // this is 1, or $$c = 2; //if affects $a,$GLOBALS["a"], which is unfornate, all the ugliness is to handle php''s weird behavior. On May 4, 9:15 am, Tim Shaffer <timshaf...-BUHhN+a2lJ4@public.gmane.org> wrote:> That''s probably the ugliest ruby code I''ve ever seen.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
and $a=null; $a["db"]["config"]=1; //all of a sudden $a contains something, while in ruby it NullException: throws undefined method `[]'' for nil:NilClass //in php is quite valid, and used everywhere, which is unfornate. On May 4, 9:22 am, femto <femto...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Yes,it''s self compiled, > why using _VARS, and not directly local_variables? > because php has some weird var logic, > like say > $a =1; > echo $GLOBALS["a"]; //this is 1, it automaticly affects entry in > $GLOBALS, and in the opposite direction, > > $GLOBALS["a"]=1; > echo $a; //now $a is 1, which is really unfornate. > > not to mention some indirect variable access. > > like > $a=1; > $c="a"; > echo $$c; // this is 1, or > $$c = 2; //if affects $a,$GLOBALS["a"], which is unfornate, > all the ugliness is to handle php''s weird behavior. > > On May 4, 9:15 am, Tim Shaffer <timshaf...-BUHhN+a2lJ4@public.gmane.org> wrote: > > > > > > > > > That''s probably the ugliest ruby code I''ve ever seen.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
it''s not a good idea 2011/5/3 femto <femtowin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> and > $a=null; > $a["db"]["config"]=1; > //all of a sudden $a contains something, while in ruby it > NullException: throws undefined method `[]'' for nil:NilClass > //in php is quite valid, and used everywhere, which is unfornate. > > > On May 4, 9:22 am, femto <femto...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Yes,it''s self compiled, > > why using _VARS, and not directly local_variables? > > because php has some weird var logic, > > like say > > $a =1; > > echo $GLOBALS["a"]; //this is 1, it automaticly affects entry in > > $GLOBALS, and in the opposite direction, > > > > $GLOBALS["a"]=1; > > echo $a; //now $a is 1, which is really unfornate. > > > > not to mention some indirect variable access. > > > > like > > $a=1; > > $c="a"; > > echo $$c; // this is 1, or > > $$c = 2; //if affects $a,$GLOBALS["a"], which is unfornate, > > all the ugliness is to handle php''s weird behavior. > > > > On May 4, 9:15 am, Tim Shaffer <timshaf...-BUHhN+a2lJ4@public.gmane.org> wrote: > > > > > > > > > > > > > > > > > That''s probably the ugliest ruby code I''ve ever seen. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- Rodrigo Mendonça (62) 8567-3142 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 4 May 2011 02:22, femto <femtowin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Yes,it''s self compiled,It''s not "compiled". It''s Ruby - Ruby is an interpreted language, and the deformed Ruby code you''ve posted there is interpreted when it''s run. On May 4, 9:15 am, Tim Shaffer <timshaf...-BUHhN+a2lJ4@public.gmane.org> wrote:> That''s probably the ugliest ruby code I''ve ever seen.+1 Anyway, it doesn''t matter, as it has nothing to do with Rails - turning unmanageable, procedural PHP scripts into unreadable, unmaintainable Ruby is hardly going to be of any use to any Rails user. If you have an existing PHP app you want implemented in Rails, you would be *much* better of redesigning it to run *properly* with Rails and Ruby idioms, not trying to shoehorn a hideous, rough equivalent translation from the PHP scripts. I can''t imagine any reasons why someone would want to do this. So in answer to you first question, I''m not interested for $2,500 - even if you were offering to pay me that to use it. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 4 May 2011 02:22, femto <femtowin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Yes,it''s self compiled, > why using _VARS, and not directly local_variables? > because php has some weird var logic, > like say > > $GLOBALS["a"]=1; > echo $a; //now $a is 1, which is really unfornate.This is because you''re at the top-level namespace. The PHP script example is badly-written in the first place, and the Ruby code it''s translated into is .... well, I hesitate to use the words on a public, international forum :-/ -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
+1 this is a very bad idea. From what I understand this is sold as a tool for reusing custom PHP code while you are rewriting your application in rails. How do you believe generating Ruby code will help in this? It''s seems a bit backwards. If you wanted to reuse code, shouldn''t you be calling that code natively from your Ruby code? Maybe using a JSON interface? That is of cause assuming the PHP code is modular to begin with. Best, Andy On Tue, May 3, 2011 at 4:55 PM, femto Zheng <femtowin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello, we just researched a Php to Ruby compilation software, > because our client has some Php Project, > and that can accelarates their transition to rails, > and there are a lot of php projects out there, both open sourced and close > sourced, > so this software may be helpful to accelarates the changes from php world > to ruby''s world. > (Besides, some clouds, like VMWare cloudfoundry supports rails now, you can > compile your php''s > project into rails and runs ontop of it). > > This project compiles php code to ruby code as close as possbile, > so the following php code would compile to this code, > $instanceName = ''db''; > $config = $sugar_config[''dbconfig'']; > if(!isset($dbinstances)){ > $dbinstances = array(); > } > //fall back to the default instance name > if(empty($sugar_config[''db''][$instanceName])){ > $instanceName = ''''; > } > if(!isset($dbinstances[$instanceName])){ > $my_db_manager = ''MysqlManager''; > if( $config[''db_type''] == "mysql" ) { > if ((!isset($sugar_config[''mysqli_disabled'']) > || $sugar_config[''mysqli_disabled''] == false) > && function_exists(''mysqli_connect'')) { > $my_db_manager = ''MysqliManager''; > } > } > if( $config[''db_type''] == "oci8" ){ > } > elseif( $config[''db_type''] == "mssql" ){ > if ( function_exists(''sqlsrv_connect'') > && (empty($config[''db_mssql_force_driver'']) || > $config[''db_mssql_force_driver''] == ''sqlsrv'' )) > $my_db_manager = ''SqlsrvManager''; > elseif (is_freetds() > && (empty($config[''db_mssql_force_driver'']) || > $config[''db_mssql_force_driver''] == ''freetds'' )) > $my_db_manager = ''FreeTDSManager''; > else > $my_db_manager = ''MssqlManager''; > } > $GLOBALS[''log'']->info("using $my_db_manager DBManager > backend"); > if(!empty($config[''db_manager''])){ > $my_db_manager = $config[''db_manager'']; > } > > require_once("include/database/{$my_db_manager}.php"); > $dbinstances[$instanceName] = new $my_db_manager(); > $dbinstances[$instanceName]->getHelper(); > $dbinstances[$instanceName]->connect($config, true); > $dbinstances[$instanceName]->count_id = $count; > $dbinstances[$instanceName]->references = 0; > $dbinstances[$instanceName]->getHelper()->db > $dbinstances[$instanceName]; > } > else { > $old_count++; > $dbinstances[$instanceName]->references = $old_count; > } > #to this ruby code > _VARS["instanceName"] = "db" > _VARS["config"] = ((_VARS["sugar_config"] ||= { }))["dbconfig"] > if (not isset(_VARS["dbinstances"]).php_true_value).php_true_value then > _VARS["dbinstances"] = PhpArray.new > end > if empty((((_VARS["sugar_config"] ||= { })["db"] ||= { > }))[_VARS["instanceName"]]).php_true_value then > _VARS["instanceName"] = "" > end > if (not isset(((_VARS["dbinstances"] ||= { > }))[_VARS["instanceName"]]).php_true_value).php_true_value then > _VARS["my_db_manager"] = "MysqlManager" > if (((_VARS["config"] ||= { }))["db_type"] => "mysql").php_true_value then > if (((not isset(((_VARS["sugar_config"] ||= { > }))["mysqli_disabled"]).php_true_value).php_true_value or > (((_VARS["sugar_config"] ||= { }))["mysqli_disabled"] => false).php_true_value).php_true_value and self.function_exists(binding, > "mysqli_connect").php_true_value).php_true_value then > _VARS["my_db_manager"] = "MysqliManager" > end > end > if (((_VARS["config"] ||= { }))["db_type"] == "oci8").php_true_value > then > nil > else > if (((_VARS["config"] ||= { }))["db_type"] == "mssql") then > if (self.function_exists(binding, > "sqlsrv_connect").php_true_value and (empty(((_VARS["config"] ||= { > }))["db_mssql_force_driver"]).php_true_value or (((_VARS["config"] ||= { > }))["db_mssql_force_driver"] => "sqlsrv").php_true_value).php_true_value).php_true_value then > _VARS["my_db_manager"] = "SqlsrvManager" > else > if (self.is_freetds(binding).php_true_value and > (empty(((_VARS["config"] ||= { }))["db_mssql_force_driver"]).php_true_value > or (((_VARS["config"] ||= { }))["db_mssql_force_driver"] => "freetds").php_true_value).php_true_value) then > _VARS["my_db_manager"] = "FreeTDSManager" > else > _VARS["my_db_manager"] = "MssqlManager" > end > end > end > end > _GLOBALS["log"].info(binding, "using #{_VARS["my_db_manager"]} > DBManager backend") > if (not empty(((_VARS["config"] ||= { > }))["db_manager"]).php_true_value).php_true_value then > _VARS["my_db_manager"] = ((_VARS["config"] ||= { }))["db_manager"] > end > _require_once("include/database/#{_VARS["my_db_manager"]}.php", > binding) > (_VARS["dbinstances"] ||= { })[_VARS["instanceName"]] > HomeController.const_get(_VARS["my_db_manager"]).new(binding) > ((_VARS["dbinstances"] ||= { > }))[_VARS["instanceName"]].getHelper(binding) > ((_VARS["dbinstances"] ||= { > }))[_VARS["instanceName"]].connect(binding, _VARS["config"], true) > ((_VARS["dbinstances"] ||= { }))[_VARS["instanceName"]].count_id > _VARS["count"] > ((_VARS["dbinstances"] ||= { }))[_VARS["instanceName"]].references > 0 > ((_VARS["dbinstances"] ||= { > }))[_VARS["instanceName"]].getHelper(binding).db = ((_VARS["dbinstances"] > ||= { }))[_VARS["instanceName"]] > else > _VARS["old_count"] = _VARS["old_count"].+(1) > ((_VARS["dbinstances"] ||= { }))[_VARS["instanceName"]].references > _VARS["old_count"] > end > > So we are going to release this to public. > $2500, one license ,up to 5 people''s use. > Anybody Interested? Talk to me. > my gmail is just this. > > Best Regards. > femto > > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hello all, because most of php''s application is feature rich than rails''s existing offer, like say, crm solutions, sugarcrm, I know rails have similar offering,( fat_free_crm), but unfornately, this is really far from the feature sugarcrm offers, sugarcrm has been developed since 2004, all 7 years, and has been funded $2 million in venture capital, I just don''t think anyone could port that easily in a short time frame. for hand-rewritten the php''s application, well, that''s at least theoretically, I''ve done that before, that''s quite time-consuming and error-prone. On May 4, 3:47 pm, Andreas Saebjoernsen <andr...-icZdIMMiY0Pv2he6Dqnq4NvLeJWuRmrY@public.gmane.org> wrote:> +1 this is a very bad idea. > > From what I understand this is sold as a tool for reusing custom PHP code > while you are rewriting your application in rails. How do you believe > generating Ruby code will help in this? It''s seems a bit backwards. If you > wanted to reuse code, shouldn''t you be calling that code natively from your > Ruby code? Maybe using a JSON interface? That is of cause assuming the PHP > code is modular to begin with. > > Best, > Andy > > > > > > > > On Tue, May 3, 2011 at 4:55 PM, femto Zheng <femto...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hello, we just researched a Php to Ruby compilation software, > > because our client has some Php Project, > > and that can accelarates their transition to rails, > > and there are a lot of php projects out there, both open sourced and close > > sourced, > > so this software may be helpful to accelarates the changes from php world > > to ruby''s world. > > (Besides, some clouds, like VMWare cloudfoundry supports rails now, you can > > compile your php''s > > project into rails and runs ontop of it). > > > This project compiles php code to ruby code as close as possbile, > > so the following php code would compile to this code, > > $instanceName = ''db''; > > $config = $sugar_config[''dbconfig'']; > > if(!isset($dbinstances)){ > > $dbinstances = array(); > > } > > //fall back to the default instance name > > if(empty($sugar_config[''db''][$instanceName])){ > > $instanceName = ''''; > > } > > if(!isset($dbinstances[$instanceName])){ > > $my_db_manager = ''MysqlManager''; > > if( $config[''db_type''] == "mysql" ) { > > if ((!isset($sugar_config[''mysqli_disabled'']) > > || $sugar_config[''mysqli_disabled''] == false) > > && function_exists(''mysqli_connect'')) { > > $my_db_manager = ''MysqliManager''; > > } > > } > > if( $config[''db_type''] == "oci8" ){ > > } > > elseif( $config[''db_type''] == "mssql" ){ > > if ( function_exists(''sqlsrv_connect'') > > && (empty($config[''db_mssql_force_driver'']) || > > $config[''db_mssql_force_driver''] == ''sqlsrv'' )) > > $my_db_manager = ''SqlsrvManager''; > > elseif (is_freetds() > > && (empty($config[''db_mssql_force_driver'']) || > > $config[''db_mssql_force_driver''] == ''freetds'' )) > > $my_db_manager = ''FreeTDSManager''; > > else > > $my_db_manager = ''MssqlManager''; > > } > > $GLOBALS[''log'']->info("using $my_db_manager DBManager > > backend"); > > if(!empty($config[''db_manager''])){ > > $my_db_manager = $config[''db_manager'']; > > } > > > require_once("include/database/{$my_db_manager}.php"); > > $dbinstances[$instanceName] = new $my_db_manager(); > > $dbinstances[$instanceName]->getHelper(); > > $dbinstances[$instanceName]->connect($config, true); > > $dbinstances[$instanceName]->count_id = $count; > > $dbinstances[$instanceName]->references = 0; > > $dbinstances[$instanceName]->getHelper()->db > > $dbinstances[$instanceName]; > > } > > else { > > $old_count++; > > $dbinstances[$instanceName]->references = $old_count; > > } > > #to this ruby code > > _VARS["instanceName"] = "db" > > _VARS["config"] = ((_VARS["sugar_config"] ||= { }))["dbconfig"] > > if (not isset(_VARS["dbinstances"]).php_true_value).php_true_value then > > _VARS["dbinstances"] = PhpArray.new > > end > > if empty((((_VARS["sugar_config"] ||= { })["db"] ||= { > > }))[_VARS["instanceName"]]).php_true_value then > > _VARS["instanceName"] = "" > > end > > if (not isset(((_VARS["dbinstances"] ||= { > > }))[_VARS["instanceName"]]).php_true_value).php_true_value then > > _VARS["my_db_manager"] = "MysqlManager" > > if (((_VARS["config"] ||= { }))["db_type"] => > "mysql").php_true_value then > > if (((not isset(((_VARS["sugar_config"] ||= { > > }))["mysqli_disabled"]).php_true_value).php_true_value or > > (((_VARS["sugar_config"] ||= { }))["mysqli_disabled"] => > false).php_true_value).php_true_value and self.function_exists(binding, > > "mysqli_connect").php_true_value).php_true_value then > > _VARS["my_db_manager"] = "MysqliManager" > > end > > end > > if (((_VARS["config"] ||= { }))["db_type"] == "oci8").php_true_value > > then > > nil > > else > > if (((_VARS["config"] ||= { }))["db_type"] == "mssql") then > > if (self.function_exists(binding, > > "sqlsrv_connect").php_true_value and (empty(((_VARS["config"] ||= { > > }))["db_mssql_force_driver"]).php_true_value or (((_VARS["config"] ||= { > > }))["db_mssql_force_driver"] => > "sqlsrv").php_true_value).php_true_value).php_true_value then > > _VARS["my_db_manager"] = "SqlsrvManager" > > else > > if (self.is_freetds(binding).php_true_value and > > (empty(((_VARS["config"] ||= { }))["db_mssql_force_driver"]).php_true_value > > or (((_VARS["config"] ||= { }))["db_mssql_force_driver"] => > "freetds").php_true_value).php_true_value) then > > _VARS["my_db_manager"] = "FreeTDSManager" > > else > > _VARS["my_db_manager"] = "MssqlManager" > > end > > end > > end > > end > > _GLOBALS["log"].info(binding, "using #{_VARS["my_db_manager"]} > > DBManager backend") > > if (not empty(((_VARS["config"] ||= { > > }))["db_manager"]).php_true_value).php_true_value then > > _VARS["my_db_manager"] = ((_VARS["config"] ||= { }))["db_manager"] > > end > > _require_once("include/database/#{_VARS["my_db_manager"]}.php", > > binding) > > (_VARS["dbinstances"] ||= { })[_VARS["instanceName"]] > > HomeController.const_get(_VARS["my_db_manager"]).new(binding) > > ((_VARS["dbinstances"] ||= { > > }))[_VARS["instanceName"]].getHelper(binding) > > ((_VARS["dbinstances"] ||= { > > }))[_VARS["instanceName"]].connect(binding, _VARS["config"], true) > > ((_VARS["dbinstances"] ||= { }))[_VARS["instanceName"]].count_id > > _VARS["count"] > > ((_VARS["dbinstances"] ||= { }))[_VARS["instanceName"]].references > > 0 > > ((_VARS["dbinstances"] ||= { > > }))[_VARS["instanceName"]].getHelper(binding).db = ((_VARS["dbinstances"] > > ||= { }))[_VARS["instanceName"]] > > else > > _VARS["old_count"] = _VARS["old_count"].+(1) > > ((_VARS["dbinstances"] ||= { }))[_VARS["instanceName"]].references > > _VARS["old_count"] > > end > > > So we are going to release this to public. > > $2500, one license ,up to 5 people''s use. > > Anybody Interested? Talk to me. > > my gmail is just this. > > > Best Regards. > > femto > > > -- > > You received this message because you are subscribed to the Google Groups > > "Ruby on Rails: Talk" group. > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-talk?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On May 4, 4:57 am, femto <femto...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello all, because most of php''s application is feature rich than > rails''s existing offer, > like say, crm solutions, sugarcrm, > I know rails have similar offering,( fat_free_crm), but unfornately, > this is really far > from the feature sugarcrm offers, > sugarcrm has been developed since 2004, all 7 years, and has been > funded > $2 million in venture capital, I just don''t think anyone could port > that easily in > a short time frame. >I''m still quite unclear on *why* one would want to rewrite a complete package like SugarCRM in Ruby; after all, PHP is supported practically anywhere there''s a web server, and any package big enough to be worth translating is likely to have an extension API. Further, it''s not like it''s going to be simple to extend the spaghetti that the translation produces in Ruby... I''m also curious how this approach compares to that of the phuby library (https://github.com/tenderlove/phuby) which provides a PHP runtime to Ruby code. --Matt Jones -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Tue, May 3, 2011 at 6:55 PM, femto Zheng <femtowin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello, we just researched a Php to Ruby compilation software, > because our client has some Php Project, > and that can accelarates their transition to rails, > and there are a lot of php projects out there, both open sourced and close > sourced, > so this software may be helpful to accelarates the changes from php world > to ruby''s world. > (Besides, some clouds, like VMWare cloudfoundry supports rails now, you can > compile your php''s > project into rails and runs ontop of it). > > This project compiles php code to ruby code as close as possbile, > so the following php code would compile to this code, > $instanceName = ''db''; > $config = $sugar_config[''dbconfig'']; > if(!isset($dbinstances)){ > $dbinstances = array(); > } > //fall back to the default instance name > if(empty($sugar_config[''db''][$instanceName])){ > $instanceName = ''''; > } > if(!isset($dbinstances[$instanceName])){ > $my_db_manager = ''MysqlManager''; > if( $config[''db_type''] == "mysql" ) { > if ((!isset($sugar_config[''mysqli_disabled'']) > || $sugar_config[''mysqli_disabled''] == false) > && function_exists(''mysqli_connect'')) { > $my_db_manager = ''MysqliManager''; > } > } > if( $config[''db_type''] == "oci8" ){ > } > elseif( $config[''db_type''] == "mssql" ){ > if ( function_exists(''sqlsrv_connect'') > && (empty($config[''db_mssql_force_driver'']) || > $config[''db_mssql_force_driver''] == ''sqlsrv'' )) > $my_db_manager = ''SqlsrvManager''; > elseif (is_freetds() > && (empty($config[''db_mssql_force_driver'']) || > $config[''db_mssql_force_driver''] == ''freetds'' )) > $my_db_manager = ''FreeTDSManager''; > else > $my_db_manager = ''MssqlManager''; > } > $GLOBALS[''log'']->info("using $my_db_manager DBManager > backend"); > if(!empty($config[''db_manager''])){ > $my_db_manager = $config[''db_manager'']; > } > > require_once("include/database/{$my_db_manager}.php"); > $dbinstances[$instanceName] = new $my_db_manager(); > $dbinstances[$instanceName]->getHelper(); > $dbinstances[$instanceName]->connect($config, true); > $dbinstances[$instanceName]->count_id = $count; > $dbinstances[$instanceName]->references = 0; > $dbinstances[$instanceName]->getHelper()->db > $dbinstances[$instanceName]; > } > else { > $old_count++; > $dbinstances[$instanceName]->references = $old_count; > } > #to this ruby code > _VARS["instanceName"] = "db" > _VARS["config"] = ((_VARS["sugar_config"] ||= { }))["dbconfig"] > if (not isset(_VARS["dbinstances"]).php_true_value).php_true_value then > _VARS["dbinstances"] = PhpArray.new > end > if empty((((_VARS["sugar_config"] ||= { })["db"] ||= { > }))[_VARS["instanceName"]]).php_true_value then > _VARS["instanceName"] = "" > end > if (not isset(((_VARS["dbinstances"] ||= { > }))[_VARS["instanceName"]]).php_true_value).php_true_value then > _VARS["my_db_manager"] = "MysqlManager" > if (((_VARS["config"] ||= { }))["db_type"] => "mysql").php_true_value then > if (((not isset(((_VARS["sugar_config"] ||= { > }))["mysqli_disabled"]).php_true_value).php_true_value or > (((_VARS["sugar_config"] ||= { }))["mysqli_disabled"] => false).php_true_value).php_true_value and self.function_exists(binding, > "mysqli_connect").php_true_value).php_true_value then > _VARS["my_db_manager"] = "MysqliManager" > end > end > if (((_VARS["config"] ||= { }))["db_type"] == "oci8").php_true_value > then > nil > else > if (((_VARS["config"] ||= { }))["db_type"] == "mssql") then > if (self.function_exists(binding, > "sqlsrv_connect").php_true_value and (empty(((_VARS["config"] ||= { > }))["db_mssql_force_driver"]).php_true_value or (((_VARS["config"] ||= { > }))["db_mssql_force_driver"] => "sqlsrv").php_true_value).php_true_value).php_true_value then > _VARS["my_db_manager"] = "SqlsrvManager" > else > if (self.is_freetds(binding).php_true_value and > (empty(((_VARS["config"] ||= { }))["db_mssql_force_driver"]).php_true_value > or (((_VARS["config"] ||= { }))["db_mssql_force_driver"] => "freetds").php_true_value).php_true_value) then > _VARS["my_db_manager"] = "FreeTDSManager" > else > _VARS["my_db_manager"] = "MssqlManager" > end > end > end > end > _GLOBALS["log"].info(binding, "using #{_VARS["my_db_manager"]} > DBManager backend") > if (not empty(((_VARS["config"] ||= { > }))["db_manager"]).php_true_value).php_true_value then > _VARS["my_db_manager"] = ((_VARS["config"] ||= { }))["db_manager"] > end > _require_once("include/database/#{_VARS["my_db_manager"]}.php", > binding) > (_VARS["dbinstances"] ||= { })[_VARS["instanceName"]] > HomeController.const_get(_VARS["my_db_manager"]).new(binding) > ((_VARS["dbinstances"] ||= { > }))[_VARS["instanceName"]].getHelper(binding) > ((_VARS["dbinstances"] ||= { > }))[_VARS["instanceName"]].connect(binding, _VARS["config"], true) > ((_VARS["dbinstances"] ||= { }))[_VARS["instanceName"]].count_id > _VARS["count"] > ((_VARS["dbinstances"] ||= { }))[_VARS["instanceName"]].references > 0 > ((_VARS["dbinstances"] ||= { > }))[_VARS["instanceName"]].getHelper(binding).db = ((_VARS["dbinstances"] > ||= { }))[_VARS["instanceName"]] > else > _VARS["old_count"] = _VARS["old_count"].+(1) > ((_VARS["dbinstances"] ||= { }))[_VARS["instanceName"]].references > _VARS["old_count"] > end > > So we are going to release this to public. > $2500, one license ,up to 5 people''s use. >Eeeeeeewwwwww. That looks worse than my early days in TSQL where I decided to put app logic in the db, cursors and all. Just rewrite it if it is that important, I mean what do you gain really if you convert to ruby but you have to maintain this unless you have Rainman or someone on staff. Does the magic box also write tests for you?> Anybody Interested? Talk to me. > my gmail is just this. > > Best Regards. > femto > > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Femto Zheng wrote in post #996564:> Hello all, because most of php''s application is feature rich than > rails''s existing offer, > like say, crm solutions, sugarcrm, > I know rails have similar offering,( fat_free_crm), but unfornately, > this is really far > from the feature sugarcrm offers, > sugarcrm has been developed since 2004, all 7 years, and has been > funded > $2 million in venture capital, I just don''t think anyone could port > that easily in > a short time frame. > > for hand-rewritten the php''s application, well, that''s at least > theoretically, > I''ve done that before, that''s quite time-consuming and error-prone. >Possibly time-consuming, yes. Error-prone depends on the tests that are in place... But the generated Ruby you show above would cause most Rubyists to flee. If the entire application is translated with that amount of syntactic noise, what is your maintenance path? Edit the original php application, then translate again?!? I''m not knocking your accomplishment (Lord knows I''ve written code that writes some awfully ugly code), but there a wide gap between syntactic/semantic correctness and syntactic/semantic "elegance", and I think the "elegance" attribute is what has drawn many people to Ruby. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Yes, quite agree. ''But the generated Ruby you show above would cause most Rubyists to flee.'' Yes, I agree. If without those bizarre php''s variable behavior, I would just compile local variable to local variable, ''I''m still quite unclear on *why* one would want to rewrite a complete package like SugarCRM in Ruby; after all, PHP is supported practically anywhere there''s a web server, and any package big enough to be worth translating is likely to have an extension API. Further, it''s not like it''s going to be simple to extend the spaghetti that the translation produces in Ruby...'' First, we all agree that php''s valid code, public function getHelper() { if ( !($this->helper instanceof DBHelper) ) { global $sugar_config; switch ( $sugar_config[''dbconfig''][''db_type''] ) { case "mysql": $my_db_helper = ''MysqlHelper''; if ( (!isset($sugar_config[''mysqli_disabled'']) || $sugar_config[''mysqli_disabled''] == false) && function_exists(''mysqli_connect'') ) $my_db_helper = ''MysqliHelper''; break; case "mssql": if ( function_exists(''sqlsrv_connect'') && (empty($config[''db_mssql_force_driver'']) || $config[''db_mssql_force_driver''] == ''sqlsrv'' )) $my_db_helper = ''SqlsrvHelper''; elseif (is_freetds() && (empty($config[''db_mssql_force_driver'']) || $config[''db_mssql_force_driver''] == ''freetds'' )) $my_db_helper = ''FreeTDSHelper''; else $my_db_helper = ''MssqlHelper''; break; default: $my_db_helper = ''MysqlHelper''; } $GLOBALS[''log'']->info("using $my_db_helper DBHelper backend"); require_once("include/database/{$my_db_helper}.php"); $this->helper = new $my_db_helper(); $this->helper->db = $this; } return $this->helper; } is perfectly beatiful, if php can support no ''$'' before variable. before doing this project I think php is stupid language, but after this I change my mind, actually php''s code is quite well written and encapsulated(if without that ''$''). That''s no wonder why DHH, who''s background is php, comes to ruby and writes out Rails, but no somebody that with a java background comes to ruby and writes out Rails,that''s not without a reason. Because php''s just syntax noise more than ruby. Many mental position is still good.ps, we all know ajax right, coined by Jesse James Garrett, after that people know ajax, but before which the xmlhttp just exists there many years and going unnoticed.same for the php, php exists there many years and neglected by rails'' guy and think it''s spaghetti code. For phuby you mentioned, I''ved checked out, it says it requires php, it still needs you to download and compiles php-5.3.0 to your box, so it''s a simple wrapper around php? the final code is still php? No, our goal is makes your code Ruby/Rails, say you download a simple php project, and puts it into your disk, e:\php-project\sugarcrm, and then you just fire a up a rails application and config.host = "e:\php-project\sugarcrm" and it runs.It will compiles your accessed php file and to a related .rb file so for the compilation part, if you think _VARS["a"] perfectly equal to $a or(a in ruby''s sense), the ||={} is just coping with php''s accessing optionally equals to hash, then the whole mental model would be very simple.after that, when the whose system can be running, then you can simply change/extend a certain point, we all know ruby''s quite easy to extend, so may you put your custom code in some /custom/include/dbmanger.rb and requires that, (or you may wan to more put into rails folder,app/controller/model or something) self.helper = sugar_config[''dbconfig''][''db_type''] + ''Helper'' if ["mysql,mssql"].include?(sugar_config[''dbconfig''][''db_type'']) Just like I claimed, tons of tons good stuff/wealth buries in php, like say, cssmin: class cssmin { public static function minify($css, $options = "remove-last-semicolon") { $options = ($options == "") ? array() : (is_array($options) ? $options : explode(",", $options)); if (in_array("preserve-urls", $options)) { // Encode url() to base64 $css = preg_replace_callback("/url\s*\((.*)\)/siU", "cssmin_encode_url", $css); } // Remove comments $css = preg_replace("/\/\*[\d\D]*?\*\/|\t+/", " ", $css); // Replace CR, LF and TAB to spaces $css = str_replace(array("\n", "\r", "\t"), " ", $css); // Replace multiple to single space $css = preg_replace("/\s\s+/", " ", $css); // Remove unneeded spaces $css = preg_replace("/\s*({|}|\[|=|~|\+|>|\||;|:|,)\s*/", "$1", $css); if (in_array("remove-last-semicolon", $options)) { // Removes the last semicolon of every style definition $css = str_replace(";}", "}", $css); } $css = trim($css); if (in_array("preserve-urls", $options)) { // Decode url() $css = preg_replace_callback("/url\s*\((.*)\)/siU", "cssmin_encode_url", $css); } return $css; } I know there''ll be a ruby equivalent, I am just giving an example, what if there''s not a cssmin funtionality, but some other fancy funtionality? On Thu, May 5, 2011 at 12:44 AM, Ar Chron <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Femto Zheng wrote in post #996564: > > Hello all, because most of php''s application is feature rich than > > rails''s existing offer, > > like say, crm solutions, sugarcrm, > > I know rails have similar offering,( fat_free_crm), but unfornately, > > this is really far > > from the feature sugarcrm offers, > > sugarcrm has been developed since 2004, all 7 years, and has been > > funded > > $2 million in venture capital, I just don''t think anyone could port > > that easily in > > a short time frame. > > > > for hand-rewritten the php''s application, well, that''s at least > > theoretically, > > I''ve done that before, that''s quite time-consuming and error-prone. > > > > Possibly time-consuming, yes. Error-prone depends on the tests that are > in place... But the generated Ruby you show above would cause most > Rubyists to flee. > > If the entire application is translated with that amount of syntactic > noise, what is your maintenance path? Edit the original php > application, then translate again?!? > > I''m not knocking your accomplishment (Lord knows I''ve written code that > writes some awfully ugly code), but there a wide gap between > syntactic/semantic correctness and syntactic/semantic "elegance", and I > think the "elegance" attribute is what has drawn many people to Ruby. > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- http://hi.baidu.com/femto http://www.aisiming.com/ -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
because our client has some NDA agreement, and I think I can use sugarcrm as the example, consider you have some project large like this, 50+ files, every file more than several thousand lines, after that you just go crazy. not to whether you''re writing extension points for it. And handling customized ORM rules, things like adding a field/relation/in ui, than the database will be filled with one more table, say your table is Contract, and the adding fields would be added to Contract_cust, and your ORM takes care of that, I just don''t think ActiveRecord copes that well. On Thu, May 5, 2011 at 9:01 AM, femto Zheng <femtowin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Yes, quite agree. > ''But the generated Ruby you show above would cause most > Rubyists to flee.'' > Yes, I agree. If without those bizarre php''s variable behavior, > I would just compile local variable to local variable, > > ''I''m still quite unclear on *why* one would want to rewrite a complete > > package like SugarCRM in Ruby; after all, PHP is supported practically > anywhere there''s a web server, and any package big enough to be worth > translating is likely to have an extension API. Further, it''s not like > it''s going to be simple to extend the spaghetti that the translation > produces in Ruby...'' > > First, we all agree that php''s valid code, > > public function getHelper() > { > > if ( !($this->helper instanceof DBHelper) ) { > global $sugar_config; > > switch ( $sugar_config[''dbconfig''][''db_type''] ) { > case "mysql": > $my_db_helper = ''MysqlHelper''; > if ( (!isset($sugar_config[''mysqli_disabled'']) > || $sugar_config[''mysqli_disabled''] == false) > && function_exists(''mysqli_connect'') ) > $my_db_helper = ''MysqliHelper''; > break; > case "mssql": > if ( function_exists(''sqlsrv_connect'') > && (empty($config[''db_mssql_force_driver'']) || > $config[''db_mssql_force_driver''] == ''sqlsrv'' )) > $my_db_helper = ''SqlsrvHelper''; > elseif (is_freetds() > && (empty($config[''db_mssql_force_driver'']) || > $config[''db_mssql_force_driver''] == ''freetds'' )) > $my_db_helper = ''FreeTDSHelper''; > else > $my_db_helper = ''MssqlHelper''; > break; > default: > $my_db_helper = ''MysqlHelper''; > } > $GLOBALS[''log'']->info("using $my_db_helper DBHelper backend"); > require_once("include/database/{$my_db_helper}.php"); > $this->helper = new $my_db_helper(); > $this->helper->db = $this; > } > > return $this->helper; > } > is perfectly beatiful, if php can support no ''$'' before variable. > before doing this project I think php is stupid language, but after this > I change my mind, actually php''s code is quite well written and > encapsulated(if without that ''$''). That''s no wonder why DHH, who''s > background is php, comes to ruby and writes out Rails, but no somebody > that with a java background comes to ruby and writes out Rails,that''s not > without > a reason. Because php''s just syntax noise more than ruby. Many mental > position > is still good.ps, we all know ajax right, coined by Jesse James Garrett, > after > that people know ajax, but before which the xmlhttp just exists there many > years > and going unnoticed.same for the php, php exists there many years and > neglected > by rails'' guy and think it''s spaghetti code. > > > For phuby you mentioned, I''ved checked out, > it says it requires php, it still needs you to download and compiles > php-5.3.0 to your box, so it''s a simple wrapper around php? > the final code is still php? > No, our goal is makes your code Ruby/Rails, > say you download a simple php project, and puts it into your disk, > > e:\php-project\sugarcrm, > and then you just fire a up a rails application > and config.host = "e:\php-project\sugarcrm" > and it runs.It will compiles your accessed php file and to a related > .rb file > > so for the compilation part, > if you think _VARS["a"] perfectly equal to $a or(a in ruby''s sense), > the ||={} is just coping with php''s accessing optionally equals to hash, > then the whole mental model would be very simple.after that, when the > whose system can be running, then you can simply change/extend a > certain point, > we all know ruby''s quite easy to extend, so may you put your custom > code in some /custom/include/dbmanger.rb > and requires that, (or you may wan to more put into rails > folder,app/controller/model or something) > self.helper = sugar_config[''dbconfig''][''db_type''] + ''Helper'' if > ["mysql,mssql"].include?(sugar_config[''dbconfig''][''db_type'']) > > Just like I claimed, tons of tons good stuff/wealth buries in php, > like say, > cssmin: > > class cssmin > { > public static function minify($css, $options = "remove-last-semicolon") > { > $options = ($options == "") ? array() : (is_array($options) ? $options : > explode(",", $options)); > if (in_array("preserve-urls", $options)) > { > // Encode url() to base64 > $css = preg_replace_callback("/url\s*\((.*)\)/siU", "cssmin_encode_url", > $css); > } > // Remove comments > $css = preg_replace("/\/\*[\d\D]*?\*\/|\t+/", " ", $css); > // Replace CR, LF and TAB to spaces > $css = str_replace(array("\n", "\r", "\t"), " ", $css); > // Replace multiple to single space > $css = preg_replace("/\s\s+/", " ", $css); > // Remove unneeded spaces > $css = preg_replace("/\s*({|}|\[|=|~|\+|>|\||;|:|,)\s*/", "$1", $css); > if (in_array("remove-last-semicolon", $options)) > { > // Removes the last semicolon of every style definition > $css = str_replace(";}", "}", $css); > } > $css = trim($css); > if (in_array("preserve-urls", $options)) > { > // Decode url() > $css = preg_replace_callback("/url\s*\((.*)\)/siU", "cssmin_encode_url", > $css); > } > return $css; > } > I know there''ll be a ruby equivalent, I am just giving an example, > what if there''s not a cssmin funtionality, but some other > fancy funtionality? > > > On Thu, May 5, 2011 at 12:44 AM, Ar Chron <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > >> Femto Zheng wrote in post #996564: >> > Hello all, because most of php''s application is feature rich than >> > rails''s existing offer, >> > like say, crm solutions, sugarcrm, >> > I know rails have similar offering,( fat_free_crm), but unfornately, >> > this is really far >> > from the feature sugarcrm offers, >> > sugarcrm has been developed since 2004, all 7 years, and has been >> > funded >> > $2 million in venture capital, I just don''t think anyone could port >> > that easily in >> > a short time frame. >> > >> > for hand-rewritten the php''s application, well, that''s at least >> > theoretically, >> > I''ve done that before, that''s quite time-consuming and error-prone. >> > >> >> Possibly time-consuming, yes. Error-prone depends on the tests that are >> in place... But the generated Ruby you show above would cause most >> Rubyists to flee. >> >> If the entire application is translated with that amount of syntactic >> noise, what is your maintenance path? Edit the original php >> application, then translate again?!? >> >> I''m not knocking your accomplishment (Lord knows I''ve written code that >> writes some awfully ugly code), but there a wide gap between >> syntactic/semantic correctness and syntactic/semantic "elegance", and I >> think the "elegance" attribute is what has drawn many people to Ruby. >> >> -- >> Posted via http://www.ruby-forum.com/. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> >> > > > -- > http://hi.baidu.com/femto > http://www.aisiming.com/ > >-- http://hi.baidu.com/femto http://www.aisiming.com/ -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.