![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.