README.txt
[gitlive] / Netrc.js
index 763415b..52f287e 100644 (file)
--- a/Netrc.js
+++ b/Netrc.js
@@ -1,13 +1,32 @@
 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");
@@ -29,14 +48,13 @@ Netrc = {
            authdata[line.machine] = line;
             
         });
-        this.data = authdata;
+        this._data = authdata;
          
-    },
-    
-    forhost: function(name)
-    {
-        return this.data[name];
     }
     
+  
+    
     
 }
+// load the file up.
+Netrc._load();
\ No newline at end of file