prune-erickson 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/prune-erickson +86 -315
  3. data/lib/prune-erickson.rb +86 -315
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b7da5d2431577e893d44b2d9c121bd8b2a1021bf
4
- data.tar.gz: 573a11a3d95cd34a874b5a3b9ca9b388abeb6791
3
+ metadata.gz: 5d4176908e38f35c3bb01b2eb2713252a390dd9f
4
+ data.tar.gz: 428655ae7b3aa223da65b72ecde1942b9f20712f
5
5
  SHA512:
6
- metadata.gz: 2d418b17843bcad101a17f19354f7a2c80f6078e1334edebdbe903c1a43b4b2b73d8a60e8586b4a80ac5b05c7c2c9bf327de24d51e0522935c89d1cc40c9e248
7
- data.tar.gz: c8c105c3034bc95b3b162d03ae9f8167c3e6420190df793fb8495405e643862f060504bbee62f5209d38bed20ea09f8ccf67f7a76921d8a9bf6778ed37c0027c
6
+ metadata.gz: c5eb940d7db778f6a91db65d9f58bd23f8920790882ca7b78183bd98e3582748170f5201794a269d9292d7abe19c9cf6ace1eb9584f588995061773b300dc87c
7
+ data.tar.gz: 5ba88a6d8fcf5eaa12032ef93c1665ed9e9a272812bf6c36bc6dda61260379534bd12fe6b88d9bda083615cb6c8779573a57fad294db6afe2f7e08a4b3354f33
@@ -21,41 +21,15 @@ def labelChecker (row, testvar)
21
21
  end
22
22
  }
23
23
  end
24
-
25
- def fieldChecker (row)
26
- unless row.include? "OppCommunity"
27
- print "you are missing the OppCommunity field\n".yellow.blink
28
- else
29
- end
30
- unless row.include? "FirstName"
31
- print "you are missing the FirstName field\n".yellow.blink
32
- end
33
- unless row.include? "LastName"
34
- print "you are missing the LastName field\n".yellow.blink
35
- end
36
- unless row.include? "Phone"
37
- print "you are missing the phone field\n".yellow.blink
38
- end
39
- unless row.include? "Address"
40
- print "you are missing the Address field\n".yellow.blink
41
- end
42
- unless row.include? "City"
43
- print "you are missing the City field\n".yellow.blink
44
- end
45
- unless row.include? "State"
46
- print "you are missing the State field\n".yellow.blink
47
- end
48
- unless row.include? "Zipcode"
49
- print "you are missing the Zipcode field\n".yellow.blink
50
- end
51
- unless row.include? "Address"
52
- print "you are missing the Address field\n".yellow.blink
53
- end
54
- unless row.include? "Address"
55
- print "you are missing the Address field\n".yellow.blink
56
- end
57
- unless row.include? "Email"
58
- print "you are missing the Email field\n".yellow.blink
24
+ fields = ['OppCommunity','FirstName','LastName','Phone','Address','City','State','Zipcode','Address','Email']
25
+ # new_fields = ['Community of Interest','First Name','Last Name','Address 1','city','State or Province','Zip or Postal Code','Email Address','Home Phone']
26
+ def fieldChecker (row,fields)
27
+
28
+ fields.each do |field|
29
+ unless row.include? field
30
+ print "you are missing the #{field} field\n".yellow.blink
31
+ else
32
+ end
59
33
  end
60
34
  end
61
35
 
@@ -107,8 +81,8 @@ def processData (sheet, newvar, testvar)
107
81
  }
108
82
  end
109
83
 
110
- def printFile (newvar, testvar, output, il_or_cc, k=0, l=1,offset=0)
111
- # print newvar
84
+ def printFile (newvar, testvar, output, il_or_cc, k=0, l=1,offset=0, j_int_offset = 0)
85
+
112
86
  newBook = Spreadsheet::Workbook.new
113
87
  newSheet = newBook.create_worksheet
114
88
  if il_or_cc == ""
@@ -117,7 +91,8 @@ def printFile (newvar, testvar, output, il_or_cc, k=0, l=1,offset=0)
117
91
  end
118
92
  end
119
93
  for i in k..newvar.length
120
- for j in l..testvar.length-1
94
+
95
+ for j in l..(testvar.length-j_int_offset)
121
96
  newSheet.row(i+offset).push newvar[(i*testvar.length)+j]
122
97
  end
123
98
  if il_or_cc != ""
@@ -129,284 +104,54 @@ def printFile (newvar, testvar, output, il_or_cc, k=0, l=1,offset=0)
129
104
  end
130
105
  end
131
106
  end
132
- print "output file is in same file under out.xls to open, use \n \n open #{output}"
133
- print "\n"
107
+ if il_or_cc == ""
108
+ puts " |--> #{output[20..26]}"
109
+ else
110
+ puts "output file is in same file under out.xls to open, use \n \n open #{output}"
111
+ end
134
112
  newBook.write output
135
113
  end
136
114
 
137
115
  def com_separated_files (output)
138
- puts output
139
- labels = Array.new
140
- apl_array = Array.new
141
- ach_array = Array.new
142
- bbv_array = Array.new
143
- ccv_array = Array.new
144
- cci_array = Array.new
145
- dvf_array = Array.new
146
- eth_array = Array.new
147
- frv_array = Array.new
148
- gsv_array = Array.new
149
- hsd_array = Array.new
150
- lhn_array = Array.new
151
- lph_array = Array.new
152
- mgc_array = Array.new
153
- ocv_array = Array.new
154
- rwv_array = Array.new
155
- sbv_array = Array.new
156
- tck_array = Array.new
157
- wcd_array = Array.new
158
-
116
+ # puts output
117
+ com_data = {
118
+ 'com_codes' => ['apl', 'ach', 'bbv', 'ccv', 'cci', 'cwf', 'dvf', 'eth', 'frv', 'gsv', 'hsd', 'lhn', 'lph', 'mgc', 'ocv', 'rwv', 'sbv', 'tck', 'wcd'],
119
+ 'labels' => Array.new,
120
+ }
121
+ com_data['com_codes'].each do |code|
122
+ com_data[code] = Array.new
123
+ end
159
124
  original = Spreadsheet.open(output)
160
125
  original_sheet = original.worksheet(0)
161
126
 
162
-
163
127
  rowlength = original_sheet.row(0)
164
- puts rowlength.length
128
+ # puts rowlength.length
165
129
  # make a directory for the new files
166
130
  unless File.directory?("com_separated_files")
167
131
  %x(mkdir com_separated_files)
168
132
  end
169
133
  original_sheet.each do |row|
170
- if row[0] == "apl".upcase
171
-
172
- # print row to other array and print label to a community array
173
- row.each do |x|
174
- apl_array.push x
175
- end
176
- unless labels.include?("apl".upcase)
177
- labels.push "apl".upcase
178
- end
179
- end
180
- if row[0] == "ach".upcase
181
-
182
- # print row to other array and print label to a community array
183
- row.each do |x|
184
- ach_array.push x
185
- end
186
- unless labels.include?("ach".upcase)
187
- labels.push "ach".upcase
188
- end
189
- end
190
- if row[0] == "bbv".upcase
191
-
192
- # print row to other array and print label to a community array
193
- row.each do |x|
194
- bbv_array.push x
195
- end
196
- unless labels.include?("bbv".upcase)
197
- labels.push "bbv".upcase
198
- end
199
- end
200
- if row[0] == "ccv".upcase
201
-
202
- # print row to other array and print label to a community array
203
- row.each do |x|
204
- ccv_array.push x
205
- end
206
- unless labels.include?("ccv".upcase)
207
- labels.push "ccv".upcase
208
- end
209
- end
210
- if row[0] == "cci".upcase
211
-
212
- # print row to other array and print label to a community array
213
- row.each do |x|
214
- cci_array.push x
215
- end
216
- unless labels.include?("cci".upcase)
217
- labels.push "cci".upcase
218
- end
219
- end
220
- if row[0] == "dvf".upcase
221
-
222
- # print row to other array and print label to a community array
223
- row.each do |x|
224
- dvf_array.push x
225
- end
226
- unless labels.include?("dvf".upcase)
227
- labels.push "dvf".upcase
228
- end
229
- end
230
- if row[0] == "eth".upcase
231
-
232
- # print row to other array and print label to a community array
233
- row.each do |x|
234
- eth_array.push x
235
- end
236
- unless labels.include?("eth".upcase)
237
- labels.push "eth".upcase
238
- end
239
- end
240
- if row[0] == "frv".upcase
241
-
242
- # print row to other array and print label to a community array
243
- row.each do |x|
244
- frv_array.push x
245
- end
246
- unless labels.include?("frv".upcase)
247
- labels.push "frv".upcase
248
- end
249
- end
250
- if row[0] == "gsv".upcase
251
-
252
- # print row to other array and print label to a community array
253
- row.each do |x|
254
- gsv_array.push x
255
- end
256
- unless labels.include?("gsv".upcase)
257
- labels.push "gsv".upcase
258
- end
259
- end
260
- if row[0] == "hsd".upcase
261
-
262
- # print row to other array and print label to a community array
263
- row.each do |x|
264
- hsd_array.push x
265
- end
266
- unless labels.include?("hsd".upcase)
267
- labels.push "hsd".upcase
268
- end
269
- end
270
- if row[0] == "lhn".upcase
271
-
134
+ com_data['com_codes'].each do |code|
135
+ if row[0] == "#{code}".upcase
272
136
  # print row to other array and print label to a community array
