Alright, just for fun I’m kicking off a new blog series. I’m going to publish a new “Deploy a Framework Friday” each week for about the next, well, bunch of weeks. There are a TON of frameworks that are available on PaaS Technologies.
This first entry I’m going to implement a simple Sinatra app with Ruby. Nothing fancy, simply a hello world and the respective deployment to a Cloud Foundry PaaS.
First, let’s whip out the super complex code (right, this isn’t complex, I just like sarcasm). The hello.rb file I created.
get ‘/’ do
get ‘/route’ do
"Hello from a route URI!"
Next add a Gemfile & respective Gemfile.lock as such.
But myself and fellow hacker & Geoloqi Crew put something together to figure out where the bus is. Nothing super fancy, but the idea is solid. We wanted to get a simple mobile application put together that would identify where it is, what the closest bus stop is, and pull up the next arriving bus(es) for that stop. We were throwing in a few other ideas, such as pulling up specific stops based on your favorites or even specific buses at that route based on your preferred routes.
Pat (@patrickarlt) & I (@adron) started out by pulling in the GTFS data from TriMet. I setup a basic import to turn all the stop locations in the GTFS data into a Place within a layer within Geoloqi. Pat setup a URL that could be used to call down the latest X arriving buses. Then we combined forces figuring out how to efficiently get all of the 7000+ bus stops into Geoloqi. That proved a little bit more of an issue than we thought. Not a huge issue, but one that got Kyle (@kyledrake) and Aaron (@aaronpk) Coding some fast batch solutions to get it all into Geoloqi while Pat & I handled the application.
On Sunday we’re lined up to get the application into a MVP (Minimally Viable Product) state. We’re hoping to be able to maybe even use it tomorrow in at least a simple way. From that point forward we’ll hopefully move past the MVP into other functionality! 🙂
Another thing to note, is that with our basic implementation we’re using GTFS data. This is a data format that is standardized and used by many of the agencies around the country. So technically any transit agency, as long as they have a way to return their route arrivals, can be setup to use our application we’re building. Some of the other GTFS data can be retrieved here;
Day one of the hackathon has been seriously kick ass! I’ve had a blast and heard some great ideas, seen some great code, even working demo results, and seen amazing skills applied all around! At this juncture, I’m exhausted, got a little more to code, and ready for day 2 of hacking!
After installing these things I created a new folder in a Rubymine Project.
I added a Ruby Class named SinatraSingsOsx to the project. I then realized that Rubymine did not detect that I had installed Sinatra, so I did a quick find in Rubymine to find and get it synced/installed so that Rubymine was aware of the gems.
Using the gem quick install in Rubymine I chose the documentation and dependent gems.
Once those were synced up I added the following Ruby Code to the file I created in the project.
Now that I’ve run the application in Rubymine I wanted to do the same with Shotgun using the same Ruby code. The first thing I needed to do was stop the server running that Rubymine had launched. If you look at the bottom of the IDE you’ll see the window displaying the current server status.
On the left hand side of this status window click on the large red button. This will stop the service. To verify just scroll to the bottom of this status window and you will see the message “Process finished with exit code 1“.
Now that I had the server cleaned up and stopped, I started a terminal again and navigated to the directory that the *.rb file is in that I want to start (host/run/execute, I’m not really sure what the appropriate word would really be at this point). So once at the appropriate path (machineName:SinatraSingingOSX adron$) I typed:
Once this executes the same server that Rubymine uses, the WEBrick, will startup the application again. I launched the browser to assure this ran as expected and got the same results as if running it through Rubymine. I guess, it all really depends, want to just start building and checking things out or want to build with an IDE like Rubymine. It all really boils down to taste and what you’re working with. I’ve been going back and forth between pure text editor and IDE just to familiarize myself with both avenues of using Rails and coding with Ruby.
After the verification I hit Ctrl + C to stop the web server. This basically works on the msysgit in Windows, on OS-X, or on whatever distro of Linux you have running. The cool thing is, so does Rubymine. I figured if I was going to work toward familiarization of an IDE and using the terminal I’d use commands and IDEs that would work on whatever OS I’m running. It’s all good synergies that way. 🙂
I wanted to keep this entry pretty short. With that in mind I simply logged what I worked on while en route home on the bus one evening. So on the next bus ride I’m going to tackle getting some specific notes with Sinatra, getting this all pushed into Heroku (of course, I’m all about the Cloud, you didn’t think I’d put it up on a shared host did you!) Until then, chow.