Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/ruby -rubygems
- #
- # dev tools by Aleksander Cynarski <alek@click5.pl>
- #
- 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) }}
Add Comment
Please, Sign In to add comment