Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ begin
gem.email = "lpillow@gmail.com"
gem.homepage = "http://github.com/pillowfactory/csv-mapper"
gem.authors = ["Luke Pillow"]
gem.add_development_dependency "rspec", ">= 1.2.9"
gem.add_development_dependency "rspec", "< 2.0.0"
gem.add_dependency "fastercsv"
gem.extra_rdoc_files << "History.txt"
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
Expand All @@ -32,8 +32,6 @@ Spec::Rake::SpecTask.new(:rcov) do |spec|
spec.rcov = true
end

task :spec => :check_dependencies

task :default => :spec

require 'rake/rdoctask'
Expand Down
2 changes: 1 addition & 1 deletion lib/csv-mapper/row_map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def map_to(klass, defaults={})
#
# i.e. read_attributes_from_file('files+' => 'files_plus', 'files-' => 'files_minus)
def read_attributes_from_file aliases = {}
attributes = FasterCSV.new(@csv_data, @parser_options).readline
attributes = FasterCSV.new(@csv_data, parser_options).readline
@start_at_row = [ @start_at_row, 1 ].max
@csv_data.rewind
attributes.each_with_index do |name, index|
Expand Down
2 changes: 1 addition & 1 deletion spec/csv-mapper/attribute_map_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/../spec_helper.rb'
require File.expand_path(__FILE__ + '/../../spec_helper.rb')

describe CsvMapper::AttributeMap do

Expand Down
2 changes: 1 addition & 1 deletion spec/csv-mapper/row_map_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/../spec_helper.rb'
require File.expand_path(__FILE__ + '/../../spec_helper.rb')

describe CsvMapper::RowMap do

Expand Down
13 changes: 12 additions & 1 deletion spec/csv-mapper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/spec_helper.rb'
require File.expand_path(__FILE__ + '/../spec_helper.rb')

describe CsvMapper do
describe "included" do
Expand Down Expand Up @@ -63,6 +63,17 @@ def upcase_name(row, index)
results[1].number_of_years_old.should == '26'
end

it "should read attributes from a non-comma delimited file" do
results = @mapped.import(File.dirname(__FILE__) + '/test.tsv') do
delimited_by "\t"
read_attributes_from_file('Age' => 'number_of_years_old')
end

results[1].first_name.should == 'Jane'
results[1].last_name.should == 'Doe'
results[1].number_of_years_old.should == '26'
end

it "should import non-comma delimited files" do
piped_io = 'foo|bar|00|01'

Expand Down
4 changes: 4 additions & 0 deletions spec/test.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
First Name Last Name Age
John Doe 27
Jane Doe 26
Bat Man 52