netrc 0.7.9 → 0.8.0

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OWIyNjAwOGRlMDg1MjMxOGRlYTNjMTZkOTk5ZGYxNjQ3ZDhkMzg0Mg==
4
+ ZDlhMTI4YjIzMDU0Y2Y1NDlkZjJiNDI3NTUzNWYzNDNmMTk5OGU3OA==
5
5
  data.tar.gz: !binary |-
6
- YzVhZjQ2YWEyZjBlMGMwMDM2MTQyOGQ4NWQzMTU3YTRkY2JkM2YyNQ==
6
+ NTBhOWYyMmUwZDk3Y2Q3NDkzYmQ2MTczYjhhZmM4NWZiODYxM2E0OA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NzdlNjBjMWQ5ZjU3ZWNjMjk2OTAxZmRiYTZhYjkwMTZmOTM5N2EzMThlM2U4
10
- OGU2MzVlMGUzZDliOTQ1YWM3NWNlZDUxYmJiMDg0YTMxMzFjNTVkODM0ZWQw
11
- NjA1NWFlMjRiMzE3Njk2YTU4YmM2NGM0NDFmOWQ3MTQ5OWVlZTM=
9
+ ZjQ4ZDAzYTRkNzhmZTFjNTg2ZDg4NTkwN2U1YzQ2YmM3Mjk2MmI4YzVkMDUw
10
+ YmQwNmJjNjYxZjhlODgyOTJmMTVlMDYwMTI1NjExNTQ0MzkzMjExNjU4Yjli
11
+ ZmVlZmYxOTkxZmIzMjhjZDI4NzZiOTJjNzdhN2I2MjE4NTlmZTI=
12
12
  data.tar.gz: !binary |-
13
- OWZmNTViOGUwNDRkMWVmYTAwNTg3MmU2YWFkMTQ0MDk5ZmZjNDljYzA3ODcw
14
- NTNjODczZjBhY2Q2N2RmOWYyZmQwYjdlNjI3MWU2YWIzZjcyMjE1MDdlZjcz
15
- MDQ2ODc1MmZmZTBjZmU2ZDU1N2Y4OWU3NDMzNGUyNjBkOGNlYzI=
13
+ NTU1ODU3NTllYTg1NTQ4OWY5N2NlNWRjYWIzMzBlY2QyMzU3NzM3YjcwNDhk
14
+ YTkwNGJiOWIyNWZkMzYzNzM3NWIyOGVjMzU1YmZmNjIwNGY4NDRmMTdjYTc0
15
+ ZTExYjFmNDMxNjQyODE1NWQ2MDA3ZjliZDYxMzEyNzk3MmI2M2U=
@@ -1,4 +1,9 @@
1
- 0.7.9 10/15/14
1
+ 0.8.0 10/16/14
2
+ ==============
3
+
4
+ re-revert entry changes with minor bump
5
+
6
+ 0.7.9 10/16/14
2
7
  ==============
3
8
 
4
9
  revert entry changes for a backwards-compatible version
@@ -1,7 +1,7 @@
1
1
  require 'rbconfig'
2
2
 
3
3
  class Netrc
4
- VERSION = "0.7.9"
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
- [item[3], item[5]]
162
+ Entry.new(item[3], item[5])
163
163
  elsif @default
164
- [@default[3], @default[5]]
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
@@ -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')
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.7.9
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keith Rarick