Monthly Archives: April 2011

Writing A Thor Application

I’ve talked about what I went through to learn thor, already. After all of that, I found myself becoming rather fond of thor and the end result of learning thor was a nice little command line tool that I am … Continue reading 

Posted in Bootstrap, Command Line, Ruby, Thor | 2 Comments

Cleaning Up Log Files On Linux, With Logrotate

In my previous post, I talked about the need to run a command on a schedule with cron. I also mentioned cron creating a bunch of email and how to redirect the output to log files with the whenever gem. … Continue reading 

Posted in Linux, Logs, Philosophy of Software | Leave a comment

The Whenever Gem: Making Cron Easy

I recently had to learn how to use Cron to set up a scheduled task on our rails server. In spite of the ubiquity of cron, I found the documentation and even the “how to” tutorials to be horrible at … Continue reading 

Posted in Command Line, DSL, Linux, Ruby | 3 Comments

Replacing An If Statement With An Object

I found myself writing this code yesterday: def to_s if status == AssessmentStatus::Open date = get_assessment_short_date(:date_opened) “#{}, Opened #{date}” else date = get_assessment_short_date(:date_closed) “#{}, Closed #{date}” end end   I wrote it and moved on. It worked and it did … Continue reading 

Posted in Analysis and Design, AntiPatterns, Principles and Patterns, Ruby | 8 Comments

Getting Started With Thor

I’ve known about Thor for some time now, and have been using it in my Rails 3 work. It seemed like a great little tool for writing command line apps in ruby. So, when I had a need to write … Continue reading 

Posted in Documentation, Open Source, Ruby, Thor | Leave a comment

Case Insensitive Dir.glob In Ruby: Really? It Has To Be That Cryptic?

I’m writing a small file importer in Ruby 1.9, to grab files form an FTP drop. The files are HL7 format, and will have a .HL7 extension. However, I had no guarantee that it would be capitalized .HL7 for the … Continue reading 

Posted in Ruby | 5 Comments

A Better Solution For Partial View Controllers

A few days ago, I wrote about using the Cells gem to create an encapsulated segment of my app, with view and controller, etc. Well, this didn’t work out so well after all. Aside form the initial problem of `content_for` … Continue reading 

Posted in Model-View-Controller, Quality, Rails, Ruby | 1 Comment

Cleaning Up Rails Helper Methods With A Helper Class: Good Idea, Bad Idea, Or ‘Meh’?

I found myself writing a very ugly helper method in my rails ApplicationHelper module: def render_program_dashboard(patient_program) key = patient_program.program.key content_for :css do stylesheet_link_tag “#{key}/patient_program” end dashboard_instance = nil dashboard_class_name = “#{key.to_s.classify}::ProgramDashboard” begin dashboard_class = dashboard_class_name.constantize dashboard_instance = rescue … Continue reading 

Posted in Model-View-Controller, Quality, Rails, Ruby | 2 Comments

Cells: Partial Controllers And Views For Rails 3

I’ve got a sort-of meta-application that I’m building in Rails 3 for a client. The core of the application is a framework on which we build various “Programs” that a patient can participate in. On the Patient Profile screen, a … Continue reading 

Posted in Model-View-Controller, Quality, Rails, Ruby | 5 Comments

Solving Some SSH Issues For Deploying Rails Apps

So you think “The Rails Life” is all unicorns, rainbows and glitter? Yeah. Guess again. Right now it feels more like a glitter cannon shredding a unicorn into a rainbow colored bloody pulp… Joey and I are deploying our rails … Continue reading 

Posted in Command Line, Deployment, Git, Linux, OSX, Rails, Rake, Ruby, Vlad | 3 Comments