diff --git a/Rakefile b/Rakefile index fc10f7c..6698428 100644 --- a/Rakefile +++ b/Rakefile @@ -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 @@ -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' diff --git a/lib/csv-mapper/row_map.rb b/lib/csv-mapper/row_map.rb index e1ad9ef..143a669 100644 --- a/lib/csv-mapper/row_map.rb +++ b/lib/csv-mapper/row_map.rb @@ -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| diff --git a/spec/csv-mapper/attribute_map_spec.rb b/spec/csv-mapper/attribute_map_spec.rb index acd8461..bb0074f 100644 --- a/spec/csv-mapper/attribute_map_spec.rb +++ b/spec/csv-mapper/attribute_map_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../spec_helper.rb' +require File.expand_path(__FILE__ + '/../../spec_helper.rb') describe CsvMapper::AttributeMap do diff --git a/spec/csv-mapper/row_map_spec.rb b/spec/csv-mapper/row_map_spec.rb index c6c4a19..6c35b89 100644 --- a/spec/csv-mapper/row_map_spec.rb +++ b/spec/csv-mapper/row_map_spec.rb @@ -1,4 +1,4 @@ -require File.dirname(__FILE__) + '/../spec_helper.rb' +require File.expand_path(__FILE__ + '/../../spec_helper.rb') describe CsvMapper::RowMap do diff --git a/spec/csv-mapper_spec.rb b/spec/csv-mapper_spec.rb index e12628c..9294aa8 100644 --- a/spec/csv-mapper_spec.rb +++ b/spec/csv-mapper_spec.rb @@ -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 @@ -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' diff --git a/spec/test.tsv b/spec/test.tsv new file mode 100644 index 0000000..22609e4 --- /dev/null +++ b/spec/test.tsv @@ -0,0 +1,4 @@ +First Name Last Name Age +John Doe 27 +Jane Doe 26 +Bat Man 52