netrc 0.10.3 → 0.11.0

This diff has not been reviewed by any users.
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: ff42e907d9e08059eca13e54dac95b5a7247cb02
4
- data.tar.gz: d2692d21a8ab3880d2c06135e972e91b17c6455f
3
+ metadata.gz: f70510e23b55b31e755aca0e6d44f45b23476219
4
+ data.tar.gz: a059abe6bcfbafdf5bccdd780044b599bf817e9f
5
5
  SHA512:
6
- metadata.gz: 92a9c3f6b1e85e748ab46f573eab3cd08b25dab74b82559be56d439f41099476c9b380c2f0ac032b17a01cd0da08696b1380a9935db9c6f2edfda724af56c2e7
7
- data.tar.gz: 42e37d26587a9379f712f31f6b9c98923d7b439697e25037cff58bda148501dfcfee4c6441b260a5ae27b9905675141a975ca6e4e27da6b2b6d444110bc277cc
6
+ metadata.gz: ee4839509d4962d11095ac46b2610bc4975c0a8deb60ad5b5c3114fce33ecbfef2c7acdd2525051c7dedd02076f3c3277a06b71d4ca1e8b462601605f1c4cd12
7
+ data.tar.gz: e91eff73081c73e280c46bbbaa8bfc2ff17dbff809ef81bb97e3bc50cabffd0e1946f5287b4c2d8c190afb9da1d6ed198a4fe0089f7a0b3695da7fe1ada617ed
data/Readme.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Netrc
2
2
 
3
3
  This library reads and writes
4
- [`.netrc` files](http://www.gnu.org/software/inetutils/manual/html_node/The-_002enetrc-File.html).
4
+ [`.netrc` files](http://www.gnu.org/software/inetutils/manual/html_node/The-_002enetrc-file.html).
5
5
 
6
6
  ## API
7
7
 
@@ -13,8 +13,11 @@ If the file doesn't exist, Netrc.read will return an empty object. If
13
13
  the filename ends in ".gpg", it will be decrypted using
14
14
  [GPG](http://www.gnupg.org/).
15
15
 
16
- Read the user's default netrc file. On Unix: `$HOME/.netrc`.
17
- On Windows: `%HOME%\_netrc`, `%HOMEDRIVE%%HOMEPATH%\_netrc`, or `%USERPROFILE%\_netrc` (whichever is set first).
16
+ Read the user's default netrc file.
17
+
18
+ **On Unix:** `$NETRC/.netrc` or `$HOME/.netrc` (whichever is set first).
19
+
20
+ **On Windows:** `%NETRC%\_netrc`, `%HOME%\_netrc`, `%HOMEDRIVE%%HOMEPATH%\_netrc`, or `%USERPROFILE%\_netrc` (whichever is set first).
18
21
 
19
22
  n = Netrc.read
20
23
 
@@ -47,4 +50,4 @@ Have fun!
47
50
  ## Running Tests
48
51
 
49
52
  $ bundle install
50
- $ bundle exec turn test
53
+ $ bundle exec ruby -e 'Dir.glob "./test/**/test_*.rb", &method(:require)'
@@ -1,3 +1,9 @@
1
+ 0.11.0 10/29/15
2
+ ===============
3
+
4
+ Respect NETRC environment variable
5
+ Fix for JRuby PernGen Space
6
+
1
7
  0.10.3 02/24/15
2
8
  ===============
3
9
 
@@ -1,14 +1,14 @@
1
1
  require 'rbconfig'
2
2
 
3
3
  class Netrc
4
- VERSION = "0.10.3"
4
+ VERSION = "0.11.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)
11
+ File.join(ENV['NETRC'] || home_path, netrc_filename)
12
12
  end
13
13
 
14
14
  def self.home_path
@@ -18,7 +18,7 @@ class Netrc
18
18
  home ||= File.join(ENV['HOMEDRIVE'], ENV['HOMEPATH']) if ENV['HOMEDRIVE'] && ENV['HOMEPATH']
19
19
  home ||= ENV['USERPROFILE']
20
20
  # XXX: old stuff; most likely unnecessary
21
- home = home.gsub("\\", "/") unless home.nil?
21
+ home = home.tr("\\", "/") unless home.nil?
22
22
  end
23
23
 
24
24
  (home && File.readable?(home)) ? home : Dir.pwd
@@ -65,8 +65,25 @@ class Netrc
65
65
  new(path, parse(lex([])))
66
66
  end
67
67
 
68
+ class TokenArray < Array
69
+ def take
70
+ if length < 1
71
+ raise Error, "unexpected EOF"
72
+ end
73
+ shift
74
+ end
75
+
76
+ def readto
77
+ l = []
78
+ while length > 0 && ! yield(self[0])
79
+ l << shift
80
+ end
81
+ return l.join
82
+ end
83
+ end
84
+
68
85
  def self.lex(lines)
69
- tokens = []
86
+ tokens = TokenArray.new
70
87
  for line in lines
71
88
  content, comment = line.split(/(\s*#.*)/m)
72
89
  content.each_char do |char|
@@ -96,6 +113,8 @@ class Netrc
96
113
  s =~ /^\s/
97
114
  end
98
115
 
116
+
117
+
99
118
  # Returns two values, a header and a list of items.
100
119
  # Each item is a tuple, containing some or all of:
101
120
  # - machine keyword (including trailing whitespace+comments)
@@ -110,19 +129,8 @@ class Netrc
110
129
  def self.parse(ts)
111
130
  cur, item = [], []
112
131
 
113
- def ts.take
114
- if length < 1
115
- raise Error, "unexpected EOF"
116
- end
117
- shift
118
- end
119
-
120
- def ts.readto
121
- l = []
122
- while length > 0 && ! yield(self[0])
123
- l << shift
124
- end
125
- return l.join
132
+ unless ts.is_a?(TokenArray)
133
+ ts = TokenArray.new(ts)
126
134
  end
127
135
 
128
136
  pre = ts.readto{|t| t == "machine" || t == "default"}
@@ -1,9 +1,9 @@
1
1
  $VERBOSE = true
2
- require 'test/unit'
2
+ require 'minitest/autorun'
3
3
 
4
4
  require File.expand_path("#{File.dirname(__FILE__)}/../lib/netrc")
5
5
 
6
- class TestLex < Test::Unit::TestCase
6
+ class TestLex < Minitest::Test
7
7
  def test_lex_empty
8
8
  t = Netrc.lex([])
9
9
  assert_equal([], t)
@@ -1,11 +1,11 @@
1
1
  $VERBOSE = true
2
- require 'test/unit'
2
+ require 'minitest/autorun'
3
3
  require 'fileutils'
4
4
 
5
5
  require File.expand_path("#{File.dirname(__FILE__)}/../lib/netrc")
6
6
  require "rbconfig"
7
7
 
8
- class TestNetrc < Test::Unit::TestCase
8
+ class TestNetrc < Minitest::Test
9
9
 
10
10
  def setup
11
11
  Dir.glob('data/*.netrc').each{|f| File.chmod(0600, f)}
@@ -205,6 +205,13 @@ class TestNetrc < Test::Unit::TestCase
205
205
  ENV["HOME"], nil_home = nil_home, ENV["HOME"]
206
206
  end
207
207
 
208
+ def test_netrc_environment_variable
209
+ ENV["NETRC"] = File.join(Dir.pwd, 'data')
210
+ assert_equal File.join(Dir.pwd, 'data', '.netrc'), Netrc.default_path
211
+ ensure
212
+ ENV.delete("NETRC")
213
+ end
214
+
208
215
  def test_read_entry
209
216
  entry = Netrc.read("data/sample.netrc")['m']
210
217
  assert_equal 'l', entry.login
@@ -1,9 +1,9 @@
1
1
  $VERBOSE = true
2
- require 'test/unit'
2
+ require 'minitest/autorun'
3
3
 
4
4
  require File.expand_path("#{File.dirname(__FILE__)}/../lib/netrc")
5
5
 
6
- class TestParse < Test::Unit::TestCase
6
+ class TestParse < Minitest::Test
7
7
  def test_parse_empty
8
8
  pre, items = Netrc.parse([])
9
9
  assert_equal("", pre)
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.10.3
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keith Rarick
@@ -9,10 +9,10 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-02-24 00:00:00.000000000 Z
12
+ date: 2015-10-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: turn
15
+ name: minitest
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
18
  - - ">="
@@ -68,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
68
  version: '0'
69
69
  requirements: []
70
70
  rubyforge_project:
71
- rubygems_version: 2.4.5
71
+ rubygems_version: 2.4.5.1
72
72
  signing_key:
73
73
  specification_version: 4
74
74
  summary: Library to read and write netrc files.