netrc 0.2 → 0.3

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 +3 -3
  2. data/test/test_netrc.rb +7 -0
  3. metadata +2 -2
data/lib/netrc.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class Netrc
2
- VERSION = "0.2"
2
+ VERSION = "0.3"
3
3
  Windows = (RUBY_PLATFORM =~ /win32|mingw32/i)
4
4
 
5
5
  def self.default_path
@@ -18,7 +18,7 @@ class Netrc
18
18
  def self.read(path=default_path)
19
19
  perm = File.stat(path).mode & 0777
20
20
  if perm != 0600
21
- raise Error, "Permission bits should be 0600, but are "+perm.to_s(8)
21
+ raise Error, "Permission bits for '#{path}' should be 0600, but are "+perm.to_s(8)
22
22
  end
23
23
  new(path, parse(lex(IO.readlines(path))))
24
24
  rescue Errno::ENOENT
@@ -122,7 +122,7 @@ class Netrc
122
122
  end
123
123
 
124
124
  def save
125
- File.open(@path, 'w') {|file| file.print(unparse)}
125
+ File.open(@path, 'w', 0600) {|file| file.print(unparse)}
126
126
  end
127
127
 
128
128
  def unparse
data/test/test_netrc.rb CHANGED
@@ -93,4 +93,11 @@ class TestNetrc < MiniTest::Unit::TestCase
93
93
  n.save
94
94
  assert_equal(File.read("data/sample.netrc"), n.unparse)
95
95
  end
96
+
97
+ def test_save_create
98
+ FileUtils.rm_f("/tmp/created.netrc")
99
+ n = Netrc.read("/tmp/created.netrc")
100
+ n.save
101
+ assert_equal(0600, File.stat("/tmp/created.netrc").mode & 0777)
102
+ end
96
103
  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.2'
4
+ version: '0.3'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-16 00:00:00.000000000Z
12
+ date: 2011-11-21 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description: This library can read and update netrc files, preserving formatting including
15
15
  comments and whitespace.