theman 0.0.5 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,246 @@
1
+ require 'spec_helper'
2
+
3
+ describe Theman::Agency, "sed chomp" do
4
+ before do
5
+ conn = ActiveRecord::Base.connection.raw_connection
6
+ csv = File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec', 'fixtures', 'temp_two.csv'))
7
+
8
+ agent = ::Theman::Agency.new conn, csv do |agent|
9
+ agent.seds "-n -e :a -e '1,15!{P;N;D;};N;ba'"
10
+ end
11
+
12
+ @model = Theman::Object.new(agent.table_name, ActiveRecord::Base)
13
+ end
14
+
15
+ it "should have all the records from the csv" do
16
+ @model.count.should == 5
17
+ end
18
+ end
19
+
20
+ describe Theman::Agency, "data types" do
21
+ before do
22
+ conn = ActiveRecord::Base.connection.raw_connection
23
+ csv = File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec', 'fixtures', 'temp_one.csv'))
24
+ @agent = ::Theman::Agency.new conn, csv do |agent|
25
+ agent.nulls /"N"/, /"UNKNOWN"/, /""/
26
+ agent.table do |t|
27
+ t.date :col_date
28
+ t.boolean :col_four
29
+ t.float :col_five
30
+ end
31
+ end
32
+ @model = Theman::Object.new(@agent.table_name, ActiveRecord::Base)
33
+ end
34
+
35
+ it "should create date col" do
36
+ @model.first.col_date.class.should == Date
37
+ end
38
+
39
+ it "should create boolean col" do
40
+ @model.where(:col_four => true).count.should == 2
41
+ end
42
+
43
+ it "should create float col" do
44
+ @model.where("col_five > 10.0").count.should == 2
45
+ end
46
+
47
+ it "should have an array of nulls" do
48
+ @agent.nulls_to_sed.should == ["-e 's/\"N\"//g'", "-e 's/\"UNKNOWN\"//g'", "-e 's/\"\"//g'"]
49
+ end
50
+
51
+ it "should have nulls not strings" do
52
+ @model.where(:col_two => nil).count.should == 2
53
+ @model.where(:col_three => nil).count.should == 2
54
+ end
55
+ end
56
+
57
+ describe Theman::Agency, "european date styles" do
58
+ before do
59
+ conn = ActiveRecord::Base.connection.raw_connection
60
+ csv = File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec', 'fixtures', 'temp_three.csv'))
61
+ agent = ::Theman::Agency.new conn, csv do |smith|
62
+ smith.datestyle 'European'
63
+ smith.table do |t|
64
+ t.date :col_date
65
+ end
66
+ end
67
+ @model = Theman::Object.new(agent.table_name, ActiveRecord::Base)
68
+ end
69
+
70
+ it "should have correct date" do
71
+ date = @model.first.col_date
72
+ date.day.should == 25
73
+ date.month.should == 12
74
+ end
75
+ end
76
+
77
+ describe Theman::Agency, "US date styles" do
78
+ before do
79
+ conn = ActiveRecord::Base.connection.raw_connection
80
+ csv = File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec', 'fixtures', 'temp_four.csv'))
81
+ agent = ::Theman::Agency.new conn, csv do |smith|
82
+ smith.datestyle 'US'
83
+ smith.table do |t|
84
+ t.date :col_date
85
+ end
86
+ end
87
+ @model = Theman::Object.new(agent.table_name, ActiveRecord::Base)
88
+ end
89
+
90
+ it "should have correct date" do
91
+ date = @model.first.col_date
92
+ date.day.should == 25
93
+ date.month.should == 12
94
+ end
95
+ end
96
+
97
+ describe Theman::Agency, "ISO date styles" do
98
+ before do
99
+ conn = ActiveRecord::Base.connection.raw_connection
100
+ csv = File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec', 'fixtures', 'temp_five.csv'))
101
+ agent = ::Theman::Agency.new conn, csv do |smith|
102
+ smith.datestyle 'ISO'
103
+ smith.table do |t|
104
+ t.date :col_date
105
+ end
106
+ end
107
+ @model = Theman::Object.new(agent.table_name, ActiveRecord::Base)
108
+ end
109
+
110
+ it "should have correct date" do
111
+ date = @model.first.col_date
112
+ date.day.should == 25
113
+ date.month.should == 12
114
+ end
115
+ end
116
+
117
+ describe Theman::Agency, "procedural" do
118
+ before do
119
+ @conn = ActiveRecord::Base.connection.raw_connection
120
+ @csv = File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec', 'fixtures', 'temp_two.csv'))
121
+ end
122
+
123
+ it "should be able to be called procedural" do
124
+ smith = ::Theman::Agency.new @conn, @csv
125
+ smith.datestyle "European"
126
+ smith.seds "-n -e :a -e '1,15!{P;N;D;};N;ba'"
127
+ smith.nulls /"XXXX"/
128
+
129
+ smith.table do |t|
130
+ t.date :date
131
+ end
132
+
133
+ smith.create!
134
+
135
+ model = Theman::Object.new(smith.table_name, ActiveRecord::Base)
136
+ model.first.date.class.should == Date
137
+ model.first.org_code.class.should == NilClass
138
+ model.count.should == 5
139
+ end
140
+ end
141
+
142
+ describe Theman::Agency, "create table" do
143
+ before do
144
+ conn = ActiveRecord::Base.connection.raw_connection
145
+ csv = File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec', 'fixtures', 'temp_one.csv'))
146
+ agent = ::Theman::Agency.new conn, csv do |agent|
147
+ agent.nulls /"N"/, /"UNKNOWN"/, /""/
148
+ agent.table do |t|
149
+ t.string :col_two, :limit => 50
150
+ end
151
+ end
152
+ @model = Theman::Object.new(agent.table_name, ActiveRecord::Base)
153
+ end
154
+
155
+ it "should have" do
156
+ @model.first.col_two.should == "some \\text\\"
157
+ end
158
+ end
159
+
160
+ describe Theman::Agency, "add primary key" do
161
+ before do
162
+ conn = ActiveRecord::Base.connection.raw_connection
163
+ csv = File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec', 'fixtures', 'temp_one.csv'))
164
+ agent = ::Theman::Agency.new conn, csv
165
+ agent.create!
166
+ agent.add_primary_key!
167
+ @model = Theman::Object.new(agent.table_name, ActiveRecord::Base)
168
+ end
169
+
170
+ it "should have serial primary key" do
171
+ @model.first.agents_pkey.should == 1
172
+ end
173
+ end
174
+
175
+ describe Theman::Agency, "delimiters" do
176
+ before do
177
+ conn = ActiveRecord::Base.connection.raw_connection
178
+ csv = File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec', 'fixtures', 'temp_six.txt'))
179
+ agent = ::Theman::Agency.new conn, csv do |agent|
180
+ agent.delimiter "|"
181
+ end
182
+ @model = Theman::Object.new(agent.table_name, ActiveRecord::Base)
183
+ end
184
+
185
+ it "should have imported pipe delimited txt file" do
186
+ @model.count.should == 4
187
+ end
188
+ end
189
+
190
+ describe Theman::Agency, "no headers" do
191
+ before do
192
+ conn = ActiveRecord::Base.connection.raw_connection
193
+ csv = File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec', 'fixtures', 'temp_seven.csv'))
194
+ agent = Theman::Agency.new conn, csv, :headers => false do |agent|
195
+ agent.nulls /"N"/, /"UNKNOWN"/, /""/
196
+ agent.table do |t|
197
+ t.date :col_date
198
+ t.string :col_two
199
+ t.string :col_three
200
+ t.boolean :col_four
201
+ t.float :col_five
202
+ end
203
+ end
204
+ @model = Theman::Object.new(agent.table_name, ActiveRecord::Base)
205
+ end
206
+
207
+ it "should import csv without headers" do
208
+ @model.count.should == 4
209
+ end
210
+ end
211
+
212
+ describe Theman::Agency, "with advanced sed" do
213
+ before do
214
+ conn = ActiveRecord::Base.connection.raw_connection
215
+ csv = File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec', 'fixtures', 'temp_eight.csv'))
216
+ agent = Theman::Agency.new conn, csv, :headers => false do |agent|
217
+ agent.seds '-e \'s/[A-Z][A-Z]$/\"&\"/\' -e \'s/^[0-9|-]*/&/\'', '\'s/,\(.*\),/,\"\1\",/\''
218
+ agent.table do |t|
219
+ t.string :col_one
220
+ t.string :col_two
221
+ t.string :col_three
222
+ end
223
+ end
224
+ @model = Theman::Object.new(agent.table_name, ActiveRecord::Base)
225
+ end
226
+
227
+ it "should import csv without headers" do
228
+ @model.count.should == 249
229
+ end
230
+ end
231
+
232
+ describe Theman::Agency, "data types" do
233
+ it "should be able to run in transaction" do
234
+ conn = ActiveRecord::Base.connection.raw_connection
235
+ csv = File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec', 'fixtures', 'temp_three.csv'))
236
+
237
+ agent = Theman::Agency.new conn, csv, :on_commit => :drop
238
+
239
+ agent.transaction do
240
+ agent.create!
241
+
242
+ model = Theman::Object.new(agent.table_name, ActiveRecord::Base)
243
+ model.count.should == 4
244
+ end
245
+ end
246
+ end
@@ -0,0 +1,75 @@
1
+ require 'spec_helper'
2
+
3
+ describe Theman::Agency::Columns, "data types" do
4
+ before do
5
+ @columns = Theman::Agency::Columns.new(ActiveRecord::Base.connection.raw_connection)
6
+ end
7
+
8
+ it "should return string col with limit" do
9
+ @columns.string :col_one
10
+ @columns.string :col_two, :limit => 50
11
+ @columns.to_sql.should == "\"col_one\" character varying(255), \"col_two\" character varying(50)"
12
+ end
13
+
14
+ it "should NOT NULL" do
15
+ @columns.string :col_one, :limit => 20, :null => false
16
+ @columns.to_sql.should == "\"col_one\" character varying(20) NOT NULL"
17
+ end
18
+
19
+ it "should default" do
20
+ @columns.string :col_one, :limit => 50, :default => "'sam the man'"
21
+ @columns.to_sql.should == "\"col_one\" character varying(50) DEFAULT 'sam the man'"
22
+ end
23
+
24
+ it "should return a text" do
25
+ @columns.text :col_one
26
+ @columns.to_sql.should == "\"col_one\" text"
27
+ end
28
+
29
+ it "should return int type with scale" do
30
+ @columns.integer :col_one
31
+ @columns.integer :col_two, :limit => 1
32
+ @columns.integer :col_three, :limit => 5
33
+ @columns.to_sql.should == "\"col_one\" integer, \"col_two\" smallint, \"col_three\" bigint"
34
+ end
35
+
36
+ it "should return a float type with precision" do
37
+ @columns.float :col_one
38
+ @columns.to_sql.should == "\"col_one\" double precision"
39
+ end
40
+
41
+ it "should return a decimal with precision" do
42
+ @columns.decimal :col_one
43
+ @columns.to_sql.should == "\"col_one\" double precision"
44
+ end
45
+
46
+ it "should return a binary" do
47
+ @columns.binary :col_one
48
+ @columns.to_sql.should == "\"col_one\" oid"
49
+ end
50
+
51
+ it "should return a datetime" do
52
+ @columns.datetime :col_one
53
+ @columns.to_sql.should == "\"col_one\" timestamp without time zone"
54
+ end
55
+
56
+ it "should return a timestamp" do
57
+ @columns.timestamp :col_one
58
+ @columns.to_sql.should == "\"col_one\" timestamp without time zone"
59
+ end
60
+
61
+ it "should return a time" do
62
+ @columns.time :col_one
63
+ @columns.to_sql.should == "\"col_one\" time without time zone"
64
+ end
65
+
66
+ it "should return a date" do
67
+ @columns.date :col_one
68
+ @columns.to_sql.should == "\"col_one\" date"
69
+ end
70
+
71
+ it "should return a boolean" do
72
+ @columns.boolean :col_one
73
+ @columns.to_sql.should == "\"col_one\" boolean"
74
+ end
75
+ end
@@ -0,0 +1,249 @@
1
+ 1,AFGHANISTAN,AF
2
+ 2,ALBANIA,AL
3
+ 3,ALGERIA,DZ
4
+ 4,AMERICAN SAMOA,AS
5
+ 5,ANDORRA,AD
6
+ 6,ANGOLA,AO
7
+ 7,ANGUILLA,AI
8
+ 8,ANTARCTICA,AQ
9
+ 9,ANTIGUA AND BARBUDA,AG
10
+ 10,ARGENTINA,AR
11
+ 11,ARMENIA,AM
12
+ 12,ARUBA,AW
13
+ 13,AUSTRALIA,AU
14
+ 14,AUSTRIA,AT
15
+ 15,AZERBAIJAN,AZ
16
+ 16,BAHAMAS,BS
17
+ 17,BAHRAIN,BH
18
+ 18,BANGLADESH,BD
19
+ 19,BARBADOS,BB
20
+ 20,BELARUS,BY
21
+ 21,BELGIUM,BE
22
+ 22,BELIZE,BZ
23
+ 23,BENIN,BJ
24
+ 24,BERMUDA,BM
25
+ 25,BHUTAN,BT
26
+ 26,BOLIVIA,BO
27
+ 27,BOSNIA AND HERZEGOVINA,BA
28
+ 28,BOTSWANA,BW
29
+ 29,BOUVET ISLAND,BV
30
+ 30,BRAZIL,BR
31
+ 31,BRITISH INDIAN OCEAN TERRITORY,IO
32
+ 32,BRUNEI DARUSSALAM,BN
33
+ 33,BULGARIA,BG
34
+ 34,BURKINA FASO,BF
35
+ 35,BURUNDI,BI
36
+ 36,CAMBODIA,KH
37
+ 37,CAMEROON,CM
38
+ 38,CANADA,CA
39
+ 39,CAPE VERDE,CV
40
+ 40,CAYMAN ISLANDS,KY
41
+ 41,CENTRAL AFRICAN REPUBLIC,CF
42
+ 42,CHAD,TD
43
+ 43,CHILE,CL
44
+ 44,CHINA,CN
45
+ 45,CHRISTMAS ISLAND,CX
46
+ 46,COCOS (KEELING) ISLANDS,CC
47
+ 47,COLOMBIA,CO
48
+ 48,COMOROS,KM
49
+ 49,CONGO,CG
50
+ 50,CONGO, THE DEMOCRATIC REPUBLIC OF THE,CD
51
+ 51,COOK ISLANDS,CK
52
+ 52,COSTA RICA,CR
53
+ 53,COTE D'IVOIRE,CI
54
+ 54,CROATIA,HR
55
+ 55,CUBA,CU
56
+ 56,CYPRUS,CY
57
+ 57,CZECH REPUBLIC,CZ
58
+ 58,DENMARK,DK
59
+ 59,DJIBOUTI,DJ
60
+ 60,DOMINICA,DM
61
+ 61,DOMINICAN REPUBLIC,DO
62
+ 62,ECUADOR,EC
63
+ 63,EGYPT,EG
64
+ 64,EL SALVADOR,SV
65
+ 65,EQUATORIAL GUINEA,GQ
66
+ 66,ERITREA,ER
67
+ 67,ESTONIA,EE
68
+ 68,ETHIOPIA,ET
69
+ 69,FALKLAND ISLANDS,FK
70
+ 70,FAROE ISLANDS,FO
71
+ 71,FIJI,FJ
72
+ 72,FINLAND,FI
73
+ 73,FRANCE,FR
74
+ 74,FRENCH GUIANA,GF
75
+ 75,FRENCH POLYNESIA,PF
76
+ 76,FRENCH SOUTHERN TERRITORIES,TF
77
+ 77,GABON,GA
78
+ 78,GAMBIA,GM
79
+ 79,GEORGIA,GE
80
+ 80,GERMANY,DE
81
+ 81,GHANA,GH
82
+ 82,GIBRALTAR,GI
83
+ 83,GREECE,GR
84
+ 84,GREENLAND,GL
85
+ 85,GRENADA,GD
86
+ 86,GUADELOUPE,GP
87
+ 87,GUAM,GU
88
+ 88,GUATEMALA,GT
89
+ 89,GUINEA,GN
90
+ 90,GUINEA-BISSAU,GW
91
+ 91,GUYANA,GY
92
+ 92,HAITI,HT
93
+ 93,HEARD ISLAND AND MCDONALD ISLANDS,HM
94
+ 94,HOLY SEE (VATICAN CITY STATE),VA
95
+ 95,HONDURAS,HN
96
+ 96,HONG KONG,HK
97
+ 97,HUNGARY,HU
98
+ 98,ICELAND,IS
99
+ 99,INDIA,IN
100
+ 100,INDONESIA,ID
101
+ 101,IRAN, ISLAMIC REPUBLIC OF,IR
102
+ 102,IRAQ,IQ
103
+ 103,IRELAND,IE
104
+ 104,ISRAEL,IL
105
+ 105,ITALY,IT
106
+ 106,JAMAICA,JM
107
+ 107,JAPAN,JP
108
+ 108,JORDAN,JO
109
+ 109,KAZAKHSTAN,KZ
110
+ 110,KENYA,KE
111
+ 111,KIRIBATI,KI
112
+ 112,KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF,KP
113
+ 113,KOREA, REPUBLIC OF,KR
114
+ 114,KUWAIT,KW
115
+ 115,KYRGYZSTAN,KG
116
+ 116,LAO PEOPLE'S DEMOCRATIC REPUBLIC,LA
117
+ 117,LATVIA,LV
118
+ 118,LEBANON,LB
119
+ 119,LESOTHO,LS
120
+ 120,LIBERIA,LR
121
+ 121,LIBYAN ARAB JAMAHIRIYA,LY
122
+ 122,LIECHTENSTEIN,LI
123
+ 123,LITHUANIA,LT
124
+ 124,LUXEMBOURG,LU
125
+ 125,MACAO,MO
126
+ 126,MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF,MK
127
+ 127,MADAGASCAR,MG
128
+ 128,MALAWI,MW
129
+ 129,MALAYSIA,MY
130
+ 130,MALDIVES,MV
131
+ 131,MALI,ML
132
+ 132,MALTA,MT
133
+ 133,MARSHALL ISLANDS,MH
134
+ 134,MARTINIQUE,MQ
135
+ 135,MAURITANIA,MR
136
+ 136,MAURITIUS,MU
137
+ 137,MAYOTTE,YT
138
+ 138,MEXICO,MX
139
+ 139,MICRONESIA, FEDERATED STATES OF,FM
140
+ 140,MOLDOVA, REPUBLIC OF,MD
141
+ 141,MONACO,MC
142
+ 142,MONGOLIA,MN
143
+ 143,MONTSERRAT,MS
144
+ 144,MOROCCO,MA
145
+ 145,MOZAMBIQUE,MZ
146
+ 146,MYANMAR,MM
147
+ 147,NAMIBIA,NA
148
+ 148,NAURU,NR
149
+ 149,NEPAL,NP
150
+ 150,NETHERLANDS,NL
151
+ 151,NETHERLANDS ANTILLES,AN
152
+ 152,NEW CALEDONIA,NC
153
+ 153,NEW ZEALAND,NZ
154
+ 154,NICARAGUA,NI
155
+ 155,NIGER,NE
156
+ 156,NIGERIA,NG
157
+ 157,NIUE,NU
158
+ 158,NORFOLK ISLAND,NF
159
+ 159,NORTHERN MARIANA ISLANDS,MP
160
+ 160,NORWAY,NO
161
+ 161,OMAN,OM
162
+ 162,PAKISTAN,PK
163
+ 163,PALAU,PW
164
+ 164,PALESTINIAN TERRITORY, OCCUPIED,PS
165
+ 165,PANAMA,PA
166
+ 166,PAPUA NEW GUINEA,PG
167
+ 167,PARAGUAY,PY
168
+ 168,PERU,PE
169
+ 169,PHILIPPINES,PH
170
+ 170,PITCAIRN,PN
171
+ 171,POLAND,PL
172
+ 172,PORTUGAL,PT
173
+ 173,PUERTO RICO,PR
174
+ 174,QATAR,QA
175
+ 175,REUNION,RE
176
+ 176,ROMANIA,RO
177
+ 177,RUSSIAN FEDERATION,RU
178
+ 178,RWANDA,RW
179
+ 179,SAINT HELENA,SH
180
+ 180,SAINT KITTS AND NEVIS,KN
181
+ 181,SAINT LUCIA,LC
182
+ 182,SAINT PIERRE AND MIQUELON,PM
183
+ 183,SAINT VINCENT AND THE GRENADINES,VC
184
+ 184,SAMOA,WS
185
+ 185,SAN MARINO,SM
186
+ 186,SAO TOME AND PRINCIPE,ST
187
+ 187,SAUDI ARABIA,SA
188
+ 188,SENEGAL,SN
189
+ 189,SERBIA AND MONTENEGRO,CS
190
+ 190,SEYCHELLES,SC
191
+ 191,SIERRA LEONE,SL
192
+ 192,SINGAPORE,SG
193
+ 193,SLOVAKIA,SK
194
+ 194,SLOVENIA,SI
195
+ 195,SOLOMON ISLANDS,SB
196
+ 196,SOMALIA,SO
197
+ 197,SOUTH AFRICA,ZA
198
+ 198,SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS,GS
199
+ 199,SPAIN,ES
200
+ 200,SRI LANKA,LK
201
+ 201,SUDAN,SD
202
+ 202,SURINAME,SR
203
+ 203,SVALBARD AND JAN MAYEN,SJ
204
+ 204,SWAZILAND,SZ
205
+ 205,SWEDEN,SE
206
+ 206,SWITZERLAND,CH
207
+ 207,SYRIAN ARAB REPUBLIC,SY
208
+ 208,TAIWAN,TW
209
+ 209,TAJIKISTAN,TJ
210
+ 210,TANZANIA, UNITED REPUBLIC OF,TZ
211
+ 211,THAILAND,TH
212
+ 212,TIMOR-LESTE,TL
213
+ 213,TOGO,TG
214
+ 214,TOKELAU,TK
215
+ 215,TONGA,TO
216
+ 216,TRINIDAD AND TOBAGO,TT
217
+ 217,TUNISIA,TN
218
+ 218,TURKEY,TR
219
+ 219,TURKMENISTAN,TM
220
+ 220,TURKS AND CAICOS ISLANDS,TC
221
+ 221,TUVALU,TV
222
+ 222,UGANDA,UG
223
+ 223,UKRAINE,UA
224
+ 224,UNITED ARAB EMIRATES,AE
225
+ 225,UNITED KINGDOM,GB
226
+ 226,UNITED STATES,US
227
+ 227,UNITED STATES MINOR OUTLYING ISLANDS,UM
228
+ 228,URUGUAY,UY
229
+ 229,UZBEKISTAN,UZ
230
+ 230,VANUATU,VU
231
+ 231,VENEZUELA,VE
232
+ 232,VIET NAM,VN
233
+ 233,VIRGIN ISLANDS, BRITISH,VG
234
+ 234,VIRGIN ISLANDS, U.S.,VI
235
+ 235,WALLIS AND FUTUNA,WF
236
+ 236,WESTERN SAHARA,EH
237
+ 237,YEMEN,YE
238
+ 238,ZAMBIA,ZM
239
+ 239,ZIMBABWE,ZW
240
+ 240,UNITED KINGDOM,UK
241
+ 241,EUROPEAN UNION,EU
242
+ 242,YUGOSLAVIA,YU
243
+ 244,ARIPO,AP
244
+ -1,UNROUTABLE ADDRESS,XX
245
+ 245,ASCENSION ISLAND,AC
246
+ 246,GUERNSEY,GG
247
+ 247,ISLE OF MAN,IM
248
+ 248,JERSEY,JE
249
+ 249,EAST TIMOR,TP
@@ -0,0 +1,4 @@
1
+ "05/12/2010","some \"text\"","123134343","Y","2.0"
2
+ "05/11/2010","some other \"text\"","987983134343","Y","11.5"
3
+ "05/11/2010","","N","","10.5"
4
+ "05/11/2010","","UNKNOWN","","3.0"
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe Theman::Object do
4
+ before do
5
+ csv = File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec', 'fixtures', 'temp_one.csv'))
6
+ conn = ActiveRecord::Base.connection.raw_connection
7
+
8
+ agent = Theman::Agency.new(conn, csv) do |agent|
9
+ agent.table do |t|
10
+ t.date :col_date
11
+ t.string :col_two
12
+ end
13
+ end
14
+
15
+ @model = Theman::Object.new(agent.table_name, ActiveRecord::Base)
16
+ end
17
+
18
+ it "should superclass active record" do
19
+ @model.superclass.should == ActiveRecord::Base
20
+ end
21
+
22
+ it "should have connection" do
23
+ @model.connection.class.should == ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
24
+ end
25
+
26
+ it "should have a table name" do
27
+ @model.table_name.should match /agent[0-9]{10}/
28
+ end
29
+
30
+ it "should have an ispect method" do
31
+ @model.inspect.should match /Agent/
32
+ end
33
+
34
+ it "should count" do
35
+ @model.count.should == 4
36
+ end
37
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe Theman::Agency::Table do
4
+
5
+ end
data/theman.gemspec CHANGED
@@ -19,7 +19,6 @@ Gem::Specification.new do |s|
19
19
  s.add_development_dependency "activerecord", ">= 3.0.0"
