pdf_to_swf-paperclip-processor 0.0.2 → 0.0.3a

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.
data/README.md CHANGED
@@ -40,40 +40,19 @@ Use it as you would any other Paperclip processor. In your model:
40
40
 
41
41
  class Document < ActiveRecord::Base
42
42
 
43
- has_attached_file :document,
44
-
45
- :styles => {
46
- :original => { :params => "-z -j 100 -qq -G" }
47
- },
48
- :processors => [:pdf_to_swf]
43
+ has_attached_file :pdf,
44
+ :styles => {
45
+ :swf => {
46
+ :params => "-z -j 100 -qq -G",
47
+ :format => "swf" }
48
+ },
49
+ :processors => [:pdf_to_swf]
49
50
 
50
51
  end
51
52
 
52
53
 
53
- which will convert your pdf document into swf. However, pdf extension will be retained.
54
+ which will convert your pdf document into swf , and keep both files (.swf and .pdf) on the server
54
55
 
55
- In order to avoid this I have created a method to normalize file name and change it's extension.
56
-
57
- class Document < ActiveRecord::Base
58
-
59
- has_attached_file :document,
60
- :styles => {
61
- :original => { :params => "-z -j 100 -qq -G" }
62
- },
63
- :processors => [:pdf_to_swf],
64
- :path => ":rails_root/public/system/:attachment/:normalized_file_name",
65
- :url => "/system/:attachment/:normalized_file_name"
66
-
67
- Paperclip.interpolates :normalized_file_name do |attachment, style|
68
- attachment.instance.normalized_file_name
69
- end
70
-
71
- def normalized_file_name
72
- file = self.document_file_name.gsub( /[^a-zA-Z0-9_\-\.]/, '_')
73
- file = "#{self.id}-#{File.basename(file, ".pdf")}".slice(0...32)
74
- "#{file}.swf".downcase
75
- end
76
- end
77
56
 
78
57
  However, if you think you can do better, feel free to fork.
79
58
 
data/Rakefile CHANGED
@@ -1,2 +1,2 @@
1
1
  require 'bundler'
2
- Bundler::GemHelper.install_tasks
2
+ Bundler::GemHelper.install_tasks
@@ -1,7 +1,7 @@
1
1
  module Pdftoswf
2
2
  module Paperclip
3
3
  module Processor
4
- VERSION = "0.0.2"
4
+ VERSION = "0.0.3a"
5
5
  end
6
6
  end
7
7
  end
@@ -2,7 +2,7 @@ require "paperclip"
2
2
  module Paperclip
3
3
  class PdfToSwf < Processor
4
4
 
5
- attr_accessor :params
5
+ attr_accessor :file, :params, :format
6
6
 
7
7
  def initialize file, options = {}, attachment = nil
8
8
  super
@@ -10,11 +10,12 @@ module Paperclip
10
10
  @params = options[:params]
11
11
  @current_format = File.extname(@file.path)
12
12
  @basename = File.basename(@file.path, @current_format)
13
+ @format = options[:format]
13
14
  end
14
15
 
15
16
  def make
16
17
  src = @file
17
- dst = Tempfile.new([@basename.tableize])
18
+ dst = Tempfile.new([@basename, @format ? ".#{@format}" : ''])
18
19
  begin
19
20
  parameters = []
20
21
  parameters << @params
@@ -6,8 +6,8 @@ Gem::Specification.new do |s|
6
6
  s.name = "pdf_to_swf-paperclip-processor"
7
7
  s.version = Pdftoswf::Paperclip::Processor::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
- s.authors = ["Armin Pašalić"]
10
- s.email = ["apasalic@devlogic.eu"]
9
+ s.authors = ["Armin Pašalić", "Mojmir Novakovic-moonflash"]
10
+ s.email = ["apasalic@devlogic.eu","moonflash.as3@gmail.com"]
11
11
  s.homepage = "https://github.com/Krule/pdf_to_swf-paperclip-processor"
12
12
  s.summary = %q{Converts uploaded pdf to swf}
13
13
  s.description = %q{This gem is simple Paperclip processor which uses swftools to convert uploaded pdf files to swf}
metadata CHANGED
@@ -1,21 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdf_to_swf-paperclip-processor
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
5
- prerelease:
4
+ prerelease: true
6
5
  segments:
7
6
  - 0
8
7
  - 0
9
- - 2
10
- version: 0.0.2
8
+ - 3a
9
+ version: 0.0.3a
11
10
  platform: ruby
12
11
  authors:
13
12
  - "Armin Pa\xC5\xA1ali\xC4\x87"
13
+ - Mojmir Novakovic-moonflash
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-24 00:00:00 +01:00
18
+ date: 2011-05-05 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,7 +26,6 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- hash: 7
30
29
  segments:
31
30
  - 3
32
31
  - 0
@@ -41,7 +40,6 @@ dependencies:
41
40
  requirements:
42
41
  - - ~>
43
42
  - !ruby/object:Gem::Version
44
- hash: 5
45
43
  segments:
46
44
  - 2
47
45
  - 3
@@ -51,6 +49,7 @@ dependencies:
51
49
  description: This gem is simple Paperclip processor which uses swftools to convert uploaded pdf files to swf
52
50
  email:
53
51
  - apasalic@devlogic.eu
52
+ - moonflash.as3@gmail.com
54
53
  executables: []
55
54
 
56
55
  extensions: []
@@ -79,23 +78,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
79
78
  requirements:
80
79
  - - ">="
81
80
  - !ruby/object:Gem::Version
82
- hash: 3
83
81
  segments:
84
82
  - 0
85
83
  version: "0"
86
84
  required_rubygems_version: !ruby/object:Gem::Requirement
87
85
  none: false
88
86
  requirements:
89
- - - ">="
87
+ - - ">"
90
88
  - !ruby/object:Gem::Version
91
- hash: 3
92
89
  segments:
93
- - 0
94
- version: "0"
90
+ - 1
91
+ - 3
92
+ - 1
93
+ version: 1.3.1
95
94
  requirements: []
96
95
 
97
96
  rubyforge_project: pdf_to_swf-paperclip-processor
98
- rubygems_version: 1.4.1
97
+ rubygems_version: 1.3.7
99
98
  signing_key:
100
99
  specification_version: 3
101
100
  summary: Converts uploaded pdf to swf