docsplit-paperclip-processor 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
4
+ gem "docsplit"
data/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # Ruby on Rails 3 Paperclip Docsplit Processor #
2
+
3
+ This gem is Paperclip processor, utilizing Docsplit in order to convert uploaded files to pdf and extract information/thumbnails.
4
+ These include the Microsoft Office formats: doc, docx, ppt, xls and so on, as well as html, odf, rtf, swf, svg, and wpd.
5
+
6
+ ## Requirements ##
7
+
8
+ * [Paperclip][0]
9
+ * [Docsplit][1]
10
+
11
+ ## Installation ##
12
+
13
+ (This gem is written and tested on Ruby 1.9 and Rails 3 only).
14
+
15
+ In order to install it, add to your Gemfile:
16
+
17
+ gem 'docsplit-paperclip-processor'
18
+
19
+ And then run:
20
+
21
+ bundle install
22
+
23
+
24
+ ## Using Processor ##
25
+
26
+ Use it as you would any other Paperclip processor. For example, in your model:
27
+
28
+ class Document < ActiveRecord::Base
29
+
30
+ has_attached_file :file,
31
+ :styles => {
32
+ :pdf => {
33
+ :format => "pdf",
34
+ :processors => [:docsplit_pdf]
35
+ }
36
+ }
37
+
38
+ end
39
+
40
+
41
+ which will convert your document into pdf.
42
+
43
+ ### Extract information (text, metadata) and thumbnail ###
44
+
45
+ Will be include in the next releases.
46
+
47
+ ## Release info ##
48
+
49
+ Be warned, this gem is released as early beta version.
50
+ If you are using it you are doing so on your own responsibility.
51
+
52
+ Have fun with it and drop me a note if you like it.
53
+
54
+
55
+ [0]: https://github.com/thoughtbot/paperclip
56
+ [1]: http://documentcloud.github.com/docsplit/
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "docsplit-paperclip-processor/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "docsplit-paperclip-processor"
7
+ s.version = Docsplit::Paperclip::Processor::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Tien Le"]
10
+ s.email = ["tienlx@gmail.com"]
11
+ s.homepage = "https://github.com/tienle/docsplit-paperclip-processor"
12
+ s.summary = %q{A Paperclip processor for Docsplit}
13
+ s.description = %q{This gem is simple Paperclip processor which uses Docsplit to convert uploaded files to pdf, or extract information/thumbnails from them}
14
+
15
+ s.rubyforge_project = "docsplit-paperclip-processor"
16
+
17
+ s.add_dependency "paperclip", "~> 2.4"
18
+
19
+ s.files = `git ls-files`.split("\n")
20
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
+ s.require_paths = ["lib"]
23
+ end
@@ -0,0 +1,28 @@
1
+ require "paperclip"
2
+ module Paperclip
3
+ class DocsplitPdf < Processor
4
+
5
+ attr_accessor :src, :options
6
+
7
+ def initialize(file, options = {}, attachment = nil)
8
+ super
9
+ @src = file
10
+ @options = options
11
+ @basename = File.basename(@file.path, '.*')
12
+ end
13
+
14
+ def make
15
+ begin
16
+ src_path = File.expand_path(@src.path)
17
+ dst_path = Dir.tmpdir
18
+ escaped_src, escaped_dst = [src_path, dst_path].map &Docsplit::ESCAPE
19
+
20
+ Docsplit.extract_pdf(escaped_src, :output => escaped_dst)
21
+ rescue Cocaine::CommandLineError => e
22
+ Rails.logger.error e.message
23
+ raise PaperclipError, "There was an error converting #{basename} to pdf"
24
+ end
25
+ File.open(File.join(dst_path, "#{@basename}.pdf"))
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,7 @@
1
+ module Docsplit
2
+ module Paperclip
3
+ module Processor
4
+ VERSION = "0.1.0"
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: docsplit-paperclip-processor
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Tien Le
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-03-09 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: paperclip
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 11
29
+ segments:
30
+ - 2
31
+ - 4
32
+ version: "2.4"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ description: This gem is simple Paperclip processor which uses Docsplit to convert uploaded files to pdf, or extract information/thumbnails from them
36
+ email:
37
+ - tienlx@gmail.com
38
+ executables: []
39
+
40
+ extensions: []
41
+
42
+ extra_rdoc_files: []
43
+
44
+ files:
45
+ - .gitignore
46
+ - Gemfile
47
+ - README.md
48
+ - Rakefile
49
+ - docsplit-paperclip-processor.gemspec
50
+ - lib/docsplit-paperclip-processor.rb
51
+ - lib/docsplit-paperclip-processor/version.rb
52
+ homepage: https://github.com/tienle/docsplit-paperclip-processor
53
+ licenses: []
54
+
55
+ post_install_message:
56
+ rdoc_options: []
57
+
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ hash: 3
66
+ segments:
67
+ - 0
68
+ version: "0"
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
77
+ version: "0"
78
+ requirements: []
79
+
80
+ rubyforge_project: docsplit-paperclip-processor
81
+ rubygems_version: 1.8.6
82
+ signing_key:
83
+ specification_version: 3
84
+ summary: A Paperclip processor for Docsplit
85
+ test_files: []
86
+