hiera 1.1.1 → 1.1.2.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of hiera might be problematic. Click here for more details.

data/lib/hiera.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'yaml'
2
2
 
3
3
  class Hiera
4
- VERSION = "1.1.1"
4
+ VERSION = "1.1.2-rc1"
5
5
 
6
6
  autoload :Config, "hiera/config"
7
7
  autoload :Util, "hiera/util"
data/lib/hiera/config.rb CHANGED
@@ -1,17 +1,30 @@
1
1
  class Hiera::Config
2
2
  class << self
3
- # Takes a string or hash as input, strings are treated as filenames
3
+ ##
4
+ # load takes a string or hash as input, strings are treated as filenames
4
5
  # hashes are stored as data that would have been in the config file
5
6
  #
6
7
  # Unless specified it will only use YAML as backend with a single
7
8
  # 'common' hierarchy and console logger
9
+ #
10
+ # @return [Hash] representing the configuration. e.g.
11
+ # {:backends => "yaml", :hierarchy => "common"}
8
12
  def load(source)
9
13
  @config = {:backends => "yaml",
10
14
  :hierarchy => "common"}
11
15
 
12
16
  if source.is_a?(String)
13
17
  if File.exist?(source)
14
- config = YAML.load_file(source)
18
+ config = begin
19
+ yaml_load_file(source)
20
+ rescue TypeError => detail
21
+ case detail.message
22
+ when /no implicit conversion from nil to integer/
23
+ false
24
+ else
25
+ raise detail
26
+ end
27
+ end
15
28
  @config.merge! config if config
16
29
  else
17
30
  raise "Config file #{source} not found"
@@ -32,6 +45,16 @@ class Hiera::Config
32
45
  @config
33
46
  end
34
47
 
48
+ ##
49
+ # yaml_load_file directly delegates to YAML.load_file and is intended to be
50
+ # a private, internal method suitable for stubbing and mocking.
51
+ #
52
+ # @return [Object] return value of {YAML.load_file}
53
+ def yaml_load_file(source)
54
+ YAML.load_file(source)
55
+ end
56
+ private :yaml_load_file
57
+
35
58
  def load_backends
36
59
  @config[:backends].each do |backend|
37
60
  begin
@@ -59,6 +59,18 @@ class Hiera
59
59
  Hiera.expects(:logger=).with("console")
60
60
  Config.load({})
61
61
  end
62
+
63
+ context "loading '/dev/null' as spec tests do" do
64
+ before :each do
65
+ # Simulate the behavior of YAML.load_file('/dev/null') in MRI 1.9.3p194
66
+ Config.stubs(:yaml_load_file).
67
+ raises(TypeError, "no implicit conversion from nil to integer")
68
+ end
69
+
70
+ it "is not exceptional behavior" do
71
+ expect { Config.load('/dev/null') }.to_not raise_error
72
+ end
73
+ end
62
74
  end
63
75
 
64
76
  describe "#load_backends" do
metadata CHANGED
@@ -1,13 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hiera
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
5
- prerelease:
4
+ hash: -3999677168
5
+ prerelease: 6
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
+ - 2
10
+ - rc
9
11
  - 1
10
- version: 1.1.1
12
+ version: 1.1.2.rc1
11
13
  platform: ruby
12
14
  authors:
13
15
  - Puppet Labs
@@ -15,7 +17,7 @@ autorequire:
15
17
  bindir: bin
16
18
  cert_chain: []
17
19
 
18
- date: 2012-10-31 00:00:00 Z
20
+ date: 2012-12-19 00:00:00 Z
19
21
  dependencies:
20
22
  - !ruby/object:Gem::Dependency
21
23
  name: json
@@ -81,12 +83,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
83
  required_rubygems_version: !ruby/object:Gem::Requirement
82
84
  none: false
83
85
  requirements:
84
- - - ">="
86
+ - - ">"
85
87
  - !ruby/object:Gem::Version
86
- hash: 3
88
+ hash: 25
87
89
  segments:
88
- - 0
89
- version: "0"
90
+ - 1
91
+ - 3
92
+ - 1
93
+ version: 1.3.1
90
94
  requirements: []
91
95
 
92
96
  rubyforge_project: