jasper-command-line 0.2.1 → 0.2.2

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.
@@ -86,27 +86,35 @@ module JasperCommandLine
86
86
  # Export it!
87
87
 
88
88
  if sign_options
89
- file = Tempfile.new(['pdf-', '.pdf'])
90
- signed_file = Tempfile.new(['signed-pdf-', '.pdf'])
91
- begin
92
- file.write JasperExportManager._invoke('exportReportToPdf', 'Lnet.sf.jasperreports.engine.JasperPrint;', jasper_print)
89
+ temp_file = Tempfile.new(['pdf-', '.pdf'])
90
+ temp_signed_file = Tempfile.new(['signed-pdf-', '.pdf'])
91
+ file = temp_file.path
92
+ signed_file = temp_signed_file.path
93
+
94
+ temp_file.close!
95
+ temp_signed_file.close!
93
96
 
94
- call_options = [
95
- '-n',
96
- '-t', file.path,
97
- '-s', sign_options[:key_file],
98
- '-p', %Q["#{sign_options[:password]}"],
99
- '-o', signed_file.path
100
- ]
101
- call_options.push '-l', %Q["#{sign_options[:location]}"] if sign_options[:location]
102
- call_options.push '-r', %Q["#{sign_options[:reason]}"] if sign_options[:reason]
97
+ File.open(file, 'wb') { |f| f.write JasperExportManager._invoke('exportReportToPdf', 'Lnet.sf.jasperreports.engine.JasperPrint;', jasper_print) }
103
98
 
104
- `java -jar #{File.dirname(__FILE__)}/java/PortableSigner/PortableSigner.jar #{call_options.join(' ')}`
99
+ call_options = [
100
+ '-n',
101
+ '-t', file,
102
+ '-s', sign_options[:key_file],
103
+ '-p', %Q["#{sign_options[:password]}"],
104
+ '-o', signed_file
105
+ ]
106
+ call_options.push '-l', %Q["#{sign_options[:location]}"] if sign_options[:location]
107
+ call_options.push '-r', %Q["#{sign_options[:reason]}"] if sign_options[:reason]
105
108
 
106
- return File.read(signed_file.path)
109
+ `java -jar #{File.dirname(__FILE__)}/java/PortableSigner/PortableSigner.jar #{call_options.join(' ')}`
110
+
111
+ begin
112
+ return File.read(signed_file)
107
113
  ensure
108
- file.close!
109
- signed_file.close!
114
+ begin
115
+ File.unlink file, signed_file
116
+ rescue
117
+ end
110
118
  end
111
119
  else
112
120
  JasperExportManager._invoke('exportReportToPdf', 'Lnet.sf.jasperreports.engine.JasperPrint;', jasper_print)
@@ -1,3 +1,3 @@
1
1
  module JasperCommandLine
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jasper-command-line
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: