Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 45 lines (28 sloc) 1.023 kb
f555fc4 @kr init
kr authored
1 # Netrc
2
479791f @technomancy Document GPG support.
technomancy authored
3 This library reads and writes
4 [`.netrc` files](http://www.gnu.org/software/inetutils/manual/html_node/The-_002enetrc-File.html).
f555fc4 @kr init
kr authored
5
6 ## API
7
8 Read a netrc file:
9
10 n = Netrc.read("sample.netrc")
11
c25a2c0 @technomancy Remove implicit switch to encrypted file.
technomancy authored
12 If the file doesn't exist, Netrc.read will return an empty object. If
13 the filename ends in ".gpg", it will be decrypted using
14 [GPG](http://www.gnupg.org/).
479791f @technomancy Document GPG support.
technomancy authored
15
f555fc4 @kr init
kr authored
16 Read the user's default netrc file (`$HOME/.netrc` on Unix;
17 `%HOME%\_netrc` on Windows):
18
19 n = Netrc.read
20
21 Look up a username and password:
22
d173391 @kr use better example hostnames
kr authored
23 user, pass = n["example.com"]
f555fc4 @kr init
kr authored
24
25 Write a username and password:
26
d173391 @kr use better example hostnames
kr authored
27 n["example.com"] = user, newpass
f555fc4 @kr init
kr authored
28 n.save
29
aaa24a3 @kr explain new entry behavior
kr authored
30 If you make an entry that wasn't there before, it will be appended
31 to the end of the file. Sometimes people want to include a comment
32 explaining that the entry was added automatically. You can do it
33 like this:
34
35 n.new_item_prefix = "# This entry was added automatically\n"
d173391 @kr use better example hostnames
kr authored
36 n["example.com"] = user, newpass
aaa24a3 @kr explain new entry behavior
kr authored
37 n.save
38
f555fc4 @kr init
kr authored
39 Have fun!
6a90f4e @kr document how to run the tests
kr authored
40
41 ## Running Tests
42
e82e476 @dpiddy Add Gemfile, specify turn as a development dependency in the gemspec.
dpiddy authored
43 $ bundle install
44 $ bundle exec turn test
Something went wrong with that request. Please try again.