nhmood / watson-ruby

inline issue manager
MIT License
634 stars 50 forks source link

gsub uses (.?)+ to grab anything after lib (optional), better regex? [lib/watson/config.rb] #174

Closed nhmood closed 10 years ago

nhmood commented 10 years ago

filename : lib/watson/config.rb line # : 183 tag : review md5 : eee2d53ddc5024dab741cfc289cb963a

     # [review] - gsub uses (.?)+ to grab anything after lib (optional), better regex?
     _full_path = __dir__.gsub(%r!/lib/watson(.?)+!, '') + "/assets/defaultConf"
     debug_print "Full path to defaultConf (in gem): #{ _full_path }\n"
         # Check to make sure we can access the default file
     if !Watson::FS.check_file(_full_path)
       print "Unable to open #{ _full_path }\n"
       print "Cannot create default, exiting...\n"
       return false
     else
       # Open default config file in read mode and read into temp
       _input = File.open(_full_path, 'r')
       _default = _input.read
           # Open rc file in current directory in write mode and write default
       _output = File.open(@rc_file, 'w')
       _output.write(_default)