
Security News
New Website “Is It Really FOSS?” Tracks Transparency in Open Source Distribution Models
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Brocade generates barcodes for Rails ActiveRecord models.
I extracted this from one of my projects and, although the code is nice and extensible, right now it only does what I need in that project. So for example it could produce barcodes in any symbology -- but currently only does Code 128.
There are two parts to Brocade: barcode generation and file management (because the barcodes are saved as image files). I use Barby to generate the barcodes and code copied from Paperclip to manage the files.
Brocade is simple to use:
class Item < ActiveRecord::Base
has_barcode
def barcodable
:serial_number
end
end
First declare declare your model has_barcode
. Second override the barcodable
method to return the name of the method Brocade should call to get the data to barcode.
Now you get this:
>> item = Item.create :serial_number => 42, :name => 'Deep Thought'
# writes barcode to /path/to/your/app/public/system/barcodes/items/3615/code128.png
-- assuming item
's id is 3615.
>> item.update_attributes :name => 'Deeper Thought'
# no change to barcode
>> item.update_attributes :serial_number => 153
# writes barcode to /path/to/your/app/public/system/barcodes/items/3615/code128.png
# i.e. writes out a new barcode image over the top of the original one
>> item.barcode_path
# => "/path/to/your/app/public/system/barcodes/items/3615/code128.png"
>> item.barcode_url
# => "/system/barcodes/items/3615/code128.png"
>> item.destroy
# deletes barcode image.
You can pass options to Brocade to control the PNG it generates. For example:
class Item < ActiveRecord::Base
has_barcode :margin => 5, :height => 40
end
These options are passed through to Barby's PNG Outputter. Note that setting the width makes no difference.
Install as a gem. In your config.rb
:
config.gem 'brocade'
The Barby and PNG gems, and ImageMagick.
Please use GitHub's issue tracker.
Copyright (c) 2010 Andy Stewart. See LICENSE for details.
FAQs
Unknown package
We found that brocade demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.