20
20
  s.add_development_dependency "pg"
21
21
 
22
- s.add_runtime_dependency "activerecord"
23
22
  s.add_runtime_dependency "pg"
24
23
 
25
24
  s.files = `git ls-files`.split("\n")
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
+ - 1
7
8
  - 0
8
- - 5
9
- version: 0.0.5
9
+ version: 0.1.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Rufus Post
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-11-08 00:00:00 +11:00
17
+ date: 2011-02-15 00:00:00 +11:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -76,7 +76,7 @@ dependencies:
76
76
  type: :development
77
77
  version_requirements: *id004
78
78
  - !ruby/object:Gem::Dependency
79
- name: activerecord
79
+ name: pg
80
80
  prerelease: false
81
81
  requirement: &id005 !ruby/object:Gem::Requirement
82
82
  none: false
@@ -88,19 +88,6 @@ dependencies:
88
88
  version: "0"
89
89
  type: :runtime
90
90
  version_requirements: *id005
91
- - !ruby/object:Gem::Dependency
92
- name: pg
93
- prerelease: false
94
- requirement: &id006 !ruby/object:Gem::Requirement
95
- none: false
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- segments:
100
- - 0
101
- version: "0"
102
- type: :runtime
103
- version_requirements: *id006
104
91
  description: FasterCSV is great and all but when you get to 100mb files it takes a while and you may only be looking for certain records that match some criteria, enter theman
