Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merged with twilson63/master

  • Loading branch information...
commit c4a3c6b1a47c8d4f1a8a62a830e805ae608e3039 2 parents 2f10901 + ae67480
@danieltamiosso danieltamiosso authored
View
1  .rvmrc
@@ -0,0 +1 @@
+rvm use jruby
View
1  CHANGELOG
@@ -0,0 +1 @@
+6-27-2011 - bumped version 0.1.0
View
2  Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- casperreports (0.1.2)
+ casperreports (0.0.4)
GEM
remote: http://rubygems.org/
View
8 casper_reports.gemspec
@@ -5,15 +5,15 @@ $:.unshift lib unless $:.include?(lib)
Gem::Specification.new do |s|
s.name = "casperreports"
- s.version = "0.1.2"
+ s.version = "0.1.1"
s.platform = Gem::Platform::RUBY
- s.authors = ["Tom Wilson"]
+ s.authors = ["Tom Wilson","Daniel Tamiosso"]
s.email = ["tom@jackhq.com"]
s.homepage = "http://github.com/twilson63/casper"
s.summary = "An Opinionated Library for JasperReports"
- s.description = "A simple library that allows you to send a jrxml document, xml document, and selector to generate a jaspser pdf report. "
+ s.description = "A simple library that allows you to send a jrxml document, xml document, selector, and type ('pdf','xls') to generate a jaspser report. "
s.required_rubygems_version = ">= 1.3.6"
s.add_development_dependency "rspec", ">= 2.5.0"
s.files = Dir.glob("{lib}/**/*") + Dir.glob("{include}/**/*") + Dir.glob("{spec}/**/*") + %w(LICENSE readme.md Rakefile)
s.require_path = 'lib'
-end
+end
View
21 lib/casper_reports.rb
@@ -1,3 +1,19 @@
+# Welcome to Casper
+# The friendly cousin of Jasper Reports
+
+# Casper allows you to generate a pdf from a jrxml file, xml data, and a xpath selector
+
+# The compile statement return a string of bytes that can be streammed to file or to
+# a browser.
+
+# Example:
+#
+# c = Casper.new
+# pdf_data = c.compile open('text.jrxml'), open('data.xml'), '//node', 'pdf'
+# open('mypdf.pdf', 'wb').write pdf_data
+
+# Requirements
+# This Gem requires jruby > 1.6.0
require 'java'
# Load Jar and Java Classes
@@ -14,9 +30,10 @@
# Provide a simple class interface to running a jasper report
class CasperReports
+ VERSION = '0.1.1'
- def compile(jrxml, data, xpath, type)
+ def compile(jrxml, data, xpath, type='pdf')
String.from_java_bytes(Java::XmlDataReportProducer.compile(jrxml, data, xpath, type))
end
-end
+end
View
13 spec/data/testreport.jrxml
@@ -12,6 +12,9 @@
<field name="last-name" class="java.lang.String">
<fieldDescription><![CDATA[last-name]]></fieldDescription>
</field>
+ <field name="work-phone" class="java.lang.String">
+ <fieldDescription><![CDATA[work-phone]]></fieldDescription>
+ </field>
<background>
<band splitType="Stretch"/>
</background>
@@ -33,6 +36,11 @@
<textElement/>
<text><![CDATA[last-name]]></text>
</staticText>
+ <staticText>
+ <reportElement x="283" y="0" width="100" height="20"/>
+ <textElement/>
+ <text><![CDATA[work-phone]]></text>
+ </staticText>
</band>
</columnHeader>
<detail>
@@ -47,6 +55,11 @@
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA[$F{last-name}]]></textFieldExpression>
</textField>
+ <textField>
+ <reportElement x="283" y="3" width="100" height="20"/>
+ <textElement/>
+ <textFieldExpression class="java.lang.String"><![CDATA[$F{work-phone}]]></textFieldExpression>
+ </textField>
</band>
</detail>
<columnFooter>
Please sign in to comment.
Something went wrong with that request. Please try again.