paperclip-av-transcoder 0.1.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1df0550437cae7d8664437905d9d6fe3365fcac3
4
- data.tar.gz: dbc3fe8b3f626585a909df6de8e7f3c5a21cd71b
3
+ metadata.gz: 858fffd20c3c059ebc73712eedfb4150b1297f2f
4
+ data.tar.gz: b74db6d2e7358e2b1654f0306774c6a25aacb907
5
5
  SHA512:
6
- metadata.gz: a3dbbf2a67c7956073a96dc95bd7d5bb8dc3c82e96a8220ad5d1c0418a62b8273ba841409e5851cfc6745477788867643f5e7cc29a10bed2d9798436253cca7d
7
- data.tar.gz: 0acfbd006071a9c0324947de1e3ba7d37d73a9a4c08f4071c237152068acf72248b505e5aff75fe558745364513076f717ccd47ef5c90f29bf6158880911565e
6
+ metadata.gz: 5adddefa0f940151502182a571de4f2d70dcf5ec44599a75207e25e9e9ff3890becb4d5fb6221b4fce233409a183fdb12bea9cf023224262952b705c1aaeab57
7
+ data.tar.gz: 397819cee502c272fc65243ae658f5fd40cbcae3cf9aad40e5d78a7876c4abb78c2c016d9d8c3b0477c2476ae219770700b76f014547778c18d077c3fb0c38d4
@@ -1,7 +1,7 @@
1
1
  module Paperclip
2
2
  module Av
3
3
  module Transcoder
4
- VERSION = "0.1.0"
4
+ VERSION = "0.5.0"
5
5
  end
6
6
  end
7
7
  end
@@ -20,7 +20,7 @@ module Paperclip
20
20
  @geometry = options[:geometry]
21
21
  unless @geometry.nil?
22
22
  modifier = @geometry[0]
23
- @geometry[0] = '' if ['#', '<', '>'].includes? modifier
23
+ @geometry[0] = '' if ['#', '<', '>'].include? modifier
24
24
  @width, @height = @geometry.split('x')
25
25
  @keep_aspect = @width[0] == '!' || @height[0] == '!'
26
26
  @pad_only = @keep_aspect && modifier == '#'
@@ -41,28 +41,33 @@ module Paperclip
41
41
  ::Av.cli.add_source @file
42
42
  dst = Tempfile.new([@basename, @format ? ".#{@format}" : ''])
43
43
  dst.binmode
44
-
45
- cli = ::Av.cli(quite: true)
46
- cli.add_source(@file.path)
47
- cli.add_destination(dst.path)
48
- cli.reset_input_filters
49
- if @convert_options[:input]
50
- @convert_options[:input].each do |h|
51
- cli.add_input_param h
52
- end
53
- end
54
- if @convert_options[:output]
55
- @convert_options[:output].each do |h|
56
- cli.add_output_param h
44
+
45
+ if @meta
46
+ log "Transocding supported file #{@file.path}"
47
+ cli = ::Av.cli(quite: true)
48
+ cli.add_source(@file.path)
49
+ cli.add_destination(dst.path)
50
+ cli.reset_input_filters
51
+ if @convert_options.present?
52
+ if @convert_options[:input]
53
+ @convert_options[:input].each do |h|
54
+ cli.add_input_param h
55
+ end
56
+ end
57
+ if @convert_options[:output]
58
+ @convert_options[:output].each do |h|
59
+ cli.add_output_param h
60
+ end
61
+ end
57
62
  end
58
- end
59
63
 
60
- begin
61
- cli.run
62
- log "Successfully transcoded #{@base} to #{dst}"
63
- return dst # Things went fine, pass the file to paperclip for saving
64
- rescue Cocaine::ExitStatusError => e
65
- raise Paperclip::Error, "error while transcoding #{@basename}: #{e}" if @whiny
64
+ begin
65
+ cli.run
66
+ log "Successfully transcoded #{@base} to #{dst}"
67
+ return dst
68
+ rescue Cocaine::ExitStatusError => e
69
+ raise Paperclip::Error, "error while transcoding #{@basename}: #{e}" if @whiny
70
+ end
66
71
  end
67
72
  # If the file is not supported, just return it
68
73
  @file
@@ -25,5 +25,5 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency "sqlite3"
26
26
 
27
27
  spec.add_dependency "paperclip", ">=2.5.2"
28
- spec.add_dependency "av", ">= 0.0.1"
28
+ spec.add_dependency "av", ">= 0.4.0"
29
29
  end
@@ -1,9 +1,13 @@
1
1
  ActiveRecord::Schema.define version: 0 do
2
2
  create_table "documents", force: true do |t|
3
3
  t.string :owner
4
- t.string :original_file_name
5
- t.string :original_content_type
6
- t.integer :original_updated_at
7
- t.integer :original_file_size
4
+ t.string :video_file_name
5
+ t.string :video_content_type
6
+ t.integer :video_updated_at
7
+ t.integer :video_file_size
8
+ t.string :image_file_name
9
+ t.string :image_content_type
10
+ t.integer :image_updated_at
11
+ t.integer :image_file_size
8
12
  end
