prune-erickson 0.1.0 → 0.2.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.
- checksums.yaml +4 -4
- data/bin/prune-erickson +135 -3
- metadata +21 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff7762770b7c681fdbd0a737b463684b1341e344
|
4
|
+
data.tar.gz: 3e646c0ef4e49a477c21316aceff0179f3888591
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e804ae19263777bc32115388bb1d88770ff9a478d64a4b393e6b5f193b6128bbdba075b30f5bc98a225c281b8485924679acd9a0f3d1c80231f122c515a843e
|
7
|
+
data.tar.gz: a0bfa9a11a44356b5f28c5248547ccc60f8e496aa64cda23e40de07d55a9fc422cbfdbe0e6da25e6425b378cb75c3cb8f094bfb7e1a14ad347d2bd3baa7681aa
|
data/bin/prune-erickson
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
2
|
+
require 'roo'
|
3
3
|
require 'spreadsheet'
|
4
4
|
require "csv"
|
5
5
|
require 'colorize'
|
6
|
+
# require 'fileUtils'
|
7
|
+
|
6
8
|
|
7
9
|
# --------------------------------------------
|
8
10
|
# GRABS INFORMATION FROM COMMAND LINE AND MAKES DATA AVAILABLE FOR PROGRAM
|
@@ -47,7 +49,7 @@ if ARGV.length == 1 and ARGV[0] == "help"
|
|
47
49
|
elsif ARGV.length == 1 and (ARGV[0] == "-v" or ARGV[0] == "-version" or ARGV[0] == "version")
|
48
50
|
print "\n
|
49
51
|
-------------------
|
50
|
-
| VERSION | 0.
|
52
|
+
| VERSION | 0.2.0 |
|
51
53
|
-------------------
|
52
54
|
"
|
53
55
|
print "
|
@@ -59,6 +61,136 @@ print "
|
|
59
61
|
Stay tuned for the official release 1.0.0 which could be any
|
60
62
|
day now.
|
61
63
|
".yellow
|
64
|
+
elsif fileName =~ /\S+(.xlsx)/
|
65
|
+
|
66
|
+
unless File.exist?(fileName)
|
67
|
+
print "\n\n
|
68
|
+
WHOOPS!!!
|
69
|
+
|
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
|
62
194
|
elsif ARGV.length == 1 and ARGV[0] != "version" or ARGV[0] != "help" or ARGV[0] != '-version' or ARGV[0] != "-v"
|
63
195
|
# if ~~~> catch different files and options before running code to check for errors.
|
64
196
|
# \S+[.xls*] this is a regex for the xls input and output files
|
@@ -71,7 +203,7 @@ elsif ARGV.length == 1 and ARGV[0] != "version" or ARGV[0] != "help" or ARGV[0]
|
|
71
203
|
print "\n"
|
72
204
|
# reads file
|
73
205
|
|
74
|
-
if File.exist?(fileName)
|
206
|
+
if File.exist?(fileName.to_s)
|
75
207
|
book = Spreadsheet.open fileName
|
76
208
|
sheet1 = book.worksheet sheetNum
|
77
209
|
newBook = Spreadsheet::Workbook.new
|
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.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alejandro Londono
|
@@ -50,6 +50,26 @@ dependencies:
|
|
50
50
|
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: 0.7.7
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: roo
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '2.1'
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 2.1.1
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '2.1'
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 2.1.1
|
53
73
|
description: An excel processing script to remove erroneous data
|
54
74
|
email: alejandro.londono@erickson.com
|
55
75
|
executables:
|