prune-erickson 0.0.2 → 0.0.3

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/prune-erickson +141 -119
  3. metadata +21 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5b58440e742b79b1f8af460a8f642adb48ee2f5f
4
- data.tar.gz: 29d4af0e353050a5c0bbd372b35d12373b55ea3b
3
+ metadata.gz: 0764deb0a204a83b4ed2a1f1b689348cf61461ab
4
+ data.tar.gz: 9d22ed53859ca4d9168e7d23261ffc8190aae7c8
5
5
  SHA512:
6
- metadata.gz: 25a37a4daa446f5bd82e7469a8169d5acad6935a853ec46bb199a41fd22beaa251c7bafa83d79f739e008079d8d81313121a4591f81677414cc0f930c4522005
7
- data.tar.gz: f183396d625c7a144c688c64689d8b6e4e677d7dff6e8dcc3141580615ce68204256a1d6ea340877689fdf6cb272b38e7cf45dfefc50e68b73863ead2c5cdcd9
6
+ metadata.gz: c9626ba2ca84e98c745824dc22eb216567f388aff2604d8e7726697a33ceae1430026637c6b6af0b22e7eaa0f4a2989851b2a4d6be8347800769decd2a31d71a
7
+ data.tar.gz: 5767bb307f628a7408ce8ac3285e3e7aa4be404a661716af4b3233d21592dd519dc564c58745843d1afb27e32d57c895732e7969def4e052d72c15f463f6404a
data/bin/prune-erickson CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'spreadsheet'
4
-
4
+ require 'colorize'
5
5
 
6
6
  # --------------------------------------------
7
7
  # GRABS INFORMATION FROM COMMAND LINE AND MAKES DATA AVAILABLE FOR PROGRAM
@@ -19,7 +19,8 @@ print "\n\n"
19
19
  # ASKING FOR HELP
20
20
  if ARGV.length == 1 and ARGV[0] == "help"
21
21
  print "
22
- THANK YOU FOR USING PRUNE!! /_(O__O)_/
22
+ THANK YOU FOR USING PRUNE!! /_(O__O)_/"
23
+ print "
23
24
  \n
24
25
  .. ...
25
26
  | | / /
