jasper-rails 0.1.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/LICENSE.txt +21 -0
- data/README.md +123 -0
- data/lib/jasper-rails.rb +28 -4
- data/lib/jasper-rails/version.rb +1 -1
- data/lib/java/jasperreports-4.7.1.jar +0 -0
- metadata +52 -31
- data/lib/java/jasperreports-4.5.1.jar +0 -0
data/.gitignore
CHANGED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
Copyright (C) 2012 Marlus Saraiva, Rodrigo Maia
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
# jasper-rails
|
2
|
+
|
3
|
+
JasperReports/Rails integration using Rjb (Ruby Java Bridge)
|
4
|
+
|
5
|
+
For rspec integration, see: [jasper-rails-rspec](http://github.com/fortesinformatica/jasper-rails-rspec).
|
6
|
+
|
7
|
+
# News!
|
8
|
+
|
9
|
+
Updated to JasperReports 4.7.1
|
10
|
+
|
11
|
+
## Dependencies
|
12
|
+
|
13
|
+
You need a Java Virtual Machine installed and set up in order to use this gem.
|
14
|
+
|
15
|
+
## Install
|
16
|
+
|
17
|
+
```
|
18
|
+
gem install jasper-rails
|
19
|
+
```
|
20
|
+
|
21
|
+
## Configure
|
22
|
+
|
23
|
+
Add `jasper-rails` to your Gemfile:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
gem "jasper-rails"
|
27
|
+
```
|
28
|
+
|
29
|
+
Note: If you're running your application on OS X, this is usually all you have to do. On Linux, you might have
|
30
|
+
to set the JAVA_HOME. On Windows, good luck!
|
31
|
+
|
32
|
+
For any issues related to the java/ruby integration, please check out: [http://rjb.rubyforge.org/](http://rjb.rubyforge.org/). You will find here plenty tips that might help you to solve your problem.
|
33
|
+
|
34
|
+
## Using jasper-rails
|
35
|
+
|
36
|
+
1) Tell your controller that it "responds to" :pdf and it "responds with" some list:
|
37
|
+
|
38
|
+
Note: This list will become your datasource inside the report.
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
respond_to :html, :xml, :pdf
|
42
|
+
|
43
|
+
def index
|
44
|
+
@people = Person.all
|
45
|
+
respond_with @people
|
46
|
+
end
|
47
|
+
```
|
48
|
+
|
49
|
+
2) Create your jasper report source file using iReport or any compatible jasper tool.
|
50
|
+
|
51
|
+
3) Set the "Query Text" and "The language for the dataset query" properties of your report.
|
52
|
+
|
53
|
+
Note: If you're using iReport, you can find those properties in the "Properties panel".
|
54
|
+
Don't forget to select the report root node in your "Report inspector".
|
55
|
+
|
56
|
+
Example: If you have a list of people, you should have something like:
|
57
|
+
* "Query Text" = /people/person
|
58
|
+
* "The language for the dataset query" = xpath
|
59
|
+
|
60
|
+
4) Design your report (add fields, groups, images, etc.)
|
61
|
+
|
62
|
+
5) Save the report source file in your views folder (just like any other html view file):
|
63
|
+
|
64
|
+
Example:
|
65
|
+
|
66
|
+
* app/views/people/index.jrxml
|
67
|
+
|
68
|
+
## Parameters
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
def index
|
72
|
+
@people = Person.all
|
73
|
+
|
74
|
+
# This variable will be available in your report!
|
75
|
+
@user = "John Doe"
|
76
|
+
|
77
|
+
respond_with @people
|
78
|
+
end
|
79
|
+
```
|
80
|
+
|
81
|
+
All you have to do now is to create, in iReport, a parameter called "user" (yes, without the "@") and drop it in your report!
|
82
|
+
|
83
|
+
Limitation: By now, all parameters are converted to java String. We intend to change this in the near future.
|
84
|
+
|
85
|
+
## RSpec integration
|
86
|
+
Check out: [jasper-rails-rspec](http://github.com/fortesinformatica/jasper-rails-rspec).
|
87
|
+
|
88
|
+
## DEMO
|
89
|
+
For a running example, just clone: [jasper-rails-demo](http://github.com/fortesinformatica/jasper-rails-demo).
|
90
|
+
|
91
|
+
## History
|
92
|
+
This project was first developed at Grupo Fortes in 2011 and we have been using it in several projects since then.
|
93
|
+
Pay attention that all the features it supports right now were based in those project's especific needs. Therefore you might find a lot of
|
94
|
+
JasperResports' features that are not yet supported. So, use it at your own risk!
|
95
|
+
|
96
|
+
## TODO
|
97
|
+
* Configuration
|
98
|
+
* Better error treatment
|
99
|
+
* More RSpec matchers
|
100
|
+
* SPECS!!!
|
101
|
+
|
102
|
+
## LICENSE
|
103
|
+
|
104
|
+
Copyright (C) 2012 Marlus Saraiva, Rodrigo Maia
|
105
|
+
|
106
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
107
|
+
a copy of this software and associated documentation files (the
|
108
|
+
"Software"), to deal in the Software without restriction, including
|
109
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
110
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
111
|
+
permit persons to whom the Software is furnished to do so, subject to
|
112
|
+
the following conditions:
|
113
|
+
|
114
|
+
The above copyright notice and this permission notice shall be
|
115
|
+
included in all copies or substantial portions of the Software.
|
116
|
+
|
117
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
118
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
119
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
120
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
121
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
122
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
123
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/jasper-rails.rb
CHANGED
@@ -1,8 +1,32 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2012 Marlus Saraiva, Rodrigo Maia
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
|
1
23
|
require "jasper-rails/version"
|
2
24
|
require "rails"
|
3
25
|
require "rjb"
|
4
26
|
|
5
|
-
Mime::Type.
|
27
|
+
if Mime::Type.lookup_by_extension("pdf").nil?
|
28
|
+
Mime::Type.register "application/pdf", :pdf
|
29
|
+
end
|
6
30
|
|
7
31
|
module JasperRails
|
8
32
|
|
@@ -10,7 +34,7 @@ module JasperRails
|
|
10
34
|
Dir["#{File.dirname(__FILE__)}/java/*.jar"].each do |jar|
|
11
35
|
classpath << File::PATH_SEPARATOR + File.expand_path(jar)
|
12
36
|
end
|
13
|
-
|
37
|
+
|
14
38
|
Dir["lib/*.jar"].each do |jar|
|
15
39
|
classpath << File::PATH_SEPARATOR + File.expand_path(jar)
|
16
40
|
end
|
@@ -23,7 +47,8 @@ module JasperRails
|
|
23
47
|
JasperFillManager = Rjb::import 'net.sf.jasperreports.engine.JasperFillManager'
|
24
48
|
JasperPrint = Rjb::import 'net.sf.jasperreports.engine.JasperPrint'
|
25
49
|
JRXmlUtils = Rjb::import 'net.sf.jasperreports.engine.util.JRXmlUtils'
|
26
|
-
|
50
|
+
# This is here to avoid the "already initialized constant QUERY_EXECUTER_FACTORY_PREFIX" warnings.
|
51
|
+
JRXPathQueryExecuterFactory = silence_warnings{Rjb::import 'net.sf.jasperreports.engine.query.JRXPathQueryExecuterFactory'}
|
27
52
|
InputSource = Rjb::import 'org.xml.sax.InputSource'
|
28
53
|
StringReader = Rjb::import 'java.io.StringReader'
|
29
54
|
HashMap = Rjb::import 'java.util.HashMap'
|
@@ -56,7 +81,6 @@ module JasperRails
|
|
56
81
|
input_source.setCharacterStream(StringReader.new(datasource.to_xml(options).to_s))
|
57
82
|
data_document = silence_warnings do
|
58
83
|
# This is here to avoid the "already initialized constant DOCUMENT_POSITION_*" warnings.
|
59
|
-
# It's harmless. But pretty annoying.
|
60
84
|
JRXmlUtils._invoke('parse', 'Lorg.xml.sax.InputSource;', input_source)
|
61
85
|
end
|
62
86
|
|
data/lib/jasper-rails/version.rb
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,36 +1,50 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: jasper-rails
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
version: 1.0.0
|
6
10
|
platform: ruby
|
7
|
-
authors:
|
11
|
+
authors:
|
8
12
|
- Marlus Saraiva
|
9
13
|
- Rodrigo Maia
|
10
14
|
autorequire:
|
11
15
|
bindir: bin
|
12
16
|
cert_chain: []
|
13
|
-
|
14
|
-
|
15
|
-
|
17
|
+
|
18
|
+
date: 2012-10-04 00:00:00 -03:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
16
22
|
name: rjb
|
17
|
-
|
18
|
-
|
19
|
-
requirements:
|
20
|
-
- -
|
21
|
-
- !ruby/object:Gem::Version
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 1
|
30
|
+
- 4
|
31
|
+
- 0
|
22
32
|
version: 1.4.0
|
23
33
|
type: :runtime
|
24
|
-
|
25
|
-
version_requirements: *70228495461760
|
34
|
+
version_requirements: *id001
|
26
35
|
description: Generate pdf reports on Rails using Jasper Reports reporting tool
|
27
36
|
email: rodrigomaia@grupofortes.com.br
|
28
37
|
executables: []
|
38
|
+
|
29
39
|
extensions: []
|
40
|
+
|
30
41
|
extra_rdoc_files: []
|
31
|
-
|
42
|
+
|
43
|
+
files:
|
32
44
|
- .gitignore
|
33
45
|
- Gemfile
|
46
|
+
- LICENSE.txt
|
47
|
+
- README.md
|
34
48
|
- Rakefile
|
35
49
|
- jasper-rails.gemspec
|
36
50
|
- lib/jasper-rails.rb
|
@@ -41,32 +55,39 @@ files:
|
|
41
55
|
- lib/java/commons-logging-1.1.jar
|
42
56
|
- lib/java/groovy-all-1.7.5.jar
|
43
57
|
- lib/java/iText-2.1.7.jar
|
44
|
-
- lib/java/jasperreports-4.
|
58
|
+
- lib/java/jasperreports-4.7.1.jar
|
45
59
|
- lib/java/jcommon-1.0.15.jar
|
46
60
|
- lib/java/jfreechart-1.0.12.jar
|
47
61
|
- lib/java/xalan.jar
|
62
|
+
has_rdoc: true
|
48
63
|
homepage: https://github.com/fortesinformatica/jasper-rails
|
49
64
|
licenses: []
|
65
|
+
|
50
66
|
post_install_message:
|
51
67
|
rdoc_options: []
|
52
|
-
|
68
|
+
|
69
|
+
require_paths:
|
53
70
|
- lib
|
54
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
requirements:
|
63
|
-
- -
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
version: "0"
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
segments:
|
83
|
+
- 0
|
84
|
+
version: "0"
|
66
85
|
requirements: []
|
86
|
+
|
67
87
|
rubyforge_project:
|
68
|
-
rubygems_version: 1.
|
88
|
+
rubygems_version: 1.3.6
|
69
89
|
signing_key:
|
70
90
|
specification_version: 3
|
71
91
|
summary: Rails and JasperReports integration
|
72
92
|
test_files: []
|
93
|
+
|
Binary file
|