the scan artist

Paul Morganthall

Locating Sinatra views

I have adhered to strict TDD as I build cheap buster. There wasn’t much need for views until now as I have been working on the internal API. The original index action contained the simplest Sinatra ‘view’, a string.

1
2
3
get '/' do
  '<h1>cheap buster</h1>Welcome'
end

Now that I’m ready to build the first form, I figured the first step was to move the view to a separate file.

1
2
3
get '/' do
  erb :index
end

This works fine in the browser, but the test looks for the view one level down in test/views:
No such file or directory - /Users/adam/dev/cheap_buster/test/views/index.erb

The only mention I could find of this behavior was an article by Tobias Crawley from 2008. He fixed the problem by linking test/views to views, but that feels extreme. I looked through lots of Sinatra applications in the wild. Many had no tests, some didn’t test views. None did anything special to help the tests locate the views.

This feels like some kind of configuration error on my part. For now, I’ve solved the problem by adding a configuration setting to the affected tests:
app.set :views, File.expand_path('./views')

Hacky as that seems, at least the fix is quite localized, sitting right next to the tests that need the workaround.

Should you learn to program?

A relative of mine heading to college next year recently asked…

The more I need to do things, the more feel like I need to know how to program, so that when something doesn’t do what I need it to do I can develop something that does. I suspect though, that fixing a small functionality preference like this would take an absurdly long time, like the better part of a year. Maybe I’m better off getting rich instead.

By all means, get rich, but that doesn’t answer the question of whether you should learn to program. If there is any question in your mind, try it. There are so many ways to dip your toe in these days. It is worthwhile to see if you like programming. If you’re good at programming and don’t hate it, you could make some money even if programming is not your main interest.

Where should you start? Try learning Ruby. There are many resources available, and Ruby comes preloaded with an extremely helpful community. If you end up needing to program in some other language, most of your Ruby skills will be applicable. Ruby is on your MacBook right now, and is easily installed on other systems.

Perhaps you don’t need to get rich or learn to program. If a program doesn’t do what you need, perhaps another program does. There are two parts to this question, both of which you’ll refine over time.

  1. Is your computer system even capable of this function?
  2. Has someone already created the program you want?

Start by asking Google. Then ask your uncles, many of whom share your platform. Over time, you’ll get a feel for what is possible and what is available. Until then, Learn Ruby!

What is a scan artist?

scan artist = scanner + scam artist

According to Barbara Sher in her book Refuse to Choose:

Scanners love to read and write, to fix and invent things, to design projects and businesses, to cook and sing, and to create the perfect dinner party. (You’ll notice I didn’t use the word “or,” because Scanners don’t love to do one thing or the other; they love them all.) A Scanner might be fascinated with learning how to play bridge or bocce, but once she gets good at it, she might never play it again. … To Scanners the world is like a big candy store full of fascinating opportunities, and all they want is to reach out and stuff their pockets.

scam artist: person who gains the confidence of someone in order to defraud them

When I create, I often feel like a fraud. I’m not really an artist. I’m not really a creator.

I just program computers and bake bread and knit and study ants and read tarot and I Ching and solve Sudoku and love science fiction and cook and teach the dog tricks and think of ways to do laundry better and remember which way each key turns in the lock and play games and program games and speak Esperanto and build in Second Life and grow vegetables and look at the stars in my telescope and am probably in the 90th percentile of 3x5 card and imported Japanese pen collectors.

Huh. The list is incomplete and it already sounds pretty creative. I’m definitely a Scanner. And an artist. What I lack is a way to hold myself accountable for production.

For inspiration, it doesn’t get much better than Jonathan Coulton. He quit his tech job to become a songwriter and performer. He’s done really well. JoCo describes the beginning of his Thing A Week:

To keep the juices flowing, I am going to post one piece of work per week until further notice. This may be a complete song, or it may be some kind of experimental thing, a mashup, a remix, some audio of me eating cheese, who knows. Not every one will be good, or even tolerable. Many of these things will not makeany sense to anyone but me, and some of them will certainly suck. But there will be one a week, so that’s got to be worth something.

I’m going to adopt the Thing A Week practice. It worked really well for Mr. Coulton. Some of the songs he produced were genius (Re Your Brains). Some seemed kind of lame, but later turned into sensations (I’m looking at you, Mr. Fancy Pants). But he produced something every week, for 52 weeks.

That’s the plan. Each week I am going to publish something. It might be a Ruby program, or a loaf of bread, or a photo of fresh-picked green beans. It might even be art.

This week’s Thing is the scan artist blog. All done now. Come back next week.