Guest User

Untitled

a guest
Jun 21st, 2018
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. #!/usr/bin/ruby -rubygems
  2.  
  3.  
  4. #
  5. # dev tools by Aleksander Cynarski <alek@click5.pl>
  6. #
  7.  
  8. requests = {
  9. 'lista/dodaj' => {'standID' => '2', 'pageID' => '1', 'articleID' => '1'},
  10. 'lista/skasuj' => {'standID' => '2', 'pageID' => '1', 'articleID' => '1'},
  11. 'lista/pokaz' => {'standID' => '2', 'pageID' => '1', 'articleID' => '1'},
  12. 'lista/zmien' => {'standID' => '2', 'pageID' => '1', 'articleID' => '1'},
  13. 'lista/widget' => {'sss' => '3'},
  14. 'index/pokaz' => {'standID' => '2', 'pageID' => '1', 'articleID' => '1'},
  15. 'index/popularne' => {'standID' => '2', 'pageID' => '1', 'articleID' => '1'},
  16. 'generator/dodajdoalelisty' => {'standID' => '2', 'pageID' => '1', 'articleID' => '1'}
  17. }
  18.  
  19. $footer = "
  20. public function post_init()
  21. {
  22. echo json_encode($this -> data);
  23. }
  24.  
  25. }
  26.  
  27. //Class generated by GANG (Generate Application Now Guy !)
  28. "
  29.  
  30. $pout = {}
  31.  
  32. def generate_class(d)
  33. myText ="<?php
  34. /*
  35. * class " + d + "Controller
  36. * by ac
  37. */
  38. class " + d + "Controller extends Click5_Controller
  39. {
  40. private $_model;
  41.  
  42.  
  43. public function __construct($engine)
  44. {
  45. parent::__construct($engine);
  46. $this -> _model = Click5_Frontend_Disspatcher::getModel('"+d.capitalize+"');
  47. }
  48.  
  49. public function indexAction()
  50. {
  51. $this -> data['error'] = 'no_data';
  52. }
  53. "
  54. return myText
  55. end
  56.  
  57. def generate_action(d)
  58. myText="
  59. public function "+d+"Action()
  60. {
  61. $sout = $this -> _model -> getData('"+d+"');
  62.  
  63. // ...code here
  64.  
  65. }"
  66. return myText
  67. end
  68.  
  69. def collect_data(dinput, data)
  70. key = dinput.split("/")[0]
  71. act = dinput.split("/")[1]
  72. local_filename = "[CONTROLLERS_DIR]" + key.downcase + ".php"
  73. if( $pout.include?(local_filename) )
  74. $pout[local_filename] = $pout[local_filename] + generate_action(act.downcase)
  75. else
  76. $pout[local_filename] = generate_class(key.downcase)
  77. end
  78. end
  79.  
  80. requests.each { |key, value| collect_data(key, value) }
  81. $pout.each {|key,value| File.open(key, 'w') {|f| f.write(value + $footer) }}
Add Comment
Please, Sign In to add comment