paperclip-av-chainer 0.0.4
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 +7 -0
- data/.gitignore +23 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +5 -0
- data/lib/paperclip/av/chainer.rb +2 -0
- data/lib/paperclip/av/chainer/version.rb +7 -0
- data/lib/paperclip/paperclip_processors/chainer.rb +65 -0
- data/paperclip-av-chainer.gemspec +30 -0
- data/spec/chainer/chainer_spec.rb +17 -0
- data/spec/schema.rb +9 -0
- data/spec/spec_helper.rb +37 -0
- data/spec/support/assets/audio.zip +0 -0
- metadata +173 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ce63bcf3605ea9ce89f25521589ed27e133e5702
|
4
|
+
data.tar.gz: fdc7c8bbfc44ac81ec30c280caf1457e6ae773cc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f4e7dcf3961f09cd8baed8ff317b1f5ac410b9f5d78294716d159bbd60d9fcba1d9296cbb49ad6efcf1c79d53562941c089b1ab217660ed2e6bb1b2c80746445
|
7
|
+
data.tar.gz: 32d6f2381a45dd73bb582f6bbff6d78332451c86fd778b03f7931a9da96c4f1d74a016e13ca367ac16ab32f446ae9a112101e5219bbeb9ffa7e400f1f85fd304
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
.DS_Store
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Omar Abdel-Wahab
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Paperclip::Av::Chainer
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'paperclip-av-chainer'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install paperclip-av-chainer
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( https://github.com/[my-github-username]/paperclip-av-chainer/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'zip'
|
2
|
+
require 'av'
|
3
|
+
|
4
|
+
module Paperclip
|
5
|
+
class Chainer < Processor
|
6
|
+
attr_accessor :whiny, :destination, :extension, :basename, :supported_formats
|
7
|
+
|
8
|
+
def initialize file, options = {}, attachment = nil
|
9
|
+
Paperclip.log "[chainer] Got file #{file.path}"
|
10
|
+
@whiny = options[:whiny].nil? ? true : options[:whiny]
|
11
|
+
@file = file
|
12
|
+
@extension = File.extname(@file.path)
|
13
|
+
@basename = File.basename(@file.path, @extension)
|
14
|
+
@supported_formats = ['.zip']
|
15
|
+
@destination = Pathname.new("#{Dir.tmpdir}/#{SecureRandom.uuid}")
|
16
|
+
end
|
17
|
+
|
18
|
+
def make
|
19
|
+
if @supported_formats.include?(@extension)
|
20
|
+
Paperclip.log "[chainer] Got file #{@file.path} with extension #{@extension}"
|
21
|
+
case @extension
|
22
|
+
when '.zip'
|
23
|
+
unzip
|
24
|
+
end
|
25
|
+
result = concatenate
|
26
|
+
Paperclip.log "[chainer] Successfully concatenated source into #{result.path}"
|
27
|
+
# Explicitly return in order to allow the next processor in the chain to work
|
28
|
+
# on the new file
|
29
|
+
return result
|
30
|
+
end
|
31
|
+
# If the file is not supported, just return it
|
32
|
+
@file
|
33
|
+
end
|
34
|
+
|
35
|
+
def unzip
|
36
|
+
Paperclip.log "[chainer] Extracting contents to #{@destination}"
|
37
|
+
Zip::File.open(File.expand_path(@file.path)) do |zip_file|
|
38
|
+
Paperclip.log "[chainer] Creating #{@destination}"
|
39
|
+
FileUtils.mkdir_p(@destination)
|
40
|
+
zip_file.each do |source|
|
41
|
+
# Extract to file/directory/symlink
|
42
|
+
Paperclip.log "[chainer] Extracting #{source.name}"
|
43
|
+
target_file = @destination.join(source.name)
|
44
|
+
@target_format = File.extname(source.name)
|
45
|
+
zip_file.extract(source, target_file) unless File.exists?(target_file)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def concatenate
|
51
|
+
list = Dir["#{@destination}/*"]
|
52
|
+
target = Tempfile.new(['chainer-', @target_format])
|
53
|
+
Paperclip.log "[chainer] Concatentating #{list.inspect} from #{@destination} into #{target.path}"
|
54
|
+
begin
|
55
|
+
cli = ::Av.cli
|
56
|
+
cli.filter_concat(list)
|
57
|
+
cli.add_destination(target.path)
|
58
|
+
cli.run
|
59
|
+
return target
|
60
|
+
rescue Cocaine::ExitStatusError => e
|
61
|
+
raise Paperclip::Error, "error while concatenating video for #{@file.path}: #{e}" if @whiny
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'paperclip/av/chainer/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "paperclip-av-chainer"
|
8
|
+
spec.version = Paperclip::Av::Chainer::VERSION
|
9
|
+
spec.authors = ["Omar Abdel-Wahab"]
|
10
|
+
spec.email = ["owahab@gmail.com"]
|
11
|
+
spec.summary = %q{Audio/Video Chainer for Paperclip using FFMPEG/Avconv}
|
12
|
+
spec.description = %q{Audio/Video Chainer for Paperclip using FFMPEG/Avconv}
|
13
|
+
spec.homepage = "https://github.com/ruby-av/paperclip-av-chainer"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.0.0"
|
24
|
+
spec.add_development_dependency "rails", ">= 4.0.0"
|
25
|
+
spec.add_development_dependency "sqlite3"
|
26
|
+
|
27
|
+
spec.add_dependency "paperclip", ">=2.5.2"
|
28
|
+
spec.add_dependency "rubyzip", "~> 1.1.0"
|
29
|
+
spec.add_dependency "av", ">= 0.0.1"
|
30
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Paperclip::Chainer do
|
4
|
+
let(:subject) { Paperclip::Chainer.new(source) }
|
5
|
+
let(:document) { Document.create(original: Rack::Test::UploadedFile.new(source, 'application/zip')) }
|
6
|
+
let(:source) { File.new(File.expand_path('spec/support/assets/audio.zip')) }
|
7
|
+
|
8
|
+
it { expect(File.exists?(document.original.path(:small))).to eq true }
|
9
|
+
|
10
|
+
describe ".unzip" do
|
11
|
+
before do
|
12
|
+
subject.unzip
|
13
|
+
end
|
14
|
+
|
15
|
+
it { expect(Dir["#{subject.destination}/*"].count).to eq 2 }
|
16
|
+
end
|
17
|
+
end
|
data/spec/schema.rb
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rspec'
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'paperclip'
|
5
|
+
require 'paperclip/railtie'
|
6
|
+
# Prepare activerecord
|
7
|
+
require "active_record"
|
8
|
+
require 'paperclip/av/chainer'
|
9
|
+
|
10
|
+
Bundler.require(:default)
|
11
|
+
# Connect to sqlite
|
12
|
+
ActiveRecord::Base.establish_connection("adapter" => "sqlite3", "database" => ":memory:")
|
13
|
+
|
14
|
+
ActiveRecord::Base.logger = Logger.new(nil)
|
15
|
+
load(File.join(File.dirname(__FILE__), 'schema.rb'))
|
16
|
+
|
17
|
+
Paperclip::Railtie.insert
|
18
|
+
|
19
|
+
RSpec.configure do |config|
|
20
|
+
config.run_all_when_everything_filtered = true
|
21
|
+
config.filter_run focus: true
|
22
|
+
end
|
23
|
+
|
24
|
+
class Document < ActiveRecord::Base
|
25
|
+
has_attached_file :original,
|
26
|
+
storage: :filesystem,
|
27
|
+
path: "./spec/tmp/:id.:extension",
|
28
|
+
url: "/spec/tmp/:id.:extension",
|
29
|
+
styles: {
|
30
|
+
small: {
|
31
|
+
format: :ogg
|
32
|
+
}
|
33
|
+
}, processors: [:chainer]
|
34
|
+
|
35
|
+
do_not_validate_attachment_file_type :original
|
36
|
+
end
|
37
|
+
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: paperclip-av-chainer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Omar Abdel-Wahab
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.0.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.0.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 4.0.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 4.0.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sqlite3
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: paperclip
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 2.5.2
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 2.5.2
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubyzip
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.1.0
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.1.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: av
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.0.1
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.0.1
|
125
|
+
description: Audio/Video Chainer for Paperclip using FFMPEG/Avconv
|
126
|
+
email:
|
127
|
+
- owahab@gmail.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- .gitignore
|
133
|
+
- Gemfile
|
134
|
+
- LICENSE.txt
|
135
|
+
- README.md
|
136
|
+
- Rakefile
|
137
|
+
- lib/paperclip/av/chainer.rb
|
138
|
+
- lib/paperclip/av/chainer/version.rb
|
139
|
+
- lib/paperclip/paperclip_processors/chainer.rb
|
140
|
+
- paperclip-av-chainer.gemspec
|
141
|
+
- spec/chainer/chainer_spec.rb
|
142
|
+
- spec/schema.rb
|
143
|
+
- spec/spec_helper.rb
|
144
|
+
- spec/support/assets/audio.zip
|
145
|
+
homepage: https://github.com/ruby-av/paperclip-av-chainer
|
146
|
+
licenses:
|
147
|
+
- MIT
|
148
|
+
metadata: {}
|
149
|
+
post_install_message:
|
150
|
+
rdoc_options: []
|
151
|
+
require_paths:
|
152
|
+
- lib
|
153
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
|
+
requirements:
|
160
|
+
- - '>='
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: '0'
|
163
|
+
requirements: []
|
164
|
+
rubyforge_project:
|
165
|
+
rubygems_version: 2.0.3
|
166
|
+
signing_key:
|
167
|
+
specification_version: 4
|
168
|
+
summary: Audio/Video Chainer for Paperclip using FFMPEG/Avconv
|
169
|
+
test_files:
|
170
|
+
- spec/chainer/chainer_spec.rb
|
171
|
+
- spec/schema.rb
|
172
|
+
- spec/spec_helper.rb
|
173
|
+
- spec/support/assets/audio.zip
|