vtools 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,8 +6,9 @@ module VTools
6
6
  class ConvertOptions < Hash
7
7
  include SharedMethods
8
8
 
9
- def initialize options = {}
9
+ def initialize options = {}, additional = {}
10
10
  @ignore = [:width, :height, :resolution, :extension, :preserve_aspect, :duration, :postfix]
11
+ merge! additional
11
12
  parse! options
12
13
  end
13
14
 
@@ -36,8 +36,10 @@ module VTools
36
36
  options = nil
37
37
 
38
38
  Open3.popen3(exec) do |stdin, stdout, stderr|
39
+ lines = stdout.readlines.join(" ")
40
+ VTools.fix_encoding lines
39
41
  # save thumb if no error
40
- if (error = VTools.fix_encoding(stdout.readlines).join(" ")).empty?
42
+ if (error = lines).empty?
41
43
  thumbs << thumb = {:path => file, :offset => time_offset(seconds)}
42
44
 
43
45
  Handler.exec :in_thumb, @video, thumb # callbacks
@@ -2,5 +2,5 @@
2
2
 
3
3
  # current version
4
4
  module VTools
5
- VERSION = [ 0, 1, 0 ]
5
+ VERSION = [ 0, 1, 1 ]
6
6
  end
@@ -42,13 +42,13 @@ module VTools
42
42
 
43
43
  # generate thumbs
44
44
  def create_thumbs setup = {}
45
- @thumbs_options = ThumbsOptions.new setup.merge({:aspect => calculated_aspect_ratio})
45
+ @thumbs_options = ThumbsOptions.new setup
46
46
  @thumbnailer.run
47
47
  end
48
48
 
49
49
  # convert video
50
50
  def convert setup = {}
51
- @convert_options = ConvertOptions.new(setup)
51
+ @convert_options = ConvertOptions.new(setup, {:aspect => calculated_aspect_ratio})
52
52
  @converter.run
53
53
  end
54
54
 
@@ -129,6 +129,22 @@ describe VTools::Thumbnailer do
129
129
 
130
130
  expect { @thumbnailer.run }.to raise_error VTools::ProcessError, /Thumbnailer error:/
131
131
  end
132
+
133
+ it "processes invalid encoding" do
134
+ @options = {:thumb_count => 1, :thumb_start_point => 0}
135
+ prepare_thumbnailer [
136
+ File.readlines(
137
+ "#{File.realpath(File.dirname(__FILE__))}/fixtures/outputs/file_with_iso-8859-1.txt"
138
+ )[10]
139
+ ]
140
+
141
+ VTools::Handler.should_receive(:exec).with(:thumb_error, video, / Errors: /)
142
+
143
+ @thumbnailer.should_not_receive(:time_offset)
144
+ @thumbnailer.should_receive(:set_point).and_return { |sec| sec }
145
+
146
+ expect { @thumbnailer.run }.to raise_error VTools::ProcessError, /Thumbnailer error:/
147
+ end
132
148
  end
133
149
 
134
150
  context "#set_point" do
@@ -36,11 +36,10 @@ describe VTools::Video do
36
36
 
37
37
  it "executes thumbnailer" do
38
38
  thumb = double(nil)
39
- @video.stub(:calculated_aspect_ratio).and_return { 1.2 }
40
39
  @video.instance_variable_set(:@thumbnailer, thumb)
41
40
 
42
41
  setup = { :thumb => "options" }
43
- VTools::ThumbsOptions.should_receive(:new).with(setup.merge(:aspect => 1.2))
42
+ VTools::ThumbsOptions.should_receive(:new).with(setup)
44
43
  thumb.should_receive(:run)
45
44
 
46
45
  @video.create_thumbs setup
@@ -51,10 +50,11 @@ describe VTools::Video do
51
50
 
52
51
  it "executes converter" do
53
52
  convert = double(nil)
53
+ @video.stub(:calculated_aspect_ratio).and_return(1.2)
54
54
  @video.instance_variable_set(:@converter, convert)
55
55
 
56
56
  setup = { :convert => "options" }
57
- VTools::ConvertOptions.should_receive(:new).with(setup)
57
+ VTools::ConvertOptions.should_receive(:new).with(setup, {:aspect => 1.2})
58
58
  convert.should_receive(:run)
59
59
 
60
60
  @video.convert setup
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vtools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-12-13 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: daemons
16
- requirement: &82591300 !ruby/object:Gem::Requirement
16
+ requirement: &82931940 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.1.4
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *82591300
24
+ version_requirements: *82931940
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: json
27
- requirement: &82591110 !ruby/object:Gem::Requirement
27
+ requirement: &82933480 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *82591110
35
+ version_requirements: *82933480
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &82590880 !ruby/object:Gem::Requirement
38
+ requirement: &82933220 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *82590880
46
+ version_requirements: *82933220
47
47
  description: FFMPEG & FFMPEGTHUMBNAILER based video processor. Permits to generate
48
48
  thumbs and encode/edit video. Can be started as daemon.
49
49
  email: v.tofir@gmail.com