Skip to content

Commit

Permalink
Use interpoleted strings instead of printf style.
Browse files Browse the repository at this point in the history
  • Loading branch information
hugopl committed Aug 3, 2015
1 parent 68c8a77 commit 31c5fb3
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions lib/hiera/backend/redis_backend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Redis_backend
attr_reader :redis, :options

def initialize
Hiera.debug('Hiera Redis backend %s starting' % VERSION)
Hiera.debug("Hiera Redis backend #{VERSION} starting")
@redis = connect
end

Expand All @@ -22,26 +22,26 @@ def deserialize(args = {})
require 'yaml'
YAML::load args[:data]
else
Hiera.warn 'Invalid configuration for :deserialize; found %s' % options[:deserialize]
Hiera.warn("Invalid configuration for :deserialize; found #{options[:deserialize]}")
args[:data]
end

Hiera.debug 'Deserialized %s' % options[:deserialize].to_s.upcase
Hiera.debug("Deserialized #{options[:deserialize].to_s.upcase}")
result

# when we try to deserialize a string
rescue JSON::ParserError
args[:data]
rescue => e
Hiera.warn 'Exception raised: %s: %s' % [e.class, e.message]
Hiera.warn("Exception raised: #{e.class}: #{e.message}")
end

def lookup(key, scope, order_override, resolution_type, context = {})
answer = nil

Backend.datasources(scope, order_override) do |source|
redis_key = '%s' % [source.split('/'), key].join(options[:separator])
Hiera.debug 'Looking for %s%s%s' % [source, options[:separator], key]
redis_key = [source.split('/'), key].join(options[:separator]).to_s
Hiera.debug("Looking for #{source}#{options[:separator]}#{key}")

data = redis_query redis_key

Expand Down Expand Up @@ -74,7 +74,6 @@ def lookup(key, scope, order_override, resolution_type, context = {})
private

def connect

# override default options
@options = {
:host => 'localhost',
Expand All @@ -95,7 +94,6 @@ def connect
end

def redis_query(redis_key)

case redis.type redis_key
when 'set'
redis.smembers redis_key
Expand All @@ -108,7 +106,7 @@ def redis_query(redis_key)
when 'zset'
redis.zrange(redis_key, 0, -1)
else
Hiera.debug('No such key: %s' % redis_key)
Hiera.debug("No such key: #{redis_key}")
nil
end
rescue Redis::CannotConnectError => e
Expand Down

0 comments on commit 31c5fb3

Please sign in to comment.