prune-erickson 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/prune-erickson +136 -5
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 987fedff6b3405b97f7e23d16d81f357a680005e
|
4
|
+
data.tar.gz: dacc237a294d45c507b96c340b0409832ed263fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 663029e33b7d15dfd4f4b9d86b2ae0d5423f44a72a9862daa5e351f0d6eb7bfe11bcbfc272e02532f15b2d5d3efb7a569a7c3b6988c3621b60861d37a4c0c731
|
7
|
+
data.tar.gz: 55a871c81b89d656de2808757606b9befbdc8f2e01be2aa10fb479bf331cdac29217906f43c452d2e5ce34a31a4ef0a6dacfbab5b815e95e691cb26223b9a5c8
|
data/bin/prune-erickson
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'spreadsheet'
|
4
|
+
require "csv"
|
4
5
|
require 'colorize'
|
5
6
|
|
6
7
|
# --------------------------------------------
|
@@ -35,14 +36,18 @@ if ARGV.length == 1 and ARGV[0] == "help"
|
|
35
36
|
\ `. /
|
36
37
|
| |
|
37
38
|
| | \n\n\n".colorize(:light_blue)
|
38
|
-
|
39
|
+
puts "to edit a file use this format:"
|
40
|
+
puts "FOR .xls \n".yellow
|
39
41
|
|
40
|
-
prune-erickson [filename.xls (string)] [sheet-number (number)] [output.xls (string)]\n\n\n
|
41
|
-
"
|
42
|
+
puts "prune-erickson [filename.xls (string)] [sheet-number (number)] [output.xls (string)]\n\n\n"
|
43
|
+
puts "FOR .csv \n".yellow
|
44
|
+
puts "prune-erickson [filename.csv (string)] [output.xls (string)]\n\n\n"
|
45
|
+
puts "Make sure to cd into your correct directory where the file is located.
|
46
|
+
the output file will be in the same directory \n\n\n".yellow
|
42
47
|
elsif ARGV.length == 1 and (ARGV[0] == "-v" or ARGV[0] == "-version" or ARGV[0] == "version")
|
43
48
|
print "\n
|
44
49
|
-------------------
|
45
|
-
| VERSION | 0.0
|
50
|
+
| VERSION | 0.1.0 |
|
46
51
|
-------------------
|
47
52
|
"
|
48
53
|
print "
|
@@ -60,7 +65,7 @@ elsif ARGV.length == 1 and ARGV[0] != "version" or ARGV[0] != "help" or ARGV[0]
|
|
60
65
|
# \s\S\s to pick up the index number
|
61
66
|
# I should also check that book is not nil
|
62
67
|
if ARGV[0] =~ /\S+[.xls*]/ and ARGV[1] =~ /\d/ and ARGV[2] =~ /\S+[.xls*]/
|
63
|
-
|
68
|
+
# --------------------------------------------
|
64
69
|
Spreadsheet.client_encoding = 'UTF-8'
|
65
70
|
print "~>reading file you have requested"
|
66
71
|
print "\n"
|
@@ -193,6 +198,132 @@ elsif ARGV.length == 1 and ARGV[0] != "version" or ARGV[0] != "help" or ARGV[0]
|
|
193
198
|
print "\n\n
|
194
199
|
WHOOPS!!!
|
195
200
|
|
201
|
+
It looks like this file is in the wrong folder or does not exsist.
|
202
|
+
try locating the folder and inputing the correct path\n\n".red
|
203
|
+
end
|
204
|
+
elsif ARGV[0] =~ /\S+[.csv*]/ and ARGV[1] =~ /\S+[.xls*]/
|
205
|
+
output = ARGV[1]
|
206
|
+
if File.exist?(fileName)
|
207
|
+
file_data = CSV.read(fileName)
|
208
|
+
newBook = Spreadsheet::Workbook.new
|
209
|
+
newSheet = newBook.create_worksheet
|
210
|
+
|
211
|
+
newSheet.name = "output"
|
212
|
+
|
213
|
+
testvar = Array.new
|
214
|
+
|
215
|
+
print "~>looking for unnecessary information"
|
216
|
+
print "\n"
|
217
|
+
|
218
|
+
file_data[0].each_with_index{|val, index|
|
219
|
+
|
220
|
+
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"
|
221
|
+
testvar.push(index)
|
222
|
+
end
|
223
|
+
}
|
224
|
+
|
225
|
+
unless file_data[0].include? "OppCommunity"
|
226
|
+
print "you are missing the OppCommunity field\n".yellow.blink
|
227
|
+
else
|
228
|
+
|
229
|
+
end
|
230
|
+
unless file_data[0].include? "FirstName"
|
231
|
+
print "you are missing the FirstName field\n".yellow.blink
|
232
|
+
end
|
233
|
+
unless file_data[0].include? "LastName"
|
234
|
+
print "you are missing the LastName field\n".yellow.blink
|
235
|
+
end
|
236
|
+
unless file_data[0].include? "Phone"
|
237
|
+
print "you are missing the phone field\n".yellow.blink
|
238
|
+
end
|
239
|
+
unless file_data[0].include? "Address"
|
240
|
+
print "you are missing the Address field\n".yellow.blink
|
241
|
+
end
|
242
|
+
unless file_data[0].include? "City"
|
243
|
+
print "you are missing the City field\n".yellow.blink
|
244
|
+
end
|
245
|
+
unless file_data[0].include? "State"
|
246
|
+
print "you are missing the State field\n".yellow.blink
|
247
|
+
end
|
248
|
+
unless file_data[0].include? "Zipcode"
|
249
|
+
print "you are missing the Zipcode field\n".yellow.blink
|
250
|
+
end
|
251
|
+
unless file_data[0].include? "Address"
|
252
|
+
print "you are missing the Address field\n".yellow.blink
|
253
|
+
end
|
254
|
+
unless file_data[0].include? "Address"
|
255
|
+
print "you are missing the Address field\n".yellow.blink
|
256
|
+
end
|
257
|
+
unless file_data[0].include? "Email"
|
258
|
+
print "you are missing the Email field\n".yellow.blink
|
259
|
+
end
|
260
|
+
# puts testvar
|
261
|
+
newvar = Array.new
|
262
|
+
newvar.push "zero"
|
263
|
+
file_data.each do |row|
|
264
|
+
row.each_with_index {|val, index|
|
265
|
+
if testvar.include? index
|
266
|
+
|
267
|
+
newvar.push val
|
268
|
+
end
|
269
|
+
}
|
270
|
+
end
|
271
|
+
print "~~>writing new file \n\n"
|
272
|
+
|
273
|
+
newvar.map! { |x|
|
274
|
+
|
275
|
+
if x == "OppCommunity"
|
276
|
+
print "renaming field #{x} \n".colorize(:light_blue)
|
277
|
+
x = "Community of Interest"
|
278
|
+
elsif x == "FirstName"
|
279
|
+
print "renaming field #{x} \n".colorize(:light_blue)
|
280
|
+
x = "First Name"
|
281
|
+
elsif x == "LastName"
|
282
|
+
print "renaming field #{x} \n".colorize(:light_blue)
|
283
|
+
x = "Last Name"
|
284
|
+
elsif x == "Address"
|
285
|
+
print "renaming field #{x} \n".colorize(:light_blue)
|
286
|
+
x = "Address 1"
|
287
|
+
elsif x == "city"
|
288
|
+
print "renaming field #{x} \n".colorize(:light_blue)
|
289
|
+
x = "city"
|
290
|
+
elsif x == "State"
|
291
|
+
print "renaming field #{x} \n".colorize(:light_blue)
|
292
|
+
x = "State or Province"
|
293
|
+
elsif x == "Zipcode"
|
294
|
+
print "renaming field #{x} \n".colorize(:light_blue)
|
295
|
+
x = "Zip or Postal Code"
|
296
|
+
elsif x == "Email"
|
297
|
+
print "renaming field #{x} \n".colorize(:light_blue)
|
298
|
+
x = "Email Address"
|
299
|
+
elsif x == "Phone"
|
300
|
+
print "renaming field #{x} \n".colorize(:light_blue)
|
301
|
+
x = "Home Phone"
|
302
|
+
else
|
303
|
+
x=x
|
304
|
+
end
|
305
|
+
}
|
306
|
+
# print newvar
|
307
|
+
for i in 0..newvar.length
|
308
|
+
for j in 1..testvar.length
|
309
|
+
|
310
|
+
|
311
|
+
newSheet.row(i).push newvar[(i*testvar.length)+j]
|
312
|
+
end
|
313
|
+
if i > 0
|
314
|
+
newSheet.row(i).push "IL"
|
315
|
+
else
|
316
|
+
newSheet.row(i).push "ILorCC"
|
317
|
+
end
|
318
|
+
end
|
319
|
+
print "output file is in same file under out.xls to open, use \n \n open #{output}"
|
320
|
+
print "\n"
|
321
|
+
newBook.write output
|
322
|
+
|
323
|
+
else
|
324
|
+
print "\n\n
|
325
|
+
WHOOPS!!!
|
326
|
+
|
196
327
|
It looks like this file is in the wrong folder or does not exsist.
|
197
328
|
try locating the folder and inputing the correct path\n\n".red
|
198
329
|
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.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alejandro Londono
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 1.0.7
|
23
|
-
type: :
|
23
|
+
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: 0.7.7
|
43
|
-
type: :
|
43
|
+
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|