Sha256: d82529397ccbacbe2fcbbf86bf9c960ee477301e488d120e7cacf6067a404876
Contents?: true
Size: 1.09 KB
Versions: 3
Compression:
Stored size: 1.09 KB
Contents
module DBF module Schema # Generate an ActiveRecord::Schema # # xBase data types are converted to generic types as follows: # - Number columns with no decimals are converted to :integer # - Number columns with decimals are converted to :float # - Date columns are converted to :datetime # - Logical columns are converted to :boolean # - Memo columns are converted to :text # - Character columns are converted to :string and the :limit option is set # to the length of the character column # # Example: # create_table "mydata" do |t| # t.column :name, :string, :limit => 30 # t.column :last_update, :datetime # t.column :is_active, :boolean # t.column :age, :integer # t.column :notes, :text # end # # @return [String] def schema s = "ActiveRecord::Schema.define do\n" s << " create_table \"#{File.basename(@data.path, ".*")}\" do |t|\n" columns.each do |column| s << " t.column #{column.schema_definition}" end s << " end\nend" s end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dbf-2.0.10 | lib/dbf/schema.rb |
dbf-2.0.9 | lib/dbf/schema.rb |
dbf-2.0.8 | lib/dbf/schema.rb |