odf-report 0.5.0 → 0.5.1

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Mzc3ZTFmODBhMzEzZjQ1MzdmMjIyMDE3OTBlMmZjMTE0MTYxODI3MA==
4
+ YzhiYWE2MTU5OTRjZWQ2NGExZDc1ZDRjMGUzM2ZlZWU1ZWY4ZWUwNg==
5
5
  data.tar.gz: !binary |-
6
- ZDY1OGI3MTRhY2Q1OTI1YjdkYzgyYjhiYjIwMDZhMjA0NzhmZjc0ZQ==
6
+ YTBkNGEzZjE1NmNkMjc3MTdiNjdmNjZhMDI4ZjAzYjg5NTU0NjJjZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZGEzNjBjYzhhZWMzMGFmNTIyYjdiYTdlNTFlMjA1ZDQyNWMwMWNiODQ3YTg1
10
- YTk0OGJhZDYzZTA5NGUxZDFjMmIzMGM1NzVlNDgzZDRhNjVkMGFjNTJiN2Fj
11
- MmI4ZTkwN2M3YzZhYjkzMTA2NmVlNzVkOWQyYjA1OWRjZTNmYzk=
9
+ ZjU1YzA0ZjY5YmRlMmJhZTE4YmM0NjY5MDQ0MDkyNGFlYjU1MGYzOTM1NTk0
10
+ Y2IyODBlMmEwNWRiODgzZmViMDI1MGE1MmJhODUxYzc3MWY4NDdlNzZmYTEw
11
+ YzVmZDA5NDIwNTVlYTRjMTQ0YTM1ZTQ0N2JkOTE4MDIyYThkOTY=
12
12
  data.tar.gz: !binary |-
13
- N2Q1Yzk4NGZiMmY3OTg0OWE2NWYyMWYzOTUyYjVlNDI3YWUxYzRiZDZmYjJh
14
- MTBlMGUzYzQwZDhiZTBhOGE1ZTAxN2VjMjljZWE2MWFjZTUwM2E4ODhiZmZl
15
- ZTljNWU3Mzc0YTkwZjk0OWQ1YWEwNDUzOWFlNGM4MmUxNmYyOTQ=
13
+ MDNlY2U4ZTU2NTUxZTYzYTZlMWZkN2YxYjI1YTE0YTFlODBmMzFiOTdmMThk
14
+ YzYyMWQwN2QzZDcxZDhmZjE3ZmQ1ZjFhY2E0NTY5MzcxM2M4NWE3NmEzZTBk
15
+ ZTI1MjI2OGJmZGMzZGIzYTcwZDYxNjYzYzYyYTgzYjhkNDFmNDc=
data/.gitignore CHANGED
@@ -3,3 +3,4 @@ pckg
3
3
  doc
4
4
  *.gem
5
5
  test/result
6
+ Gemfile.lock
@@ -2,9 +2,17 @@ h1. ODF-REPORT
2
2
 
3
3
  Gem for generating .odt files by making strings, images, tables and sections replacements in a previously created .odt file.
4
4
 
5
+ h3. NEW
6
+
7
+ * as per popular request, now uses rubyzip ~> 1.1.0
8
+ * uses @Zip::OutputStream.write_buffer@ to generate the file. This should avoid corruption issues.
9
+ * the @.generate@ method now returns the actual report binary, so you can send_data it directly
10
+ * you can also use @.generate('file.odt')@, which saves the report to the specified file
11
+
5
12
  h2. INSTALL
6
13
 
7
- (sudo) gem install odf-report
14
+ In your Gemfile
15
+ <pre>gem 'odf-report' </pre>
8
16
 
9
17
  h2. USAGE
10
18
 
@@ -185,20 +193,19 @@ def print
185
193
 
186
194
  end
187
195
 
188
- report_file_name = report.generate
189
-
190
- send_file(report_file_name)
196
+ send_data report.generate, type: 'application/vnd.oasis.opendocument.text',
197
+ disposition: 'attachment',
198
+ filename: 'report.odt'
191
199
 
192
200
  end
193
201
  </pre>
194
202
 
195
- The @generate@ method will, er... generate the document in a temp dir and returns the full path of the generated file, so you can send it back to the user.
196
203
 
197
204
  _That's all I have to say about that._
198
205
 
199
206
  h4. Generating a document in a standalone script
200
207
 
201
- It's just the same as in a Rails app, but you can inform the path where the file will be generated instead of using a temp dir.
208
+ It's just the same as in a Rails app, but you can inform the path where the file will be saved.
202
209
 
203
210
  <pre>
204
211
  report = ODFReport::Report.new("ticket.odt") do |r|
@@ -207,21 +214,12 @@ report = ODFReport::Report.new("ticket.odt") do |r|
207
214
 
208
215
  end
209
216
 
210
- report.generate("./documents/")
217
+ report.generate("./documents/new_ticket.odt")
211
218
  </pre>
212
219
 
213
220
  <hr/>
214
221
 
215
222
  h3. REQUIREMENTS
216
223
 
217
- *rubyzip*: for manipulating the contents of the odt file, since it's actually a zip file.
218
- *nokogiri*: for parsing and manipulating the document xml files.
219
-
220
-
221
- <hr/>
222
-
223
- h3. THE FUTURE
224
-
225
- Well, this is my first attempt. This gem was extracted from an actual project we developed internally, to fulfill our specific needs.
226
-
227
- That said, I would really appreciate any input you can come up with. Critics, suggestions, bug reports are welcome and will be thoroughly examined.
224
+ * rubyzip*: for manipulating the contents of the odt file, since it's actually a zip file.
225
+ * nokogiri*: for parsing and manipulating the document xml files.
@@ -21,9 +21,11 @@ module ODFReport
21
21
 
22
22
  file.each do |entry|
23
23
 
24
- unless entry.directory?
24
+ next if entry.directory?
25
25
 
26
- data = entry.get_input_stream.read
26
+ entry.get_input_stream do |is|
27
+
28
+ data = is.sysread
27
29
 
28
30
  if content_files.include?(entry.name)
29
31
  yield data
@@ -31,6 +33,7 @@ module ODFReport
31
33
 
32
34
  @output_stream.put_next_entry(entry.name)
33
35
  @output_stream.write data
36
+
34
37
  end
35
38
 
36
39
  end
@@ -78,7 +78,7 @@ class Report
78
78
  end
79
79
 
80
80
  if dest
81
- ::File.open(dest, "w") {|f| f.write(@file.data) }
81
+ ::File.open(dest, "wb") {|f| f.write(@file.data) }
82
82
  else
83
83
  @file.data
84
84
  end
@@ -1,3 +1,3 @@
1
1
  module ODFReport
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: odf-report
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sandro Duarte
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-24 00:00:00.000000000 Z
11
+ date: 2014-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler