flexible_csv 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,9 +1,15 @@
1
1
  = FlexibleCsv
2
2
 
3
- <em>Chris Powers, The Killswitch Collective (http://killswitchcollective.com/blog/authors/chris_powers)</em>
3
+ <em>Created by Chris Powers</em>
4
4
 
5
5
  The FlexibleCsv gem uses the FasterCSV gem to parse user created CSV files that may not have standard headers. For example, you know there's an email address column somewhere in there, but it may be called "Email" or "Email Address" or "email-address", and it might be in the first column, but it might be in the third.
6
6
 
7
+ == Install
8
+
9
+ This gem is hosted by gemcutter.org, so just:
10
+
11
+ gem install flexible_csv
12
+
7
13
  == Examples
8
14
 
9
15
  These CSV data snippets have the same data but are formatted much differently. Using FlexibleCsv to map possible column names to data nodes, these differences become negligible.
data/lib/flexible_csv.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  class FlexibleCsv
2
2
  require 'faster_csv'
3
- require 'hacks.rb'
3
+ require File.join(File.dirname(__FILE__), 'hacks.rb')
4
4
 
5
5
  # a Hash where the key is the method name, and the value is the array of possible headers
6
6
  attr_reader :column_hash
data/lib/hacks.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  class FasterCSV::Row
2
2
  # allows for hash access by virtual attributes
3
3
  def method_missing(method_name, *args)
4
- self[method_name] || self[method_name.to_s] || super
4
+ self[method_name] || self[method_name.to_s] || nil
5
5
  end
6
6
  end
@@ -21,7 +21,9 @@ describe FlexibleCsv do
21
21
  it "should work with example 1" do
22
22
  @parser.parse(@csv_data1).each do |row|
23
23
  row["full_name"].should_not be_blank
24
+ row.full_name.should_not be_blank
24
25
  row["email"].should_not be_blank
26
+ row.email.should_not be_blank
25
27
  end
26
28
  end
27
29
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flexible_csv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Powers