netrc 0.7.9 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/changelog.txt +6 -1
- data/lib/netrc.rb +7 -3
- data/test/test_netrc.rb +34 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZDlhMTI4YjIzMDU0Y2Y1NDlkZjJiNDI3NTUzNWYzNDNmMTk5OGU3OA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NTBhOWYyMmUwZDk3Y2Q3NDkzYmQ2MTczYjhhZmM4NWZiODYxM2E0OA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZjQ4ZDAzYTRkNzhmZTFjNTg2ZDg4NTkwN2U1YzQ2YmM3Mjk2MmI4YzVkMDUw
|
10
|
+
YmQwNmJjNjYxZjhlODgyOTJmMTVlMDYwMTI1NjExNTQ0MzkzMjExNjU4Yjli
|
11
|
+
ZmVlZmYxOTkxZmIzMjhjZDI4NzZiOTJjNzdhN2I2MjE4NTlmZTI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTU1ODU3NTllYTg1NTQ4OWY5N2NlNWRjYWIzMzBlY2QyMzU3NzM3YjcwNDhk
|
14
|
+
YTkwNGJiOWIyNWZkMzYzNzM3NWIyOGVjMzU1YmZmNjIwNGY4NDRmMTdjYTc0
|
15
|
+
ZTExYjFmNDMxNjQyODE1NWQ2MDA3ZjliZDYxMzEyNzk3MmI2M2U=
|
data/changelog.txt
CHANGED
data/lib/netrc.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'rbconfig'
|
2
2
|
|
3
3
|
class Netrc
|
4
|
-
VERSION = "0.
|
4
|
+
VERSION = "0.8.0"
|
5
5
|
|
6
6
|
# see http://stackoverflow.com/questions/4871309/what-is-the-correct-way-to-detect-if-ruby-is-running-on-windows
|
7
7
|
WINDOWS = RbConfig::CONFIG["host_os"] =~ /mswin|mingw|cygwin/
|
@@ -159,9 +159,9 @@ class Netrc
|
|
159
159
|
|
160
160
|
def [](k)
|
161
161
|
if item = @data.detect {|datum| datum[1] == k}
|
162
|
-
|
162
|
+
Entry.new(item[3], item[5])
|
163
163
|
elsif @default
|
164
|
-
|
164
|
+
Entry.new(@default[3], @default[5])
|
165
165
|
end
|
166
166
|
end
|
167
167
|
|
@@ -221,6 +221,10 @@ class Netrc
|
|
221
221
|
end.join
|
222
222
|
end
|
223
223
|
|
224
|
+
Entry = Struct.new(:login, :password) do
|
225
|
+
alias to_ary to_a
|
226
|
+
end
|
227
|
+
|
224
228
|
end
|
225
229
|
|
226
230
|
class Netrc::Error < ::StandardError
|
data/test/test_netrc.rb
CHANGED
@@ -120,7 +120,7 @@ class TestNetrc < Test::Unit::TestCase
|
|
120
120
|
def test_set_get
|
121
121
|
n = Netrc.read("data/sample.netrc")
|
122
122
|
n["m"] = "a", "b"
|
123
|
-
assert_equal(["a", "b"], n["m"])
|
123
|
+
assert_equal(["a", "b"], n["m"].to_a)
|
124
124
|
end
|
125
125
|
|
126
126
|
def test_add
|
@@ -157,7 +157,7 @@ class TestNetrc < Test::Unit::TestCase
|
|
157
157
|
n = Netrc.read("data/sample.netrc")
|
158
158
|
n.new_item_prefix = "# added\n"
|
159
159
|
n["x"] = "a", "b"
|
160
|
-
assert_equal(["a", "b"], n["x"])
|
160
|
+
assert_equal(["a", "b"], n["x"].to_a)
|
161
161
|
end
|
162
162
|
|
163
163
|
def test_get_missing
|
@@ -200,6 +200,38 @@ class TestNetrc < Test::Unit::TestCase
|
|
200
200
|
ENV["HOME"], nil_home = nil_home, ENV["HOME"]
|
201
201
|
end
|
202
202
|
|
203
|
+
def test_read_entry
|
204
|
+
entry = Netrc.read("data/sample.netrc")['m']
|
205
|
+
assert_equal 'l', entry.login
|
206
|
+
assert_equal 'p', entry.password
|
207
|
+
|
208
|
+
# hash-style
|
209
|
+
assert_equal 'l', entry[:login]
|
210
|
+
assert_equal 'p', entry[:password]
|
211
|
+
end
|
212
|
+
|
213
|
+
def test_write_entry
|
214
|
+
n = Netrc.read("data/sample.netrc")
|
215
|
+
entry = n['m']
|
216
|
+
entry.login = 'new_login'
|
217
|
+
entry.password = 'new_password'
|
218
|
+
n['m'] = entry
|
219
|
+
assert_equal(['new_login', 'new_password'], n['m'].to_a)
|
220
|
+
end
|
221
|
+
|
222
|
+
def test_entry_splat
|
223
|
+
e = Netrc::Entry.new("user", "pass")
|
224
|
+
user, pass = *e
|
225
|
+
assert_equal("user", user)
|
226
|
+
assert_equal("pass", pass)
|
227
|
+
end
|
228
|
+
|
229
|
+
def test_entry_implicit_splat
|
230
|
+
e = Netrc::Entry.new("user", "pass")
|
231
|
+
user, pass = e
|
232
|
+
assert_equal("user", user)
|
233
|
+
assert_equal("pass", pass)
|
234
|
+
end
|
203
235
|
|
204
236
|
def test_with_default
|
205
237
|
netrc = Netrc.read('data/sample_with_default.netrc')
|