watson-ruby 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,16 +2,16 @@ module Watson
2
2
  # Command line parser class
3
3
  # Controls program flow and parses options given by command line
4
4
  class Command
5
-
5
+
6
6
  # Debug printing for this class
7
7
  DEBUG = false
8
-
8
+
9
9
  class << self
10
10
 
11
11
  # Include for debug_print
12
12
  include Watson
13
13
 
14
-
14
+
15
15
  ###########################################################
16
16
  # Command line controller
17
17
  # Manages program flow from given command line arguments
@@ -21,7 +21,7 @@ module Watson
21
21
 
22
22
  # Identify method entry
23
23
  debug_print "#{ self } : #{ __method__ }\n"
24
-
24
+
25
25
  # List of possible flags, used later in parsing and for user reference
26
26
  _flag_list = ["-c", "--context-depth",
27
27
  "-d", "--dirs",
@@ -55,7 +55,7 @@ module Watson
55
55
  @config = Watson::Config.new
56
56
  @parser = Watson::Parser.new(@config)
57
57
  @printer = Watson::Printer.new(@config)
58
-
58
+
59
59
  # Capture Ctrl+C interrupt for clean exit
60
60
  # [review] - Not sure this is the correct place to put the Ctrl+C capture
61
61
  trap("INT") do
@@ -65,18 +65,18 @@ module Watson
65
65
 
66
66
  # Parse command line options
67
67
  # Begin by slicing off until we reach a valid flag
68
-
68
+
69
69
  # Always look at first array element in case and then slice off what we need
70
70
  # Accept parameters to be added / overwritten if called twice
71
71
  # Slice out from argument until next argument
72
-
73
- # Clean up argument list by removing elements until the first valid flag
72
+
73
+ # Clean up argument list by removing elements until the first valid flag
74
74
  until _flag_list.include?(args[0]) || args.length == 0
75
75
  # [review] - Make this non-debug print to user?
76
76
  debug_print "Unrecognized flag #{ args[0] }\n"
77
77
  args.slice!(0)
78
78
  end
79
-
79
+
80
80
  # Parse command line options
81
81
  # Grab flag (should be first arg) then slice off args until next flag
82
82
  # Repeat until all args have been dealt with
@@ -87,20 +87,20 @@ module Watson
87
87
 
88
88
  debug_print "Current Flag: #{ _flag }\n"
89
89
 
90
- # Go through args until we find the next valid flag or all args are parsed
90
+ # Go through args until we find the next valid flag or all args are parsed
91
91
  _i = 0
92
- until _flag_list.include?(args[_i]) || _i > (args.length - 1)
92
+ until _flag_list.include?(args[_i]) || _i > (args.length - 1)
93
93
  debug_print "Arg: #{ args[_i] }\n"
94
- _i = _i + 1
94
+ _i = _i + 1
95
95
  end
96
-
96
+
97
97
  # Slice off the args for the flag (inclusive) using index from above
98
98
  # [review] - This is a bit messy (to slice by _i - 1) when we have control
99
99
  # over the _i index above but I don't want to
100
100
  # think about the logic right now so look at later
101
101
  _flag_args = args.slice!(0..(_i-1))
102
102
 
103
- case _flag
103
+ case _flag
104
104
  when "-c", "--context-depth"
105
105
  debug_print "Found -c/--context-depth argument\n"
106
106
  set_context(_flag_args)
@@ -108,7 +108,7 @@ module Watson
108
108
  when "-d", "--dirs"
109
109
  debug_print "Found -d/--dirs argument\n"
110
110
  set_dirs(_flag_args)
111
-
111
+
112
112
  when "-f", "--files"
113
113
  debug_print "Found -f/--files argument\n"
114
114
  set_files(_flag_args)
@@ -120,7 +120,7 @@ module Watson
120
120
  when "-p", "--parse-depth"
121
121
  debug_print "Found -r/--parse-depth argument\n"
122
122
  set_parse_depth(_flag_args)
123
-
123
+
124
124
  when "-r", "--remote"
125
125
  debug_print "Found -r/--remote argument\n"
126
126
  # Run config to populate all the fields and such
@@ -128,10 +128,10 @@ module Watson
128
128
  @config.check_conf
129
129
  @config.read_conf
130
130
  setup_remote(_flag_args)
131
-
131
+
132
132
  # If setting up remote, exit afterwards
133
133
  exit true
134
-
134
+
135
135
  when "-t", "--tags"
136
136
  debug_print "Found -t/--tags argument\n"
137
137
  set_tags(_flag_args)
@@ -154,13 +154,13 @@ module Watson
154
154
 
155
155
 
156
156
  ###########################################################
157
- # Print help for watson
157
+ # Print help for watson
158
158
  def help
159
159
  # [todo] - Add bold and colored printing
160
-
160
+
161
161
  # Identify method entry
162
162
  debug_print "#{ self } : #{ __method__ }\n"
163
-
163
+
164
164
  print BOLD;
165
165
  print "Usage: watson [OPTION]...\n"
166
166
  print "Running watson with no arguments will parse with settings in RC file\n"
@@ -188,7 +188,7 @@ module Watson
188
188
  print "watson home page: <http://goosecode.com/projects/watson>\n"
189
189
  print "[goosecode] labs | 2012-2013\n"
190
190
  print RESET;
191
-
191
+
192
192
  return true
193
193
 
194
194
  end
@@ -197,16 +197,16 @@ module Watson
197
197
  ###########################################################
198
198
  # Print version information about watson
199
199
  def version
200
-
200
+
201
201
  # Identify method entry
202
202
  debug_print "#{ self } : #{ __method__ }\n"
203
-
203
+
204
204
  print "watson v1.0\n"
205
205
  print "Copyright (c) 2012-2013 goosecode labs\n"
206
206
  print "Licensed under MIT, see LICENSE for details\n"
207
207
  print "\n"
208
208
 
209
- print "Written by nhmood, see <http://goosecode.com/projects/watson>\n"
209
+ print "Written by nhmood, see <http://goosecode.com/projects/watson>\n"
210
210
  return true
211
211
  end
212
212
 
@@ -214,11 +214,11 @@ module Watson
214
214
  ###########################################################
215
215
  # set_context
216
216
  # Set context_depth parameter in config
217
- def set_context(args)
218
-
217
+ def set_context(args)
218
+
219
219
  # Identify method entry
220
220
  debug_print "#{ self } : #{ __method__ }\n"
221
-
221
+
222
222
  # Need at least one dir in args
223
223
  if args.length <= 0
224
224
  # [review] - Make this a non-debug print to user?
@@ -226,12 +226,12 @@ module Watson
226
226
  return false
227
227
  end
228
228
 
229
-
229
+
230
230
  # For context_depth we do NOT append to RC, ALWAYS overwrite
231
- # For each argument passed, make sure valid, then set @config.parse_depth
231
+ # For each argument passed, make sure valid, then set @config.parse_depth
232
232
  args.each do | _context_depth |
233
233
  if _context_depth.match(/^(\d+)/)
234
- debug_print "Setting #{ _context_depth } to config context_depth\n"
234
+ debug_print "Setting #{ _context_depth } to config context_depth\n"
235
235
  @config.context_depth = _context_depth.to_i
236
236
  else
237
237
  debug_print "#{ _context_depth } invalid depth, ignoring\n"
@@ -239,7 +239,7 @@ module Watson
239
239
  end
240
240
 
241
241
  # Doesn't make much sense to set context_depth for each individual post
242
- # When you use this command line arg, it writes the config parameter
242
+ # When you use this command line arg, it writes the config parameter
243
243
  @config.update_conf("context_depth")
244
244
 
245
245
  debug_print "Updated context_depth: #{ @config.context_depth }\n"
@@ -248,13 +248,13 @@ module Watson
248
248
 
249
249
 
250
250
  ###########################################################
251
- # set_dirs
252
- # Set directories to be parsed by watson
253
- def set_dirs(args)
251
+ # set_dirs
252
+ # Set directories to be parsed by watson
253
+ def set_dirs(args)
254
254
 
255
255
  # Identify method entry
256
256
  debug_print "#{ self } : #{ __method__ }\n"
257
-
257
+
258
258
  # Need at least one dir in args
259
259
  if args.length <= 0
260
260
  # [review] - Make this a non-debug print to user?
@@ -263,9 +263,9 @@ module Watson
263
263
  end
264
264
 
265
265
  # Set config flag for CL entryset in config
266
- @config.cl_entry_set = true
266
+ @config.cl_entry_set = true
267
267
  debug_print "Updated cl_entry_set flag: #{ @config.cl_entry_set }\n"
268
-
268
+
269
269
  # [review] - Should we clean the dir before adding here?
270
270
  # For each argument passed, make sure valid, then add to @config.dir_list
271
271
  args.each do | _dir |
@@ -288,13 +288,13 @@ module Watson
288
288
 
289
289
 
290
290
  ###########################################################
291
- # set_files
292
- # Set files to be parsed by watson
293
- def set_files(args)
291
+ # set_files
292
+ # Set files to be parsed by watson
293
+ def set_files(args)
294
294
 
295
295
  # Identify method entry
296
296
  debug_print "#{ self } : #{ __method__ }\n"
297
-
297
+
298
298
  # Need at least one file in args
299
299
  if args.length <= 0
300
300
  debug_print "No args passed, exiting\n"
@@ -302,7 +302,7 @@ module Watson
302
302
  end
303
303
 
304
304
  # Set config flag for CL entryset in config
305
- @config.cl_entry_set = true
305
+ @config.cl_entry_set = true
306
306
  debug_print "Updated cl_entry_set flag: #{ @config.cl_entry_set }\n"
307
307
 
308
308
  # For each argument passed, make sure valid, then add to @config.file_list
@@ -323,12 +323,12 @@ module Watson
323
323
 
324
324
  ###########################################################
325
325
  # set_ignores
326
- # Set files and dirs to be ignored when parsing by watson
326
+ # Set files and dirs to be ignored when parsing by watson
327
327
  def set_ignores(args)
328
328
 
329
329
  # Identify method entry
330
330
  debug_print "#{ self } : #{ __method__ }\n"
331
-
331
+
332
332
  # Need at least one ignore in args
333
333
  if args.length <= 0
334
334
  debug_print "No args passed, exiting\n"
@@ -336,11 +336,11 @@ module Watson
336
336
  end
337
337
 
338
338
  # Set config flag for CL ignore set in config
339
- @config.cl_ignore_set = true
339
+ @config.cl_ignore_set = true
340
340
  debug_print "Updated cl_ignore_set flag: #{ @config.cl_ignore_set }\n"
341
341
 
342
342
 
343
- # For ignores we do NOT overwrite RC, just append
343
+ # For ignores we do NOT overwrite RC, just append
344
344
  # For each argument passed, add to @config.ignore_list
345
345
  args.each do | _ignore |
346
346
  debug_print "Adding #{ _ignore } to config ignore_list\n"
@@ -353,13 +353,13 @@ module Watson
353
353
 
354
354
 
355
355
  ###########################################################
356
- # set_parse_depth
356
+ # set_parse_depth
357
357
  # Set how deep to recursively parse directories
358
358
  def set_parse_depth(args)
359
-
359
+
360
360
  # Identify method entry
361
361
  debug_print "#{ self } : #{ __method__ }\n"
362
-
362
+
363
363
  # This should be a single, numeric, value
364
364
  # If they pass more, just take the last valid value
365
365
  if args.length <= 0
@@ -367,11 +367,11 @@ module Watson
367
367
  return false
368
368
  end
369
369
 
370
- # For max_dpeth we do NOT append to RC, ALWAYS overwrite
371
- # For each argument passed, make sure valid, then set @config.parse_depth
370
+ # For max_dpeth we do NOT append to RC, ALWAYS overwrite
371
+ # For each argument passed, make sure valid, then set @config.parse_depth
372
372
  args.each do | _parse_depth |
373
373
  if _parse_depth.match(/^(\d+)/)
374
- debug_print "Setting #{ _parse_depth } to config parse_depth\n"
374
+ debug_print "Setting #{ _parse_depth } to config parse_depth\n"
375
375
  @config.parse_depth = _parse_depth
376
376
  else
377
377
  debug_print "#{ _parse_depth } invalid depth, ignoring\n"
@@ -385,20 +385,20 @@ module Watson
385
385
 
386
386
  ###########################################################
387
387
  # set_tags
388
- # Set tags to look for when parsing files and folders
388
+ # Set tags to look for when parsing files and folders
389
389
  def set_tags(args)
390
390
 
391
391
  # Identify method entry
392
392
  debug_print "#{ self } : #{ __method__ }\n"
393
-
393
+
394
394
  # Need at least one tag in args
395
395
  if args.length <= 0
396
396
  debug_print "No args passed, exiting\n"
397
397
  return false
398
398
  end
399
-
399
+
400
400
  # Set config flag for CL tag set in config
401
- @config.cl_tag_set = true
401
+ @config.cl_tag_set = true
402
402
  debug_print "Updated cl_tag_set flag: #{ @config.cl_tag_set }\n"
403
403
 
404
404
  # If set from CL, we overwrite the RC parameters
@@ -415,16 +415,16 @@ module Watson
415
415
 
416
416
  ###########################################################
417
417
  # setup_remote
418
- # Handle setup of remote issue posting for GitHub and Bitbucket
418
+ # Handle setup of remote issue posting for GitHub and Bitbucket
419
419
  def setup_remote(args)
420
420
 
421
421
  # Identify method entry
422
422
  debug_print "#{ self } : #{ __method__ }\n"
423
-
423
+
424
424
  Printer.print_header
425
-
425
+
426
426
  print BOLD + "Existing Remotes:\n" + RESET
427
-
427
+
428
428
  # Check the config for any remote entries (GitHub or Bitbucket) and print
429
429
  # We *should* always have a repo + API together, but API should be enough
430
430
  if @config.github_api.empty? && @config.bitbucket_api.empty?
@@ -444,16 +444,16 @@ module Watson
444
444
 
445
445
  # If github or bitbucket passed, setup
446
446
  # If just -r (0 args) do nothing and only have above printed
447
- # If more than 1 arg is passed, unrecognized, warn user
447
+ # If more than 1 arg is passed, unrecognized, warn user
448
448
  if args.length == 1
449
449
  case args[0].downcase
450
450
  when "github"
451
451
  debug_print "GitHub setup called from CL\n"
452
- Watson::Remote::GitHub.setup(@config)
453
-
452
+ Watson::Remote::GitHub.setup(@config)
453
+
454
454
  when "bitbucket"
455
455
  debug_print "Bitbucket setup called from CL\n"
456
- Watson::Remote::Bitbucket.setup(@config)
456
+ Watson::Remote::Bitbucket.setup(@config)
457
457
  end
458
458
  elsif args.length > 1
459
459
  Printer.print_status "x", RED
@@ -464,7 +464,7 @@ module Watson
464
464
  return false
465
465
  end
466
466
  end
467
-
467
+
468
468
  end
469
469
  end
470
470
  end
data/lib/watson/config.rb CHANGED
@@ -6,40 +6,40 @@ module Watson
6
6
 
7
7
  # Include for debug_print
8
8
  include Watson
9
-
9
+
10
10
  # Debug printing for this class
11
- DEBUG = false
12
-
11
+ DEBUG = false
12
+
13
13
  # [review] - Combine into single statement (for performance or something?)
14
14
  # [todo] - Add config options (rc file) for default max depth and context lines
15
15
 
16
- # List of all files/folders to ignore when parsing
16
+ # List of all files/folders to ignore when parsing
17
17
  attr_accessor :ignore_list
18
- # List of directories to parse
18
+ # List of directories to parse
19
19
  attr_accessor :dir_list
20
20
  # List of all files to parse
21
- attr_accessor :file_list
21
+ attr_accessor :file_list
22
22
  # List of tags to look for when parsing
23
- attr_accessor :tag_list
23
+ attr_accessor :tag_list
24
24
  # Number of directories to parse recursively
25
25
  attr_accessor :parse_depth
26
26
  # Number of lines of issue context to grab
27
- attr_accessor :context_depth
27
+ attr_accessor :context_depth
28
28
 
29
29
  # Flag for command line setting of file/dir to parse
30
30
  attr_accessor :cl_entry_set
31
31
  # Flag for command line setting of file/dir to ignore
32
32
  attr_accessor :cl_ignore_set
33
33
  # Flag for command line setting of tag to parse for
34
- attr_accessor :cl_tag_set
34
+ attr_accessor :cl_tag_set
35
35
 
36
36
  # Flag for whether less is avaliable to print results
37
37
  attr_reader :use_less
38
38
  # Flag for where the temp file for printing is located
39
- attr_reader :tmp_file
39
+ attr_reader :tmp_file
40
40
 
41
41
  # Flag for whether remote access is avaliable
42
- attr_accessor :remote_valid
42
+ attr_accessor :remote_valid
43
43
 
44
44
  # Flag for whether GitHub access is avaliable
45
45
  attr_accessor :github_valid
@@ -47,7 +47,7 @@ module Watson
47
47
  attr_accessor :github_api
48
48
  # GitHub repo associated with current directory + watson config
49
49
  attr_accessor :github_repo
50
- # Hash to hold list of all GitHub issues associated with repo
50
+ # Hash to hold list of all GitHub issues associated with repo
51
51
  attr_accessor :github_issues
52
52
 
53
53
 
@@ -56,12 +56,12 @@ module Watson
56
56
  # Bitbucket API key generated from Remote::Bitbucket setup (username for now)
57
57
  attr_accessor :bitbucket_api
58
58
  # Bitbucket password for access until OAuth is implemented for Bitbucket
59
- attr_accessor :bitbucket_pw
59
+ attr_accessor :bitbucket_pw
60
60
  # Bitbucket repo associated with current directory + watson config
61
61
  attr_accessor :bitbucket_repo
62
- # Hash to hold list of all Bitbucket issues associated with repo
63
- attr_accessor :bitbucket_issues
64
-
62
+ # Hash to hold list of all Bitbucket issues associated with repo
63
+ attr_accessor :bitbucket_issues
64
+
65
65
 
66
66
  ###########################################################
67
67
  # Config initialization method to setup necessary parameters, states, and vars
@@ -69,8 +69,8 @@ module Watson
69
69
 
70
70
  # [review] - Read and store rc FP inside initialize?
71
71
  # This way we don't need to keep reopening the FP to use it
72
- # but then we need a way to reliably close the FP when done
73
-
72
+ # but then we need a way to reliably close the FP when done
73
+
74
74
  # Identify method entry
75
75
  debug_print "#{self.class} : #{__method__}\n"
76
76
 
@@ -95,10 +95,10 @@ module Watson
95
95
  @dir_list = Array.new()
96
96
  @file_list = Array.new()
97
97
  @tag_list = Array.new()
98
-
98
+
99
99
  # Remote options
100
100
  @remote_valid = false
101
-
101
+
102
102
  @github_valid = false
103
103
  @github_api = ""
104
104
  @github_repo = ""
@@ -118,17 +118,17 @@ module Watson
118
118
 
119
119
 
120
120
  ###########################################################
121
- # Parse through configuration and obtain remote info if necessary
121
+ # Parse through configuration and obtain remote info if necessary
122
122
  def run
123
-
123
+
124
124
  # Identify method entry
125
125
  debug_print "#{ self.class } : #{ __method__ }\n"
126
-
127
- # check_conf should create if no conf found, exit entirely if can't do either
126
+
127
+ # check_conf should create if no conf found, exit entirely if can't do either
128
128
  exit if check_conf == false
129
129
  read_conf
130
-
131
- unless @github_api.empty? && @github_api.empty?
130
+
131
+ unless @github_api.empty? && @github_repo.empty?
132
132
  Remote::GitHub.get_issues(self)
133
133
  end
134
134
 
@@ -153,13 +153,13 @@ module Watson
153
153
  if !Watson::FS.check_file(@rc_file)
154
154
  debug_print "#{ @rc_file } not found\n"
155
155
  debug_print "Creating default #{ @rc_file }\n"
156
-
156
+
157
157
  # Create default .rc and return create_conf (true if created,
158
158
  # false if not)
159
159
  return create_conf
160
160
  else
161
161
  debug_print "#{ @rc_file } found\n"
162
- return true
162
+ return true
163
163
  end
164
164
  end
165
165
 
@@ -169,16 +169,16 @@ module Watson
169
169
  # Copies default config from /assets/defaultConf to the current directory
170
170
  def create_conf
171
171
  # [review] - Not sure if I should use the open/read/write or Fileutils.cp
172
-
172
+
173
173
  # Identify method entry
174
174
  debug_print "#{ self.class } : #{ __method__ }\n"
175
175
 
176
-
176
+
177
177
  # Generate full path since File doesn't care about the LOAD_PATH
178
- # [review] - gsub uses (.?)+ to grab anything after lib (optional), better regex?
178
+ # [review] - gsub uses (.?)+ to grab anything after lib (optional), better regex?
179
179
  _full_path = __dir__.gsub(%r!/lib/watson(.?)+!, '') + "/assets/defaultConf"
180
180
  debug_print "Full path to defaultConf (in gem): #{ _full_path }\n"
181
-
181
+
182
182
  # Check to make sure we can access the default file
183
183
  if !Watson::FS.check_file(_full_path)
184
184
  print "Unable to open #{ _full_path }\n"
@@ -192,24 +192,24 @@ module Watson
192
192
  # Open rc file in current directory in write mode and write default
193
193
  _output = File.open(@rc_file, 'w')
194
194
  _output.write(_default)
195
-
195
+
196
196
  # Close both default and new rc files
197
197
  _input.close
198
198
  _output.close
199
199
 
200
200
  debug_print "Successfully wrote defaultConf to current directory\n"
201
201
  return true
202
- end
202
+ end
203
203
  end
204
204
 
205
205
 
206
206
  ###########################################################
207
- # Read configuration file and populate Config container class
207
+ # Read configuration file and populate Config container class
208
208
  def read_conf
209
209
 
210
210
  # Identify method entry
211
211
  debug_print "#{ self.class } : #{ __method__ }\n"
212
-
212
+
213
213
 
214
214
  debug_print "Reading #{ @rc_file }\n"
215
215
  if !Watson::FS.check_file(@rc_file)
@@ -224,11 +224,11 @@ module Watson
224
224
  @use_less = check_less
225
225
 
226
226
 
227
- # Add all the standard items to ignorelist
227
+ # Add all the standard items to ignorelist
228
228
  # This gets added regardless of ignore list specified
229
229
  # [review] - Keep *.swp in there?
230
230
  # [todo] - Add conditional to @rc_file such that if passed by -f we accept it
231
- # [todo] - Add current file (watson) to avoid accidentally printing app tags
231
+ # [todo] - Add current file (watson) to avoid accidentally printing app tags
232
232
  @ignore_list.push(".")
233
233
  @ignore_list.push("..")
234
234
  @ignore_list.push("*.swp")
@@ -238,12 +238,12 @@ module Watson
238
238
  # Open and read rc
239
239
  # [review] - Not sure if explicit file close is required here
240
240
  _rc = File.open(@rc_file, 'r').read
241
-
242
- debug_print "\n\n"
243
-
241
+
242
+ debug_print "\n\n"
243
+
244
244
  # Create temp section var to keep track of what we are populating in config
245
245
  _section = ""
246
-
246
+
247
247
  # Keep index to print what line we are on
248
248
  # Could fool around with Enumerable + each_with_index but oh well
249
249
  _i = 0;
@@ -261,15 +261,15 @@ module Watson
261
261
  # [review] - More "Ruby" way of going to next line?
262
262
  next
263
263
  end
264
-
265
-
264
+
265
+
266
266
  # [review] - Use if with match so we can call next on the line reading loop
267
267
  # Tried using match(){|_mtch|} as well as do |_mtch| but those don't seem to
268
268
  # register the next call to the outer loop, so this way will do for now
269
269
 
270
270
  # Regex on line to find out if we are in a new [section] of
271
271
  # config parameters. If so, store it into section var and move
272
- # to next line
272
+ # to next line
273
273
  _mtch = _line.match(/^\[(\w+)\]/)
274
274
  if _mtch
275
275
  debug_print "Found section #{ _mtch[1] }\n"
@@ -280,13 +280,13 @@ module Watson
280
280
 
281
281
  case _section
282
282
  when "context_depth"
283
- # No need for regex on context value, command should read this in only as a #
283
+ # No need for regex on context value, command should read this in only as a #
284
284
  # Chomp to get rid of any nonsense
285
285
  @context_depth = _line.chomp!
286
286
 
287
287
 
288
288
  when "parse_depth"
289
- # No need for regex on parse value, command should read this in only as a #
289
+ # No need for regex on parse value, command should read this in only as a #
290
290
  # Chomp to get rid of any nonsense
291
291
  @parse_depth = _line.chomp!
292
292
 
@@ -297,26 +297,26 @@ module Watson
297
297
  # [review] - Populate @dirs/files_list first, then check size instead
298
298
  if @cl_entry_set
299
299
  debug_print "Directories or files set from command line ignoring rc [dirs]\n"
300
- next
300
+ next
301
301
  end
302
-
302
+
303
303
  # Regex to grab directory
304
304
  # Then substitute trailing / (necessary for later formatting)
305
305
  # Then push to @dir_list
306
306
  _mtch = _line.match(/^((\w+)?\.?\/?)+/)[0].gsub(/(\/)+$/, "")
307
307
  if !_mtch.empty?
308
- @dir_list.push(_mtch)
308
+ @dir_list.push(_mtch)
309
309
  debug_print "#{ _mtch } added to @dir_list\n"
310
310
  end
311
311
  debug_print "@dir_list --> #{ @dir_list }\n"
312
-
312
+
313
313
 
314
314
  when "tags"
315
- # Same as previous for tags
315
+ # Same as previous for tags
316
316
  # [review] - Populate @tag_list, then check size instead
317
317
  if @cl_tag_set
318
318
  debug_print "Tags set from command line, ignoring rc [tags]\n"
319
- next
319
+ next
320
320
  end
321
321
 
322
322
  # Same as previous for tags
@@ -329,36 +329,36 @@ module Watson
329
329
  debug_print "#{ _mtch } added to @tag_list\n"
330
330
  end
331
331
  debug_print "@tag_list --> #{ @tag_list }\n"
332
-
332
+
333
333
 
334
334
  when "ignore"
335
335
  # Same as previous for ignores
336
336
  # [review] - Populate @tag_list, then check size instead
337
-
337
+
338
338
  if @cl_ignore_set
339
339
  debug_print "Ignores set from command line, ignoring rc [ignores]\n"
340
340
  next
341
341
  end
342
-
342
+
343
343
  # Same as previous for ignores (regex same as dirs)
344
344
  # Don't eliminate trailing / because not sure if dir can have
345
345
  # same name as file (Linux it can't, but not sure about Win/Mac)
346
346
  # [review] - Can Win/Mac have dir + file with same name in same dir?
347
347
  _mtch = _line.match(/^((\w+)?\.?\/?)+/)[0]
348
348
  if !_mtch.empty?
349
- @ignore_list.push(_mtch)
349
+ @ignore_list.push(_mtch)
350
350
  debug_print "#{ _mtch } added to @ignore_list\n"
351
351
  end
352
352
  debug_print "@ignore_list --> #{ @ignore_list }\n"
353
353
 
354
-
354
+
355
355
  when "github_api"
356
356
  # No need for regex on API key, GitHub setup should do this properly
357
357
  # Chomp to get rid of any nonsense
358
358
  @github_api = _line.chomp!
359
359
  debug_print "GitHub API: #{ @github_api }\n"
360
360
 
361
-
361
+
362
362
  when "github_repo"
363
363
  # Same as above
364
364
  @github_repo = _line.chomp!
@@ -368,17 +368,17 @@ module Watson
368
368
  when "bitbucket_api"
369
369
  # Same as GitHub parse above
370
370
  @bitbucket_api = _line.chomp!
371
- debug_print "Bitbucket API: #{ @bitbucket_api }\n"
372
-
373
-
371
+ debug_print "Bitbucket API: #{ @bitbucket_api }\n"
372
+
373
+
374
374
  when "bitbucket_repo"
375
375
  # Same as GitHub repo parse above
376
376
  @bitbucket_repo = _line.chomp!
377
377
  debug_print "Bitbucket Repo: #{ @bitbucket_repo }\n"
378
378
 
379
379
 
380
- else
381
- debug_print "Unknown tag found #{_section}\n"
380
+ else
381
+ debug_print "Unknown tag found #{_section}\n"
382
382
  end
383
383
 
384
384
  end
@@ -411,20 +411,20 @@ module Watson
411
411
  debug_print "Check your input(s) to update_conf\n"
412
412
  params.slice!(_i)
413
413
  end
414
- end
414
+ end
415
+
415
416
 
416
-
417
417
  # Read in currently saved RC and go through it line by line
418
418
  # Only update params that were passed to update_conf
419
419
  # This allows us to clean up the config file at the same time
420
420
 
421
-
421
+
422
422
  # Open and read rc
423
423
  # [review] - Not sure if explicit file close is required here
424
424
  _rc = File.open(@rc_file, 'r').read
425
425
  _update = File.open(@rc_file, 'w')
426
-
427
-
426
+
427
+
428
428
  # Keep index to print what line we are on
429
429
  # Could fool around with Enumerable + each_with_index but oh well
430
430
  _i = 0;
@@ -440,7 +440,7 @@ module Watson
440
440
  debug_print "#{ _i }: #{ _line }"
441
441
  _i = _i + 1
442
442
 
443
-
443
+
444
444
  # Look for sections and set section var
445
445
  _mtch = _line.match(/^\[(\w+)\]/)
446
446
  if _mtch
@@ -464,7 +464,7 @@ module Watson
464
464
  debug_print "Current section NOT a param to update\n"
465
465
  debug_print "Writing to new rc\n"
466
466
  _update.write(_line)
467
-
467
+
468
468
  # Reset newline
469
469
  _nlc = 0
470
470
  end
@@ -483,8 +483,8 @@ module Watson
483
483
  _update.write("[#{ _param }]\n")
484
484
  _update.write("#{ self.instance_variable_get("@#{ _param }") }")
485
485
  _update.write("\n\n\n")
486
- end
487
-
486
+ end
487
+
488
488
  _update.close
489
489
  end
490
490