active_importer 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -27,6 +27,7 @@ module ActiveImporter
27
27
  end
28
28
 
29
29
  def self.column(title, field, &block)
30
+ title = title.strip
30
31
  if columns[title]
31
32
  raise "Duplicate importer column '#{title}'"
32
33
  end
@@ -51,10 +52,10 @@ module ActiveImporter
51
52
  @context = options.delete(:context)
52
53
 
53
54
  @book = Roo::Spreadsheet.open(file, options)
54
- @header = @book.row(1)
55
+ @header = @book.row(1).map(&:strip)
55
56
  check_header
56
57
 
57
- @data_row_indices = (2..@book.count)
58
+ @data_row_indices = (2..@book.last_row)
58
59
  @row_count = @data_row_indices.count
59
60
  rescue => e
60
61
  @book = @header = nil
@@ -1,3 +1,3 @@
1
1
  module ActiveImporter
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -4,7 +4,7 @@ require 'stubs/employee'
4
4
  describe ActiveImporter::Base do
5
5
  let(:spreadsheet_data) do
6
6
  [
7
- ['Name', 'Birth Date', 'Department'],
7
+ [' Name ', 'Birth Date', 'Department'],
8
8
  ['John Doe', '2013-10-25', 'IT'],
9
9
  ['Jane Doe', '2013-10-26', 'Sales'],
10
10
  ]
@@ -14,7 +14,7 @@ class EmployeeImporter < ActiveImporter::Base
14
14
 
15
15
  column 'Name', :name
16
16
  column 'Birth Date', :birth_date
17
- column 'Department', :department_id do |value|
17
+ column ' Department ', :department_id do |value|
18
18
  value.length # Quick dummy way to get an integer out of a string
19
19
  end
20
20
  end
@@ -3,7 +3,7 @@ class Spreadsheet
3
3
  @data = data
4
4
  end
5
5
 
6
- def count
6
+ def last_row
7
7
  @data.count
8
8
  end
9
9
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_importer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -112,7 +112,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
112
  version: '0'
113
113
  segments:
114
114
  - 0
115
- hash: -168044513201808942
115
+ hash: -3244463273596288739
116
116
  required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  none: false
118
118
  requirements:
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  version: '0'
122
122
  segments:
123
123
  - 0
124
- hash: -168044513201808942
124
+ hash: -3244463273596288739
125
125
  requirements: []
126
126
  rubyforge_project:
127
127
  rubygems_version: 1.8.23