105
92
  email:
106
93
  - rufuspost@gmail.com
@@ -112,20 +99,29 @@ extra_rdoc_files: []
112
99
 
113
100
  files:
114
101
  - .gitignore
102
+ - .rspec
115
103
  - Gemfile
116
104
  - README.rdoc
117
105
  - Rakefile
118
106
  - lib/theman.rb
119
107
  - lib/theman/agency.rb
108
+ - lib/theman/agency/columns.rb
109
+ - lib/theman/agency/table.rb
110
+ - lib/theman/object.rb
120
111
  - lib/theman/version.rb
112
+ - spec/agency_spec.rb
113
+ - spec/columns_spec.rb
114
+ - spec/fixtures/temp_eight.csv
121
115
  - spec/fixtures/temp_five.csv
122
116
  - spec/fixtures/temp_four.csv
123
117
  - spec/fixtures/temp_one.csv
118
+ - spec/fixtures/temp_seven.csv
124
119
  - spec/fixtures/temp_six.txt
125
120
  - spec/fixtures/temp_three.csv
126
121
  - spec/fixtures/temp_two.csv
122
+ - spec/object_spec.rb
127
123
  - spec/spec_helper.rb
128
- - spec/theman_spec.rb
124
+ - spec/table_spec.rb
129
125
  - theman.gemspec
130
126
  has_rdoc: true
131
127
  homepage: http://github.com/mynameisrufus/theman