Skip to content

Commit

Permalink
fixed unified newline handling
Browse files Browse the repository at this point in the history
  • Loading branch information
geemus committed Aug 15, 2012
1 parent aa9a529 commit ecf1c6f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/netrc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ def self.check_permissions(path)
# exist, returns an empty object. Decrypt paths ending in .gpg.
def self.read(path=default_path)
check_permissions(path)
if path =~ /\.gpg$/
data = if path =~ /\.gpg$/
decrypted = `gpg --batch --quiet --decrypt #{path}`
raise Error.new("Decrypting #{path} failed.") unless $?.success?
new(path, parse(lex(decrypted.split("\n"))))
if $?.success?
decrypted
else
raise Error.new("Decrypting #{path} failed.") unless $?.success?
end
else
new(path, parse(lex(File.readlines(path))))
File.read(path)
end
new(path, parse(lex(data.lines.to_a)))
rescue Errno::ENOENT
new(path, parse(lex([])))
end
Expand Down

0 comments on commit ecf1c6f

Please sign in to comment.