Lotus Web Framework

A new framework crossed my radar on HackerNews today called Lotus. It is based on Ruby and attempts to adhere to proper OO principles. It looks simple to learn so I thought I’d give it a try. I ran into a few issues with the first example in the docs provided in the Github project, so I’ll post some fixes. This is running version 0.1.0 of the lotusrb gem. # config.ru require 'lotus' module OneFile class Application < Lotus::Application configure do routes do get '/', to: 'home#index' end end end module Controllers::Home include OneFile::Controller action 'Index' do def call(params) end end end module Views::Home class Index include OneFile::View def render 'Hello' end end end end run OneFile::Application.new If you paste that into a file called config.ru, you can then run it with rack: ...

June 23, 2014 · 2 min · 333 words · Scott Brown

Anatomy of an Ansible Bug

Tracking down Ansible bugs becomes difficult when you are playing with issues between local and remote systems. For the last couple days I was racking my brains why my database import script, written in Ansible, was not importing the data into the database. I had 3 separate imports, and only 1 was working. I looked at everything, but it wasn’t until I walked away, came back, and realized that I had mistyped one character in the path to the dump. ...

June 17, 2014 · 8 min · 1612 words · Scott Brown

IPBoard 3 - Providing a Value to a Setting During Hook Installation

Well, that title is a mouthful. It is intentionally verbose so that if anyone stumbles across this issue, they can easily find this article and not spend time (like I did) sifting through source code for an answer. Background Let’s say you are creating a new hook in your development IPBoard 3.x 1. This hook changes the values of a few settings that already exist in the system (for example, disabling Gravatar support). While this setting could be easily changed by an administrator, we want to programmatically change it through the use of hooks. ...

May 14, 2014 · 4 min · 749 words · Scott Brown

Refactoring Rails into Service Objects

One of the things that I dislike about Rails is how some actions feel untestable. Take, for example, the act of grabbing the current user. This is bog-standard code that you’d see in a lot of Rails tutorials and people’s codebases. What I don’t like about it is that the current_user method is not easily testable. Heck, which test file do you put the tests in? ...

October 28, 2013 · 3 min · 529 words · Scott Brown

Happy Programmers' Day

As a fellow programmer, I would like to wish every other programmer out there a Happy Programmers’ Day. This is a short article, but one that I feel the need to write on a day like today. I really like programming, as it helps me to not only solve people’s organizational problems, but also to bring some critical thinking to whatever is floating around in my head. Earlier this week I read Avdi Grimm’s book, Objects on Rails, and found it to be a refreshing take on how to build an MVC application, albeit on Rails. I very much like Rails but, as a programmer (and hence why I’m writing this article today), I have to admit that I have a love-hate relationship with all frameworks (mostly hate, but that’s just me). I dislike how a framework is doing things for me, because I enjoy figuring out how technology works. It seems that in this day and age, people like to build MVPs using the latest frameworks just to quickly get something up and making money. From a business point of view, I 100% agree and understand, but I’m also a programmer at heart and there is a very loud voice that yells at me whenever I use a framework. This is a voice that wants to build things properly so that scaling and readability are first-class citizens, not something relegated to “phase 2”. ...

September 13, 2013 · 2 min · 234 words · Scott Brown

Beware of Incorrect Usage in Accessor Methods

When people have looked at my code, specifically my test code, one of the most common things they ask is why I test my getters and setters. They see this as a weird thing to do, but I tend to be a very paranoid defensive programmer, so I like to ensure that my getters and setters aren’t actually modifying anything. “That is paranoid, Scott” you proclaim, and try to enlighten me on all the code that doesn’t modify accessor methods. But I’ve been burned by this assumption often, and a simple and stupid unit test ensures that the code is adhering to my assumptions. It’s quick and painless. ...

August 26, 2013 · 3 min · 512 words · Scott Brown