Skip to content

Commit

Permalink
return yamler to original state after fussing with it
Browse files Browse the repository at this point in the history
  • Loading branch information
gnarg committed Aug 16, 2011
1 parent dabac4f commit 5d83d59
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
11 changes: 9 additions & 2 deletions lib/new_relic/control/instance_methods.rb
@@ -1,5 +1,9 @@
require 'new_relic/language_support'

module NewRelic
class Control
include NewRelic::LanguageSupport::Control

# Contains methods that relate to the runtime usage of the control
# object. Note that these are subject to override in the
# NewRelic::Control::Framework classes that are actually instantiated
Expand Down Expand Up @@ -147,15 +151,18 @@ def initialize local_env, config_file_override=nil
puts "Cannot find or read #{newrelic_file}"
@yaml = {}
else
YAML::ENGINE.yamler = 'syck' if defined?(YAML::ENGINE)
@yaml = YAML.load(ERB.new(File.read(newrelic_file)).result(binding))
@yaml = load_newrelic_yml(newrelic_file, binding)
end
rescue ScriptError, StandardError => e
puts e
puts e.backtrace.join("\n")
raise "Error reading newrelic.yml file: #{e}"
end

def load_newrelic_yml(path, binding)
YAML.load(ERB.new(File.read(path)).result(binding))
end

def root
'.'
end
Expand Down
19 changes: 18 additions & 1 deletion lib/new_relic/language_support.rb
Expand Up @@ -14,7 +14,24 @@ def self.load(*args)
end
end
end


module Control
def self.included(base)
# need to use syck rather than psych when possible
if defined?(::YAML::ENGINE)
base.class_eval do
def load_newrelic_yml(*args)
yamler = ::YAML::ENGINE.yamler
::YAML::ENGINE.yamler = 'syck'
val = super
::YAML::ENGINE.yamler = yamler
val
end
end
end
end
end

module SynchronizedHash
def self.included(base)
# need to lock iteration of stats hash in 1.9.x
Expand Down

0 comments on commit 5d83d59

Please sign in to comment.