[DRE-commits] r3717 - in packages: . libbarby-ruby libbarby-ruby/branches libbarby-ruby/branches/upstream libbarby-ruby/branches/upstream/current libbarby-ruby/branches/upstream/current/bin

Gunnar Wolf gwolf at alioth.debian.org
Mon Jun 29 17:39:04 UTC 2009


Author: gwolf
Date: 2009-06-29 17:39:02 +0000 (Mon, 29 Jun 2009)
New Revision: 3717

Added:
   packages/libbarby-ruby/
   packages/libbarby-ruby/branches/
   packages/libbarby-ruby/branches/upstream/
   packages/libbarby-ruby/branches/upstream/current/
   packages/libbarby-ruby/branches/upstream/current/bin/
   packages/libbarby-ruby/branches/upstream/current/bin/barby
Log:
[svn-inject] Installing original source of libbarby-ruby

Added: packages/libbarby-ruby/branches/upstream/current/bin/barby
===================================================================
--- packages/libbarby-ruby/branches/upstream/current/bin/barby	                        (rev 0)
+++ packages/libbarby-ruby/branches/upstream/current/bin/barby	2009-06-29 17:39:02 UTC (rev 3717)
@@ -0,0 +1,41 @@
+#!/usr/bin/env ruby
+require 'optparse'
+require 'rubygems'
+
+#$: << File.join(File.dirname(__FILE__), '..', 'lib')
+require 'barby'
+
+options = {
+  :outputter => 'Png',
+  :outputter_method => 'to_png',
+  :barcode => 'Code128B'
+}
+
+ARGV.options do |o|
+  o.banner = "  Usage: #{File.basename(__FILE__)} [OPTIONS] data"
+  o.define_head '  Generates barcodes and prints the generated output to STDOUT'
+
+  o.separator ''
+  o.separator '  EXPERIMENTAL'
+  o.separator ''
+
+  o.on('-b', '--barcode=ClassName', String, 'Barcode type (Code128B)'){|v| options[:barcode] = v }
+  o.on('-o', '--outputter=ClassName', String, 'Outputter (Png)'){|v| options[:outputter] = v }
+  o.on('-m', '--method=method_name', String, 'Outputter method (to_png)'){|v| options[:outputter_method] = v }
+
+  o.on_tail("-h", "--help", "Show this help message.") { puts o; exit }
+    
+  o.parse!
+end
+
+#p STDIN.read
+#exit
+
+require "barby/outputter/#{options[:outputter].gsub(/[A-Z]/){|c| '_'+c.downcase }[1..-1]}_outputter"
+
+barcode_class = Barby.const_get(options[:barcode])
+barcode = barcode_class.new($*.empty? ? STDIN.read.chomp : $*)
+outputter_class = Barby.const_get("#{options[:outputter]}Outputter")
+outputter = outputter_class.new(barcode)
+
+print eval("outputter.#{options[:outputter_method]}(#{ENV['OPTIONS']})")


Property changes on: packages/libbarby-ruby/branches/upstream/current/bin/barby
___________________________________________________________________
Added: svn:executable
   + 




More information about the Pkg-ruby-extras-commits mailing list