-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
87 lines (76 loc) · 2.53 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
require 'rubygems'
require 'rake'
require 'rake/testtask'
require 'rcov/rcovtask'
begin
require 'jeweler'
Jeweler::Tasks.new do |gemspec|
gemspec.name = "ruby-ffprobe"
gemspec.summary = "Ruby wrapper for FFprobe multimedia analyzer"
gemspec.description = File.read(File.join(File.dirname(__FILE__),"README.rdoc"))
gemspec.email = "[email protected]"
gemspec.homepage = "http://github.com/kingpong/ruby-ffprobe"
gemspec.authors = ["Philip Garrett"]
end
Jeweler::GemcutterTasks.new
rescue LoadError
puts "Jeweler not available. Install it with: gem install jeweler"
end
namespace "ffprobe" do
task "exec" do
next if ENV["FFPROBE"]
ENV['PATH'].split(":").each do |dir|
fqpath = File.join(dir,"ffprobe")
if File.executable?(fqpath)
ENV['FFPROBE'] = fqpath
break
end
end
next if ENV["FFPROBE"]
raise "Could not find ffprobe in your path. You may set the environment variable FFPROBE to point to your ffprobe executable"
end
end
task "set_testopts_verbose" do
ENV["TESTOPTS"] = '-v'
end
Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = FileList['test/**/test*.rb']
t.verbose = true
end
desc "Run tests with verbosity enabled"
task "vtest" => [:set_testopts_verbose, :test]
namespace "test" do
desc "Generate ffprobe output test cases"
task "cases" => ["ffprobe:exec","test/testcases/source.ogv"] do |t|
require "lib/ffprobe/safe_pipe"
dest_dir = File.expand_path("test/testcases")
source = File.expand_path(t.prerequisites.last)
variations = { "no_args" => [] }
%w{files frames packets streams tags}.each do |opt|
variations[opt] = ["-show_#{opt}"]
variations["pretty_#{opt}"] = ["-show_#{opt}", "-pretty"]
end
variations["files_streams_tags"] = ["-show_files", "-show_streams", "-show_tags"]
variations["pretty_files_streams_tags"] = ["-show_files", "-show_streams", "-show_tags", "-pretty"]
variations.each_pair do |name,args|
FFProbe::SafePipe.new(ENV["FFPROBE"], *(args + [source])).run do |pipe|
File.open(File.join(dest_dir,"#{name}.testcase"),"w") do |output|
output.write pipe.read
end
end
end
end
desc "Cleanup test output and testcases"
task "clean" do
Dir["test/testcases/*.testcase"].each { |file| File.unlink(file) }
end
end
Rcov::RcovTask.new("coverage") do |t|
t.libs << "test"
t.test_files = FileList["test/**/test_*.rb"]
t.output_dir = "coverage"
t.verbose = true
t.rcov_opts << '--exclude /gems/'
end
task "rcov" => "coverage"