popcap 0.9.2 → 0.9.3
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/.gitignore +1 -0
- data/lib/pop_cap/ffmpeg/analyze_file.rb +50 -0
- data/lib/pop_cap/ffmpeg/converter.rb +1 -1
- data/lib/pop_cap/ffmpeg/ffmpeg.rb +6 -0
- data/lib/pop_cap/ffmpeg/tag_reader.rb +1 -1
- data/lib/pop_cap/ffmpeg/tag_writer.rb +7 -2
- data/lib/pop_cap/version.rb +1 -1
- data/spec/lib/pop_cap/ffmpeg/analyze_file_spec.rb +26 -0
- data/spec/lib/pop_cap/ffmpeg/tag_reader_spec.rb +0 -4
- data/spec/lib/pop_cap/ffmpeg/tag_writer_spec.rb +9 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 931fd9befcffd1b5ab9805ceff6c8fe297312444
|
4
|
+
data.tar.gz: 599f3ed43bdf4b1be7a35f90ea76c7d16d0f08ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 347cd122247302dd21ac0760dfe096d93e768099cc713cde8851d4bc5582998e3c22555d71c82776883781ac01999c51066a51d44835070509b565f9fb4dae9f
|
7
|
+
data.tar.gz: 9be5928aa054bdf3838cb3b582dc30d26f688a0683d5387a58fdcf9c7044ae56ccc41ab4c027be8ff7d80310e24c1566714be512a5212e67b7170a84fb5c6792
|
data/.gitignore
CHANGED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'pop_cap/ffmpeg/commander'
|
2
|
+
|
3
|
+
module PopCap
|
4
|
+
# Public: This class is similar to TagReader, but is useful for debugging.
|
5
|
+
# If a file cannot be read, this will return the error message generated
|
6
|
+
# by FFprobe
|
7
|
+
#
|
8
|
+
class AnalyzeFile
|
9
|
+
attr_reader :filepath
|
10
|
+
|
11
|
+
# Public: Initialize an instance of AnalyzeFile.
|
12
|
+
# filepath = relative path to a file on the filesystem
|
13
|
+
#
|
14
|
+
def initialize(filepath)
|
15
|
+
@filepath = File.expand_path(filepath)
|
16
|
+
@datetime = Time.now.strftime("%Y-%m-%d at %H:%M:%S")
|
17
|
+
end
|
18
|
+
|
19
|
+
# Public: This method returns the stderr of FFprobe -show_format
|
20
|
+
# as an array. The first element is a datetime stamp, the second
|
21
|
+
# element is the error message.
|
22
|
+
#
|
23
|
+
def examine
|
24
|
+
[datetimestamp, error]
|
25
|
+
end
|
26
|
+
|
27
|
+
# Public: A convenience class method for examining a file.
|
28
|
+
#
|
29
|
+
def self.examine(filepath)
|
30
|
+
new(filepath).examine
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
def command
|
35
|
+
%W{ffprobe -show_format -print_format json} + %W{#{filepath}}
|
36
|
+
end
|
37
|
+
|
38
|
+
def contents
|
39
|
+
Commander.new(*command).execute.stderr
|
40
|
+
end
|
41
|
+
|
42
|
+
def datetimestamp
|
43
|
+
"FFprobe read error on #{@datetime}"
|
44
|
+
end
|
45
|
+
|
46
|
+
def error
|
47
|
+
contents.split("\n").last
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -10,7 +10,8 @@ module PopCap
|
|
10
10
|
# is done to prevent corrupting the original file.
|
11
11
|
#
|
12
12
|
def write
|
13
|
-
unless
|
13
|
+
unless execute.success?
|
14
|
+
cleanup_failed_write
|
14
15
|
raise(FFmpegError, error_message('writing'))
|
15
16
|
end
|
16
17
|
FileUtils.move(tmppath, filepath)
|
@@ -24,7 +25,7 @@ module PopCap
|
|
24
25
|
|
25
26
|
private
|
26
27
|
def tmppath
|
27
|
-
'/tmp/' + File.basename(filepath)
|
28
|
+
@tmp ||= '/tmp/' + File.basename(filepath)
|
28
29
|
end
|
29
30
|
|
30
31
|
def command
|
@@ -40,5 +41,9 @@ module PopCap
|
|
40
41
|
def clean_tags
|
41
42
|
@cleaned ||= options.reject { |key,_| key == :commander }
|
42
43
|
end
|
44
|
+
|
45
|
+
def cleanup_failed_write
|
46
|
+
FileUtils.rm_f(tmppath)
|
47
|
+
end
|
43
48
|
end
|
44
49
|
end
|
data/lib/pop_cap/version.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'pop_cap/ffmpeg/analyze_file'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
module PopCap
|
6
|
+
describe AnalyzeFile do
|
7
|
+
let(:bad_file) { "#{File.expand_path('spec/fixtures/bad_file.img')}" }
|
8
|
+
|
9
|
+
before { FileUtils.touch bad_file }
|
10
|
+
after { FileUtils.rm_f bad_file }
|
11
|
+
|
12
|
+
context ".examine" do
|
13
|
+
let(:response) { AnalyzeFile.examine(bad_file) }
|
14
|
+
|
15
|
+
it 'has a datetime stamp' do
|
16
|
+
date_regex = %r(FFprobe read error on \d{4}-\d{2}-\d{2} at \d{2}:\d{2}:\d{2})
|
17
|
+
expect(response[0]).to match date_regex
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'has the error message' do
|
21
|
+
expect(response).
|
22
|
+
to include "#{bad_file}: Invalid data found when processing input"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -54,6 +54,15 @@ module PopCap
|
|
54
54
|
writer.write
|
55
55
|
end.to raise_error(FFmpegError, "Error writing #{file}.")
|
56
56
|
end
|
57
|
+
|
58
|
+
it 'removes the temp file' do
|
59
|
+
expect do
|
60
|
+
commander.should_receive(:new).with(*command) { instance }
|
61
|
+
instance.stub_chain(:execute, :success?) { false }
|
62
|
+
FileUtils.should_receive(:rm_f).with('/tmp/file.flac')
|
63
|
+
writer.write
|
64
|
+
end.to raise_error(FFmpegError, "Error writing #{file}.")
|
65
|
+
end
|
57
66
|
end
|
58
67
|
end
|
59
68
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: popcap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Culley Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: reek
|
@@ -54,6 +54,7 @@ files:
|
|
54
54
|
- README.md
|
55
55
|
- lib/pop_cap/audio_file.rb
|
56
56
|
- lib/pop_cap/class_support.rb
|
57
|
+
- lib/pop_cap/ffmpeg/analyze_file.rb
|
57
58
|
- lib/pop_cap/ffmpeg/commander.rb
|
58
59
|
- lib/pop_cap/ffmpeg/converter.rb
|
59
60
|
- lib/pop_cap/ffmpeg/ffmpeg.rb
|
@@ -74,6 +75,7 @@ files:
|
|
74
75
|
- spec/fixtures/sample.flac
|
75
76
|
- spec/lib/pop_cap/audio_file_spec.rb
|
76
77
|
- spec/lib/pop_cap/class_support_spec.rb
|
78
|
+
- spec/lib/pop_cap/ffmpeg/analyze_file_spec.rb
|
77
79
|
- spec/lib/pop_cap/ffmpeg/commander_spec.rb
|
78
80
|
- spec/lib/pop_cap/ffmpeg/converter_spec.rb
|
79
81
|
- spec/lib/pop_cap/ffmpeg/ffmpeg_spec.rb
|
@@ -110,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
112
|
version: 1.3.6
|
111
113
|
requirements: []
|
112
114
|
rubyforge_project:
|
113
|
-
rubygems_version: 2.0.
|
115
|
+
rubygems_version: 2.0.3
|
114
116
|
signing_key:
|
115
117
|
specification_version: 4
|
116
118
|
summary: A library work with audio files on the filesystem .
|
@@ -118,6 +120,7 @@ test_files:
|
|
118
120
|
- spec/fixtures/sample.flac
|
119
121
|
- spec/lib/pop_cap/audio_file_spec.rb
|
120
122
|
- spec/lib/pop_cap/class_support_spec.rb
|
123
|
+
- spec/lib/pop_cap/ffmpeg/analyze_file_spec.rb
|
121
124
|
- spec/lib/pop_cap/ffmpeg/commander_spec.rb
|
122
125
|
- spec/lib/pop_cap/ffmpeg/converter_spec.rb
|
123
126
|
- spec/lib/pop_cap/ffmpeg/ffmpeg_spec.rb
|
@@ -135,4 +138,3 @@ test_files:
|
|
135
138
|
- spec/spec_helper.rb
|
136
139
|
- spec/support/popcap_spec_helper.rb
|
137
140
|
- spec/support/reek_spec.rb
|
138
|
-
has_rdoc:
|