rika 0.9.0-java → 0.9.1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.md +10 -7
  2. data/lib/rika.rb +11 -7
  3. data/lib/rika/version.rb +1 -1
  4. metadata +1 -1
data/README.md CHANGED
@@ -23,17 +23,20 @@ Or install it yourself as:
23
23
  ## Usage
24
24
 
25
25
  Something like this:
26
+ ```ruby
27
+ require 'rika'
26
28
 
27
- require 'rika'
29
+ parser = Rika::Parser.new('document.pdf')
28
30
 
29
- parser = Rika::Parser.new('document.pdf')
31
+ # Returns the content of the document as text:
32
+ parser.content
30
33
 
31
- parser.content # Returns the content of the document as text
32
-
33
- parser.metadata["title"] if parser.metadata_exists?("title") # Returns the metadata field title if it exists
34
-
35
- parser.available_metadata # Returns all the available metadata keys that can be read from the document
34
+ # Returns the metadata field title if it exists:
35
+ parser.metadata["title"] if parser.metadata_exists?("title")
36
36
 
37
+ # Returns all the available metadata keys that can be read from the document
38
+ parser.available_metadata
39
+ ```
37
40
  ## Contributing
38
41
 
39
42
  1. Fork it
data/lib/rika.rb CHANGED
@@ -52,13 +52,17 @@ module Rika
52
52
  protected
53
53
 
54
54
  def perform
55
- input_stream = java.io.FileInputStream.new(java.io.File.new(@filename))
56
- @metadata = Metadata.new
57
- @metadata.set("filename", File.basename(@filename))
58
- @parser = AutoDetectParser.new
59
- @content = BodyContentHandler.new
60
- @parser.parse(input_stream, @content, @metadata)
61
- input_stream.close
55
+ input_stream = nil
56
+ begin
57
+ input_stream = java.io.FileInputStream.new(java.io.File.new(@filename))
58
+ @metadata = Metadata.new
59
+ @metadata.set("filename", File.basename(@filename))
60
+ @parser = AutoDetectParser.new
61
+ @content = BodyContentHandler.new
62
+ @parser.parse(input_stream, @content, @metadata)
63
+ ensure
64
+ input_stream.close
65
+ end
62
66
  end
63
67
  end
64
68
  end
data/lib/rika/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rika
2
- VERSION = "0.9.0"
2
+ VERSION = "0.9.1"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rika
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.9.0
5
+ version: 0.9.1
6
6
  platform: java
7
7
  authors:
8
8
  - Richard Nyström