Burningpony Blog

Adventures in Web Land.

Introducing PDFthisDomain

| Comments

Inspiration

The other day I had a client ask for a print out of the website, He was hoping to be able to mark stuff up by hand. As a sympathizer of old school paper and it’s merits I almost immediately said sure, not really sure what I was getting myself into.

A long story short after a good amount of searching for a tool to speed the process along, there isn’t a web service / program that will just turn a live website into a pdf. Well I guess that shouldn’t be too hard to make…

Hacking Time

PDFthisDomain is a very simple Sinatra app that has three components. A Sinatra app, a redis instance and a single worker. A user is first prompted to enter a URL which I quickly spider using anemone a sweet ruby web crawling gem. Once the spider is complete you see a list of urls that are available for rendering. Select which urls you want and enter a valid email, and off it goes to background processing. When the render is complete you should get a link to a zip file on S3 for you to download.

PS: Emails are only stored until your job is complete. No worries ;-)

Starting Your First Business

| Comments

It’s no joke. There is a lot of work to be done. Paperwork to file, Lawyers to meet with, regulations to meet. But nothing is that hard. Just don’t forget to actually follow through!

Journey Into Testing

| Comments

My journey into testing (An RSpec-2 Factory Girl and Guard Tale)

Testing has always been to me this thing of, “if i had more time”, or “if the project had money to cover testing.”, but I have begun to realize that testing can be development as it not only helps guide good programming it makes it much simpler to keep your code in tip top shape.

As this is part 1, I wanted to talk about setting up testing environments. This is something that I feel like isn’t talked much about on the web, yet it is something almost all people expect when working on open source projects, “Could you add some tests to your code?”.

My environment.

gem 'rails', '3.1.3'
...

gem "rspec-rails", ">= 2.0.1", :group => [:development, :test]
gem 'guard-spork', :group => [:development, :test]
gem "factory_girl_rails", :group => [:development, :test]

group :development do 
  gem 'spork', '~> 0.9.0.rc9'  #Greatly Speeds up Automated Testing 
  gem 'guard'  #the magic of automated testing
  gem 'guard-bundler'
  gem 'guard-rspec'
  gem 'growl'
  gem "progress_bar"
  gem 'ruby-debug19'
end

rspec-rails

rspec is an alternative testing framework, read more about it here

RSpec is a Behaviour-Driven Development tool for Ruby programmers. BDD is an approach to software development that combines Test-Driven Development, Domain Driven Design, and Acceptance Test-Driven Planning. RSpec helps you do the TDD part of that equation, focusing on the documentation and design aspects of TDD.

I am still learning the fundamentals of RSpec so I will follow up on this

Guard

Guard has worked out to be my controller of my testing environment. It’s primary role is to simply watch for changes and perform action when a change in my code is detected, typically through a filesystem event such as saving a file. It has an impressive list of “guards” that can be found on it’s wiki, and I will talk about a few I am using but you really should check this out. Coupled with growl it is an amazing tool.

Spork and Guard-spork

Spork is a time saver, Plain and simple. It launches your rails environment in a separate process that it can fork as you go through your testing. Basically it prevents you from loading the entire environment on ever test run, as our goal here is an auto test environment were tests will be run constantly the quicker the feedback on the code the better.

Guard-Bundler

Automatically runs bundle install when a change in your gemfile is detected (Awesome)

Growl

This is the icing on the cake of Guard growl notifications of all the guard output to keep your focus on the code. Without removing focus you get your testing status.