Running a site on Tumblr Nov 28 2009
Following on from my last post, I figured I’d go into a bit more depth about the details of running a site on Tumblr, especially a customized one. You can do some pretty cool things with Tumblr, and especially with custom themes, but for now I’ll be focusing on some of the higher level considerations and settings, and I’ll do a separate post that will go into my experiences of building a custom theme for Tumblr.
When I first started playing with a new site design, and was thinking along the lines of no longer hosting my site on Feather, I did think about writing something quick and simple using Rails to suit just my needs exactly, and hosting it on the rather brilliant Heroku. I got as far as implementing some of the tests and code, before I explored the hosted service route. I was also reading a lot of good stuff about Tumblr, so setup an account and had a play, and was incredibly impressed. I started thinking about how what I had planned for my new site might fit within the constraints of being hosted on Tumblr.
- I wanted a different index page to the rest of the site, so that I could display a bigger banner graphic on the homepage only. This site represents my freelance business, and so I needed to make sure that was obvious from the homepage.
- I needed static pages. I didn’t want people to be able to comment on my about page, or see my contact page in the stream on the homepage whenever I updated it. I needed to link directly to those pages from the header.
- I wanted to be able to easily edit those static pages like the rest of the blog content on the site.
- I wanted to implement an easy-to-use drop in widget for comments on posts, and for the contact form.
- I needed to host the site on a custom domain (ejdraper.com), and I wanted it to redirect from www.ejdraper.com to ejdraper.com.
- I wanted to be able to easily make changes and tweaks to the layout, and to update links on the site without too much effort.
These were the most pressing initial concerns, and certainly the static pages were my first sticking point that I felt could mean that I simply couldn’t use Tumblr in the way I wanted. Then I found private posts.
Private posts are kept separate from the overall stream, and can only be found if you know the URL. Perfect for linking to them only from the places I want to link to them. They were still posts however, which meant that I could also easily edit the content if I wanted to as I would with any other type of post. This means I can run the about, contact and portfolio pages as private posts, and easily edit and tweak the content if I need to, without them showing up in the main stream of the blog.
If I want to build a new, radically different portfolio page too, I can create a brand new private post for it, build it out, and simply update the links to it when I was done, before I finally remove the old post. Tumblr works great as a CMS in this way, when you can effectively treat private posts as their own little pages.
Showing the banner graphic only on the homepage, and not on all other pages (permalink pages, tag pages, search results page) was a bit more complicated, and I’ll write more about that when I discuss custom themes. Likewise making sure that the comments aren’t shown on the about, contact and portfolio pages.
The comments use Disqus which is rigged up directly in the custom theme. For the contact form I’m using Wufoo, and I am able to drop in the required Javascript to hook that up directly into the private post to insert the form. This level of customization also means I can hook up all sorts of other external services very easily later on if I want to.
The custom domain is really easy to setup - you simply give Tumblr the domain you would like to use for the site, and then use their instructions to point the DNS for that domain to the right IP address. That’s it - once the DNS resolves your domain will start showing your Tumblr site, your username.tumblr.com address will start redirecting to your domain, and I noticed that it even auto redirects www.yourdomain.com to yourdomain.com if you’ve set the custom domain to just yourdomain.com, and vice versa if you set it to www.yourdomain.com (you’ll need to point both www.yourdomain.com and yourdomain.com to the Tumblr IP address for this to work).
Customizing the title and description of the site is simple enough, and you can then use those values in your custom theme. You can also expose other values from the theme which can be configured through a basic form, so that you don’t have to directly tweak the HTML of your custom theme to change links, text or whatever else you might want to change occasionally. We’ll cover this in more detail, and just how useful it is, in my post on theme building.
On top of all of these great customization features, you can also rig up your Tumblr account to post to Twitter and Facebook when you publish a new post, helping you further promote your content. There are options to ping Technorati and other popular blog directories, and also to promote your site on Tumblr itself. As well as all of that, you can also have Tumblr import posts and content from a number of different sources, such as RSS feeds, Twitter and Delicious, amongst others.
The only potential downside for people looking to move existing content to a new Tumblr site, is that while the API makes it incredibly easy to import posts, there isn’t a way to setup redirects from existing post permalinks to the new Tumblr URLs each post will now have. I bit the bullet and moved all of my old content over which has probably broken some older links to posts on the old permalinks, but if you are switching your domain over and have some really popular older posts that you can’t afford to have no longer working on existing permalinks, then that might be a deal breaker.
That aside, if that’s not an issue for you and you are able to move existing content over like I did, or if you are starting a fresh site, then Tumblr is seriously worth considering, even if you have extensive customization requirements for your site. I’ll discuss in more technical detail building out a Tumblr custom theme next time, if anyone has any questions about setting up a customized site on Tumblr though, please do leave a comment or drop me an e-mail.
CommentsNew site design Nov 25 2009
As the observant amongst you will have noticed, I’ve now updated this site with a brand new design. The really observant will have also noticed that it’s now hosted on Tumblr.
I really like the Tumblr platform, and I think it’s got some great tools for publishing content. The contributions and interest in the Feather blog app that me and Mike started 18 months ago seems to have dwindled this year, and maintaining that entire stack just to run my old site was getting to be more trouble than it was worth. I toyed with the idea of converting it to run on Rails 3.0, but don’t think I have the time to deal with a moving target (like we did against Merb when we started Feather).
I was also recently inspired by Gary Vaynerchuk’s book Crush It! In there he speaks a lot about using the right tools for creating and promoting content effectively, and so I’m fairly confident now that by using Tumblr, I’ll spend more time writing interesting content for the site, rather than tweaking the code that runs it!
Creating the custom theme for this site on Tumblr was fairly simple - the theme engine is very powerful, and does a lot of things right. It has a few shortcomings, namely not being able to tell when you are on a private post versus a public one, however I’ve enjoyed the process of building out the site to run on Tumblr, and am more than happy with the results.
So any comments on the new design are welcome, and if anyone is interested in some of the more technical aspects of Tumblr themes, please let me know, I may be able to help! Some more interesting posts coming soon.
CommentsUnboxing the HTC Hero, and a mini review Sep 12 2009
This week I took delivery of my new phone, the HTC Hero. After getting bored and frustrated with the iPhone, both from a user perspective, and very much so from a developer perspective, I looked into the Android platform in greater detail. After playing around with the emulator and writing some code, I was sold. The HTC Hero is one of the newer Android devices on the market, and seemed to do everything I wanted and more, so I decided to switch.
Unboxing the device was a joy, as HTC have obviously decided to start paying attention to the Apple school of thought regarding packaging, and it was all very well done. The phone itself was well protected, and the accessories were well packaged too. In the box, besides the phone, you get a mini USB cable, a charger that uses the USB cable to connect from the plug to the phone, a 2GB mini SD memory card (the internal storage on the Hero is tiny, so this is welcome), a set of headphones, ear buds, and a mic clip, and quick start guide for getting up and running with the phone.
Getting the phone setup is a breeze - you simply need to remove the back, remove the battery so as to be able to insert your SIM card, and at the same time you’ll need to remove the protective plastic from around the battery. Insert the mini SD card, replace the battery, and replace the back cover of the phone. Then plug in to the charger and wait for it to charge up. Mine took around 90 minutes to reach full charge - I’m sure you can probably boot it up and play with it after a few minutes, but I like to give it one full uninterrupted charge to begin with.
Once the phone was charged, initially turning it on will run you through a setup wizard. As with all Android phones, it gives you the option of connecting it to your Google account for mail, calendar and contacts, which is brilliant - give it your credentials, and it’ll start syncing all of that stuff for you immediately, really handy. The Hero also gives you the option of syncing with Facebook, Twitter and Flickr for the various social networking apps and plugins that the phone has. The Facebook integration goes to a deep level, integrating with your address book of contacts, and might actually make Facebook more useful. Clicking a contact will let you see at a glance their details, text messages, e-mails, and if linked with a Facebook profile, their recent FB updates. The Twitter client is really good, and also has notifications so that you know when there are new tweets - it would be cool however to customize that to only notify for mentions, DMs, or perhaps specific searches. This device runs HTC’s Sense user interface over the top of the normal Android OS, meaning you get a very swish widget based UI, with seven different home screens to customize, for maximum personalization.
The onscreen keyboard is really intelligent, especially word lookups, giving you suggestions (but not forcing them on you), and allowing you to easily add new things to the dictionary for future reference. On the physical inputs, the trackball is really useful, as are the physical buttons on the phone - call, home, menu and end call buttons are complemented with a back button, and a shortcut button for searching.
As for the Android OS itself, it’s fantastic. So much more customizable and freeing than the iPhone, the possibilities are truly endless. The marketplace has a lot of applications and games on there already, with many more to come I’m sure as the potential audience increases. The very fact that you can have applications that run in the background opens up the possibilities on the device for all sorts of very cool ideas, and so it’s a very exciting development platform. Myself and my buddy Mike are working on a few different ideas, and the SDK is a joy to develop against.
While I’ve only had the phone for less than a week, I can already tell that it’s an incredibly useful and well thought out device. It’s a similar experience in a way to when I got my first iPhone, only this time around the potential seems that much greater, and that’s very exciting.
If anyone has any comments about the phone, or Android in general, feel free to shoot me a mail or leave a comment. You can see all the photos from the unboxing on Flickr.
CommentsAnnouncing Appsta Jul 13 2009
I’ve just released a new gem called Appsta. Put simply, Appsta makes bootstrapping Rails applications much easier. But really it just builds upon an awesome new feature in Rails 2.3, templates. Templates are like build scripts for new applications - after the skeleton of the application is created, you can use a template to customize it to how you like it, removing unnecessary files, adding in libraries and gems you use regularly etc.
Appsta has two components - the helper library, and the command line tool. The helper library has a few simple commands that can help you when writing a template, by giving you functionality to setup your application on Heroku, creating your project repository on GitHub, and bundling up the creation of a local Git repository into a single command. This means that you can automatically provision source control and web hosting for your application as soon as the application is created, instantly giving you a stable and reliable platform for development.
The command line tool is basically a default Rails template that uses the commands in the helper library to setup your project on GitHub, and host your application on Heroku with two environments (production and staging). It also sets your application up with some default gems, and switches to using jQuery as the JavaScript library.
To install it, simply install the gem:
sudo gem install appsta
The idea is that some of you may like the Appsta defaults, and after installing the gem, will be able to simply run:
appsta <app_name>
to get up and running with your new application. However everyone seems to have their own preferences about frameworks and gems to use when building out a new application, and so more useful will probably be the helper library itself, allowing you to build out your own Rails template, but still make use of simple commands to setup your app on Heroku and GitHub. To do this, load Appsta in your Rails template:
require "appsta"
Appsta.load
and then make use of some of the commands
# sets up the local Git repository - initializing,
# adding all files, and making an initial commit
git_setup
# setup your application on Heroku as a
# production environment (http://app.heroku.com)
heroku
# setup your application on Heroku as a
# staging environment (http://app-staging.heroku.com)
heroku(:staging)
# setup your application on GitHub
github
The Heroku and GitHub commands ask the user for their credentials while running, and the commands themselves return useful information about the remote service so that if you want that can be captured and used later in your template (which is what Appsta does to produce the README file that is generated with a new application).
For more information on the usage of these commands, check out the default template bundled with Appsta. And if you have any questions or comments, please let me know! Likewise if you have improvements, please feel free to fork the project on GitHub, and let me know if you have a contribution you’d like me to look at rolling back into the main tree. This is just version 1.0, so there is plenty of additional functionality that could be built into this helper library.
Lastly, quick shout out to my boy Mike for writing a ton of code on the original version of Appsta before I rewrote the whole thing to take advantage more of Rails templates, and also for chatting over some of the ideas that you see in Appsta today.
CommentsRailsConf 2009 May 28 2009
Better late than never eh? Three weeks after the end of RailsConf, I thought I’d write a wrap-up post. Me and my wife turned the trip over to Vegas into a much needed holiday - we were out there four days before the conference began, and had a few more days left in Vegas after it ended too. Overall we had a great time, although I can’t say that it was a particularly relaxing break - Vegas tends to leave you more tired than when you arrived! In this post though I’ll focus on my thoughts of the conference itself.
Day 0: The Tutorials
I only attended the morning tutorial on the Monday sessions, as I was meeting with Mike in the afternoon. However, the jQuery on Rails session I attended in the morning was very good. It was a nice mix of things I knew (but good to run through again to reaffirm that knowledge), as well as some cool bits I hadn’t yet come across. It was very technical which was great, and while it was more of a jQuery focused session, rather than specific jQuery on Rails, that was fine by me as I was hoping for a real focus on the framework and it’s great features. This session didn’t disappoint, and Yehuda and Andy did very well given it was the first session, and there were a few technical challenges to overcome (namely, lack of power strips and issues with the wifi).
Day 1
Keynote: I enjoyed the keynote, but was also left a little disappointed by it in the end. It was well delivered, and had a good message, however some of the Rails 3 concepts touched on didn’t have very much detail with them (understandable, given the state of a lot of the Rails 3 features) - but in a few cases it may have been better to have left them out, rather than bringing them up and creating more questions than the keynote answered. Specifically, how some of the newer features would deal with legacy compatibility, and things like supporting HTML5 data attributes and how older browsers like IE6 might deal with that, or what could be done to support those browsers when they don’t support more modern features. I get that I could just stick with earlier versions of Rails, but it’d be a shame if the fancy new version (with plenty of other new features that would be useful regardless of which browsers you’re targeting) doesn’t work at all because of a few things that just won’t work on browsers older than three or four years old.
On the whole though, it was at least a thought provoking opening to the conference.
GitHub Panel: this session was excellent. The GitHub guys gave off a great vibe the entire time - it was fun, informative, and enjoyable. It’s obvious they are really doing something they enjoy, and they’ve built it all themselves from the ground up. Was great to see them answer a lot of questions about GitHub, and about starting up a business like GitHub; it was really very interesting.
Behind Call of Duty: World at War: this talk was a little disappointing. I expected a lot more technical detail, and was actually hoping for a focus on how they handled stuff like stats tracking, aggregating stats from millions of consoles into their community portal. Instead the talk seemed a little bit underwhelming.
Writing Modular Applications: I know this talk was a stand-in replacement at the last minute for something else, but it was an inspired choice. Fairly high level, but extremely thought provoking, it was a great 40 minutes. Jim himself said the title was a bit inaccurate, but it was interesting to see the topics he spoke about presented in the specific way he did - an almost out of context look at decoupling of code. Hard to explain, but it’s well worth trying to find video or slides for this one.
Smacking Git Around: I think on reflection, this was my favourite talk of the entire conference. Scott’s energy and enthusiasm for Git is incredible, and his talk was well delivered, had a decent dose of humour, but above all, was incredibly useful. I think it was actually about three or four hours worth of Git tips and tricks delivered in just 40 minutes, and it was brilliant. The slides are online, and for someone that’s got the Git basics down, but wants a run down of some of the more interesting tricks for Git, it’s very useful.
Scaling Rails: lastly on the first day, this talk from the guys at Phusion was a funny end to the day. A bit light on technical details, it was still entertaining, and it was a must see if only for the great demo of Rubystein 3D, a basic game they wrote in Ruby, borrowing heavily from Wolfenstein, and with a lot of “cameos” from members of the community. Funny stuff.
Day 2
Rails Metal, Rack and Sinatra: really interesting session from Adam Wiggins of Heroku, touching on a few of the more interesting aspects of Rack, and specifically what Rack allows us to do - from Rails Metal, through to the embedding of Sinatra apps within Rails apps. Very cool stuff, interesting from start to finish.
Rails 3: Step Off of the Golden Path: another interesting one, delving into some of the Rails 3 stuff in more detail than the keynote did. It’s still a little tricky to get into too much detail simply because so much stuff within Rails 3 is open to change, or not yet finished, but Matt did a good job here of bringing together some of the more interesting bits, specifically in and around the options you will have for alternatives to the norm when building a Rails app (testing, JavaScript libraries etc) and how Rails 3 makes using these alternatives easier.
What Makes Ruby Go: An Implementation Primer: this I think was my second favourite talk after the Git one - two guys who really know the topic (Charles Nutter and Evan Phoenix, who work on JRuby and Rubinius respectively) chatting over some technical Ruby stuff, including specific sneaky performance issues. Very interesting, shame it was only 50 minutes really.
Heroku Q&A: I was interested in Heroku already before this talk, so was pleased to get the opportunity to watch the guys behind it demo the service, and take questions. They started with the basics, getting started with Heroku and hosting basic apps, before answering some questions on more advanced stuff and demoing a few other bits. Was good to watch to get a better idea of how Heroku works, and how to use it.
Day 3
Building A Video Portal In Rails: this was a solid talk, if a little disappointing. I expected a talk on the more interesting technical challenges facing a video portal, specifically transcoding. Unfortunately, the particular solution being presented outsourced the video storage, transcoding and distribution to a third party platform, meaning that the talk was relegated to simply speaking about the integration. I was definitely hoping for more information on the technical side of running a site like that.
Skipped the next session and instead me and Mike went to LarkConf. To quote the always awesome Jon Larkowski who arranged it, LarkConf is “the premiere ad hoc coffee shop networking un-conference opportunity”. And it was awesome. Was cool to meet Jon, as well as a couple of the guys behind Exceptional, and the owner/founder of CafeCourses. Great stuff, and the most fun I had networking all week.
Russian Doll Pattern: Mountable Apps in Rails 3: this talk was a little underwhelming. Like the opening keynote, it left me with more questions than it answered, and while it went into a lot more detail than the keynote did, there was definitely some mixed messages coming across. It was unfortunate, but Drupal was mentioned rather a lot, and I think that confused a lot of the participants - it wasn’t entirely clear on the purpose of mountable apps, and it probably would have been better to make clear the relation this work obviously has to merb-slices. However, there were still some interesting tidbits of information in the talk, and it was obvious a lot of the confusion was down to most of these things still being up in the air, as Rails 3 is still a long way away.
Closing Keynote: This was a Q&A session with some of the Rails Core guys, and ranged from being interesting, to a little bit boring. It was a good way to end the conference, but obviously the content relied entirely on the quality of the questions. There was some great questions (things like the process for having patches dealt with by the Core team, with Koz pointing out that they are humans too, and sometimes make mistakes), to more boring questions. There was also the odd funny one (such as Obie asking “are you guys letting Yehuda turn Rails 3 into Drupal?”, which coming right after the Russian Doll talk, was forefront on a lot of peoples minds still). Overall, there were some interesting things to take away from the session, and it was a solid way to finish up.
Overall
On the whole, I immensely enjoyed RailsConf 2009. It was my first conference, and it was a good mixture of some fun networking, good sessions, and thanks to the location, made for a great break away too. My only real complaints about the conference itself is that there were a few weak sessions in there, and I definitely would have liked to have seen more technical content. While I understand that given the timeslots, there isn’t always time to do too much low level content, I do wonder whether a separate track on a slightly different schedule (one session to every two on other tracks, for example) could have held some more engaging talks on lower level ideas and concepts. Kind of a mix between the 40 minute talks, and the tutorial sessions held on the Monday. However, the Git talk and the Ruby implementation session were absolutely brilliant, and contained a great deal of useful information and content, packed into one session.
I’ll be interested to see where RailsConf takes place next year, but either way I definitely enjoyed the conference atmosphere, and meeting people, and will be thinking of attending a few other upcoming conferences, especially ones that have a more technical focus.
CommentsFreebird Apr 11 2009
I meant to write this article four weeks ago, as I had just finished in my full time position with Touch Local, and was about to start working freelance full-time. Since then, my freelance work has kept me plenty busy, and I never got chance to write this post. So today I figured I’d take some time out to write it, with the added bonus that I now have a month worth of working for myself to reflect upon.
The last month has been incredibly exciting. I’ve updated this site to make it more professional, and to give potential clients more information about me and what it is I do. I’ve had a lot of work on which has been great, but I’ve also had a lot of business admin to do, which has taken some getting used to. Working on business accounts, raising invoices, writing proposals and contracts has all taken some time, but I’ve now got everything setup in a way which makes admin tasks a lot quicker. I’m going to write in more detail soon about the tools that can help freelancers with a lot of day to day tasks.
Not having to commute has definitely had a positive impact, and I get that time back now to put back into working, or into relaxing. Being more flexible is also great - I work in the evenings and the weekends, but can take time out in the week, or have the occasional late rise. Sometimes it can be hard to switch off from the work that needs doing, but at least in that regard I really enjoy what I do, so it isn’t so bad.
And that’s really what makes working for myself as a freelancer and running my own business so enjoyable. I’m working on things that I enjoy doing, from home, working hours that suit me. I also have the time to work on some of my own ideas now too, which is very exciting indeed.
So if anyone reading this needs Ruby on Rails development doing, please get in touch. You can also browse the rest of this site to find out more about me, and what it is I offer. And if anyone else reading this is considering becoming a freelancer, then don’t hesitate to drop me a line if you’d like to hear more about my experiences so far!
CommentsFoot Locker Unlocked Feb 24 2009
So me and my buddy Mike have recently put together and launched a new site, Foot Locker Unlocked. This was a rewrite and redesign of an existing version of the site in Ruby on Rails. It’s main focus is the sneaker gallery, where you can read about all sorts of different sneakers, as well as see some great images of them, and rate them. It has a fair few social features, with more to follow. The site also integrates nicely with the similarly redesigned Wordpress blog. It was good fun putting it together, and there are more features and improvements planned for the future which is very exciting.
CommentsSetup Feather to run as a slice within a Merb app Jan 30 2009
In response to a few queries and comments on my post about the ejdraper.com blog running as a Feather slice underneath a parent Merb application, I decided to put together a sample app demonstrating just how you’d configure such a beast.
Introducing Feather Sample Slice Host… this is an up-to-date Merb application (Merb 1.0.8.1) that hosts Feather as a slice. It comes with a few common plugins installed, and an ultra basic theme override to demonstrate the themes working. It shows how you can easily integrate Feather into a Merb application, and you should be able to use it as a base for any application that you’d like to build with Feather integrated. You need to install Feather as a gem first - for now, simply “git clone” the Feather code, and then run “sudo rake install” in the root of the Feather codebase. A configured development sqlite3 database is included with the sample app so that you should then just be able to “git clone” the host app code and fire it up!
For those that are interested, integrating Feather as a slice boils down to the following steps:
- if you haven’t already, grab Feather as a gem (same as above, clone the code, and then “sudo rake install” in the project root; this will change when the first gem version of Feather, 0.5, is officially released shortly)
- create a brand new Merb app
- add Feather, and a few of it’s dependencies to “config/dependencies.rb”
- add the appropriate Feather slice commands to the host apps router, to mount Feather at /blog (or wherever you would like)
- run “rake slices:feather:install” and “rake slices:merb-auth-slice-password:install” from the root of the host app to copy static resources over
- setup the database, using the “Feather::Database.initial_setup” method from the Merb console (“merb -i”)
- implement a login form under the “app/views/exceptions/unauthenticated.html.erb” view
- install any plugins required
- setup any themes needed (if using the themes plugin)
- implement the rest of the functionality you want in your host application!
For any of the steps above that aren’t all too clear, you should be able to refer to the sample application now to see exactly what is required. It isn’t currently as straightforward as I’d like, and as a part of the aforementioned 0.5 gem release, I’d like to provide an easy command to add Feather to a Merb application, or create a new Merb host app with Feather already installed as a slice. For now though, the above checklist alongside the sample app should have most of you up and running in no time!
As always, any questions, please feel free to contact me or leave a comment.
CommentsReCover Jan 18 2009
I’ve just pushed out the second version of Cover-Up, and so it should be available via gem within a few hours.
Version 0.2 includes the following:
- fixed a couple of bugs
- added the option to provide your own logger to the code coverage run (see README)
- few improvements to try and speed the code coverage execution up a bit
The speed improvements will be fairly useful as the initial version was a bit sluggish, although I still have more work I’d like to do in this area to try and speed up the code coverage even further.
The logger is useful for those that want to run their own traces over the code during the code coverage run, or simply for tracking down a problem that isn’t obvious in the results that Cover-Up returns already. Obviously any code you add in as a logger will potentially slow the code coverage run down further though.
So if anyone is interested, please take a look, and any questions, comments, or suggestions, please let me know! It’s still a work in progress but it is getting better all the time!
CommentsCover-Up Jan 14 2009
I started writing a new tool on Monday, a flexible, dynamic code coverage gem written in Ruby, for Ruby code. rcov is useful, but I needed the ability to easily wrap any Ruby code in coverage, dynamically at runtime, and I wanted more flexibility in the results that come back. There are probably ways to achieve both of these with rcov given the right options, but I wanted something that offered this out of the box, in an easy to use manner. I also thought it’d be fun to write something that’d work out the coverage of any Ruby code you give it.
Introducing… Cover-Up! Hosted over at GitHub It’s a really straightforward code coverage tool, and once installed, you simply need to do the following:
# load the gem
gem "cover-up"
require "cover-up"
# initiate the coverage, specifying a pattern for the files to be covered
results = coverage(:include => "app/*/**.rb") do
# execute the code to be covered
run_my_tests
end
results # this will contain the code coverage results
In the above example, the coverage would execute the “run_my_tests” method, and would match the code executed against the files specified with the input pattern, in this case, any Ruby files within a subfolder of “app”. It would then produce the statistics to say how many of the lines within those files were hit, how many weren’t, and how many were excluded (such as comments and whitespace etc).
All of those statistics are within the results object that comes back, and can be accessed as a whole, or on a file-by-file basis. This makes it really easy not just to run coverage over tests, but over other ad-hoc Ruby code too, to see what code is being executed by a given action. It also makes it really easy to hook up to your app, and to format the results however you want.
It’s only a couple of days old at the minute, and so is unlikely to be perfect - but I think it’s a good start, and even has tests of it’s own, so feel free to grab the gem which should be available depending upon the gem server mirrors over the next few hours:
sudo gem install cover-up
Or grab it from GitHub. Feel free to fork and improve the source too, patches very much welcome! I’m going to keep improving it over the coming days, so keep an eye on the code!
CommentsPage 9 of 31 | Next page | Previous page