Skip to content

Commit b844743

Browse files
author
Manuel Kniep
committed
spelling
1 parent 316fb16 commit b844743

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

README.rdoc

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@ With these Table Importer you are able to import any legacy Data and map it easi
1212

1313
=== Usage
1414

15-
* get your Data as nested Array in rows ans columns
15+
* get your Data as nested Array in rows and columns
1616
* build a dictionary to map your data to your Classes
17-
* {"ClassName"=>attributes}
17+
{"ClassName"=>attributes}
1818
where attributes is a hash of of objects attributes and its corresponding columns
19-
* attributes = {:attribute=>:col_1}
19+
attributes = {:attribute=>:col_1}
2020
* you can use number or letters eg. :col1, :col_1, :col_A, :colB, :col_AB, :col_aa etc.
21-
* for pre processing data use array with a lambda as last element (:attribute => [:co_l,col_2,lambda{|col1,col2| col1 +" " +col2 }]
22-
* use constant values :attribute=> "My Value"
23-
* for associations user Hashes :association => {:attribute=>:col1}
21+
* for pre processing data use array with a lambda as last element
22+
:attribute => [:co_l,col_2,lambda{|col1,col2| col1 +" " +col2 }]
23+
* use constant values
24+
:attribute=> "My Value"
25+
* for associations user Hashes
26+
:association => {:attribute=>:col1}
2427
* Build the Mapper by passing the dictonary
2528
mapper = TableImporter::Mapper.new(dictonary)
2629
* Build the Importer by passing the data and the mapper
@@ -31,12 +34,12 @@ where attributes is a hash of of objects attributes and its corresponding column
3134

3235
=== Note
3336

34-
The the Objects are only build not saved so you can post process them before saving.
37+
The Objects are only build not saved so you can post process them before saving.
3538

3639

3740
=== Example
3841

39-
Assume you hab the follwoing Tabluar Data (e.g. from a CVS File with CSV.read("your_file.csv"))
42+
Assume you have the follwoing Tabluar Data (e.g. from a CVS File with CSV.read("your_file.csv"))
4043

4144
data=
4245
[
@@ -47,25 +50,20 @@ Assume you hab the follwoing Tabluar Data (e.g. from a CVS File with CSV.read("y
4750
And you have the follwoing simple Data Structure
4851

4952
Class Contact < ActiveRecord::Base
50-
5153
# first_name String (column1)
5254
# last_name String (column2)
5355
# full_name String (column1 column2)
5456
has_many :tags
5557
belongs_to :user
5658
has_one :address
57-
5859
end
5960

6061
Class Tag < ActiveRecord::Base
61-
6262
#tagging String (column 8, 9 and 10)
6363
belongs_to :contact
64-
6564
end
6665

6766
Class User < ActiveRecord::Base
68-
6967
# name String (column 6)
7068
has_many :contacts
7169
has_one :group
@@ -76,14 +74,12 @@ And you have the follwoing simple Data Structure
7674
end
7775

7876
Class Address
79-
8077
# street String (column3)
8178
# number Integer (RegEx Number Part of column3)
8279
# zip String (column4)
8380
# city String (column5)
8481
# country String ('USA' constant for the import)
8582
belongs_to :contact
86-
8783
end
8884

8985
You can build your Data as follows
@@ -93,7 +89,7 @@ You can build your Data as follows
9389
dictonary = {"Contact" =>{:first_name=>:col_1,:last_name=>:col_2,:full_name=>[:col_1,:col_2,lambda{|f,l| "#{v} #{l}"}],
9490
# has_many associations you have three tags here
9591
:tags=>{:tagging => [:col_8,:col_9,:col_10]},
96-
# belongs_to
92+
# nested belongs_to
9793
:user => {:name=>:col_6,:group=>{:name=>:col_7}},
9894
# has_one
9995
:address => {:street=>[:col_3,lambda{|s| s[/(.*?) ([\d]+)/,1]}],

0 commit comments

Comments
 (0)