+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...@gmail.com> 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@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com. > 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.