app_conf 0.2.7 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
data/app_conf.gemspec CHANGED
@@ -2,7 +2,7 @@ require 'base64'
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'app_conf'
5
- s.version = '0.2.7'
5
+ s.version = '0.2.8'
6
6
  s.authors = 'Phil Thompson'
7
7
  s.email = Base64.decode64("cGhpbEBlbGVjdHJpY3Zpc2lvbnMuY29t\n")
8
8
  s.summary = 'Simplest YAML Backed Application Wide Configuration (AppConfig)'
data/lib/app_conf.rb CHANGED
@@ -14,17 +14,13 @@ class AppConf
14
14
  end
15
15
 
16
16
  def self.save(key, filename)
17
-
18
-
19
17
  mode = File.exist?(filename) ? 'r+' : 'w+'
20
18
  File.open(filename, mode) do |f|
21
19
  unless f.eof?
22
20
  begin
23
21
  pos = f.pos
24
22
  line = f.readline
25
- rescue
26
- raise YAML::ParseError, 'No document start (---) found.'
27
- end until line =~ /^---/
23
+ end until line =~ /^---/ || f.eof?
28
24
  f.seek(pos)
29
25
  end
30
26
  hash = {key.to_s => @@root[key].to_hash}
@@ -45,9 +45,10 @@ user:
45
45
  File.read('config.yml').must_equal "# comment 1\n# comment 2\n\n--- \nuser: \n name: \n first: Joe\n"
46
46
  end
47
47
 
48
- it 'fails when no ---' do
48
+ it 'overwrites when no ---' do
49
49
  File.open('config.yml', 'w') {|f| f.write('some config') }
50
- lambda {AppConf.save :user, 'config.yml'}.must_raise YAML::ParseError
50
+ AppConf.save :user, 'config.yml'
51
+ File.read('config.yml').must_equal "--- \nuser: \n name: \n first: Joe\n"
51
52
  end
52
53
  end
53
54
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app_conf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-17 00:00:00.000000000Z
12
+ date: 2011-12-19 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fakefs
16
- requirement: &9586880 !ruby/object:Gem::Requirement
16
+ requirement: &22647140 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *9586880
24
+ version_requirements: *22647140
25
25
  description:
26
26
  email: phil@electricvisions.com
27
27
  executables: []