viddl 0.0.4 → 0.0.5
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 +4 -4
- data/README.md +2 -1
- data/bin/viddl +6 -0
- data/lib/viddl.rb +1 -1
- data/lib/viddl/video/clip.rb +16 -7
- data/lib/viddl/video/instance.rb +1 -0
- data/spec/video/clip_spec.rb +29 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b07f12926474b14cea4f3d36255ccfcd0d9b12b
|
4
|
+
data.tar.gz: 2058b3dc1af7197158eacdddffbf88e979383c0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99e34cc08878f9e6c6193925bb6456481fb28ec07689c608f0b0e6f66e5d9c9fd75da9f5f267b16f23d0cd2ec78a206465751c54456e097b8ad825c7e4412bc2
|
7
|
+
data.tar.gz: 0d498f7807d838375aecf08408b329ba61704846d364a39008b22c320aa19ec8c338f5006e1ce18717d63b5f3a5b1c6d1101b1cec0f3523c98273b91cbbf74ad
|
data/README.md
CHANGED
data/bin/viddl
CHANGED
data/lib/viddl.rb
CHANGED
data/lib/viddl/video/clip.rb
CHANGED
@@ -23,6 +23,7 @@ module Viddl
|
|
23
23
|
# @option options [Integer, String] :width The desired width to resize to
|
24
24
|
# @option options [Integer, String] :height The desired height to resize to
|
25
25
|
# @option options [Hash] :crop The desired crop parameters (:x, :y, :width, :height)
|
26
|
+
# @option options [Pathname, String] :output_path Path where clip will be written
|
26
27
|
# @return [Clip]
|
27
28
|
def self.process(path, options = {})
|
28
29
|
clip = new(path)
|
@@ -44,14 +45,15 @@ module Viddl
|
|
44
45
|
# @option options [Integer, String] :width The desired width to resize to
|
45
46
|
# @option options [Integer, String] :height The desired height to resize to
|
46
47
|
# @option options [Hash] :crop The desired crop parameters (:x, :y, :width, :height)
|
48
|
+
# @option options [Pathname, String] :output_path Path where clip will be written
|
47
49
|
# @return [Boolean]
|
48
50
|
def process(options = {})
|
49
51
|
command = command_line(options)
|
50
52
|
Kernel.system(command)
|
51
53
|
end
|
52
54
|
|
53
|
-
# Path of the created clip
|
54
|
-
# @return [Pathname]
|
55
|
+
# Path of the created clip. Is nil until file exists
|
56
|
+
# @return [Pathname, nil]
|
55
57
|
def path
|
56
58
|
if !@path.nil? && File.exists?(@path)
|
57
59
|
@path
|
@@ -69,6 +71,7 @@ module Viddl
|
|
69
71
|
# @option options [Integer, String] :width The desired width to resize to
|
70
72
|
# @option options [Integer, String] :height The desired height to resize to
|
71
73
|
# @option options [Hash] :crop The desired crop parameters (:x, :y, :width, :height)
|
74
|
+
# @option options [Pathname, String] :output_path Path where clip will be written
|
72
75
|
# @return [String]
|
73
76
|
def command_line(options = {})
|
74
77
|
if options.values.compact.empty?
|
@@ -118,18 +121,24 @@ module Viddl
|
|
118
121
|
# @option options [Integer, String] :width The desired width to resize to
|
119
122
|
# @option options [Integer, String] :height The desired height to resize to
|
120
123
|
# @option options [Hash] :crop The desired crop parameters (:x, :y, :width, :height)
|
124
|
+
# @option options [Pathname, String] :output_path Path where clip will be written
|
121
125
|
# @return [String]
|
122
126
|
def populate_output_path(options = {})
|
123
127
|
base = @source_path.scan(/#{Download::TEMPDIR}\/(.*)/).flatten.first
|
124
128
|
result = base
|
125
129
|
if !options.values.flatten.compact.empty?
|
126
130
|
name, ext = *base.split(".")
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
+
result = if options[:output_path].nil? || File.directory?(options[:output_path])
|
132
|
+
tokens = ""
|
133
|
+
MODULES.each do |mod|
|
134
|
+
token = mod.filename_token(options)
|
135
|
+
tokens += "-#{token}" unless token.nil?
|
136
|
+
end
|
137
|
+
path = "#{options[:output_path]}/" unless options[:output_path].nil?
|
138
|
+
"#{path}#{name}#{tokens}.#{ext}"
|
139
|
+
elsif !options[:output_path].nil?
|
140
|
+
"#{options[:output_path]}.#{ext}"
|
131
141
|
end
|
132
|
-
result = "#{name}#{tokens}.#{ext}"
|
133
142
|
end
|
134
143
|
@path = Pathname.new(result)
|
135
144
|
end
|
data/lib/viddl/video/instance.rb
CHANGED
@@ -27,6 +27,7 @@ module Viddl
|
|
27
27
|
# @option options [Integer, String] :width The desired width to resize to
|
28
28
|
# @option options [Integer, String] :height The desired height to resize to
|
29
29
|
# @option options [Hash] :crop The desired crop parameters (:x, :y, :width, :height)
|
30
|
+
# @option options [Pathname, String] :output_path path where clip will be written. Can be directory or filename
|
30
31
|
# @return [Array<Clip>]
|
31
32
|
def create_clip(options = {})
|
32
33
|
source_filenames.map do |filename|
|
data/spec/video/clip_spec.rb
CHANGED
@@ -335,6 +335,35 @@ describe Viddl::Video::Clip do
|
|
335
335
|
|
336
336
|
end
|
337
337
|
|
338
|
+
context "with output path" do
|
339
|
+
|
340
|
+
context "with valid directory" do
|
341
|
+
|
342
|
+
it "includes directory" do
|
343
|
+
expect(File).to(receive(:directory?).and_return(true))
|
344
|
+
options = {
|
345
|
+
output_path: "this/isadir"
|
346
|
+
}
|
347
|
+
path = @clip.send(:populate_output_path, options)
|
348
|
+
expect(path.to_s).to(eq("this/isadir/6g4dkBF5anU.mkv"))
|
349
|
+
end
|
350
|
+
|
351
|
+
end
|
352
|
+
|
353
|
+
context "with path/filename" do
|
354
|
+
|
355
|
+
it "includes path/filename" do
|
356
|
+
expect(File).to(receive(:directory?).and_return(false))
|
357
|
+
options = {
|
358
|
+
output_path: "thisis/afile"
|
359
|
+
}
|
360
|
+
path = @clip.send(:populate_output_path, options)
|
361
|
+
expect(path.to_s).to(eq("thisis/afile.mkv"))
|
362
|
+
end
|
363
|
+
|
364
|
+
end
|
365
|
+
end
|
366
|
+
|
338
367
|
context "crop options" do
|
339
368
|
|
340
369
|
context "valid" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: viddl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ari Russo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|