odt2html 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
1
  pkg
2
+ Gemfile.lock
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.1 / 2011-03-03
4
+ - Allow to put output into variable instead of forcing it to write to stdout
5
+
3
6
  ## 0.1.0 / 2011-03-02
4
7
  - Forked to Github
5
8
  - Added code to handle <text:line_break>
data/README.md CHANGED
@@ -1,21 +1,20 @@
1
1
  # ODT2HTML
2
2
 
3
- This program converts OpenDocument text files to XHTML.
4
- Copyright (C) 2006 J. David Eisenberg
3
+ ## Usage
5
4
 
6
- This library is free software; you can redistribute it and/or
7
- modify it under the terms of the GNU Lesser General Public
8
- License as published by the Free Software Foundation; either
9
- version 2.1 of the License, or (at your option) any later version.
5
+ $ odt2html [OPTIONS]
10
6
 
11
- This library is distributed in the hope that it will be useful,
12
- but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
- Lesser General Public License for more details.
7
+ ## Available options
15
8
 
16
- You should have received a copy of the GNU Lesser General Public
17
- License along with this library; if not, write to the Free Software
18
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
9
+ Option | Description
10
+ --------------- | -------------
11
+ --in [PATH] | Path to input file(required)
12
+ --out [PATH] | Path to output file(output to STDOUT if not provided)
13
+ --css [PATH] | Path to css file(css in header if not provided)
14
+ --images [PATH] | Path to images directory
19
15
 
20
- Author: J. David Eisenberg
21
- Contact: catcode@catcode.com
16
+ ## About
17
+
18
+ Author: Bernard Potocki <<bernard.potocki@imanel.org>>
19
+
20
+ Oryginal work: J. David Eisenberg <<catcode@catcode.com>>
data/bin/odt2html CHANGED
@@ -6,4 +6,6 @@ require 'rubygems'
6
6
  require 'odt2html'
7
7
 
8
8
  app = ODT2HTML::Base.new
9
- app.convert
9
+ output = app.convert
10
+
11
+ puts output unless output.nil?
data/lib/odt2html.rb CHANGED
@@ -6,7 +6,7 @@ require 'getoptlong'
6
6
 
7
7
  module ODT2HTML
8
8
 
9
- VERSION = "0.1.0"
9
+ VERSION = "0.1.1"
10
10
  ROOT_PATH = File.expand_path(File.dirname(__FILE__))
11
11
 
12
12
  autoload :Base, "#{ROOT_PATH}/odt2html/base"
data/lib/odt2html/base.rb CHANGED
@@ -219,15 +219,23 @@ HDR
219
219
  if (@output_filename) then
220
220
  output_file = File.open( @output_filename, "w")
221
221
  else
222
- output_file = $stdout
222
+ output_file = String.new
223
223
  end
224
224
 
225
225
  @output_doc.write( output_file, 2 )
226
- output_file.close
227
226
 
228
- rescue Exception => e
229
- puts "Cannot convert file: #{e}"
230
- puts e.backtrace.join("\n")
227
+ if @output_filename
228
+ output_file.close
229
+ return nil
230
+ else
231
+ return output_file
232
+ end
233
+ rescue ArgumentError => e
234
+ puts e.message
235
+ exit
236
+ rescue Exception => e
237
+ puts "Cannot convert file: #{e}"
238
+ puts e.backtrace.join("\n")
231
239
  end
232
240
 
233
241
  def usage
@@ -5,20 +5,11 @@ describe "files" do
5
5
  odt_path = File.join(File.dirname(__FILE__), *%w[.. fixtures example.odt])
6
6
  html_path = File.join(File.dirname(__FILE__), *%w[.. fixtures example.html])
7
7
  html_file = File.open(html_path)
8
- tempfile = Tempfile.new('html')
9
8
 
10
- begin
11
- parser = ODT2HTML::Base.new
12
- parser.instance_variable_set('@input_filename', odt_path)
13
- parser.instance_variable_set('@output_filename', tempfile.path)
9
+ parser = ODT2HTML::Base.new
10
+ parser.instance_variable_set('@input_filename', odt_path)
14
11
 
15
- parser.convert
16
-
17
- tempfile.rewind
18
- html_content = html_file.read.gsub("[TITLE_HERE]", odt_path)
19
- tempfile.read.should eql(html_content)
20
- ensure
21
- tempfile.close!
22
- end
12
+ html_content = html_file.read.gsub("[TITLE_HERE]", odt_path)
13
+ parser.convert.should eql(html_content)
23
14
  end
24
15
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: odt2html
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Bernard Potocki
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-02 00:00:00 +01:00
18
+ date: 2011-03-04 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency