docsplit_images 0.1.5 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -1,5 +1,7 @@
1
1
  # docsplit_images
2
2
 
3
+ [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/jameshuynh/docsplit_images)
4
+
3
5
  Docsplit images is used to convert a document file (pdf, xls, xlsx, ppt, pptx, doc, docx, etc...) to a list of images combining with famous paperclip gem at [https://github.com/thoughtbot/paperclip](paperclip)
4
6
 
5
7
  ## Installation
@@ -44,7 +46,7 @@ On the Mac, you can download a [http://www.pdflabs.com/docs/install-pdftk/](rece
44
46
 
45
47
  ### Install Gem
46
48
 
47
- gem 'docsplit_images', '0.1.5', :git => 'git@github.com:jameshuynh/docsplit_images.git'
49
+ gem 'docsplit_images', :git => 'git@github.com:jameshuynh/docsplit_images.git', tag: "v0.1.7"
48
50
 
49
51
  ## Setting Up
50
52
 
@@ -61,7 +63,7 @@ In your model:
61
63
  ...
62
64
  attr_accessible :mydocument
63
65
  has_attached_file :mydocument
64
- docsplit_images_conversion_for :mydocument
66
+ docsplit_images_conversion_for :mydocument, {size: "800x"}
65
67
  ...
66
68
  end
67
69
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5
1
+ 0.1.8
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "docsplit_images"
8
- s.version = "0.1.5"
8
+ s.version = "0.1.8"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["jameshuynh"]
12
- s.date = "2012-11-26"
12
+ s.date = "2013-04-19"
13
13
  s.description = "Split Images for your document in one line of code"
14
14
  s.email = "james@rubify.com"
15
15
  s.extra_rdoc_files = [
@@ -37,7 +37,7 @@ Gem::Specification.new do |s|
37
37
  s.homepage = "http://github.com/jameshuynh/docsplit_images"
38
38
  s.licenses = ["MIT"]
39
39
  s.require_paths = ["lib"]
40
- s.rubygems_version = "1.8.24"
40
+ s.rubygems_version = "1.8.23"
41
41
  s.summary = "Split Images for your document"
42
42
 
43
43
  if s.respond_to? :specification_version then
@@ -24,7 +24,7 @@ module DocsplitImages
24
24
  parent_dir = File.dirname(File.dirname(self.send(self.class.docsplit_attachment_name).path))
25
25
  FileUtils.rm_rf("#{parent_dir}/images")
26
26
  FileUtils.mkdir("#{parent_dir}/images")
27
- Docsplit.extract_images(self.send(self.class.docsplit_attachment_name).path, {:output => "#{parent_dir}/images"})
27
+ Docsplit.extract_images(self.send(self.class.docsplit_attachment_name).path, {:output => "#{parent_dir}/images"}, self.class.docsplit_attachment_options)
28
28
  self.number_of_images_entry = Dir.entries("#{parent_dir}/images").size - 2
29
29
  @file_has_changed = false
30
30
  self.is_processing_image = false
@@ -33,14 +33,17 @@ module DocsplitImages
33
33
 
34
34
  ## paperclip overriding
35
35
  def prepare_for_destroy
36
- parent_dir = File.dirname(File.dirname(self.send(self.class.docsplit_attachment_name).path))
37
- FileUtils.rm_rf("#{parent_dir}/images")
36
+ begin
37
+ parent_dir = File.dirname(File.dirname(self.send(self.class.docsplit_attachment_name).path))
38
+ FileUtils.rm_rf("#{parent_dir}/images")
39
+ rescue
40
+ end
38
41
  super
39
42
  end
40
43
 
41
44
  def is_pdf_convertible?
42
45
  extname = File.extname(self.send("#{self.class.docsplit_attachment_name}_file_name")).downcase.gsub(".", "")
43
- return ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'odt', 'ods', 'odp'].index( extname ) != nil
46
+ return ['doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'odt', 'ods', 'odp', 'pdf'].index( extname ) != nil
44
47
  end
45
48
 
46
49
  def document_images_folder
@@ -64,10 +67,12 @@ module DocsplitImages
64
67
  end
65
68
 
66
69
  module ClassMethods
67
- def docsplit_images_conversion_for(attribute)
70
+ def docsplit_images_conversion_for(attribute, opts={})
68
71
  self.instance_eval do
69
72
  cattr_accessor :docsplit_attachment_name
73
+ cattr_accessor :docsplit_attachment_options
70
74
  self.docsplit_attachment_name = attribute
75
+ self.docsplit_attachment_options = opts
71
76
  end
72
77
  self.send(:include, DocsplitImages::Conversion)
73
78
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docsplit_images
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-26 00:00:00.000000000 Z
12
+ date: 2013-04-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: paperclip
@@ -162,7 +162,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
162
162
  version: '0'
163
163
  segments:
164
164
  - 0
165
- hash: -4543510368769755332
165
+ hash: 1310594466607129291
166
166
  required_rubygems_version: !ruby/object:Gem::Requirement
167
167
  none: false
168
168
  requirements:
@@ -171,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
171
  version: '0'
172
172
  requirements: []
173
173
  rubyforge_project:
174
- rubygems_version: 1.8.24
174
+ rubygems_version: 1.8.23
175
175
  signing_key:
176
176
  specification_version: 3
177
177
  summary: Split Images for your document