def source
@source ||= if @path =~ /^http/
require 'open-uri'
open(@path).read
else
begin
source = File.open(@path, Cucumber.file_mode('r', DEFAULT_ENCODING)).read
encoding = encoding_for(source)
if(DEFAULT_ENCODING.downcase != encoding.downcase)
source = File.open(@path, Cucumber.file_mode('r', encoding)).read
source = to_default_encoding(source, encoding)
end
source
rescue Errno::EACCES => e
e.message << "\nCouldn't open #{File.expand_path(@path)}"
raise e
rescue Errno::ENOENT => e
if(@path == 'features')
STDERR.puts("You don't have a 'features' directory. Please create one to get started.",
"See http://cukes.info/ for more information.")
exit 1
end
raise e
end
end
end