beardley 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.travis.yml +6 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +38 -0
- data/LICENSE +20 -0
- data/README.rdoc +11 -0
- data/Rakefile +12 -0
- data/beardley.gemspec +24 -0
- data/lib/beardley.rb +77 -0
- data/lib/beardley/report.rb +141 -0
- data/lib/beardley/version.rb +11 -0
- data/test/fixtures/barcode.jrxml +19 -0
- data/test/fixtures/empty.jrxml +27 -0
- data/test/helper.rb +19 -0
- data/test/test_print.rb +53 -0
- data/vendor/java/barbecue-1.5-beta1.jar +0 -0
- data/vendor/java/barcode4j-2.1.jar +0 -0
- data/vendor/java/commons-beanutils-1.8.2.jar +0 -0
- data/vendor/java/commons-collections-3.2.1.jar +0 -0
- data/vendor/java/commons-digester-2.1.jar +0 -0
- data/vendor/java/commons-logging-1.1.jar +0 -0
- data/vendor/java/iText-2.1.7.jar +0 -0
- data/vendor/java/jasperreports-5.0.0.jar +0 -0
- data/vendor/java/jcommon-1.0.15.jar +0 -0
- data/vendor/java/jfreechart-1.0.12.jar +0 -0
- data/vendor/java/xalan.jar +0 -0
- metadata +150 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
beardley (0.1.2)
|
5
|
+
beardley-groovy (>= 1.7.5)
|
6
|
+
rjb (= 1.4.6)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
beardley-groovy (1.7.5.0)
|
12
|
+
colorize (0.5.8)
|
13
|
+
coveralls (0.6.4)
|
14
|
+
colorize
|
15
|
+
multi_json (~> 1.3)
|
16
|
+
rest-client
|
17
|
+
simplecov (>= 0.7)
|
18
|
+
thor
|
19
|
+
mime-types (1.22)
|
20
|
+
multi_json (1.7.2)
|
21
|
+
rake (10.0.4)
|
22
|
+
rest-client (1.6.7)
|
23
|
+
mime-types (>= 1.16)
|
24
|
+
rjb (1.4.6)
|
25
|
+
simplecov (0.7.1)
|
26
|
+
multi_json (~> 1.0)
|
27
|
+
simplecov-html (~> 0.7.1)
|
28
|
+
simplecov-html (0.7.1)
|
29
|
+
thor (0.18.1)
|
30
|
+
|
31
|
+
PLATFORMS
|
32
|
+
ruby
|
33
|
+
|
34
|
+
DEPENDENCIES
|
35
|
+
beardley!
|
36
|
+
bundler (> 1)
|
37
|
+
coveralls (>= 0.6)
|
38
|
+
rake (>= 10)
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008-2012 Brice Texier
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
= Beardley
|
2
|
+
{<img src="https://badge.fury.io/rb/beardley.png" alt="Gem Version" />}[http://badge.fury.io/rb/beardley]
|
3
|
+
{<img src="https://api.travis-ci.org/burisu/beardley.png?branch=master"/>}[https://travis-ci.org/burisu/beardley]
|
4
|
+
{<img src="https://gemnasium.com/burisu/beardley.png"/>}[https://gemnasium.com/burisu/beardley]
|
5
|
+
{<img src="https://codeclimate.com/github/burisu/beardley.png" />}[https://codeclimate.com/github/burisu/beardley]
|
6
|
+
{<img src="https://coveralls.io/repos/burisu/beardley/badge.png?branch=master" alt="Coverage Status" />}[https://coveralls.io/r/burisu/beardley]
|
7
|
+
|
8
|
+
Beardley provides a minimal use of JasperReport.
|
9
|
+
|
10
|
+
== More informations
|
11
|
+
* http://en.wikipedia.org/wiki/List_of_recurring_The_Simpsons_characters#Jasper_Beardly
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'bundler'
|
3
|
+
Bundler::GemHelper.install_tasks
|
4
|
+
|
5
|
+
require 'rake/testtask'
|
6
|
+
Rake::TestTask.new(:test) do |test|
|
7
|
+
test.libs << 'lib' << 'test'
|
8
|
+
test.pattern = 'test/**/test_*.rb'
|
9
|
+
test.verbose = true
|
10
|
+
end
|
11
|
+
|
12
|
+
task :default => :test
|
data/beardley.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "beardley/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "beardley"
|
7
|
+
s.version = Beardley::VERSION::STRING
|
8
|
+
s.authors = ["Brice Texier"]
|
9
|
+
s.summary = %q{JasperReports integration}
|
10
|
+
s.description = %q{Generate reports using JasperReports reporting tool}
|
11
|
+
s.email = "burisu@oneiros.fr"
|
12
|
+
s.homepage = "https://github.com/burisu/beardley"
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
|
19
|
+
s.add_dependency('rjb', '1.4.6')
|
20
|
+
s.add_dependency('beardley-groovy', '>= 1.7.5')
|
21
|
+
s.add_development_dependency('rake', '>= 10')
|
22
|
+
s.add_development_dependency('coveralls', '>= 0.6')
|
23
|
+
s.add_development_dependency('bundler', '> 1')
|
24
|
+
end
|
data/lib/beardley.rb
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2012 Marlus Saraiva, Rodrigo Maia
|
3
|
+
# Copyright (C) 2013 Brice Texier
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
# a copy of this software and associated documentation files (the
|
7
|
+
# "Software"), to deal in the Software without restriction, including
|
8
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
# the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
require "beardley/version"
|
25
|
+
require "beardley-groovy"
|
26
|
+
require "pathname"
|
27
|
+
require "digest"
|
28
|
+
require "rjb"
|
29
|
+
|
30
|
+
|
31
|
+
module Beardley
|
32
|
+
|
33
|
+
class << self
|
34
|
+
attr_accessor :config
|
35
|
+
end
|
36
|
+
|
37
|
+
classpath = '.' + File::PATH_SEPARATOR + Beardley::Groovy.classpath.to_s
|
38
|
+
Dir["#{File.dirname(__FILE__)}/../vendor/java/*.jar"].each do |jar|
|
39
|
+
classpath << File::PATH_SEPARATOR + File.expand_path(jar)
|
40
|
+
end
|
41
|
+
|
42
|
+
Rjb::load( classpath, ['-Djava.awt.headless=true','-Xms128M', '-Xmx256M'] )
|
43
|
+
|
44
|
+
Locale = Rjb::import('java.util.Locale')
|
45
|
+
|
46
|
+
JRException = Rjb::import('net.sf.jasperreports.engine.JRException')
|
47
|
+
JRExporterParameter = Rjb::import('net.sf.jasperreports.engine.JRExporterParameter')
|
48
|
+
JRXmlUtils = Rjb::import('net.sf.jasperreports.engine.util.JRXmlUtils')
|
49
|
+
JRXPathQueryExecuterFactory = Rjb::import('net.sf.jasperreports.engine.query.JRXPathQueryExecuterFactory')
|
50
|
+
JREmptyDataSource = Rjb::import('net.sf.jasperreports.engine.JREmptyDataSource')
|
51
|
+
JROdtExporter = Rjb::import('net.sf.jasperreports.engine.export.oasis.JROdtExporter')
|
52
|
+
JRDocxExporter = Rjb::import('net.sf.jasperreports.engine.export.ooxml.JRDocxExporter')
|
53
|
+
|
54
|
+
JasperCompileManager = Rjb::import('net.sf.jasperreports.engine.JasperCompileManager')
|
55
|
+
JasperExportManager = Rjb::import('net.sf.jasperreports.engine.JasperExportManager')
|
56
|
+
JasperFillManager = Rjb::import('net.sf.jasperreports.engine.JasperFillManager')
|
57
|
+
JasperPrint = Rjb::import('net.sf.jasperreports.engine.JasperPrint')
|
58
|
+
|
59
|
+
InputSource = Rjb::import('org.xml.sax.InputSource')
|
60
|
+
StringReader = Rjb::import('java.io.StringReader')
|
61
|
+
HashMap = Rjb::import('java.util.HashMap')
|
62
|
+
ByteArrayInputStream = Rjb::import('java.io.ByteArrayInputStream')
|
63
|
+
JavaString = Rjb::import('java.lang.String')
|
64
|
+
JFreeChart = Rjb::import('org.jfree.chart.JFreeChart')
|
65
|
+
JavaStringBuffer = Rjb::import('java.lang.StringBuffer')
|
66
|
+
|
67
|
+
# Default report params
|
68
|
+
self.config = {
|
69
|
+
:report_params => {
|
70
|
+
"REPORT_LOCALE" => Locale.new('en', 'US'),
|
71
|
+
"XML_LOCALE" => Locale.new('en', 'US'),
|
72
|
+
"XML_DATE_PATTERN" => 'yyyy-MM-dd'
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
autoload :Report, 'beardley/report'
|
77
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2012 Marlus Saraiva, Rodrigo Maia
|
3
|
+
# Copyright (C) 2013 Brice Texier
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
# a copy of this software and associated documentation files (the
|
7
|
+
# "Software"), to deal in the Software without restriction, including
|
8
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
# the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
module Beardley
|
25
|
+
|
26
|
+
# This class permit to produce reports in PDF, ODT and DOCX using Jasper
|
27
|
+
class Report
|
28
|
+
attr_reader :source_file, :object_file
|
29
|
+
|
30
|
+
# Constructor for a report generator
|
31
|
+
def initialize(report, options = {})
|
32
|
+
@parameters = options.delete(:report) || {}
|
33
|
+
@source_file, @object_file = nil, nil
|
34
|
+
if report.is_a?(Pathname)
|
35
|
+
@source_file = report if report.extname.downcase == ".jrxml"
|
36
|
+
@object_file = report if report.extname.downcase == ".jasper"
|
37
|
+
elsif report.is_a?(String)
|
38
|
+
hash = Digest::SHA256.hexdigest(report)
|
39
|
+
@source_file = Pathname.new(options[:tmp_dir] || "/tmp").join("report-" + hash + '.jrxml')
|
40
|
+
File.open(@source_file, 'wb') do |f|
|
41
|
+
f.write(report)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
@object_file ||= @source_file.dirname.join(@source_file.basename.to_s + ".jasper")
|
45
|
+
raise ArgumentError.new("An object must be given at least") unless @object_file.is_a?(Pathname)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Export report to PDF with given datasource
|
49
|
+
def to_pdf(*args)
|
50
|
+
options = extract_options!(args)
|
51
|
+
datasource = args[0]
|
52
|
+
return JasperExportManager._invoke('exportReportToPdf', 'Lnet.sf.jasperreports.engine.JasperPrint;', prepare(datasource))
|
53
|
+
end
|
54
|
+
|
55
|
+
# Export report to ODT with given datasource
|
56
|
+
def to_odt(*args)
|
57
|
+
return to(:odt, *args)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Export report to DOCX with given datasource
|
61
|
+
def to_docx(*args)
|
62
|
+
return to(:docx, *args)
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
# Generic method to export to some format like ODT and DOCX
|
68
|
+
def to(format, *args)
|
69
|
+
options = extract_options!(args)
|
70
|
+
datasource = args[0]
|
71
|
+
file = Tempfile.new("to_#{format}")
|
72
|
+
exporter = Beardley.const_get("JR#{format.to_s.capitalize}Exporter").new
|
73
|
+
exporter.setParameter(JRExporterParameter.JASPER_PRINT, prepare(datasource))
|
74
|
+
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, file.path.to_s)
|
75
|
+
exporter.exportReport
|
76
|
+
file.rewind
|
77
|
+
report = file.read
|
78
|
+
file.close(true)
|
79
|
+
return report
|
80
|
+
end
|
81
|
+
|
82
|
+
# Extract options from a list of arguments
|
83
|
+
def extract_options!(args)
|
84
|
+
return (args[-1].is_a?(Hash) ? args.delete_at(-1) : {})
|
85
|
+
end
|
86
|
+
|
87
|
+
# Create object file if not exist and load datasource
|
88
|
+
def prepare(datasource = nil)
|
89
|
+
# Compile it, if needed
|
90
|
+
if @source_file && ((!@object_file.exist? && @source_file.exist?) || (@source_file.exist? && @source_file.mtime > @object_file.mtime))
|
91
|
+
JasperCompileManager.compileReportToFile(@source_file.to_s, @object_file.to_s)
|
92
|
+
end
|
93
|
+
load_datasource(datasource)
|
94
|
+
end
|
95
|
+
|
96
|
+
# Load parsed XML datasource with java component
|
97
|
+
def load_datasource(datasource = nil)
|
98
|
+
# Converting default report params to java HashMap
|
99
|
+
jasper_params = HashMap.new
|
100
|
+
Beardley.config[:report_params].each do |k,v|
|
101
|
+
jasper_params.put(k, v)
|
102
|
+
end
|
103
|
+
|
104
|
+
# Convert the ruby parameters' hash to a java HashMap, but keeps it as
|
105
|
+
# default when they already represent a JRB entity.
|
106
|
+
# Pay attention that, for now, all other parameters are converted to string!
|
107
|
+
@parameters.each do |key, value|
|
108
|
+
jasper_params.put(JavaString.new(key.to_s), parameter_value_of(value))
|
109
|
+
end
|
110
|
+
|
111
|
+
jasper_print = nil
|
112
|
+
|
113
|
+
# Fill the report
|
114
|
+
if datasource
|
115
|
+
input_source = InputSource.new
|
116
|
+
input_source.setCharacterStream(StringReader.new(datasource.to_s))
|
117
|
+
data_document = JRXmlUtils._invoke('parse', 'Lorg.xml.sax.InputSource;', input_source)
|
118
|
+
|
119
|
+
jasper_params.put(JRXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT, data_document)
|
120
|
+
jasper_print = JasperFillManager.fillReport(@object_file.to_s, jasper_params)
|
121
|
+
else
|
122
|
+
jasper_print = JasperFillManager.fillReport(@object_file.to_s, jasper_params, JREmptyDataSource.new)
|
123
|
+
end
|
124
|
+
return jasper_print
|
125
|
+
end
|
126
|
+
|
127
|
+
# Returns the value without conversion when it's converted to Java Types.
|
128
|
+
# When isn't a Rjb class, returns a Java String of it.
|
129
|
+
def parameter_value_of(param)
|
130
|
+
# Using Rjb::import('java.util.HashMap').new, it returns an instance of
|
131
|
+
# Rjb::Rjb_JavaProxy, so the Rjb_JavaProxy parent is the Rjb module itself.
|
132
|
+
if param.class.parent == Rjb
|
133
|
+
param
|
134
|
+
else
|
135
|
+
JavaString.new(param.to_s)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="barcode_v2" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="541d2746-f9ec-4e09-a5f3-c1d8820d80ab">
|
3
|
+
<property name="ireport.zoom" value="1.0"/>
|
4
|
+
<property name="ireport.x" value="0"/>
|
5
|
+
<property name="ireport.y" value="0"/>
|
6
|
+
<background>
|
7
|
+
<band splitType="Stretch"/>
|
8
|
+
</background>
|
9
|
+
<title>
|
10
|
+
<band height="79" splitType="Stretch">
|
11
|
+
<componentElement>
|
12
|
+
<reportElement uuid="7484d411-2749-4a11-aa2a-19384e63122f" x="165" y="29" width="200" height="50"/>
|
13
|
+
<jr:barbecue xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" type="PDF417" drawText="false" checksumRequired="false">
|
14
|
+
<jr:codeExpression><![CDATA["1234"]]></jr:codeExpression>
|
15
|
+
</jr:barbecue>
|
16
|
+
</componentElement>
|
17
|
+
</band>
|
18
|
+
</title>
|
19
|
+
</jasperReport>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="empty" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="e240522d-9475-4430-b448-16f6a8e3a3cd">
|
3
|
+
<background>
|
4
|
+
<band splitType="Stretch"/>
|
5
|
+
</background>
|
6
|
+
<title>
|
7
|
+
<band height="79" splitType="Stretch"/>
|
8
|
+
</title>
|
9
|
+
<pageHeader>
|
10
|
+
<band height="35" splitType="Stretch"/>
|
11
|
+
</pageHeader>
|
12
|
+
<columnHeader>
|
13
|
+
<band height="61" splitType="Stretch"/>
|
14
|
+
</columnHeader>
|
15
|
+
<detail>
|
16
|
+
<band height="125" splitType="Stretch"/>
|
17
|
+
</detail>
|
18
|
+
<columnFooter>
|
19
|
+
<band height="45" splitType="Stretch"/>
|
20
|
+
</columnFooter>
|
21
|
+
<pageFooter>
|
22
|
+
<band height="54" splitType="Stretch"/>
|
23
|
+
</pageFooter>
|
24
|
+
<summary>
|
25
|
+
<band height="42" splitType="Stretch"/>
|
26
|
+
</summary>
|
27
|
+
</jasperReport>
|
data/test/helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'coveralls'
|
2
|
+
Coveralls.wear!
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'test/unit'
|
6
|
+
|
7
|
+
# Load JAVA env variables
|
8
|
+
begin
|
9
|
+
ENV['JAVA_HOME'] ||= `readlink -f /usr/bin/java | sed "s:/jre/bin/java::"`.strip
|
10
|
+
architecture = `dpkg --print-architecture`.strip
|
11
|
+
ENV['LD_LIBRARY_PATH'] = "#{ENV['LD_LIBRARY_PATH']}:#{ENV['JAVA_HOME']}/jre/lib/#{architecture}:#{ENV['JAVA_HOME']}/jre/lib/#{architecture}/client"
|
12
|
+
rescue
|
13
|
+
puts "JAVA_HOME has not been set automatically because it's not Debian here."
|
14
|
+
end
|
15
|
+
|
16
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
17
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
18
|
+
|
19
|
+
require 'beardley'
|
data/test/test_print.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
class TestPrint < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_print_of_a_xml_string
|
7
|
+
report = Beardley::Report.new('<?xml version="1.0" encoding="UTF-8"?>
|
8
|
+
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="show" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="9c1f11b7-03dd-4803-9e1b-41b87b9d23c0"/>')
|
9
|
+
assert_equal Pathname, report.source_file.class
|
10
|
+
assert_equal Pathname, report.object_file.class
|
11
|
+
report.to_pdf
|
12
|
+
report.to_odt
|
13
|
+
report.to_docx
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_print_of_empty_report
|
17
|
+
empty = Pathname.new(__FILE__).dirname.join("fixtures", "empty.jrxml")
|
18
|
+
assert empty.exist?
|
19
|
+
report = Beardley::Report.new(empty)
|
20
|
+
assert_equal Pathname, report.source_file.class
|
21
|
+
assert_equal Pathname, report.object_file.class
|
22
|
+
report.to_pdf
|
23
|
+
report.to_odt
|
24
|
+
report.to_docx
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_print_of_empty_report_with_datasource
|
28
|
+
empty = Pathname.new(__FILE__).dirname.join("fixtures", "empty.jrxml")
|
29
|
+
assert empty.exist?
|
30
|
+
report = Beardley::Report.new(empty)
|
31
|
+
assert_equal Pathname, report.source_file.class
|
32
|
+
assert_equal Pathname, report.object_file.class
|
33
|
+
datasource = '<?xml version="1.0" encoding="UTF-8"?>
|
34
|
+
<things><thing name="First">1</thing><thing name="Second">2</thing></things>'
|
35
|
+
report.to_pdf(datasource)
|
36
|
+
report.to_odt(datasource)
|
37
|
+
report.to_docx(datasource)
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_print_of_barcode_report
|
41
|
+
barcode = Pathname.new(__FILE__).dirname.join("fixtures", "barcode.jrxml")
|
42
|
+
assert barcode.exist?
|
43
|
+
report = Beardley::Report.new(barcode)
|
44
|
+
assert_equal Pathname, report.source_file.class
|
45
|
+
assert_equal Pathname, report.object_file.class
|
46
|
+
report.to_pdf
|
47
|
+
report.to_odt
|
48
|
+
report.to_docx
|
49
|
+
end
|
50
|
+
|
51
|
+
# TODO Test parameters
|
52
|
+
|
53
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: beardley
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Brice Texier
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-04-07 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rjb
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - '='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.4.6
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - '='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.4.6
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: beardley-groovy
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.7.5
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.7.5
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '10'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: coveralls
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0.6'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0.6'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: bundler
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>'
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '1'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>'
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '1'
|
94
|
+
description: Generate reports using JasperReports reporting tool
|
95
|
+
email: burisu@oneiros.fr
|
96
|
+
executables: []
|
97
|
+
extensions: []
|
98
|
+
extra_rdoc_files: []
|
99
|
+
files:
|
100
|
+
- .gitignore
|
101
|
+
- .travis.yml
|
102
|
+
- Gemfile
|
103
|
+
- Gemfile.lock
|
104
|
+
- LICENSE
|
105
|
+
- README.rdoc
|
106
|
+
- Rakefile
|
107
|
+
- beardley.gemspec
|
108
|
+
- lib/beardley.rb
|
109
|
+
- lib/beardley/report.rb
|
110
|
+
- lib/beardley/version.rb
|
111
|
+
- test/fixtures/barcode.jrxml
|
112
|
+
- test/fixtures/empty.jrxml
|
113
|
+
- test/helper.rb
|
114
|
+
- test/test_print.rb
|
115
|
+
- vendor/java/barbecue-1.5-beta1.jar
|
116
|
+
- vendor/java/barcode4j-2.1.jar
|
117
|
+
- vendor/java/commons-beanutils-1.8.2.jar
|
118
|
+
- vendor/java/commons-collections-3.2.1.jar
|
119
|
+
- vendor/java/commons-digester-2.1.jar
|
120
|
+
- vendor/java/commons-logging-1.1.jar
|
121
|
+
- vendor/java/iText-2.1.7.jar
|
122
|
+
- vendor/java/jasperreports-5.0.0.jar
|
123
|
+
- vendor/java/jcommon-1.0.15.jar
|
124
|
+
- vendor/java/jfreechart-1.0.12.jar
|
125
|
+
- vendor/java/xalan.jar
|
126
|
+
homepage: https://github.com/burisu/beardley
|
127
|
+
licenses: []
|
128
|
+
post_install_message:
|
129
|
+
rdoc_options: []
|
130
|
+
require_paths:
|
131
|
+
- lib
|
132
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
+
none: false
|
134
|
+
requirements:
|
135
|
+
- - ! '>='
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
|
+
none: false
|
140
|
+
requirements:
|
141
|
+
- - ! '>='
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
requirements: []
|
145
|
+
rubyforge_project:
|
146
|
+
rubygems_version: 1.8.23
|
147
|
+
signing_key:
|
148
|
+
specification_version: 3
|
149
|
+
summary: JasperReports integration
|
150
|
+
test_files: []
|