Sha256: 72bca90402b6d9afdd02015d53b32fe33068187530abc3fa4273e3e2d4e203f3

Contents?: true

Size: 1.08 KB

Versions: 7

Compression:

Stored size: 1.08 KB

Contents

#!/usr/bin/env ruby -s

require 'rubygems'
require 'dbf'

$a ||= false
$s ||= false
$c ||= false

if defined? $h then
  puts "usage: #{File.basename(__FILE__)} [-h|-s|-a|-c] filename"
  puts "  -h = print this message"
  puts "  -s = print summary information"
  puts "  -a = create an ActiveRecord::Schema"
  puts "  -c = create a csv file"
else

  filename = ARGV.shift
  abort "You must supply a filename on the command line" unless filename

  # create an ActiveRecord::Schema
  if $a
    table = DBF::Table.new filename
    puts table.schema
  end
  
  if $s
    table = DBF::Table.new filename
    puts
    puts "Database: #{filename}"
    puts "Type: (#{table.version}) #{table.version_description}"
    puts "Memo File: #{table.has_memo_file? ? 'true' : false}"
    puts "Records: #{table.record_count}"
    
    puts "\nFields:"
    puts "Name             Type       Length     Decimal"
    puts "-" * 78
    table.columns.each do |f|
      puts "%-16s %-10s %-10s %-10s" % [f.name, f.type, f.length, f.decimal]
    end
  end

  if $c
   table = DBF::Table.new filename
   table.to_csv
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
dbf-2.0.3 bin/dbf
dbf-2.0.2 bin/dbf
dbf-2.0.1 bin/dbf
dbf-2.0.0 bin/dbf
dbf-1.7.8 bin/dbf
dbf-1.7.5 bin/dbf
dbf-1.7.4 bin/dbf