morganwildermuth / LPCodingChallenge

0 stars 0 forks source link

make require_relative calls consistent #2

Closed vinbarnes closed 10 years ago

vinbarnes commented 10 years ago

Is there a reason for the slightly different ways you're calling require_relative?

https://github.com/morganwildermuth/LPCodingChallenge/blob/master/text_parser.rb#L1

require_relative "line_parser"

versus

https://github.com/morganwildermuth/LPCodingChallenge/blob/master/spec/tests.rb#L1-L2

require_relative "../text_parser.rb"
require_relative "test_methods.rb"
morganwildermuth commented 10 years ago

I hadn't realized I'd done that; do you know if one way is preferred over the other? Assuming there's no best practice in this area besides consistency, I'll update the require_relative arguments to leave off the file extension.

vinbarnes commented 10 years ago

You rarely if ever come across Ruby source files that are required by explicitly including the .rb file extension. Common practice is to call require "my_ruby_file" for a file named my_ruby_file.rb. At least that's been my experience. If you'd like to dig deeper into code loading in Ruby, there is a good writeup on the subject and the Ruby docs provide a decent overview too.