9
13
  end
@@ -11,7 +11,7 @@ Bundler.require(:default)
11
11
  # Connect to sqlite
12
12
  ActiveRecord::Base.establish_connection("adapter" => "sqlite3", "database" => ":memory:")
13
13
 
14
- ActiveRecord::Base.logger = Logger.new(nil)
14
+ ActiveRecord::Base.logger = Logger.new(STDOUT)
15
15
  load(File.join(File.dirname(__FILE__), 'schema.rb'))
16
16
 
17
17
  Paperclip::Railtie.insert
@@ -22,7 +22,7 @@ RSpec.configure do |config|
22
22
  end
23
23
 
24
24
  class Document < ActiveRecord::Base
25
- has_attached_file :original,
25
+ has_attached_file :video,
26
26
  storage: :filesystem,
27
27
  path: "./spec/tmp/:id.:extension",
28
28
  url: "/spec/tmp/:id.:extension",
@@ -32,7 +32,6 @@ class Document < ActiveRecord::Base
32
32
  format: 'ogv',
33
33
  convert_options: {
34
34
  output: {
35
- af: "volume=volume=10",
36
35
  ab: '256k',
37
36
  ar: 44100,
38
37
  ac: 2
@@ -41,5 +40,17 @@ class Document < ActiveRecord::Base
41
40
  }
42
41
  },
43
42
  processors: [:transcoder]
44
- do_not_validate_attachment_file_type :original
43
+
44
+ has_attached_file :image,
45
+ storage: :filesystem,
46
+ path: "./spec/tmp/:id.:extension",
47
+ url: "/spec/tmp/:id.:extension",
48
+ whiny: true,
49
+ styles: {
50
+ small: "100x100"
51
+ },
52
+ processors: [:transcoder, :thumbnail]
53
+
54
+ do_not_validate_attachment_file_type :video
55
+ do_not_validate_attachment_file_type :image
45
56
  end
@@ -1,12 +1,26 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Paperclip::Transcoder do
4
- let(:subject) { Paperclip::Transcoder.new(source) }
5
- let(:document) { Document.create(original: source) }
6
- let(:source) { File.new(Dir.pwd + '/spec/support/assets/sample.mp4') }
4
+ let(:supported) { File.new(Dir.pwd + '/spec/support/assets/sample.mp4') }
5
+ let(:unsupported) { File.new(File.expand_path('spec/support/assets/image.png')) }
6
+
7
7
  let(:destination) { Pathname.new("#{Dir.tmpdir}/transcoder/") }
8
8
 
9
- describe ".transcode" do
10
- it { expect(File.exists?(document.original.path(:small))).to eq true }
9
+ describe "supported formats" do
10
+ let(:subject) { Paperclip::Chainer.new(supported) }
11
+ let(:document) { Document.create(video: Rack::Test::UploadedFile.new(supported, 'video/mp4')) }
12
+
13
+ describe ".transcode" do
14
+ it { expect(File.exists?(document.video.path(:small))).to eq true }
15
+ end
16
+ end
17
+
18
+ describe "unsupported formats" do
19
+ let(:subject) { Paperclip::Chainer.new(unsupported) }
20
+ let(:document) { Document.create(image: Rack::Test::UploadedFile.new(unsupported, 'image/png')) }
21
+ describe ".transcode" do
22
+ it { expect(File.exists?(document.image.path(:small))).to eq true }
23
+ end
11
24
  end
25
+
12
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip-av-transcoder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Omar Abdel-Wahab
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-11 00:00:00.000000000 Z
11
+ date: 2014-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - '>='
102
102
  - !ruby/object:Gem::Version
103
- version: 0.0.1
103
+ version: 0.4.0
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - '>='
109
109
  - !ruby/object:Gem::Version
110
- version: 0.0.1
110
+ version: 0.4.0
111
111
  description: Audio/Video Transcoder for Paperclip using FFMPEG/Avconv
112
112
  email:
113
113
  - owahab@gmail.com
@@ -130,6 +130,7 @@ files:
130
130
  - spec/support/assets/audio.zip
131
131
  - spec/support/assets/audio/audio1.spx
132
132
  - spec/support/assets/audio/audio2.spx
133
+ - spec/support/assets/image.png
133
134
  - spec/support/assets/sample.mp4
134
135
  - spec/transcoder/transcoder_spec.rb
135
136
  homepage: https://github.com/ruby-av/paperclip-av-transcoder
@@ -162,5 +163,6 @@ test_files:
162
163
  - spec/support/assets/audio.zip
163
164
  - spec/support/assets/audio/audio1.spx
164
165
  - spec/support/assets/audio/audio2.spx
166
+ - spec/support/assets/image.png
165
167
  - spec/support/assets/sample.mp4
166
168
  - spec/transcoder/transcoder_spec.rb