273
- row.each do |x|
274
- lhn_array.push x
275
- end
276
- unless labels.include?("lhn".upcase)
277
- labels.push "lhn".upcase
278
- end
279
- end
280
- if row[0] == "lph".upcase
281
-
282
- # print row to other array and print label to a community array
283
- row.each do |x|
284
- lph_array.push x
285
- end
286
- unless labels.include?("lph".upcase)
287
- labels.push "lph".upcase
288
- end
289
- end
290
- if row[0] == "mgc".upcase
291
-
292
- # print row to other array and print label to a community array
293
- row.each do |x|
294
- mgc_array.push x
295
- end
296
- unless labels.include?("mgc".upcase)
297
- labels.push "mgc".upcase
298
- end
299
- end
300
- if row[0] == "ocv".upcase
301
-
302
- # print row to other array and print label to a community array
303
- row.each do |x|
304
- ocv_array.push x
305
- end
306
- unless labels.include?("ocv".upcase)
307
- labels.push "ocv".upcase
308
- end
309
- end
310
- if row[0] == "rwv".upcase
311
-
312
- # print row to other array and print label to a community array
313
- row.each do |x|
314
- rwv_array.push x
315
- end
316
- unless labels.include?("rwv".upcase)
317
- labels.push "rwv".upcase
318
- end
319
- end
320
- if row[0] == "sbv".upcase
321
-
322
- # print row to other array and print label to a community array
323
- row.each do |x|
324
- sbv_array.push x
325
- end
326
- unless labels.include?("sbv".upcase)
327
- labels.push "sbv".upcase
328
- end
329
- end
330
- if row[0] == "tck".upcase
331
-
332
- # print row to other array and print label to a community array
333
- row.each do |x|
334
- tck_array.push x
335
- end
336
- unless labels.include?("tck".upcase)
337
- labels.push "tck".upcase
338
- end
339
- end
340
- if row[0] == "wcd".upcase
341
-
342
- # print row to other array and print label to a community array
343
- row.each do |x|
344
- wcd_array.push x
345
- end
346
- unless labels.include?("wcd".upcase)
347
- labels.push "wcd".upcase
137
+ row.each do |x|
138
+ com_data[code].push x
139
+ end
140
+ unless com_data['labels'].include?("#{code}".upcase)
141
+ com_data['labels'].push "#{code}".upcase
142
+ end
348
143
  end
349
144
  end
350
145
  end
351
146
  print "creating files for these communities:\n".blue
352
- puts "#{labels}".blue
353
- print rowlength
354
- if apl_array.length > 0
355
- printFile(apl_array, rowlength, "com_separated_files/apl.xls", "", 0, 0,1)
356
- end
357
- if ach_array.length > 0
358
- printFile(ach_array, rowlength, "com_separated_files/ach.xls", "", 0, 0,1)
359
- end
360
- if bbv_array.length > 0
361
- printFile(bbv_array, rowlength, "com_separated_files/bbv.xls", "", 0, 0,1)
362
- end
363
- if ccv_array.length > 0
364
- printFile(ccv_array, rowlength, "com_separated_files/ccv.xls", "", 0, 0,1)
365
- end
366
- if cci_array.length > 0
367
- printFile(cci_array, rowlength, "com_separated_files/cci.xls", "", 0, 0,1)
368
- end
369
- if dvf_array.length > 0
370
- printFile(dvf_array, rowlength, "com_separated_files/dvf.xls", "", 0, 0,1)
371
- end
372
- if eth_array.length > 0
373
- printFile(eth_array, rowlength, "com_separated_files/eth.xls", "", 0, 0,1)
374
- end
375
- if frv_array.length > 0
376
- printFile(frv_array, rowlength, "com_separated_files/frv.xls", "", 0, 0,1)
377
- end
378
- if gsv_array.length > 0
379
- printFile(gsv_array, rowlength, "com_separated_files/gsv.xls", "", 0, 0,1)
380
- end
381
- if hsd_array.length > 0
382
- printFile(hsd_array, rowlength, "com_separated_files/hsd.xls", "", 0, 0,1)
383
- end
384
- if lhn_array.length > 0
385
- printFile(lhn_array, rowlength, "com_separated_files/lhn.xls", "", 0, 0,1)
386
- end
387
- if lph_array.length > 0
388
- printFile(lph_array, rowlength, "com_separated_files/lph.xls", "", 0, 0,1)
389
- end
390
- if mgc_array.length > 0
391
- printFile(mgc_array, rowlength, "com_separated_files/mgc.xls", "", 0, 0,1)
392
- end
393
- if ocv_array.length > 0
394
- printFile(ocv_array, rowlength, "com_separated_files/ocv.xls", "", 0, 0,1)
395
- end
396
- if rwv_array.length > 0
397
- printFile(rwv_array, rowlength, "com_separated_files/rwv.xls", "", 0, 0,1)
398
- end
399
- if sbv_array.length > 0
400
- printFile(sbv_array, rowlength, "com_separated_files/sbv.xls", "", 0, 0,1)
401
- end
402
- if tck_array.length > 0
403
- printFile(tck_array, rowlength, "com_separated_files/tck.xls", "", 0, 0,1)
404
- end
405
- if wcd_array.length > 0
406
- printFile(wcd_array, rowlength, "com_separated_files/wcd.xls", "", 0, 0,1)
147
+ puts "#{com_data['labels']}".blue
148
+ puts "you can see your files in this directory"
149
+ puts "../com_separated_files"
150
+ com_data['com_codes'].each do |code|
151
+ if com_data[code].length > 0
152
+ printFile(com_data[code], rowlength, "com_separated_files/#{code}.xls", "", 0, 0,1,1)
153
+ end
407
154
  end
408
-
409
-
410
155
  end
411
156
 
412
157
  # --------------------------------------------
@@ -414,18 +159,6 @@ end
414
159
  fileName = ARGV[0]
415
160
  sheetNum = ARGV[1].to_i-1
416
161
  output = ARGV[2]
417
- print "\n\n"
418
- print "Is this an email campaign for Continuing Care? (CC) [y/n]".yellow
419
-
420
- res = STDIN.gets.strip
421
- print "\n\n"
422
- if res == 'y' || res == 'Y'
423
- il_or_cc = 'CC'
424
- else
425
- il_or_cc = "IL"
426
- end
427
- print "Do you wish to create separate files based on community names?[y/n]".yellow
428
- comres= STDIN.gets.strip
429
162
 
430
163
  # --------------------------------------------
431
164
  # ASKING FOR HELP
@@ -458,7 +191,7 @@ if ARGV.length == 1 and ARGV[0] == "help"
458
191
  elsif ARGV.length == 1 and (ARGV[0] == "-v" or ARGV[0] == "-version" or ARGV[0] == "version")
459
192
  print "\n
460
193
  -------------------
461
- | VERSION | 0.2.1 |
194
+ | VERSION | 0.4.0 |
462
195
  -------------------
463
196
  "
464
197
  print "
@@ -476,7 +209,19 @@ elsif ARGV.length == 1 and ARGV[0] != "version" or ARGV[0] != "help" or ARGV[0]
476
209
  # line 68 catches any user input that relates to .xls files in the form of
477
210
  # prune-erickson yourfile.xls [digit] outputfile.xls
478
211
  if ARGV[0] =~ /\S+.xls\b/ and ARGV[1] =~ /\d/ and ARGV[2] =~ /\S+.xls\b/
479
-
212
+ print "\n\n"
213
+ print "Is this an email campaign for Continuing Care? (CC) [y/n]".yellow
214
+
215
+ res = STDIN.gets.strip
216
+ print "\n\n"
217
+ if res == 'y' || res == 'Y'
218
+ il_or_cc = 'CC'
219
+ else
220
+ il_or_cc = "IL"
221
+ end
222
+ print "Do you wish to create separate files based on community names?[y/n]".yellow
223
+ comres= STDIN.gets.strip
224
+
480
225
  Spreadsheet.client_encoding = 'UTF-8'
481
226
  print "~>reading file you have requested"
482
227
  print "\n"
@@ -501,10 +246,11 @@ elsif ARGV.length == 1 and ARGV[0] != "version" or ARGV[0] != "help" or ARGV[0]
501
246
  are you selecting the wrong one? \n".red
502
247
  else
503
248
  labelChecker(sheet1.row(0), testvar)
504
- fieldChecker(sheet1.row(0))
249
+ fieldChecker(sheet1.row(0),fields)
505
250
  processData(sheet1, newvar, testvar)
506
251
  printFile(newvar, testvar, output, il_or_cc)
507
252
  if comres == 'y' || comres == 'Y'
253
+
508
254
  com_separated_files(output)
509
255
  end
510
256
  end
@@ -516,6 +262,19 @@ elsif ARGV.length == 1 and ARGV[0] != "version" or ARGV[0] != "help" or ARGV[0]
516
262
  try locating the folder and inputing the correct path\n\n".red
517
263
  end
518
264
  elsif ARGV[0] =~ /\S+[.csv*]/ and ARGV[1] =~ /\S+.xls\b/
265
+ print "\n\n"
266
+ print "Is this an email campaign for Continuing Care? (CC) [y/n]".yellow
267
+
268
+ res = STDIN.gets.strip
269
+ print "\n\n"
270
+ if res == 'y' || res == 'Y'
271
+ il_or_cc = 'CC'
272
+ else
273
+ il_or_cc = "IL"
274
+ end
275
+ print "Do you wish to create separate files based on community names?[y/n]".yellow
276
+ comres= STDIN.gets.strip
277
+
519
278
  output = ARGV[1]
520
279
  if File.exist?(fileName)
521
280
  file_data = CSV.read(fileName)
@@ -530,7 +289,7 @@ elsif ARGV.length == 1 and ARGV[0] != "version" or ARGV[0] != "help" or ARGV[0]
530
289
  print "\n"
531
290
 
532
291
  labelChecker(file_data[0], testvar)
533
- fieldChecker(file_data[0])
292
+ fieldChecker(file_data[0],fields)
534
293
  processData(file_data, newvar, testvar)
535
294
  printFile(newvar, testvar, output, il_or_cc)
536
295
  if comres == 'y' || comres == 'Y'
@@ -552,6 +311,18 @@ elsif ARGV.length == 1 and ARGV[0] != "version" or ARGV[0] != "help" or ARGV[0]
552
311
  It looks like this file is in the wrong folder or does not exsist.
553
312
  try locating the folder and inputing the correct path\n\n".red
554
313
  else
314
+ print "\n\n"
315
+ print "Is this an email campaign for Continuing Care? (CC) [y/n]".yellow
316
+
317
+ res = STDIN.gets.strip
318
+ print "\n\n"
319
+ if res == 'y' || res == 'Y'
320
+ il_or_cc = 'CC'
321
+ else
322
+ il_or_cc = "IL"
323
+ end
324
+ print "Do you wish to create separate files based on community names?[y/n]".yellow
325
+ comres= STDIN.gets.strip
555
326
 
556
327
  xlsx = Roo::Spreadsheet.open(fileName)
557
328
  newBook = Spreadsheet::Workbook.new
@@ -570,7 +341,7 @@ elsif ARGV.length == 1 and ARGV[0] != "version" or ARGV[0] != "help" or ARGV[0]
570
341
  testvar = Array.new
571
342
  newvar = Array.new
572
343
  labelChecker(header, testvar)
573
- fieldChecker(header)
344
+ fieldChecker(header, fields)
574
345
  processData(xlsxSheet, newvar, testvar)
575
346
  printFile(newvar, testvar, output, il_or_cc)
576
347
  if comres == 'y' || comres == 'Y'
@@ -585,4 +356,4 @@ elsif ARGV.length == 1 and ARGV[0] != "version" or ARGV[0] != "help" or ARGV[0]
585
356
  prune-erickson help \n\n\n
586
357
  "
587
358
  end
588
- end
359
+ end
@@ -21,41 +21,15 @@ def labelChecker (row, testvar)
21
21
  end
22
22
  }
23
23
  end
24
-
25
- def fieldChecker (row)
26
- unless row.include? "OppCommunity"
27
- print "you are missing the OppCommunity field\n".yellow.blink
28
- else
29
- end
30
- unless row.include? "FirstName"
31
- print "you are missing the FirstName field\n".yellow.blink
32
- end
33
- unless row.include? "LastName"
34
- print "you are missing the LastName field\n".yellow.blink
35
- end
36
- unless row.include? "Phone"
37
- print "you are missing the phone field\n".yellow.blink
38
- end
39
- unless row.include? "Address"
40
- print "you are missing the Address field\n".yellow.blink
41
- end
42
- unless row.include? "City"
43
- print "you are missing the City field\n".yellow.blink
44
- end
45
- unless row.include? "State"
46
- print "you are missing the State field\n".yellow.blink
47
- end
48
- unless row.include? "Zipcode"
49
- print "you are missing the Zipcode field\n".yellow.blink
50
- end
51
- unless row.include? "Address"
52
- print "you are missing the Address field\n".yellow.blink
53
- end
54
- unless row.include? "Address"
55
- print "you are missing the Address field\n".yellow.blink
56
- end
57
- unless row.include? "Email"
58
- print "you are missing the Email field\n".yellow.blink
24
+ fields = ['OppCommunity','FirstName','LastName','Phone','Address','City','State','Zipcode','Address','Email']
25
+ # new_fields = ['Community of Interest','First Name','Last Name','Address 1','city','State or Province','Zip or Postal Code','Email Address','Home Phone']
26
+ def fieldChecker (row,fields)
27
+
28
+ fields.each do |field|
29
+ unless row.include? field
30
+ print "you are missing the #{field} field\n".yellow.blink
31
+ else
32
+ end
59
33
  end
60
34
  end
61
35
 
@@ -107,8 +81,8 @@ def processData (sheet, newvar, testvar)
107
81
  }
108
82
  end
109
83
 
110
- def printFile (newvar, testvar, output, il_or_cc, k=0, l=1,offset=0)
111
- # print newvar
84
+ def printFile (newvar, testvar, output, il_or_cc, k=0, l=1,offset=0, j_int_offset = 0)
85
+
112
86
  newBook = Spreadsheet::Workbook.new
113
87
  newSheet = newBook.create_worksheet
114
88
  if il_or_cc == ""
@@ -117,7 +91,8 @@ def printFile (newvar, testvar, output, il_or_cc, k=0, l=1,offset=0)
117
91
  end
118
92
  end
119
93
  for i in k..newvar.length
120
- for j in l..testvar.length-1
94
+
95
+ for j in l..(testvar.length-j_int_offset)
121
96
  newSheet.row(i+offset).push newvar[(i*testvar.length)+j]
122
97
  end
123
98
  if il_or_cc != ""
@@ -129,284 +104,54 @@ def printFile (newvar, testvar, output, il_or_cc, k=0, l=1,offset=0)
129
104
  end
130
105
  end
131
106
  end
132
- print "output file is in same file under out.xls to open, use \n \n open #{output}"
133
- print "\n"
107
+ if il_or_cc == ""
108
+ puts " |--> #{output[20..26]}"
109
+ else
110
+ puts "output file is in same file under out.xls to open, use \n \n open #{output}"
111
+ end
134
112
  newBook.write output
135
113
  end
136
114
 
137
115
  def com_separated_files (output)
138
- puts output
139
- labels = Array.new
140
- apl_array = Array.new
141
- ach_array = Array.new
142
- bbv_array = Array.new
143
- ccv_array = Array.new
144
- cci_array = Array.new
145
- dvf_array = Array.new
146
- eth_array = Array.new
147
- frv_array = Array.new
148
- gsv_array = Array.new
149
- hsd_array = Array.new
150
- lhn_array = Array.new
151
- lph_array = Array.new
152
- mgc_array = Array.new
153
- ocv_array = Array.new
154
- rwv_array = Array.new
155
- sbv_array = Array.new
156
- tck_array = Array.new
157
- wcd_array = Array.new
158
-
116
+ # puts output
117
+ com_data = {
118
+ 'com_codes' => ['apl', 'ach', 'bbv', 'ccv', 'cci', 'cwf', 'dvf', 'eth', 'frv', 'gsv', 'hsd', 'lhn', 'lph', 'mgc', 'ocv', 'rwv', 'sbv', 'tck', 'wcd'],
119
+ 'labels' => Array.new,
120
+ }
121
+ com_data['com_codes'].each do |code|
122
+ com_data[code] = Array.new
123
+ end
159
124
  original = Spreadsheet.open(output)
160
125
  original_sheet = original.worksheet(0)
161
126
 
162
-
163
127
  rowlength = original_sheet.row(0)
164
- puts rowlength.length
128
+ # puts rowlength.length
165
129
  # make a directory for the new files
166
130
  unless File.directory?("com_separated_files")
167
131
  %x(mkdir com_separated_files)
168
132
  end
169
133
  original_sheet.each do |row|
170
- if row[0] == "apl".upcase
171
-
172
- # print row to other array and print label to a community array
173
- row.each do |x|
174
- apl_array.push x
175
- end
176
- unless labels.include?("apl".upcase)
177
- labels.push "apl".upcase
178
- end
179
- end
180
- if row[0] == "ach".upcase
181
-
182
- # print row to other array and print label to a community array
183
- row.each do |x|
184
- ach_array.push x
185
- end
186
- unless labels.include?("ach".upcase)
187
- labels.push "ach".upcase
188
- end
189
- end
190
- if row[0] == "bbv".upcase
191
-
192
- # print row to other array and print label to a community array
193
- row.each do |x|
194
- bbv_array.push x
195
- end
196
- unless labels.include?("bbv".upcase)
197
- labels.push "bbv".upcase
198
- end
199
- end
200
- if row[0] == "ccv".upcase
201
-
202
- # print row to other array and print label to a community array
203
- row.each do |x|
204
- ccv_array.push x
205
- end
206
- unless labels.include?("ccv".upcase)
207
- labels.push "ccv".upcase
208
- end
209
- end
210
- if row[0] == "cci".upcase
211
-
212
- # print row to other array and print label to a community array
213
- row.each do |x|
214
- cci_array.push x
215
- end
216
- unless labels.include?("cci".upcase)
217
- labels.push "cci".upcase
218
- end
219
- end
220
- if row[0] == "dvf".upcase
221
-
222
- # print row to other array and print label to a community array
223
- row.each do |x|
224
- dvf_array.push x
225
- end
226
- unless labels.include?("dvf".upcase)
227
- labels.push "dvf".upcase
228
- end
229
- end
230
- if row[0] == "eth".upcase
231
-
232
- # print row to other array and print label to a community array
233
- row.each do |x|
234
- eth_array.push x
235
- end
236
- unless labels.include?("eth".upcase)
237
- labels.push "eth".upcase
238
- end
239
- end
240
- if row[0] == "frv".upcase
241
-
242
- # print row to other array and print label to a community array
243
- row.each do |x|
244
- frv_array.push x
245
- end
246
- unless labels.include?("frv".upcase)
247
- labels.push "frv".upcase
248
- end
249
- end
250
- if row[0] == "gsv".upcase
251
-
252
- # print row to other array and print label to a community array
253
- row.each do |x|
254
- gsv_array.push x
255
- end
256
- unless labels.include?("gsv".upcase)
257
- labels.push "gsv".upcase
258
- end
259
- end
260
- if row[0] == "hsd".upcase
261
-
262
- # print row to other array and print label to a community array
263
- row.each do |x|
264
- hsd_array.push x
265
- end
266
- unless labels.include?("hsd".upcase)
267
- labels.push "hsd".upcase
268
- end
269
- end
270
- if row[0] == "lhn".upcase
271
-
134
+ com_data['com_codes'].each do |code|
135
+ if row[0] == "#{code}".upcase
272
136
  # print row to other array and print label to a community array
273
- row.each do |x|
274
- lhn_array.push x
275
- end
276
- unless labels.include?("lhn".upcase)
277
- labels.push "lhn".upcase
278
- end
279
- end
280
- if row[0] == "lph".upcase
281
-
282
- # print row to other array and print label to a community array
283
- row.each do |x|
284
- lph_array.push x
285
- end
286
- unless labels.include?("lph".upcase)
287
- labels.push "lph".upcase
288
- end
289
- end
290
- if row[0] == "mgc".upcase
291
-
292
- # print row to other array and print label to a community array
293
- row.each do |x|
294
- mgc_array.push x
295
- end
296
- unless labels.include?("mgc".upcase)
297
- labels.push "mgc".upcase
298
- end
299
- end
300
- if row[0] == "ocv".upcase
301
-
302
- # print row to other array and print label to a community array
303
- row.each do |x|
304
- ocv_array.push x
305
- end
306
- unless labels.include?("ocv".upcase)
307
- labels.push "ocv".upcase
308
- end
309
- end
310
- if row[0] == "rwv".upcase
311
-
312
- # print row to other array and print label to a community array
313
- row.each do |x|
314
- rwv_array.push x
315
- end
316
- unless labels.include?("rwv".upcase)
317
- labels.push "rwv".upcase
318
- end
319
- end
320
- if row[0] == "sbv".upcase
321
-
322
- # print row to other array and print label to a community array
323
- row.each do |x|
324
- sbv_array.push x
325
- end
326
- unless labels.include?("sbv".upcase)
327
- labels.push "sbv".upcase
328
- end
329
- end
330
- if row[0] == "tck".upcase
331
-
332
- # print row to other array and print label to a community array
333
- row.each do |x|
334
- tck_array.push x
335
- end
336
- unless labels.include?("tck".upcase)
337
- labels.push "tck".upcase
338
- end
339
- end
340
- if row[0] == "wcd".upcase
341
-
342
- # print row to other array and print label to a community array
343
- row.each do |x|
344
- wcd_array.push x
345
- end
346
- unless labels.include?("wcd".upcase)
347
- labels.push "wcd".upcase
137
+ row.each do |x|
138
+ com_data[code].push x
139
+ end
140
+ unless com_data['labels'].include?("#{code}".upcase)
141
+ com_data['labels'].push "#{code}".upcase
142
+ end
348
143
  end
349
144
  end
350
145
  end
351
146
  print "creating files for these communities:\n".blue
352
- puts "#{labels}".blue
353
- print rowlength
354
- if apl_array.length > 0
355
- printFile(apl_array, rowlength, "com_separated_files/apl.xls", "", 0, 0,1)
356
- end
357
- if ach_array.length > 0
358
- printFile(ach_array, rowlength, "com_separated_files/ach.xls", "", 0, 0,1)
359
- end
360
- if bbv_array.length > 0
361
- printFile(bbv_array, rowlength, "com_separated_files/bbv.xls", "", 0, 0,1)
362
- end
363
- if ccv_array.length > 0
364
- printFile(ccv_array, rowlength, "com_separated_files/ccv.xls", "", 0, 0,1)
365
- end
366
- if cci_array.length > 0
367
- printFile(cci_array, rowlength, "com_separated_files/cci.xls", "", 0, 0,1)
368
- end
369
- if dvf_array.length > 0
370
- printFile(dvf_array, rowlength, "com_separated_files/dvf.xls", "", 0, 0,1)
371
- end
372
- if eth_array.length > 0
373
- printFile(eth_array, rowlength, "com_separated_files/eth.xls", "", 0, 0,1)
374
- end
375
- if frv_array.length > 0
376
- printFile(frv_array, rowlength, "com_separated_files/frv.xls", "", 0, 0,1)
377
- end
378
- if gsv_array.length > 0
379
- printFile(gsv_array, rowlength, "com_separated_files/gsv.xls", "", 0, 0,1)
380
- end
381
- if hsd_array.length > 0
382
- printFile(hsd_array, rowlength, "com_separated_files/hsd.xls", "", 0, 0,1)
383
- end
384
- if lhn_array.length > 0
385
- printFile(lhn_array, rowlength, "com_separated_files/lhn.xls", "", 0, 0,1)
386
- end
387
- if lph_array.length > 0
388
- printFile(lph_array, rowlength, "com_separated_files/lph.xls", "", 0, 0,1)
389
- end
390
- if mgc_array.length > 0
391
- printFile(mgc_array, rowlength, "com_separated_files/mgc.xls", "", 0, 0,1)
392
- end
393
- if ocv_array.length > 0
394
- printFile(ocv_array, rowlength, "com_separated_files/ocv.xls", "", 0, 0,1)
395
- end
396
- if rwv_array.length > 0
397
- printFile(rwv_array, rowlength, "com_separated_files/rwv.xls", "", 0, 0,1)
398
- end
399
- if sbv_array.length > 0
400
- printFile(sbv_array, rowlength, "com_separated_files/sbv.xls", "", 0, 0,1)
401
- end
402
- if tck_array.length > 0
403
- printFile(tck_array, rowlength, "com_separated_files/tck.xls", "", 0, 0,1)
404
- end
405
- if wcd_array.length > 0
406
- printFile(wcd_array, rowlength, "com_separated_files/wcd.xls", "", 0, 0,1)
147
+ puts "#{com_data['labels']}".blue
148
+ puts "you can see your files in this directory"
149
+ puts "../com_separated_files"
150
+ com_data['com_codes'].each do |code|
151
+ if com_data[code].length > 0
152
+ printFile(com_data[code], rowlength, "com_separated_files/#{code}.xls", "", 0, 0,1,1)
153
+ end
407
154
  end
408
-
409
-
410
155
  end
411
156
 
412
157
  # --------------------------------------------
@@ -414,18 +159,6 @@ end
414
159
  fileName = ARGV[0]
415
160
  sheetNum = ARGV[1].to_i-1
416
161
  output = ARGV[2]
417
- print "\n\n"
418
- print "Is this an email campaign for Continuing Care? (CC) [y/n]".yellow
419
-
420
- res = STDIN.gets.strip
421
- print "\n\n"
422
- if res == 'y' || res == 'Y'
423
- il_or_cc = 'CC'
424
- else
425
- il_or_cc = "IL"
426
- end
427
- print "Do you wish to create separate files based on community names?[y/n]".yellow
428
- comres= STDIN.gets.strip
429
162
 
430
163
  # --------------------------------------------
431
164
  # ASKING FOR HELP
@@ -458,7 +191,7 @@ if ARGV.length == 1 and ARGV[0] == "help"
458
191
  elsif ARGV.length == 1 and (ARGV[0] == "-v" or ARGV[0] == "-version" or ARGV[0] == "version")
459
192
  print "\n
460
193
  -------------------
461
- | VERSION | 0.2.1 |
194
+ | VERSION | 0.4.0 |
462
195
  -------------------
463
196
  "
464
197
  print "
@@ -476,7 +209,19 @@ elsif ARGV.length == 1 and ARGV[0] != "version" or ARGV[0] != "help" or ARGV[0]
476
209
  # line 68 catches any user input that relates to .xls files in the form of
477
210
  # prune-erickson yourfile.xls [digit] outputfile.xls
478
211
  if ARGV[0] =~ /\S+.xls\b/ and ARGV[1] =~ /\d/ and ARGV[2] =~ /\S+.xls\b/
479
-
212
+ print "\n\n"
213
+ print "Is this an email campaign for Continuing Care? (CC) [y/n]".yellow
214
+
215
+ res = STDIN.gets.strip
216
+ print "\n\n"
217
+ if res == 'y' || res == 'Y'
218
+ il_or_cc = 'CC'
219
+ else
220
+ il_or_cc = "IL"
221
+ end
222
+ print "Do you wish to create separate files based on community names?[y/n]".yellow
223
+ comres= STDIN.gets.strip
224
+
480
225
  Spreadsheet.client_encoding = 'UTF-8'
481
226
  print "~>reading file you have requested"
482
227
  print "\n"
@@ -501,10 +246,11 @@ elsif ARGV.length == 1 and ARGV[0] != "version" or ARGV[0] != "help" or ARGV[0]
501
246
  are you selecting the wrong one? \n".red
502
247
  else
503
248
  labelChecker(sheet1.row(0), testvar)
504
- fieldChecker(sheet1.row(0))
249
+ fieldChecker(sheet1.row(0),fields)
505
250
  processData(sheet1, newvar, testvar)
506
251
  printFile(newvar, testvar, output, il_or_cc)
507
252
  if comres == 'y' || comres == 'Y'
253
+
508
254
  com_separated_files(output)
509
255
  end
510
256
  end
@@ -516,6 +262,19 @@ elsif ARGV.length == 1 and ARGV[0] != "version" or ARGV[0] != "help" or ARGV[0]
516
262
  try locating the folder and inputing the correct path\n\n".red
517
263
  end
518
264
  elsif ARGV[0] =~ /\S+[.csv*]/ and ARGV[1] =~ /\S+.xls\b/
265
+ print "\n\n"
266
+ print "Is this an email campaign for Continuing Care? (CC) [y/n]".yellow
267
+
268
+ res = STDIN.gets.strip
269
+ print "\n\n"
270
+ if res == 'y' || res == 'Y'
271
+ il_or_cc = 'CC'
272
+ else
273
+ il_or_cc = "IL"
274
+ end
275
+ print "Do you wish to create separate files based on community names?[y/n]".yellow
276
+ comres= STDIN.gets.strip
277
+
519
278
  output = ARGV[1]
520
279
  if File.exist?(fileName)
521
280
  file_data = CSV.read(fileName)
@@ -530,7 +289,7 @@ elsif ARGV.length == 1 and ARGV[0] != "version" or ARGV[0] != "help" or ARGV[0]
530
289
  print "\n"
531
290
 
532
291
  labelChecker(file_data[0], testvar)
533
- fieldChecker(file_data[0])
292
+ fieldChecker(file_data[0],fields)
534
293
  processData(file_data, newvar, testvar)
535
294
  printFile(newvar, testvar, output, il_or_cc)
536
295
  if comres == 'y' || comres == 'Y'
@@ -552,6 +311,18 @@ elsif ARGV.length == 1 and ARGV[0] != "version" or ARGV[0] != "help" or ARGV[0]
552
311
  It looks like this file is in the wrong folder or does not exsist.
553
312
  try locating the folder and inputing the correct path\n\n".red
554
313
  else
314
+ print "\n\n"
315
+ print "Is this an email campaign for Continuing Care? (CC) [y/n]".yellow
316
+
317
+ res = STDIN.gets.strip
318
+ print "\n\n"
319
+ if res == 'y' || res == 'Y'
320
+ il_or_cc = 'CC'
321
+ else
322
+ il_or_cc = "IL"
323
+ end
324
+ print "Do you wish to create separate files based on community names?[y/n]".yellow
325
+ comres= STDIN.gets.strip
555
326
 
556
327
  xlsx = Roo::Spreadsheet.open(fileName)
557
328
  newBook = Spreadsheet::Workbook.new
@@ -570,7 +341,7 @@ elsif ARGV.length == 1 and ARGV[0] != "version" or ARGV[0] != "help" or ARGV[0]
570
341
  testvar = Array.new
571
342
  newvar = Array.new
572
343
  labelChecker(header, testvar)
573
- fieldChecker(header)
344
+ fieldChecker(header, fields)
574
345
  processData(xlsxSheet, newvar, testvar)
575
346
  printFile(newvar, testvar, output, il_or_cc)
576
347
  if comres == 'y' || comres == 'Y'
@@ -585,4 +356,4 @@ elsif ARGV.length == 1 and ARGV[0] != "version" or ARGV[0] != "help" or ARGV[0]
585
356
  prune-erickson help \n\n\n
586
357
  "
587
358
  end
588
- end
359
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prune-erickson
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alejandro Londono