Thursday, January 08, 2015

Scaffold Code on my github based on Structuring Sinatra Web Application



It is Sinatra module based and more structuring(or clean) than our previous one of my indoor project based on classical style code when I wrote it in 2013, so that’s why I rewrite the code and make it as a “framework”

Check it out from my github

A demo app using jquery, highcharts, bootstrap and Sinatra module based code, to show you how to organize the code and the folder structure to use this "framework"

Thanks to Inspired from:
Structuring Sinatra Applications
Structuring Sinatra Apps 

Online Editor c9.io 

 if you are using c9.io services as your IDE, you can easily take my following scripts to grab my code:
 require 'git'  
 require 'fileutils'  
 require 'sys/proctable'  
 $: << File.expand_path(File.dirname(__FILE__))  
 git_repo = 'https://github.com/joychester/Arowana.git'  
 target_dir = './arowana'  
 if ! Dir.exist?(target_dir)  
   g = Git.clone(git_repo, target_dir)  
 else  
   FileUtils.remove_entry(target_dir)  
   g = Git.clone(git_repo, target_dir)  
 end  
 # exec 'bundle install and rackup config.ru'  
 Dir.chdir('./arowana') do  
   `bundle install`  
   # check postgresql service if running  
   pg_service = Sys::ProcTable.ps.select { |process|  
     process.include?('postgres')  
   }  
   if pg_service.empty?  
     p 'please check your postgresql service if it is running, exiting...'  
     exit(1)  
   else  
     p 'ready to start your Arowana App'  
     `rackup config.ru -p $PORT -o $IP`  
   end  
 end