rasper 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +6 -0
- data/lib/rasper.rb +1 -0
- data/lib/rasper/compiler.rb +7 -3
- data/lib/rasper/locale.rb +29 -0
- data/lib/rasper/report.rb +4 -15
- data/lib/rasper/version.rb +1 -1
- metadata +3 -2
data/CHANGELOG
CHANGED
data/lib/rasper.rb
CHANGED
data/lib/rasper/compiler.rb
CHANGED
@@ -6,10 +6,14 @@ java_import Java::net::sf::jasperreports::engine::JasperCompileManager
|
|
6
6
|
|
7
7
|
module Rasper
|
8
8
|
class Compiler
|
9
|
+
extend Locale
|
10
|
+
|
9
11
|
def self.compile(jrxml_file, output_dir = nil)
|
10
|
-
|
11
|
-
|
12
|
-
|
12
|
+
run_with_locale do
|
13
|
+
output_dir ||= File.dirname(jrxml_file)
|
14
|
+
output_file = File.join(output_dir, File.basename(jrxml_file, '.jrxml') + '.jasper')
|
15
|
+
JasperCompileManager.compile_report_to_file(jrxml_file, output_file)
|
16
|
+
end
|
13
17
|
end
|
14
18
|
end
|
15
19
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'java'
|
2
|
+
|
3
|
+
java_import Java::java::util::Locale
|
4
|
+
|
5
|
+
module Rasper
|
6
|
+
module Locale
|
7
|
+
|
8
|
+
def run_with_locale
|
9
|
+
set_locale
|
10
|
+
begin
|
11
|
+
yield
|
12
|
+
ensure
|
13
|
+
restore_locale
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def set_locale
|
20
|
+
return unless Config.locale
|
21
|
+
@default_locale = ::Locale.get_default
|
22
|
+
::Locale.set_default(::Locale.new(*Config.locale.split('_')))
|
23
|
+
end
|
24
|
+
|
25
|
+
def restore_locale
|
26
|
+
::Locale.set_default(@default_locale) if @default_locale
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/rasper/report.rb
CHANGED
@@ -13,11 +13,12 @@ require 'active_support/core_ext'
|
|
13
13
|
|
14
14
|
module Rasper
|
15
15
|
class Report
|
16
|
+
extend Locale
|
17
|
+
|
16
18
|
class << self
|
17
19
|
def generate(jasper_name, data, params = {})
|
18
|
-
|
19
|
-
|
20
|
-
begin
|
20
|
+
run_with_locale do
|
21
|
+
set_file_resolver(params)
|
21
22
|
file_name = File.join(Config.jasper_dir || '.', jasper_name + '.jasper')
|
22
23
|
jasper_content = File.read(file_name)
|
23
24
|
data = { jasper_name => data }.to_xml
|
@@ -28,8 +29,6 @@ module Rasper
|
|
28
29
|
ByteArrayInputStream.new(jasper_content.to_java_bytes))
|
29
30
|
String.from_java_bytes(
|
30
31
|
JasperRunManager.runReportToPdf(input, params, source))
|
31
|
-
ensure
|
32
|
-
restore_locale
|
33
32
|
end
|
34
33
|
end
|
35
34
|
|
@@ -45,16 +44,6 @@ module Rasper
|
|
45
44
|
end
|
46
45
|
params['REPORT_FILE_RESOLVER'] = resolver
|
47
46
|
end
|
48
|
-
|
49
|
-
def set_locale
|
50
|
-
return unless Config.locale
|
51
|
-
@default_locale = Locale.get_default
|
52
|
-
Locale.set_default(Locale.new(*Config.locale.split('_')))
|
53
|
-
end
|
54
|
-
|
55
|
-
def restore_locale
|
56
|
-
Locale.set_default(@default_locale) if @default_locale
|
57
|
-
end
|
58
47
|
end
|
59
48
|
end
|
60
49
|
end
|
data/lib/rasper/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rasper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: builder
|
@@ -103,6 +103,7 @@ files:
|
|
103
103
|
- lib/rasper/config.rb
|
104
104
|
- lib/rasper/compiler.rb
|
105
105
|
- lib/rasper/version.rb
|
106
|
+
- lib/rasper/locale.rb
|
106
107
|
- lib/rasper/report.rb
|
107
108
|
- lib/rasper/jar_loader.rb
|
108
109
|
- README.rst
|