rasper 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,6 +1,11 @@
1
1
  Rasper
2
2
  ======
3
3
 
4
+ 2013-07-08 Rodrigo Manhães <rmanhaes@gmail.com>
5
+ 0.1.3
6
+
7
+ - Added configuration for locales.
8
+
4
9
 
5
10
  2013-02-22 Rodrigo Manhães <rmanhaes@gmail.com>
6
11
  0.1.2
data/README.rst CHANGED
@@ -37,8 +37,11 @@ Before doing anything, you should configure Rasper::
37
37
  config.jar_dir = "/dir/of/jars"
38
38
  config.jasper_dir = "/dir/of/compiled/reports"
39
39
  config.image_dir = "/dir/of/images"
40
+ config.locale = 'pt_BR'
40
41
  end
41
42
 
43
+ Locale can be any Java-supported locale, in the format above.
44
+
42
45
 
43
46
  To compile a JRXML file, just run::
44
47
 
data/bin/rasper CHANGED
@@ -14,34 +14,9 @@ if ARGV[0] == 'generate_pom'
14
14
 
15
15
  <dependencies>
16
16
  <dependency>
17
- <groupId>commons-beanutils</groupId>
18
- <artifactId>commons-beanutils</artifactId>
19
- <version>1.8.0</version>
20
- </dependency>
21
- <dependency>
22
- <groupId>commons-digester</groupId>
23
- <artifactId>commons-digester</artifactId>
24
- <version>2.0</version>
25
- </dependency>
26
- <dependency>
27
- <groupId>commons-collections</groupId>
28
- <artifactId>commons-collections</artifactId>
29
- <version>3.2</version>
30
- </dependency>
31
- <dependency>
32
- <groupId>commons-logging</groupId>
33
- <artifactId>commons-logging</artifactId>
34
- <version>1.1.1</version>
35
- </dependency>
36
- <dependency>
37
- <groupId>com.lowagie</groupId>
38
- <artifactId>itext</artifactId>
39
- <version>2.1.0</version>
40
- </dependency>
41
- <dependency>
42
- <groupId>jasperreports</groupId>
17
+ <groupId>net.sf.jasperreports</groupId>
43
18
  <artifactId>jasperreports</artifactId>
44
- <version>3.5.3</version>
19
+ <version>5.0.1</version>
45
20
  </dependency>
46
21
  <dependency>
47
22
  <groupId>xalan</groupId>
@@ -1,21 +1,22 @@
1
1
  module Rasper
2
2
  class Config
3
3
  class << self
4
- attr_reader :jar_dir, :jasper_dir, :image_dir
4
+ attr_reader :jar_dir, :jasper_dir, :image_dir, :locale
5
5
  end
6
6
 
7
7
  def self.configure
8
8
  conf = Configuration.new
9
9
  yield conf
10
- @jar_dir = conf.jar_dir
11
- @jasper_dir = conf.jasper_dir
12
- @image_dir = conf.image_dir
10
+ @jar_dir = conf.jar_dir if conf.jar_dir
11
+ @jasper_dir = conf.jasper_dir if conf.jasper_dir
12
+ @image_dir = conf.image_dir if conf.image_dir
13
+ @locale = conf.locale if conf.locale
13
14
  end
14
15
 
15
16
  private
16
17
 
17
18
  class Configuration
18
- attr_accessor :jar_dir, :jasper_dir, :image_dir
19
+ attr_accessor :jar_dir, :jasper_dir, :image_dir, :locale
19
20
  end
20
21
  end
21
22
  end
@@ -7,6 +7,7 @@ java_import Java::net::sf::jasperreports::engine::util::FileResolver
7
7
  java_import Java::net::sf::jasperreports::engine::JasperRunManager
8
8
  java_import Java::java::io::ByteArrayInputStream
9
9
  java_import Java::java::io::BufferedInputStream
10
+ java_import Java::java::util::Locale
10
11
 
11
12
  require 'active_support/core_ext'
12
13
 
@@ -15,17 +16,21 @@ module Rasper
15
16
  class << self
16
17
  def generate(jasper_name, data, params = {})
17
18
  set_file_resolver(params)
18
-
19
- file_name = File.join(Config.jasper_dir || '.', jasper_name + '.jasper')
20
- jasper_content = File.read(file_name)
21
- data = { jasper_name => data }.to_xml
22
- xpath_criteria = "/hash/#{jasper_name}/#{jasper_name.singularize}"
23
- source = JRXmlDataSource.new(
24
- ByteArrayInputStream.new(data.to_java_bytes), xpath_criteria)
25
- input = BufferedInputStream.new(
26
- ByteArrayInputStream.new(jasper_content.to_java_bytes))
27
- String.from_java_bytes(
28
- JasperRunManager.runReportToPdf(input, params, source))
19
+ set_locale
20
+ begin
21
+ file_name = File.join(Config.jasper_dir || '.', jasper_name + '.jasper')
22
+ jasper_content = File.read(file_name)
23
+ data = { jasper_name => data }.to_xml
24
+ xpath_criteria = "/hash/#{jasper_name}/#{jasper_name.singularize}"
25
+ source = JRXmlDataSource.new(
26
+ ByteArrayInputStream.new(data.to_java_bytes), xpath_criteria)
27
+ input = BufferedInputStream.new(
28
+ ByteArrayInputStream.new(jasper_content.to_java_bytes))
29
+ String.from_java_bytes(
30
+ JasperRunManager.runReportToPdf(input, params, source))
31
+ ensure
32
+ restore_locale
33
+ end
29
34
  end
30
35
 
31
36
  private
@@ -40,6 +45,16 @@ module Rasper
40
45
  end
41
46
  params['REPORT_FILE_RESOLVER'] = resolver
42
47
  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
43
58
  end
44
59
  end
45
60
  end
@@ -1,3 +1,3 @@
1
1
  module Rasper
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
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.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,23 +9,21 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-22 00:00:00.000000000 Z
12
+ date: 2013-07-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: builder
16
16
  version_requirements: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ">="
18
+ - - '>='
19
19
  - !ruby/object:Gem::Version
20
- version: !binary |-
21
- MA==
20
+ version: '0'
22
21
  none: false
23
22
  requirement: !ruby/object:Gem::Requirement
24
23
  requirements:
25
- - - ">="
24
+ - - '>='
26
25
  - !ruby/object:Gem::Version
27
- version: !binary |-
28
- MA==
26
+ version: '0'
29
27
  none: false
30
28
  prerelease: false
31
29
  type: :runtime
@@ -33,17 +31,15 @@ dependencies:
33
31
  name: activesupport
34
32
  version_requirements: !ruby/object:Gem::Requirement
35
33
  requirements:
36
- - - ">="
34
+ - - '>='
37
35
  - !ruby/object:Gem::Version
38
- version: !binary |-
39
- MA==
36
+ version: '0'
40
37
  none: false
41
38
  requirement: !ruby/object:Gem::Requirement
42
39
  requirements:
43
- - - ">="
40
+ - - '>='
44
41
  - !ruby/object:Gem::Version
45
- version: !binary |-
46
- MA==
42
+ version: '0'
47
43
  none: false
48
44
  prerelease: false
49
45
  type: :runtime
@@ -51,17 +47,15 @@ dependencies:
51
47
  name: rake
52
48
  version_requirements: !ruby/object:Gem::Requirement
53
49
  requirements:
54
- - - ">="
50
+ - - '>='
55
51
  - !ruby/object:Gem::Version
56
- version: !binary |-
57
- MA==
52
+ version: '0'
58
53
  none: false
59
54
  requirement: !ruby/object:Gem::Requirement
60
55
  requirements:
61
- - - ">="
56
+ - - '>='
62
57
  - !ruby/object:Gem::Version
63
- version: !binary |-
64
- MA==
58
+ version: '0'
65
59
  none: false
66
60
  prerelease: false
67
61
  type: :runtime
@@ -69,17 +63,15 @@ dependencies:
69
63
  name: rspec
70
64
  version_requirements: !ruby/object:Gem::Requirement
71
65
  requirements:
72
- - - ">="
66
+ - - '>='
73
67
  - !ruby/object:Gem::Version
74
- version: !binary |-
75
- MA==
68
+ version: '0'
76
69
  none: false
77
70
  requirement: !ruby/object:Gem::Requirement
78
71
  requirements:
79
- - - ">="
72
+ - - '>='
80
73
  - !ruby/object:Gem::Version
81
- version: !binary |-
82
- MA==
74
+ version: '0'
83
75
  none: false
84
76
  prerelease: false
85
77
  type: :development
@@ -87,17 +79,15 @@ dependencies:
87
79
  name: docsplit
88
80
  version_requirements: !ruby/object:Gem::Requirement
89
81
  requirements:
90
- - - ">="
82
+ - - '>='
91
83
  - !ruby/object:Gem::Version
92
- version: !binary |-
93
- MA==
84
+ version: '0'
94
85
  none: false
95
86
  requirement: !ruby/object:Gem::Requirement
96
87
  requirements:
97
- - - ">="
88
+ - - '>='
98
89
  - !ruby/object:Gem::Version
99
- version: !binary |-
100
- MA==
90
+ version: '0'
101
91
  none: false
102
92
  prerelease: false
103
93
  type: :development
@@ -110,11 +100,11 @@ extensions: []
110
100
  extra_rdoc_files: []
111
101
  files:
112
102
  - lib/rasper.rb
103
+ - lib/rasper/config.rb
113
104
  - lib/rasper/compiler.rb
114
- - lib/rasper/report.rb
115
105
  - lib/rasper/version.rb
106
+ - lib/rasper/report.rb
116
107
  - lib/rasper/jar_loader.rb
117
- - lib/rasper/config.rb
118
108
  - README.rst
119
109
  - LICENSE.txt
120
110
  - Rakefile
@@ -130,17 +120,15 @@ require_paths:
130
120
  - lib
131
121
  required_ruby_version: !ruby/object:Gem::Requirement
132
122
  requirements:
133
- - - ">="
123
+ - - '>='
134
124
  - !ruby/object:Gem::Version
135
- version: !binary |-
136
- MA==
125
+ version: '0'
137
126
  none: false
138
127
  required_rubygems_version: !ruby/object:Gem::Requirement
139
128
  requirements:
140
- - - ">="
129
+ - - '>='
141
130
  - !ruby/object:Gem::Version
142
- version: !binary |-
143
- MA==
131
+ version: '0'
144
132
  none: false
145
133
  requirements: []
146
134
  rubyforge_project: