const GLib = imports.gi.GLib;
-const File = imports['../File.js'].File;
-
+const File = imports.File.File;
+/**
+ * usage:
+ * var cfg = Netrc.forHost('www.google.com');
+ * var uname = cfg.login
+ * var pass = cfg.password
+ *
+ *
+ */
Netrc = {
- data : {},
+ forHost: function(name)
+ {
+ try {
+ return this._data[name];
+ } catch(e) {
+ throw "Host " + name + " was not found in netrc file (or parser could not read file..)\n";
+ }
+
+ },
- load : function()
+ _data : {},
+ /**
+ * private - called at the bottom..
+ */
+ _load : function()
{
var netrc = File.read(GLib.get_home_dir() + "/.netrc");
authdata[line.machine] = line;
});
- this.data = authdata;
+ this._data = authdata;
- },
-
- forhost: function(name)
- {
- return this.data[name];
}
+
+
}
-//
-Netrc.load();
\ No newline at end of file
+// load the file up.
+Netrc._load();
\ No newline at end of file