netrc 0.5 → 0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/netrc.rb +22 -10
- metadata +2 -2
data/lib/netrc.rb
CHANGED
@@ -1,23 +1,20 @@
|
|
1
1
|
class Netrc
|
2
|
-
VERSION = "0.
|
3
|
-
|
2
|
+
VERSION = "0.6"
|
3
|
+
WINDOWS = (RUBY_PLATFORM =~ /win32|mingw32/i)
|
4
4
|
|
5
5
|
def self.default_path
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
if Windows
|
11
|
-
return "_netrc"
|
6
|
+
if WINDOWS
|
7
|
+
File.join(ENV['USERPROFILE'].gsub("\\","/"), "_netrc")
|
8
|
+
else
|
9
|
+
File.join(ENV["HOME"], ".netrc")
|
12
10
|
end
|
13
|
-
".netrc"
|
14
11
|
end
|
15
12
|
|
16
13
|
# Reads path and parses it as a .netrc file. If path doesn't
|
17
14
|
# exist, returns an empty object.
|
18
15
|
def self.read(path=default_path)
|
19
16
|
perm = File.stat(path).mode & 0777
|
20
|
-
if perm != 0600
|
17
|
+
if perm != 0600 && !(WINDOWS)
|
21
18
|
raise Error, "Permission bits for '#{path}' should be 0600, but are "+perm.to_s(8)
|
22
19
|
end
|
23
20
|
new(path, parse(lex(IO.readlines(path))))
|
@@ -132,6 +129,21 @@ class Netrc
|
|
132
129
|
@data.count
|
133
130
|
end
|
134
131
|
|
132
|
+
def delete(key)
|
133
|
+
datum = nil
|
134
|
+
for value in @data
|
135
|
+
if value[1] == key
|
136
|
+
datum = value
|
137
|
+
break
|
138
|
+
end
|
139
|
+
end
|
140
|
+
@data.delete(datum)
|
141
|
+
end
|
142
|
+
|
143
|
+
def each(&block)
|
144
|
+
@data.each(&block)
|
145
|
+
end
|
146
|
+
|
135
147
|
def new_item(m, l, p)
|
136
148
|
[new_item_prefix+"machine ", m, "\n login ", l, "\n password ", p, "\n"]
|
137
149
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: netrc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.6'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2012-02-21 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: This library can read and update netrc files, preserving formatting including
|
16
16
|
comments and whitespace.
|