Một số librararies Ruby Tôi đang sử dụng sử dụng require
tuyên bố như thế này:"yêu cầu File.dirname (__ FILE__)" - làm thế nào để an toàn hoàn tác phụ thuộc hệ thống tập tin?
require File.dirname(__FILE__) + '/specification_helper.rb'
lib_dir = File.expand_path(File.join(File.dirname(__FILE__), "lib"))
require File.join(File.dirname(__FILE__), 'lib/tools', 'version')
require File.expand_path(File.join(File.dirname(__FILE__), 'datautils', 'conn'))
Không định dạng này làm cho mã của bạn không cần thiết phụ thuộc vào cấu trúc của hệ thống tập tin?
Tại sao tác giả làm theo cách này?
Có thể (an toàn) thay đổi mã này để loại bỏ sự phụ thuộc này trên hệ thống tệp không?
xem thêm codemeta.source_pdir http://en.wikibooks.org/wiki/AnyLang_Programming_Language_Comparison/Anylang_Common_Concepts – dreftymac