@@ -33,17 +34,18 @@ if ARGV.length == 1 and ARGV[0] == "help"
33
34
  ( ' \ '- |
34
35
  \ `. /
35
36
  | |
36
- | | \n\n\n
37
- to edit a file use this format:
37
+ | | \n\n\n".colorize(:light_blue)
38
+ print "to edit a file use this format:
38
39
 
39
40
  prune-erickson [filename.xls (string)] [sheet-number (number)] [output.xls (string)]\n\n\n\n
40
41
  "
41
42
  elsif ARGV.length == 1 and (ARGV[0] == "-v" or ARGV[0] == "-version" or ARGV[0] == "version")
42
43
  print "\n
43
44
  -------------------
44
- | VERSION | 0.0.2 |
45
+ | VERSION | 0.0.3 |
45
46
  -------------------
46
-
47
+ "
48
+ print "
47
49
  ~~~~~~~THIS SOFTWARE IS IN ACTIVE DEVELOPMENT~~~~~
48
50
  Keep in mind that this project is 0.0.* and is still
49
51
  continuously being updated and user tested.
@@ -51,126 +53,146 @@ elsif ARGV.length == 1 and (ARGV[0] == "-v" or ARGV[0] == "-version" or ARGV[0]
51
53
 
52
54
  Stay tuned for the official release 1.0.0 which could be any
53
55
  day now.
54
- "
55
- elsif ARGV[0] != "version" or ARGV[0] != "help" or ARGV[0] != '-version' or ARGV[0] != "-v"
56
- print "\n
57
- Are you trying to use PRUNE?
58
- why dont you try this command:\n\n
59
- prune-erickson help \n\n\n
60
- "
61
- else
62
- # --------------------------------------------
63
- Spreadsheet.client_encoding = 'UTF-8'
64
- print "~>reading file you have requested"
65
- print "\n"
66
- # reads file
67
- book = Spreadsheet.open fileName
68
- sheet1 = book.worksheet sheetNum
56
+ ".yellow
57
+ elsif ARGV.length == 1 and ARGV[0] != "version" or ARGV[0] != "help" or ARGV[0] != '-version' or ARGV[0] != "-v"
58
+ # if ~~~> catch different files and options before running code to check for errors.
59
+ # \S+[.xls*] this is a regex for the xls input and output files
60
+ # \s\S\s to pick up the index number
61
+ # I should also check that book is not nil
62
+ if ARGV[0] =~ /\S+[.xls*]/ and ARGV[1] =~ /\d/ and ARGV[2] =~ /\S+[.xls*]/
63
+ # --------------------------------------------
64
+ Spreadsheet.client_encoding = 'UTF-8'
65
+ print "~>reading file you have requested"
66
+ print "\n"
67
+ # reads file
69
68
 
70
- print '\n'
71
- newBook = Spreadsheet::Workbook.new
72
- newSheet = newBook.create_worksheet
69
+ if File.exist?(fileName)
70
+ book = Spreadsheet.open fileName
71
+ sheet1 = book.worksheet sheetNum
72
+ newBook = Spreadsheet::Workbook.new
73
+ newSheet = newBook.create_worksheet
73
74
 
74
- newSheet.name = "output"
75
+ newSheet.name = "output"
75
76
 
76
- testvar = Array.new
77
+ testvar = Array.new
78
+
79
+ print "~>looking for unnecessary information"
80
+ print "\n"
81
+ if sheet1 == nil
82
+ print "\n
83
+ (_(T__T)_/ \n\n
84
+ this sheet seems to be empty...
85
+ are you selecting the wrong one? \n".red
86
+ else
87
+ sheet1.row(0).each_with_index{|val, index|
77
88
 
78
- print "~>looking for unnecessary information"
79
- print "\n"
80
- sheet1.row(0).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
+ }
81
93
 
82
- 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"
83
- testvar.push(index)
84
- end
85
- }
94
+ unless sheet1.row(0).include? "OppCommunity"
95
+ print "you are missing the OppCommunity field\n".yellow.blink
96
+ else
86
97
 
87
- unless sheet1.row(0).include? "OppCommunity"
88
- print "you are missing the OppCommunity field\n".upcase
89
- else
98
+ end
99
+ unless sheet1.row(0).include? "FirstName"
100
+ print "you are missing the FirstName field\n".yellow.blink
101
+ end
102
+ unless sheet1.row(0).include? "LastName"
103
+ print "you are missing the LastName field\n".yellow.blink
104
+ end
105
+ unless sheet1.row(0).include? "Phone"
106
+ print "you are missing the phone field\n".yellow.blink
107
+ end
108
+ unless sheet1.row(0).include? "Address"
109
+ print "you are missing the Address field\n".yellow.blink
110
+ end
111
+ unless sheet1.row(0).include? "City"
112
+ print "you are missing the City field\n".yellow.blink
113
+ end
114
+ unless sheet1.row(0).include? "State"
115
+ print "you are missing the State field\n".yellow.blink
116
+ end
117
+ unless sheet1.row(0).include? "Zipcode"
118
+ print "you are missing the Zipcode field\n".yellow.blink
119
+ end
120
+ unless sheet1.row(0).include? "Address"
121
+ print "you are missing the Address field\n".yellow.blink
122
+ end
123
+ unless sheet1.row(0).include? "Address"
124
+ print "you are missing the Address field\n".yellow.blink
125
+ end
126
+ unless sheet1.row(0).include? "Email"
127
+ print "you are missing the Email field\n".yellow.blink
128
+ end
129
+ # puts testvar
130
+ newvar = Array.new
131
+ newvar.push "zero"
132
+ sheet1.each do |row|
133
+ row.each_with_index {|val, index|
134
+ if testvar.include? index
135
+
136
+ newvar.push val
137
+ end
138
+ }
139
+ end
140
+ print "~~>writing new file \n\n"
141
+ # print newvar
142
+ newvar.map! { |x|
90
143
 
91
- end
92
- unless sheet1.row(0).include? "FirstName"
93
- print "you are missing the FirstName field\n".upcase
94
- end
95
- unless sheet1.row(0).include? "LastName"
96
- print "you are missing the LastName field\n".upcase
97
- end
98
- unless sheet1.row(0).include? "Phone"
99
- print "you are missing the phone field\n".upcase
100
- end
101
- unless sheet1.row(0).include? "Address"
102
- print "you are missing the Address field\n".upcase
103
- end
104
- unless sheet1.row(0).include? "City"
105
- print "you are missing the City field\n".upcase
106
- end
107
- unless sheet1.row(0).include? "State"
108
- print "you are missing the State field\n".upcase
109
- end
110
- unless sheet1.row(0).include? "Zipcode"
111
- print "you are missing the Zipcode field\n".upcase
112
- end
113
- unless sheet1.row(0).include? "Address"
114
- print "you are missing the Address field\n".upcase
115
- end
116
- unless sheet1.row(0).include? "Address"
117
- print "you are missing the Address field\n".upcase
118
- end
119
- unless sheet1.row(0).include? "Email"
120
- print "you are missing the Email field\n".upcase
121
- end
122
- # puts testvar
123
- newvar = Array.new
124
- newvar.push "zero"
125
- sheet1.each do |row|
126
- row.each_with_index {|val, index|
127
- if testvar.include? index
128
-
129
- newvar.push val
144
+ if x == "OppCommunity"
145
+ print "renaming field #{x} \n".colorize(:light_blue)
146
+ x = "Community"
147
+ elsif x == "FirstName"
148
+ print "renaming field #{x} \n".colorize(:light_blue)
149
+ x = "First Name"
150
+ elsif x == "LastName"
151
+ print "renaming field #{x} \n".colorize(:light_blue)
152
+ x = "Last Name"
153
+ elsif x == "Address"
154
+ print "renaming field #{x} \n".colorize(:light_blue)
155
+ x = "Address"
156
+ elsif x == "city"
157
+ print "renaming field #{x} \n".colorize(:light_blue)
158
+ x = "city"
159
+ elsif x == "State"
160
+ print "renaming field #{x} \n".colorize(:light_blue)
161
+ x = "State"
162
+ elsif x == "Zipcode"
163
+ print "renaming field #{x} \n".colorize(:light_blue)
164
+ x = "Zipcode"
165
+ elsif x == "Email"
166
+ print "renaming field #{x} \n".colorize(:light_blue)
167
+ x = "Email"
168
+ else
169
+ x=x
170
+ end
171
+ }
172
+ # print newvar
173
+ for i in 0..newvar.length
174
+ for j in 1..testvar.length
175
+
176
+
177
+ newSheet.row(i).push newvar[(i*testvar.length)+j]
178
+ end
179
+ end
180
+ print "output file is in same file under out.xls to open, use \n \n open #{output}"
181
+ print "\n"
182
+ newBook.write output
130
183
  end
131
- }
132
- end
133
- print "~~>writing new file \n\n"
134
- # print newvar
135
- newvar.map! { |x|
136
-
137
- if x == "OppCommunity"
138
- print "renaming field #{x} \n"
139
- x = "Community"
140
- elsif x == "FirstName"
141
- print "renaming field #{x} \n"
142
- x = "First Name"
143
- elsif x == "LastName"
144
- print "renaming field #{x} \n"
145
- x = "Last Name"
146
- elsif x == "Address"
147
- print "renaming field #{x} \n"
148
- x = "Address"
149
- elsif x == "city"
150
- print "renaming field #{x} \n"
151
- x = "city"
152
- elsif x == "State"
153
- print "renaming field #{x} \n"
154
- x = "State"
155
- elsif x == "Zipcode"
156
- print "renaming field #{x} \n"
157
- x = "Zipcode"
158
- elsif x == "Email"
159
- print "renaming field #{x} \n"
160
- x = "Email"
161
184
  else
162
- x=x
163
- end
164
- }
165
- # print newvar
166
- for i in 0..newvar.length
167
- for j in 1..testvar.length
168
-
169
-
170
- newSheet.row(i).push newvar[(i*testvar.length)+j]
171
- end
185
+ print "\n\n
186
+ WHOOPS!!!
187
+
188
+ It looks like this file is in the wrong folder or does not exsist.
189
+ try locating the folder and inputing the correct path\n\n".red
190
+ end
191
+ else
192
+ print "\n
193
+ Are you trying to use PRUNE?
194
+ why dont you try this command:\n\n
195
+ prune-erickson help \n\n\n
196
+ "
172
197
  end
173
- print "output file is in same file under out.xls to open, use \n \n open #{output}"
174
- print "\n"
175
- newBook.write output
176
- end
198
+ 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.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alejandro Londono
@@ -30,6 +30,26 @@ dependencies:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 1.0.7
33
+ - !ruby/object:Gem::Dependency
34
+ name: colorize
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '0.0'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 0.7.7
43
+ type: :development
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '0.0'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 0.7.7
33
53
  description: An excel processing script to remove erroneous data
34
54
  email: alejandro.londono@erickson.com
35
55
  executables: