-
-
Save paramah/668887 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby -rubygems | |
# | |
# dev tools by Aleksander Cynarski <[email protected]> | |
# | |
requests = { | |
'lista/dodaj' => {'standID' => '2', 'pageID' => '1', 'articleID' => '1'}, | |
'lista/skasuj' => {'standID' => '2', 'pageID' => '1', 'articleID' => '1'}, | |
'lista/pokaz' => {'standID' => '2', 'pageID' => '1', 'articleID' => '1'}, | |
'lista/zmien' => {'standID' => '2', 'pageID' => '1', 'articleID' => '1'}, | |
'lista/widget' => {'sss' => '3'}, | |
'index/pokaz' => {'standID' => '2', 'pageID' => '1', 'articleID' => '1'}, | |
'index/popularne' => {'standID' => '2', 'pageID' => '1', 'articleID' => '1'}, | |
'generator/dodajdoalelisty' => {'standID' => '2', 'pageID' => '1', 'articleID' => '1'} | |
} | |
$footer = " | |
public function post_init() | |
{ | |
echo json_encode($this -> data); | |
} | |
} | |
//Class generated by GANG (Generate Application Now Guy !) | |
" | |
$pout = {} | |
def generate_class(d) | |
myText ="<?php | |
/* | |
* class " + d + "Controller | |
* by ac | |
*/ | |
class " + d + "Controller extends Click5_Controller | |
{ | |
private $_model; | |
public function __construct($engine) | |
{ | |
parent::__construct($engine); | |
$this -> _model = Click5_Frontend_Disspatcher::getModel('"+d.capitalize+"'); | |
} | |
public function indexAction() | |
{ | |
$this -> data['error'] = 'no_data'; | |
} | |
" | |
return myText | |
end | |
def generate_action(d) | |
myText=" | |
public function "+d+"Action() | |
{ | |
$sout = $this -> _model -> getData('"+d+"'); | |
// ...code here | |
}" | |
return myText | |
end | |
def collect_data(dinput, data) | |
key = dinput.split("/")[0] | |
act = dinput.split("/")[1] | |
local_filename = "[CONTROLLERS_DIR]" + key.downcase + ".php" | |
if( $pout.include?(local_filename) ) | |
$pout[local_filename] = $pout[local_filename] + generate_action(act.downcase) | |
else | |
$pout[local_filename] = generate_class(key.downcase) | |
end | |
end | |
requests.each { |key, value| collect_data(key, value) } | |
$pout.each {|key,value| File.open(key, 'w') {|f| f.write(value + $footer) }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment