# encoding: utf-8

# Copyright (C) 2011 Clemens Fuchslocher <clemens@vakuumverpackt.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

begin
	require 'json'
rescue LoadError => e
	raise 'Please install the json gem and try again: jruby --1.9 -S gem install json'
end

require_relative 'Renderer'

module VoidMeter

	class JsonRenderer < Renderer
		def initialize(results, path)
			@results = results
			@path = path
			mkdir(@path)
		end

		def render
			File.open("#{@path}/VoidMeter.json", 'w') do |file|
				file.puts(@results.results.to_json)
			end
		end
	end

end
