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.
- data/README.md +10 -7
- data/lib/rika.rb +11 -7
- data/lib/rika/version.rb +1 -1
- 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
|
-
|
29
|
+
parser = Rika::Parser.new('document.pdf')
|
28
30
|
|
29
|
-
|
31
|
+
# Returns the content of the document as text:
|
32
|
+
parser.content
|
30
33
|
|
31
|
-
|
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 =
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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