netrc 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 58ff22fb27f91e9e7a1d438fd790fa03533fd8f9
4
- data.tar.gz: 35b9f2b6f2447ca9a4f39958d165011595932239
3
+ metadata.gz: abc7dade0f83a2542764f27110f02c194a8f21eb
4
+ data.tar.gz: a0a9842ed83ed5aa376e633853444da708877972
5
5
  SHA512:
6
- metadata.gz: 178e9c25d3d775d76a6f987bdb998cd33bdfa7f164ca035fe706d32212554e3b5d36f46105c9159a48bcbcdfd4662230e43fa9e10dbeae5dfb00637cf4f138ee
7
- data.tar.gz: 13c0243fd3427f91e47b5aa4ddbe293aa058b843c00b50c35515814d1eb9f651ebfd81d69598e16c6bfe9aa69c57d422198bdcb074b2c28770f52e23c64ef161
6
+ metadata.gz: 5ec0bc4855e159e33090e53bc212cfa164b58a88d34a967b247b347c5f0b9a3d7d21ddf97883f6d71fd63d08cc5e5587800557a0567ffdb353a048c1f5bc02bf
7
+ data.tar.gz: f1d5642f7afa850e782b0b822a5e25d1828abc901b108a5a74bd884642cdee68c068676e59c40064ea465c6504a30c48078991a53ec8c012528415aa7a56659e
@@ -1,3 +1,8 @@
1
+ 0.10.0 12/10/14
2
+ ===============
3
+
4
+ use `Dir.home` for finding home on Ruby 1.9+
5
+
1
6
  0.9.0 12/01/14
2
7
  ==============
3
8
 
@@ -1,26 +1,34 @@
1
1
  require 'rbconfig'
2
2
 
3
3
  class Netrc
4
- VERSION = "0.9.0"
4
+ VERSION = "0.10.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/
8
8
  CYGWIN = RbConfig::CONFIG["host_os"] =~ /cygwin/
9
9
 
10
10
  def self.default_path
11
+ File.join(home_path, netrc_filename)
12
+ end
13
+
14
+ def self.home_path
15
+ return Dir.home if defined? Dir.home # Ruby 1.9+
11
16
  if WINDOWS && !CYGWIN
12
17
  home = ENV['HOME']
13
18
  home ||= ENV['HOMEDRIVE'] + ENV['HOMEPATH'] if ENV['HOMEDRIVE'] && ENV['HOMEPATH']
14
19
  home ||= ENV['USERPROFILE']
15
- File.join(home.gsub("\\","/"), "_netrc")
20
+ home.gsub("\\","/")
16
21
  else
17
22
  # In some cases, people run master process as "root" user, and run worker processes as "www" user.
18
23
  # Fix "Permission denied" error in worker processes when $HOME is "/root".
19
- default_dir = (ENV['HOME'] && File.exist?(ENV['HOME']) && File.stat(ENV['HOME']).readable?) ? ENV['HOME'] : './'
20
- File.join(default_dir, ".netrc")
24
+ (ENV['HOME'] && File.exist?(ENV['HOME']) && File.stat(ENV['HOME']).readable?) ? ENV['HOME'] : './'
21
25
  end
22
26
  end
23
27
 
28
+ def self.netrc_filename
29
+ WINDOWS && !CYGWIN ? "_netrc" : ".netrc"
30
+ end
31
+
24
32
  def self.config
25
33
  @config ||= {}
26
34
  end
@@ -187,15 +187,18 @@ class TestNetrc < Test::Unit::TestCase
187
187
  n["m"] = "a", "b"
188
188
  n.save
189
189
  assert_equal(0600, File.stat("/tmp/test.netrc.gpg").mode & 0777)
190
- assert_equal(["a", "b"], Netrc.read("/tmp/test.netrc.gpg")["m"])
190
+ netrc = Netrc.read("/tmp/test.netrc.gpg")["m"]
191
+ assert_equal("a", netrc.login)
192
+ assert_equal("b", netrc.password)
191
193
  end
192
194
  end
193
195
 
194
196
  def test_missing_environment
195
197
  nil_home = nil
196
198
  ENV["HOME"], nil_home = nil_home, ENV["HOME"]
197
- n = Netrc.read
198
- assert_equal(nil, n["x"])
199
+ assert_raise_with_message ArgumentError, "couldn't find HOME environment -- expanding `~'" do
200
+ Netrc.read
201
+ end
199
202
  ensure
200
203
  ENV["HOME"], nil_home = nil_home, ENV["HOME"]
201
204
  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.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keith Rarick
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-12-01 00:00:00.000000000 Z
12
+ date: 2014-12-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: turn