netrc 0.6 → 0.7

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.
Files changed (2) hide show
  1. data/lib/netrc.rb +8 -13
  2. metadata +2 -2
@@ -1,5 +1,5 @@
1
1
  class Netrc
2
- VERSION = "0.6"
2
+ VERSION = "0.7"
3
3
  WINDOWS = (RUBY_PLATFORM =~ /win32|mingw32/i)
4
4
 
5
5
  def self.default_path
@@ -17,7 +17,7 @@ class Netrc
17
17
  if perm != 0600 && !(WINDOWS)
18
18
  raise Error, "Permission bits for '#{path}' should be 0600, but are "+perm.to_s(8)
19
19
  end
20
- new(path, parse(lex(IO.readlines(path))))
20
+ new(path, parse(lex(File.readlines(path))))
21
21
  rescue Errno::ENOENT
22
22
  new(path, parse(lex([])))
23
23
  end
@@ -107,22 +107,17 @@ class Netrc
107
107
  attr_accessor :new_item_prefix
108
108
 
109
109
  def [](k)
110
- for v in @data
111
- if v[1] == k
112
- return v[3], v[5]
113
- end
110
+ if item = @data.detect {|datum| datum[1] == k}
111
+ [item[3], item[5]]
114
112
  end
115
- nil
116
113
  end
117
114
 
118
115
  def []=(k, info)
119
- for v in @data
120
- if v[1] == k
121
- v[3], v[5] = info
122
- return
123
- end
116
+ if item = @data.detect {|datum| datum[1] == k}
117
+ item[3], item[5] = info
118
+ else
119
+ @data << new_item(k, info[0], info[1])
124
120
  end
125
- @data << new_item(k, info[0], info[1])
126
121
  end
127
122
 
128
123
  def count
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.6'
4
+ version: '0.7'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-02-21 00:00:00.000000000 Z
13
+ date: 2012-02-22 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: This library can read and update netrc files, preserving formatting including
16
16
  comments and whitespace.