tika-app 0.1.1 → 0.2.0
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 +4 -4
- data/Rakefile +3 -0
- data/VERSION +1 -1
- data/lib/tika/app.rb +8 -3
- data/lib/tika/download.rb +29 -0
- data/lib/tika/rake_tasks.rb +20 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65e0e1bbada389045b72ad02f92a8d3f3ba555d7
|
4
|
+
data.tar.gz: ebffea3fd6247a413b9ab5d61edefb937b53e889
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a37ff3a208fd49d39247ab5a441d76759ba1a5c2c4d35f3f5c04ddc3ce1c46da61a510c39a02ab103219b0e697b6471602fde9e69b49d189abdd01bd7a8aa1a6
|
7
|
+
data.tar.gz: 57a649b00f61c4384f3085bfdf1a8fc4784517d5504b4061d140584466429210a9ebfb562a7a8fc267da6c7af35c9a936b64f9565af7a437cda12dc2bff1e81a
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/tika/app.rb
CHANGED
@@ -1,23 +1,28 @@
|
|
1
1
|
require_relative "error"
|
2
2
|
require_relative "commands"
|
3
3
|
require_relative "resource"
|
4
|
+
require_relative "rake_tasks"
|
4
5
|
|
5
6
|
module Tika
|
6
7
|
class App
|
7
8
|
|
9
|
+
DEFAULT_TIKA_PATH = File.expand_path("../../../bin/tika-app.jar", __FILE__)
|
10
|
+
|
8
11
|
class << self
|
9
12
|
attr_accessor :path
|
13
|
+
|
14
|
+
def install_tasks
|
15
|
+
RakeTasks.install
|
16
|
+
end
|
10
17
|
end
|
11
18
|
|
12
19
|
include Commands
|
13
20
|
|
14
|
-
DEFAULT_PATH = File.expand_path("../../../bin/tika-app.jar", __FILE__)
|
15
|
-
|
16
21
|
attr_reader :path
|
17
22
|
attr_accessor :result
|
18
23
|
|
19
24
|
def initialize(opts={})
|
20
|
-
@path = opts[:path] || self.class.path || ENV["TIKA_APP"] ||
|
25
|
+
@path = opts[:path] || self.class.path || ENV["TIKA_APP"] || DEFAULT_TIKA_PATH
|
21
26
|
end
|
22
27
|
|
23
28
|
def get_text(file, opts={})
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Tika
|
2
|
+
class Download
|
3
|
+
|
4
|
+
DEFAULT_TIKA_VERSION = "1.9"
|
5
|
+
|
6
|
+
def self.call
|
7
|
+
version = ENV["TIKA_VERSION"] || DEFAULT_TIKA_VERSION
|
8
|
+
destination_path = ENV["TIKA_PATH"] || App::DEFAULT_TIKA_PATH
|
9
|
+
unless Dir.exist? File.dirname(destination_path)
|
10
|
+
raise Error, "Destination path directory does not exist: #{File.dirname(destination_path)}"
|
11
|
+
end
|
12
|
+
if File.exist? destination_path
|
13
|
+
raise Error, "File exists at destination path #{destination_path}."
|
14
|
+
end
|
15
|
+
download_basename = "tika-app-#{version}.jar"
|
16
|
+
download_url = "http://archive.apache.org/dist/tika/#{download_basename}"
|
17
|
+
|
18
|
+
Dir.mktmpdir do |tmpdir|
|
19
|
+
puts "Downloading Tika app from #{download_url} ... "
|
20
|
+
FileUtils.cd(tmpdir) do
|
21
|
+
system "curl -O #{download_url}"
|
22
|
+
FileUtils.mv(download_basename, destination_path)
|
23
|
+
puts "Moved Tika app to #{destination_path}."
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "rake"
|
2
|
+
require_relative "download"
|
3
|
+
|
4
|
+
module Tika
|
5
|
+
module RakeTasks
|
6
|
+
|
7
|
+
extend ::Rake::DSL
|
8
|
+
|
9
|
+
def self.install
|
10
|
+
namespace :tika_app do
|
11
|
+
desc "Download Tika app (TIKA_VERSION=[#{Download::DEFAULT_TIKA_VERSION}]" \
|
12
|
+
" TIKA_PATH=[#{App::DEFAULT_TIKA_PATH}])"
|
13
|
+
task :download do
|
14
|
+
Download.call
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tika-app
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dchandekstark
|
@@ -69,7 +69,9 @@ files:
|
|
69
69
|
- lib/tika/app.rb
|
70
70
|
- lib/tika/command.rb
|
71
71
|
- lib/tika/commands.rb
|
72
|
+
- lib/tika/download.rb
|
72
73
|
- lib/tika/error.rb
|
74
|
+
- lib/tika/rake_tasks.rb
|
73
75
|
- lib/tika/resource.rb
|
74
76
|
- lib/tika/result.rb
|
75
77
|
- spec/fixtures/Lorem_ipsum.docx
|