prune-erickson 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/prune-erickson +133 -132
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ff7762770b7c681fdbd0a737b463684b1341e344
4
- data.tar.gz: 3e646c0ef4e49a477c21316aceff0179f3888591
3
+ metadata.gz: 4510d52eb40bda3fa258d64f1f3bff97ab117fa0
4
+ data.tar.gz: da9fe14ed126bf5ec839a78b94f653b95d12540c
5
5
  SHA512:
6
- metadata.gz: 9e804ae19263777bc32115388bb1d88770ff9a478d64a4b393e6b5f193b6128bbdba075b30f5bc98a225c281b8485924679acd9a0f3d1c80231f122c515a843e
7
- data.tar.gz: a0bfa9a11a44356b5f28c5248547ccc60f8e496aa64cda23e40de07d55a9fc422cbfdbe0e6da25e6425b378cb75c3cb8f094bfb7e1a14ad347d2bd3baa7681aa
6
+ metadata.gz: 86aabce24669f25b7b796f3a6db5bcc6a939938f0dfac557c486c1bffe3f6a91f728260d8b849c04c4c07c513f67b84ab5aac6de08eb9e501e88c3f5ab268f17
7
+ data.tar.gz: 9e02f8ed112fc9feb2dee674fc423c2d930f26058cf271d1d80fd837ea76735f40225b8f3c34cfef45ae054410a59e5c2044c8189ed9fc490c575ad6754196ff
data/bin/prune-erickson CHANGED
@@ -49,7 +49,7 @@ if ARGV.length == 1 and ARGV[0] == "help"
49
49
  elsif ARGV.length == 1 and (ARGV[0] == "-v" or ARGV[0] == "-version" or ARGV[0] == "version")
50
50
  print "\n
51
51
  -------------------
52
- | VERSION | 0.2.0 |
52
+ | VERSION | 0.2.1 |
53
53
  -------------------
54
54
  "
55
55
  print "
@@ -61,142 +61,13 @@ print "
61
61
  Stay tuned for the official release 1.0.0 which could be any
62
62
  day now.
63
63
  ".yellow
64
- elsif fileName =~ /\S+(.xlsx)/
65
-
66
- unless File.exist?(fileName)
67
- print "\n\n
68
- WHOOPS!!!
69
64
 
70
- It looks like this file is in the wrong folder or does not exsist.
71
- try locating the folder and inputing the correct path\n\n".red
72
- else
73
-
74
- xlsx = Roo::Spreadsheet.open(fileName)
75
- newBook = Spreadsheet::Workbook.new
76
- newSheet = newBook.create_worksheet
77
- if xlsx.sheet(sheetNum) == nil
78
- print "\n
79
- (_(T__T)_/ \n\n
80
- this sheet seems to be empty...
81
- are you selecting the wrong one? \n".red
82
- else
83
- newSheet.name = "output"
84
- header = xlsx.sheet(sheetNum).row(1)
85
- # take first row, and loop through the items in the array
86
- # sort indexes that are not necessary in the array
87
- testvar = Array.new
88
- header.each_with_index{|val, index|
89
- unless val != "OppCommunity" and val !="FirstName" and val != "LastName" and val != "Address" and val!="City" and val != "State" and val != "Zipcode" and val != "Phone" and val != "Email" and val != "ILorCC"
90
- testvar.push(index)
91
- end
92
- }
93
-
94
- # check for missing necessary information
95
- unless header.include? "OppCommunity"
96
- print "you are missing the OppCommunity field\n".yellow.blink
97
- else
98
-
99
- end
100
- unless header.include? "FirstName"
101
- print "you are missing the FirstName field\n".yellow.blink
102
- end
103
- unless header.include? "LastName"
104
- print "you are missing the LastName field\n".yellow.blink
105
- end
106
- unless header.include? "Phone"
107
- print "you are missing the phone field\n".yellow.blink
108
- end
109
- unless header.include? "Address"
110
- print "you are missing the Address field\n".yellow.blink
111
- end
112
- unless header.include? "City"
113
- print "you are missing the City field\n".yellow.blink
114
- end
115
- unless header.include? "State"
116
- print "you are missing the State field\n".yellow.blink
117
- end
118
- unless header.include? "Zipcode"
119
- print "you are missing the Zipcode field\n".yellow.blink
120
- end
121
- unless header.include? "Address"
122
- print "you are missing the Address field\n".yellow.blink
123
- end
124
- unless header.include? "Address"
125
- print "you are missing the Address field\n".yellow.blink
126
- end
127
- unless header.include? "Email"
128
- print "you are missing the Email field\n".yellow.blink
129
- end
130
-
131
- # puts testvar
132
- newvar = Array.new
133
- newvar.push "zero"
134
- xlsx.sheet(sheetNum).each do |row|
135
- row.each_with_index {|val, index|
136
- if testvar.include? index
137
-
138
- newvar.push val
139
- end
140
- }
141
- end
142
- print "~~>writing new file \n\n"
143
-
144
- newvar.map! { |x|
145
-
146
- if x == "OppCommunity"
147
- print "renaming field #{x} \n".colorize(:light_blue)
148
- x = "Community of Interest"
149
- elsif x == "FirstName"
150
- print "renaming field #{x} \n".colorize(:light_blue)
151
- x = "First Name"
152
- elsif x == "LastName"
153
- print "renaming field #{x} \n".colorize(:light_blue)
154
- x = "Last Name"
155
- elsif x == "Address"
156
- print "renaming field #{x} \n".colorize(:light_blue)
157
- x = "Address 1"
158
- elsif x == "city"
159
- print "renaming field #{x} \n".colorize(:light_blue)
160
- x = "city"
161
- elsif x == "State"
162
- print "renaming field #{x} \n".colorize(:light_blue)
163
- x = "State or Province"
164
- elsif x == "Zipcode"
165
- print "renaming field #{x} \n".colorize(:light_blue)
166
- x = "Zip or Postal Code"
167
- elsif x == "Email"
168
- print "renaming field #{x} \n".colorize(:light_blue)
169
- x = "Email Address"
170
- elsif x == "Phone"
171
- print "renaming field #{x} \n".colorize(:light_blue)
172
- x = "Home Phone"
173
- else
174
- x=x
175
- end
176
- }
177
- for i in 0..newvar.length
178
- for j in 1..testvar.length
179
-
180
-
181
- newSheet.row(i).push newvar[(i*testvar.length)+j]
182
- end
183
- if i > 0
184
- newSheet.row(i).push "IL"
185
- else
186
- newSheet.row(i).push "ILorCC"
187
- end
188
- end
189
- print "output file is in same file under out.xls to open, use \n \n open #{output}"
190
- print "\n"
191
- newBook.write output
192
- end
193
- end
194
65
  elsif ARGV.length == 1 and ARGV[0] != "version" or ARGV[0] != "help" or ARGV[0] != '-version' or ARGV[0] != "-v"
195
66
  # if ~~~> catch different files and options before running code to check for errors.
196
67
  # \S+[.xls*] this is a regex for the xls input and output files
197
68
  # \s\S\s to pick up the index number
198
69
  # I should also check that book is not nil
199
- if ARGV[0] =~ /\S+[.xls*]/ and ARGV[1] =~ /\d/ and ARGV[2] =~ /\S+[.xls*]/
70
+ if ARGV[0] =~ /\S+.xls\b/ and ARGV[1] =~ /\d/ and ARGV[2] =~ /\S+.xls\b/
200
71
  # --------------------------------------------
201
72
  Spreadsheet.client_encoding = 'UTF-8'
202
73
  print "~>reading file you have requested"
@@ -333,7 +204,7 @@ elsif ARGV.length == 1 and ARGV[0] != "version" or ARGV[0] != "help" or ARGV[0]
333
204
  It looks like this file is in the wrong folder or does not exsist.
334
205
  try locating the folder and inputing the correct path\n\n".red
335
206
  end
336
- elsif ARGV[0] =~ /\S+[.csv*]/ and ARGV[1] =~ /\S+[.xls*]/
207
+ elsif ARGV[0] =~ /\S+[.csv*]/ and ARGV[1] =~ /\S+.xls\b/
337
208
  output = ARGV[1]
338
209
  if File.exist?(fileName)
339
210
  file_data = CSV.read(fileName)
@@ -459,6 +330,136 @@ elsif ARGV.length == 1 and ARGV[0] != "version" or ARGV[0] != "help" or ARGV[0]
459
330
  It looks like this file is in the wrong folder or does not exsist.
460
331
  try locating the folder and inputing the correct path\n\n".red
461
332
  end
333
+ elsif fileName =~ /\S+.xlsx/ and ARGV[1] =~ /\d/ and ARGV[2] =~ /\S+.xls\b/
334
+
335
+ unless File.exist?(fileName)
336
+ print "\n\n
337
+ WHOOPS!!!
338
+
339
+ It looks like this file is in the wrong folder or does not exsist.
340
+ try locating the folder and inputing the correct path\n\n".red
341
+ else
342
+
343
+ xlsx = Roo::Spreadsheet.open(fileName)
344
+ newBook = Spreadsheet::Workbook.new
345
+ newSheet = newBook.create_worksheet
346
+ if xlsx.sheet(sheetNum) == nil
347
+ print "\n
348
+ (_(T__T)_/ \n\n
349
+ this sheet seems to be empty...
350
+ are you selecting the wrong one? \n".red
351
+ else
352
+ newSheet.name = "output"
353
+ header = xlsx.sheet(sheetNum).row(1)
354
+ # take first row, and loop through the items in the array
355
+ # sort indexes that are not necessary in the array
356
+ testvar = Array.new
357
+ header.each_with_index{|val, index|
358
+ unless val != "OppCommunity" and val !="FirstName" and val != "LastName" and val != "Address" and val!="City" and val != "State" and val != "Zipcode" and val != "Phone" and val != "Email" and val != "ILorCC"
359
+ testvar.push(index)
360
+ end
361
+ }
362
+
363
+ # check for missing necessary information
364
+ unless header.include? "OppCommunity"
365
+ print "you are missing the OppCommunity field\n".yellow.blink
366
+ else
367
+
368
+ end
369
+ unless header.include? "FirstName"
370
+ print "you are missing the FirstName field\n".yellow.blink
371
+ end
372
+ unless header.include? "LastName"
373
+ print "you are missing the LastName field\n".yellow.blink
374
+ end
375
+ unless header.include? "Phone"
376
+ print "you are missing the phone field\n".yellow.blink
377
+ end
378
+ unless header.include? "Address"
379
+ print "you are missing the Address field\n".yellow.blink
380
+ end
381
+ unless header.include? "City"
382
+ print "you are missing the City field\n".yellow.blink
383
+ end
384
+ unless header.include? "State"
385
+ print "you are missing the State field\n".yellow.blink
386
+ end
387
+ unless header.include? "Zipcode"
388
+ print "you are missing the Zipcode field\n".yellow.blink
389
+ end
390
+ unless header.include? "Address"
391
+ print "you are missing the Address field\n".yellow.blink
392
+ end
393
+ unless header.include? "Address"
394
+ print "you are missing the Address field\n".yellow.blink
395
+ end
396
+ unless header.include? "Email"
397
+ print "you are missing the Email field\n".yellow.blink
398
+ end
399
+
400
+ # puts testvar
401
+ newvar = Array.new
402
+ newvar.push "zero"
403
+ xlsx.sheet(sheetNum).each do |row|
404
+ row.each_with_index {|val, index|
405
+ if testvar.include? index
406
+
407
+ newvar.push val
408
+ end
409
+ }
410
+ end
411
+ print "~~>writing new file \n\n"
412
+
413
+ newvar.map! { |x|
414
+
415
+ if x == "OppCommunity"
416
+ print "renaming field #{x} \n".colorize(:light_blue)
417
+ x = "Community of Interest"
418
+ elsif x == "FirstName"
419
+ print "renaming field #{x} \n".colorize(:light_blue)
420
+ x = "First Name"
421
+ elsif x == "LastName"
422
+ print "renaming field #{x} \n".colorize(:light_blue)
423
+ x = "Last Name"
424
+ elsif x == "Address"
425
+ print "renaming field #{x} \n".colorize(:light_blue)
426
+ x = "Address 1"
427
+ elsif x == "city"
428
+ print "renaming field #{x} \n".colorize(:light_blue)
429
+ x = "city"
430
+ elsif x == "State"
431
+ print "renaming field #{x} \n".colorize(:light_blue)
432
+ x = "State or Province"
433
+ elsif x == "Zipcode"
434
+ print "renaming field #{x} \n".colorize(:light_blue)
435
+ x = "Zip or Postal Code"
436
+ elsif x == "Email"
437
+ print "renaming field #{x} \n".colorize(:light_blue)
438
+ x = "Email Address"
439
+ elsif x == "Phone"
440
+ print "renaming field #{x} \n".colorize(:light_blue)
441
+ x = "Home Phone"
442
+ else
443
+ x=x
444
+ end
445
+ }
446
+ for i in 0..newvar.length
447
+ for j in 1..testvar.length
448
+
449
+
450
+ newSheet.row(i).push newvar[(i*testvar.length)+j]
451
+ end
452
+ if i > 0
453
+ newSheet.row(i).push "IL"
454
+ else
455
+ newSheet.row(i).push "ILorCC"
456
+ end
457
+ end
458
+ print "output file is in same file under out.xls to open, use \n \n open #{output}"
459
+ print "\n"
460
+ newBook.write output
461
+ end
462
+ end
462
463
  else
463
464
  print "\n
464
465
  Are you trying to use PRUNE?
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.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alejandro Londono