netrc 0.4 → 0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/netrc.rb +17 -2
  2. data/test/test_lex.rb +6 -0
  3. metadata +5 -4
data/lib/netrc.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class Netrc
2
- VERSION = "0.4"
2
+ VERSION = "0.5"
3
3
  Windows = (RUBY_PLATFORM =~ /win32|mingw32/i)
4
4
 
5
5
  def self.default_path
@@ -29,7 +29,22 @@ class Netrc
29
29
  tokens = []
30
30
  for line in lines
31
31
  content, comment = line.split(/(\s*#.*)/m)
32
- tokens += content.split(/\b/)
32
+ content.each_char do |char|
33
+ case char
34
+ when /\s/
35
+ if tokens.last && tokens.last[-1..-1] =~ /\s/
36
+ tokens.last << char
37
+ else
38
+ tokens << char
39
+ end
40
+ else
41
+ if tokens.last && tokens.last[-1..-1] =~ /\S/
42
+ tokens.last << char
43
+ else
44
+ tokens << char
45
+ end
46
+ end
47
+ end
33
48
  if comment
34
49
  tokens << comment
35
50
  end
data/test/test_lex.rb CHANGED
@@ -49,4 +49,10 @@ class TestLex < Test::Unit::TestCase
49
49
  e = ["machine", " ", "m", " ", "login", " ", "l", " ", "password", " ", "p", "\n"]
50
50
  assert_equal(e, t)
51
51
  end
52
+
53
+ def test_lex_complex
54
+ t = Netrc.lex(["machine sub.domain.com login email@domain.com password pass\n"])
55
+ e = ["machine", " ", "sub.domain.com", " ", "login", " ", "email@domain.com", " ", "password", " ", "pass", "\n"]
56
+ assert_equal(e, t)
57
+ end
52
58
  end
metadata CHANGED
@@ -1,19 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netrc
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.4'
4
+ version: '0.5'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Keith Rarick
9
+ - geemus (Wesley Beary)
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2011-11-23 00:00:00.000000000Z
13
+ date: 2011-11-29 00:00:00.000000000Z
13
14
  dependencies: []
14
15
  description: This library can read and update netrc files, preserving formatting including
15
16
  comments and whitespace.
16
- email: kr@xph.us
17
+ email: geemus@gmail.com
17
18
  executables: []
18
19
  extensions: []
19
20
  extra_rdoc_files: []
@@ -25,7 +26,7 @@ files:
25
26
  - test/test_lex.rb
26
27
  - test/test_netrc.rb
27
28
  - test/test_parse.rb
28
- homepage: https://github.com/kr/netrc
29
+ homepage: https://github.com/geemus/netrc
29
30
  licenses: []
30
31
  post_install_message:
31
32
  rdoc_options: []