05.03.08
alonetone
code, poetry, philosophy, folly
I work on Ruby on Rails plugins fairly often, and I’m always curious how people make their plugins configurable.
For example, ActiveMessaging uses several config files - some are yaml, some are ruby - all of them get loaded when the plugin gets initialized. ActiveMessaging has more than a bit of configuration, so distinct files for it makes sense. Also, it has less singular values that get set, and more sets of configuration values (e.g. all the values for a message broker connection).
Comatose uses a singleton with attributes that get defined in a block - so like the Rails initializer, you can call this define method in an environment.rb. Again, this makes sense, there are only a few values to fiddle with, and you very often don’t have to mess with them at all.
Not sure if I’ll use it, but I’ve been playing with an idea where you can use constants to override config values using constants. Makes sense for a plugin where you have default values that would rarely, and often individually, be overridden. Nice thing about this is that constants can be defined even before the config class, so if you need them to be set before the plugin is loaded, this provides a way.
Anyway, to make it easier, I wrote a little helper method to define class attributes, set the default value, and check for constants to override the default, all at one time.
class Config
class <<self
def set_config_value(var_sym, default=nil)
cattr_accessor var_sym
const_name = var_sym.to_s.upcase
value = (Object.constants.include?(const_name)) ? Object.const_get(const_name): default
class_variable_set("@@#{var_sym}".intern, value)
end
end
# SOME_CONFIG_VALUE set as a constant will override the default
set_config_value :some_config_value, "this is a default"
end
With the Tapestry tap celebration this weekend, it’s just in the nick of time that the website for the Beantown Tapfest is now fleshed out.
I still need to spend some time making it prettier, adding images and such things, but most importantly it now has the list of events, and the online registration form which integrates with PayPal (Website Payments Standard in conjuntion with IPN). I am not a big PHP fan, but I do like being able to package up and deploy my new ‘pprf’ (PayPal Registration Form) plug-in to any WordPress site for testing. I need to make it a bit more generic, and add one more admin page, but hey, it works and I’ll probably release it as open source soon.
I’m mostly happy with the logo, as IANAD(esigner) - anything that comes from Illustrator out of my computer should be suspect, but I think the logo looks good.
Now on with the day, and hoping a get some rest before Tapestry classes kick my butt.
Grups, at least the etymology is a clever repurposing from “speculative” pseudo-Twilight Zone original Star Trek sci-fi, monosyllabic, and easy to remember.
Gen-x is too old, gen-y is too young, and a guy who would rather buy scissors for $5 and cut his own hair than spend $100 at a salon cannot be described as “metro”; but now, it seems, I have been labeled. sigh.
I feel less than comforted, and it certainly makes me rethink buying a 3rd pair of pumas (oh, yeah wore them before they were cool and had a huge Newbury St. store).
I haven’t bought distressed jeans since an embarrassing acid wash incident in the actual 80s - most folks I know got their distressed blues by never throwing them away (and for a few of us, by still being able to fit into what we bought 15 yrs ago).
Maybe it will catch on, maybe it won’t. I just can’t get all that excited by yet another attempt to establish a stereotype for fertile aging cool kids. Besides I have more jazz than Interpol on my iPod, thanks very much.
I think this may be like writing a horoscope for the 30-ish; there is enough there in its 8 pages for us all to read and find a few things applicable, while remaining vague, superficial and a bit obvious.
You don’t want to wear a suit!
You wear jeans and a hoody!
You would rather snowboard than work!
You never stopped listening to new music!
GRUP!
Way too long since I last posted, but more time is at hand.
Talked to my brother, he’s hopefully dodging an ID card since he is already in Scotland, and is legal and all.
What a lovely time. Tech makes nations and geography less important (arguably), while politicians highlight the importance of national origin as the difference between criminal and patriot.
Does it need to be said? Villainizing illegal immigrants is a PC way to hate minorities. You know, it’s not that they are different and poor and not white, it’s that they are criminals (they’re illegal , so that means they’re criminals, right?) and probably terrorists to boot (right out of the country).
Besides, they are all thieves because they are stealing our jobs. I wonder if the politicians noticed that these “criminals” can’t vote before they made them into congressional punching bags?
So maybe, just maybe, this is all code - some subtle form of racism (on second thought, not all that subtle).
When the riots start, please remember I am a petite liberal and not worth smashing.