# # Copyright (C) 2012 Marlus Saraiva, Rodrigo Maia # Copyright (C) 2013 Brice Texier # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. require "beardley/version" # require "beardley/core" # require "beardley/groovy" # require "beardley/barcode" # require "beardley/batik" # require "beardley/xml" require "pathname" require "digest" require "rjb" require "rjb-loader" module Beardley class << self attr_accessor :config, :exporters # Changes the level of verbosity def with_warnings(flag = nil) old_verbose, $VERBOSE = $VERBOSE, flag yield ensure $VERBOSE = old_verbose end end # Default report params self.config = { report_params: {} } self.exporters = { odt: 'net.sf.jasperreports.engine.export.oasis.JROdtExporter', ods: 'net.sf.jasperreports.engine.export.oasis.JROdsExporter', csv: 'net.sf.jasperreports.engine.export.JRCsvExporter', docx: 'net.sf.jasperreports.engine.export.ooxml.JRDocxExporter', xlsx: 'net.sf.jasperreports.engine.export.ooxml.JRXlsxExporter' } RjbLoader.before_load do |config| Dir[Pathname.new(__FILE__).dirname.join("..", "vendor", "java", "*.jar")].each do |path| config.classpath << File::PATH_SEPARATOR + File.expand_path(path) end end RjbLoader.after_load do |config| _Locale = Rjb::import('java.util.Locale') Beardley.config[:report_params]["REPORT_LOCALE"] = _Locale.new('en', 'US') Beardley.config[:report_params]["XML_LOCALE"] = _Locale.new('en', 'US') Beardley.config[:report_params]["XML_DATE_PATTERN"] = 'yyyy-MM-dd HH:mm:ss Z' Beardley.config[:report_params]["XML_NUMBER_PATTERN"] = '###0.00' end autoload :Report, 'beardley/report' # Rjb::load((["."] + # Beardley::Core.classpath + # Beardley::Groovy.classpath + # Beardley::Barcode.classpath + # Beardley::XML.classpath + # Beardley::Batik.classpath).join(File::PATH_SEPARATOR), # ['-Djava.awt.headless=true', '-Xms128M', '-Xmx256M']) # Locale = Rjb::import('java.util.Locale') # JRException = Rjb::import('net.sf.jasperreports.engine.JRException') # JRExporterParameter = Rjb::import('net.sf.jasperreports.engine.JRExporterParameter') # JRXmlUtils = Rjb::import('net.sf.jasperreports.engine.util.JRXmlUtils') # JRXPathQueryExecuterFactory = with_warnings { Rjb::import('net.sf.jasperreports.engine.query.JRXPathQueryExecuterFactory') } # JREmptyDataSource = Rjb::import('net.sf.jasperreports.engine.JREmptyDataSource') # JROdtExporter = Rjb::import('net.sf.jasperreports.engine.export.oasis.JROdtExporter') # JROdsExporter = Rjb::import('net.sf.jasperreports.engine.export.oasis.JROdsExporter') # JRCsvExporter = Rjb::import('net.sf.jasperreports.engine.export.JRCsvExporter') # JRDocxExporter = Rjb::import('net.sf.jasperreports.engine.export.ooxml.JRDocxExporter') # JRXlsxExporter = Rjb::import('net.sf.jasperreports.engine.export.ooxml.JRXlsxExporter') # JasperCompileManager = Rjb::import('net.sf.jasperreports.engine.JasperCompileManager') # JasperExportManager = Rjb::import('net.sf.jasperreports.engine.JasperExportManager') # JasperFillManager = Rjb::import('net.sf.jasperreports.engine.JasperFillManager') # JasperPrint = Rjb::import('net.sf.jasperreports.engine.JasperPrint') # InputSource = Rjb::import('org.xml.sax.InputSource') # StringReader = Rjb::import('java.io.StringReader') # HashMap = Rjb::import('java.util.HashMap') # ByteArrayInputStream = Rjb::import('java.io.ByteArrayInputStream') # JavaString = Rjb::import('java.lang.String') # JFreeChart = Rjb::import('org.jfree.chart.JFreeChart') # JavaStringBuffer = Rjb::import('java.lang.StringBuffer') end