hiera-mysql 0.1.0 → 0.1.1

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.
@@ -6,12 +6,17 @@ class Hiera
6
6
  module Backend
7
7
  class Mysql_backend
8
8
  def initialize
9
- require 'mysql'
9
+ begin
10
+ require 'mysql'
11
+ rescue LoadError
12
+ require 'rubygems'
13
+ require 'mysql'
14
+ end
15
+
10
16
  Hiera.debug("mysql_backend initialized")
11
- mysql_host = Config[:mysql][:host]
12
17
  end
13
18
  def lookup(key, scope, order_override, resolution_type)
14
- Hiera.debug("loaded mysql backend")
19
+ Hiera.debug("mysql_backend invoked lookup")
15
20
 
16
21
 
17
22
  # Parse the mysql query from the config, we also pass in key
@@ -52,6 +57,8 @@ class Hiera
52
57
  mysql_database=Config[:mysql][:database]
53
58
 
54
59
  dbh = Mysql.new(mysql_host, mysql_user, mysql_pass, mysql_database)
60
+ dbh.reconnect = true
61
+
55
62
  res = dbh.query(sql)
56
63
  Hiera.debug("Mysql Query returned #{res.num_rows} rows")
57
64
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Craig Dunn
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2012-03-03 00:00:00 +00:00
17
+ date: 2012-03-07 00:00:00 +00:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency