Substruct 1.0.a4
Substruct, the Ruby on Rails e-commerce and content management software just tagged and bagged the last release before we go 1.0.
The version number is seriously misleading as the project has been active for over 2 years. Oh well…
Major changes
- Update to Rails 2.1.0
- Lots of bug fixes and updates from our community
Get the good stuff
- See all of the latest changes
- Download the latest version from SVN, or a tar / gzipped archive
- Discuss Substruct with us at Google Groups
Enjoy…
Don't take it personal
As most of you know, we released a product last year, Cashboard, which handles time tracking, invoicing, and project quotes (or estimates).
Since the release I’ve refined the product based on my own needs and the multitude of feedback I’ve received via email, forums, and comments strewn across blogs all over the web.
Cashboard is my baby. I pour my blood, sweat, and redbull into it each and every day. Working on something so hard and so often, one starts to develop a relationship with the work…an attachment.
I also handle the majority of customer support and potential customer emails. It’s great because I get to keep my finger on the pulse of what needs attention. However, the downside comes in the form of insane rants, negative comments, and downright outlandish demands a few people make.
Some days it takes all my restraint not to fire off an email that looks more like the lyrics to a gangsta rap track than a customer support response. I’ve slipped a couple of times, but I’m getting better at sleeping on things. It’s a crucial skill.
I try not to take jabs against my baby as a personal attack, but it’s hard. Yet another skill I’m still trying to master.
Of course, a lot of these comments are valid, once you strip away the venom and bile. Being able to sift through the garbage and determine the meaning has paid off multiple times now in the form of design updates, and changes to Cashboard.
So next time someone bashes something you’ve done, instead of immediately lashing out – sleep on it and take it in stride. Discard the way the comment was delivered, and get to the real meaning.
Who knows, there might even be some value in it.
Substruct v1.0a3
Substruct v1.0.a3 was just tagged and bagged.
Lots of bugfixes and a mostly working test harness. Next step, fully working tests :)
Go to the home page to download, or get your fix directly from here.
Find out what ports your mongrels are using
I like mongrel. I deploy all of our Rails apps using it.
But…I got sick of opening and reading each of my mongrel_cluster.yml config files when adding a new mongrel to the server.
I cooked up this quick script to list all Rails apps on a production box – and their mongrel ports. It assumes all of your apps live in /var/www/(app_name)/current. You might have to do some modifications if you store your Rails apps in a different place.
Maybe you’ll find it useful as well.
list_mongrel_ports.rb
#!/usr/bin/env ruby
#
# Loops through all rails apps and compiles port information
# for mongrels.
#
# Great for figuring out what ports are in use when deploying a new app.
#
# Written by seth @ subimage llc - http://sublog.subimage.com
#
require 'fileutils'
APP_DIR = '/var/www/'
def get_mongrel_config_info(app)
config_f = File.join(APP_DIR, app, 'current', 'config', 'mongrel_cluster.yml')
if File.exists?(config_f)
starting_port, servers = ''
File.open(config_f, 'r') do |f|
while line = f.gets
if line.include?('port:')
starting_port = line.gsub(/port:|"| /, '')
elsif line.include?('servers:')
servers = line.gsub(/servers:| /, '')
end
end
end
servers ||= 1
ports = []
servers.to_i.times do |i|
ports << starting_port.to_i+i
end
return ports.join(', ')
else
return nil
end
end
Dir.open(APP_DIR).each do |app|
info = get_mongrel_config_info(app)
puts "#{app}\n ports: #{info}" unless info.nil?
endSample output
-> ./list_mongrel_ports.rb
cashboard
ports: 8500, 8501, 8502, 8503, 8504
getcashboard
ports: 8010, 8011
cbinfo
ports: 8700
cbforum
ports: 8705Hrm…looks like I could do a little reorganization of my ports :)
Automated testing is the shit
Up until a week ago I never really understood the draw of automated testing.
I come from the school of manual test scripts that you run through before every new release.
Write down things you should do. Walk through the app, click on stuff, make sure it works.
Slow, error prone, and time consuming – but it’s what I knew. That all changed last week when I dusted off my copy of Extreme Programming Installed and burned through the remainder I had failed to read previously.
I finally jumped into unit testing in Ruby on Rails with Mocha and Autotest. I’m steadily catching up on tests for Cashboard and it’s amazing the things you find when you start automated testing.
Mocha
Mocha is a library useful for “mocking” or “stubbing” code that you want to verify executes, but not really run. Useful for network calls, sending emails, and all those other things you want to make sure get called by your test code, but don’t actually run.
Autotest
Autotest is part of the ZenTest suite. You run it from the root of your project and it monitors your code for any changes made.
I keep it running in a terminal next to TextMate and watch it spring into action and run my tests immediately after I save them. Major time saver.
For extra nerd points you can even get Autotest to display notifications with the dude from DOOM, letting you know if your tests passed or failed.
Nice that DOOM guy is now boosting my productivity, instead of draining it in years past. (How many hours did I waste blasting monsters in that thing?)
Security in testing
I’ve already cornered a few long-standing bugs via test code, and I’m on my way to full coverage for all units.
It feels good, and secure. If you’re programming in RoR and aren’t testing today…make the jump. Dig in, learn it. It’s worth the headache and trouble you’ll save in the long run.
Side note
Does anyone else buy massive amounts of books from Amazon, read a few chapters, then let them sit? I’ve got to stop doing that and finish off the ones I purchase.
Substruct v0.97
...Just got done prepping a fairly major release of Substruct, the first and only open-source RoR e-commerce platform.
This release updates Substruct to Rails 2 / Engines 2, replaces file_column with attachment_fu, AND is the initial release that will be distributed in archive form. Sorry no PayPal IPN support yet – within the next few days hopefully…
Shouts out to Luke Ludwig for his contribution of the attachment_fu patch.
From now on, all new people to Substruct are recommended to download the latest tar/gzipped archive avaliable here.
New install instructions have been placed on the site…and are much easier than before.
Now the project even includes a rake task that checks if you have the correct gems installed.
I have only tested here on my OS X box, so hopefully things will go smooth on Windows as well.
Version 0.97
---------------------------------------
Added:
1. Added nice installer rake task
2. Upgrade to Rails 2.0.2 / Engines v2
3. Images and uploads switched from using file_column and rmagick to
using attachment_fu and mini_magick.
Upgrade steps:
1. Make sure you have the mini_magick and mime-types gems installed.
a. sudo gem install mini_magick
b. sudo gem install mime-types
* Note: mime-types gem is only needed to upgrade, but is not
needed after the upgrade is complete.
2. Back up your database just in case.
* mysql example: mysqldump -u USERNAME -p DATABASE_NAME > backup.sql
3. script/generate plugin_migration
4. rake db:migrate
* All of your uploads and images will be copied to a new location.
Since it is a copy it is non-destructive, leaving the originals
in their place.
5. Check out the new environment.rb file in the
vendor/plugins/substruct/config directory.
Google Apps setup in two words - fucked up.
I’ve been looking at Google Apps for awhile, but their recent decision to support IMAP for mail pushed me into action finally.
This week I’ve started the process of moving the mail over for Cashboard.
First impressions
The setup instructions they provide are easy enough to understand, however their admin panel is slow as all hell.
Unofficial page response times took upwards of 15 seconds – something you don’t expect from Google.
Validating your account involved adding a HTML page to your web site, which took about 24 hours for them to verify. Ok, fine… After logging in a day later I was alerted that their servers had been updated and my mail accounts were ready to go.
Not so temporary errors
Excited with the thought of checking out my new service, I attempted to login to check my email.
...And attempted again…
...and again…
...and again.

I’ve been trying now to login for about a day, all the while getting this lame error message. Notice there’s no link where I can contact someone, or ask them what the hell is up.
Google, your app support sucks – fix it already.
Prince.rb update
Michael Day from YesLogic emailed me the other day to alert me to a possible problem with my original HTML/CSS to PDF in Rails code.
We’ve recently received a bug report on our forum of Ruby leaving zombie Prince processes running on UNIX systems:http://princexml.com/bb/viewtopic.php?t=1149
It looks as if this issue affects Seth’s module and probably the Princely plugin which appears to be based upon it.
I believe the solution for this is to add a call to pdf.close_read as mentioned at the end of that thread.
Cheers,
Michael
— Print XML with Prince! http://www.princexml.com
Below I’ve pasted the newest code, and here’s a link to the fixed prince.rb library.
Enjoy.
Prince.rb
# Prince XML Ruby interface.
# http://www.princexml.com
#
# Library by Subimage Interactive - http://www.subimage.com
#
#
# USAGE
# -----------------------------------------------------------------------------
# prince = Prince.new()
# html_string = render_to_string(:template => 'some_document')
# send_data(
# prince.pdf_from_string(html_string),
# :filename => 'some_document.pdf'
# :type => 'application/pdf'
# )
#
class Prince
attr_accessor :exe_path, :style_sheets, :log_file
# Initialize method
#
def initialize()
# Finds where the application lives, so we can call it.
@exe_path = `which prince`.chomp
@style_sheets = ''
@log_file = "#{RAILS_ROOT}/log/prince.log"
end
# Sets stylesheets...
# Can pass in multiple paths for css files.
#
def add_style_sheets(*sheets)
for sheet in sheets do
@style_sheets << " -s #{sheet} "
end
end
# Returns fully formed executable path with any command line switches
# we've set based on our variables.
#
def exe_path
# Add any standard cmd line arguments we need to pass
@exe_path << " --input=html --server --log=#{@log_file} "
@exe_path << @style_sheets
return @exe_path
end
# Makes a pdf from a passed in string.
#
# Returns PDF as a stream, so we can use send_data to shoot
# it down the pipe using Rails.
#
def pdf_from_string(string)
path = self.exe_path()
# Don't spew errors to the standard out...and set up to take IO
# as input and output
path << ' --silent - -o -'
# Show the command used...
#logger.info "\n\nPRINCE XML PDF COMMAND"
#logger.info path
#logger.info ''
# Actually call the prince command, and pass the entire data stream back.
pdf = IO.popen(path, "w+")
pdf.puts(string)
pdf.close_write
output = pdf.gets(nil)
pdf.close_read
return output
end
end
GMail gets colored labels...Cool.
Just logged into my GMail account to find the Goog gang launched a new UI feature, colored labels. I geek out about small but great UI features like this.
I use my GMail account mostly for discussion lists and groups, which I auto-tag with labels. Great for keeping track of e-mail you don’t want clogging your regular account – and also a great targeted search resource when you’re looking for answers to technical problems you care about.
Of course, by default with this setup my inbox is usually a sea of things that I don’t immediately care about.
...Enter colored labels. As you can see, I’ve colored a couple of things I really care about which jump out now when I’m scanning my inbox. Killer.
Substruct 0.95
I’ve just finished tagging a new release of Substruct, the open-source Ruby on Rails e-commerce and cms engine.
There are tons of new features and an update UI. If you haven’t checked it out recently, now is the time.
Version 1.0 should be out before year’s end – including an easier way to install for n00bz to rails, amongst other things. I’m really bad with version numbers – this thing has been out about two years now and I still haven’t felt comfortable calling it 1.0 :)
Substruct website:
http://dev.subimage.com/projects/substruct
The release is available at:
http://svn.subimage.com/source/substruct/site/tags/rel_0.95/
(substruct / substruct – for SVN auth credentials)
Version 0.95
---------------------------------------
MAJOR UPGRADE...lots of new features. Do some thorough testing before you
roll this out if you're upgrading.
Upgrade steps:
1. script/generate plugin_migration
2. rake db:migrate
3. You should diff your application.rb file with application.rb.example
in config_stubs. New before_filters have been added.
Added:
- Multiple images per product
-- You can also set a default product image via drag & drop
- Product variations
- Product view pages
- Product discontinuation & quantity checking
- Tag grouping for products
- Customer logins
- Order history
- Wishlist support
- Related product support
- Inventory control now actually works
-- Products with inventory <= 0 will not show on the public-facing site
-- Item quantities decremented after a successful order
- Live shipping rate calculation RIPPED out, replaced with shipping
rate table and new preferences UI.
-- FedEx is a bitch to set up for most people, and this can achieve the same
damn thing.
Changed:
- ActiveMerchant now supported instead of Payment gem
- ContentNodeTypes removed in favor of SingleTableInheritance
-- Blog, Page, and Snippet models added
- Cart now uses subModal instead of lame DIV at the bottom of the page
- User interface / design
-- Admin UI larger to work better on 1024x768 screens minimum
-- Tweaked graphics and fonts to look better x-platform
-- Public UI updated
- OrderUser now has a requirement that email addresses be unique
-- Added migration to clean up dupe OrderUsers, and set proper associations
on OrderAccount and OrderAddress
Go to page:
1 2
(Showing 1 - 10 of 19 articles total.)

