Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 179 lines (157 sloc) 5.862 kb
d122bb7 James Ludlow Moving to GitHub.
jdl authored
1 require 'rubygems'
2 require 'rake'
3 require 'rake/clean'
4 require 'rake/testtask'
5 require 'rake/packagetask'
6 require 'rake/gempackagetask'
7 require 'rake/rdoctask'
8 require 'rake/contrib/rubyforgepublisher'
9 require 'fileutils'
10 require 'hoe'
11 begin
12 require 'spec/rake/spectask'
13 rescue LoadError
14 puts 'To use rspec for testing you must install rspec gem:'
15 puts '$ sudo gem install rspec'
16 exit
17 end
18
19 include FileUtils
20 require File.join(File.dirname(__FILE__), 'lib', 'rvideo', 'version')
21
22 AUTHOR = 'Jonathan Dahl (Slantwise Design)' # can also be an array of Authors
23 EMAIL = "jon@slantwisedesign.com"
24 DESCRIPTION = "Inspect and process video or audio files"
25 GEM_NAME = 'rvideo' # what ppl will type to install your gem
26
27 @config_file = "~/.rubyforge/user-config.yml"
28 @config = nil
29 def rubyforge_username
30 unless @config
31 begin
32 @config = YAML.load(File.read(File.expand_path(@config_file)))
33 rescue
34 puts <<-EOS
35 ERROR: No rubyforge config file found: #{@config_file}"
36 Run 'rubyforge setup' to prepare your env for access to Rubyforge
37 - See http://newgem.rubyforge.org/rubyforge.html for more details
38 EOS
39 exit
40 end
41 end
42 @rubyforge_username ||= @config["username"]
43 end
44
45 RUBYFORGE_PROJECT = 'rvideo' # The unix name for your project
46 HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
47 DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
48
49 NAME = "rvideo"
50 REV = nil
51 # UNCOMMENT IF REQUIRED:
52 # REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
53 VERS = Rvideo::VERSION::STRING + (REV ? ".#{REV}" : "")
54 CLEAN.include ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store']
55 RDOC_OPTS = ['--quiet', '--title', 'rvideo documentation',
56 "--opname", "index.html",
57 "--line-numbers",
58 "--main", "README",
59 "--inline-source"]
60
61 class Hoe
62 def extra_deps
63 @extra_deps.reject { |x| Array(x).first == 'hoe' }
64 end
65 end
66
67 # Generate all the Rake tasks
68 # Run 'rake -T' to see list of generated tasks (from gem root directory)
69 hoe = Hoe.new(GEM_NAME, VERS) do |p|
70 p.author = AUTHOR
71 p.description = DESCRIPTION
72 p.email = EMAIL
73 p.summary = DESCRIPTION
74 p.url = HOMEPATH
75 p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
76 p.test_globs = ["test/**/test_*.rb"]
77 p.clean_globs |= CLEAN #An array of file patterns to delete on clean.
78
79 # == Optional
80 p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
81 #p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
82 #p.spec_extras = {} # A hash of extra values to set in the gemspec.
83 end
84
85 CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\n\n")
86 PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
87 hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
88
89 desc 'Generate website files'
90 task :website_generate do
91 Dir['website/**/*.txt'].each do |txt|
92 sh %{ ruby scripts/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
93 end
94 end
95
96 desc 'Upload website files to rubyforge'
97 task :website_upload do
98 host = "#{rubyforge_username}@rubyforge.org"
99 remote_dir = "/var/www/gforge-projects/#{PATH}/"
100 local_dir = 'website'
101 sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
102 end
103
104 desc 'Generate and upload website files'
105 task :website => [:website_generate, :website_upload, :publish_docs]
106
107 desc 'Release the website and new gem version'
108 task :deploy => [:check_version, :website, :release] do
109 puts "Remember to create SVN tag:"
110 puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
111 "svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
112 puts "Suggested comment:"
113 puts "Tagging release #{CHANGES}"
114 end
115
116 desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
117 task :local_deploy => [:website_generate, :install_gem]
118
119 task :check_version do
120 unless ENV['VERSION']
121 puts 'Must pass a VERSION=x.y.z release version'
122 exit
123 end
124 unless ENV['VERSION'] == VERS
125 puts "Please update your version.rb to match the release version, currently #{VERS}"
126 exit
127 end
128 end
129
130 #require 'rake'
131 #require 'spec/rake/spectask'
132 require File.dirname(__FILE__) + '/lib/rvideo'
133
134 namespace :spec do
135 desc "Run Unit Specs"
136 Spec::Rake::SpecTask.new("units") do |t|
137 t.spec_files = FileList['spec/units/**/*.rb']
138 end
139
140 desc "Run Integration Specs"
141 Spec::Rake::SpecTask.new("integrations") do |t|
142 t.spec_files = FileList['spec/integrations/**/*.rb']
143 end
144 end
145
146 desc "Process a file"
147 task(:transcode) do
148 RVideo::Transcoder.logger = Logger.new(STDOUT)
149 transcode_single_job(ENV['RECIPE'], ENV['FILE'])
150 end
151
152 desc "Batch transcode files"
153 task(:batch_transcode) do
154 RVideo::Transcoder.logger = Logger.new(File.dirname(__FILE__) + '/test/output.log')
155 f = YAML::load(File.open(File.dirname(__FILE__) + '/test/batch_transcode.yml'))
156 recipes = f['recipes']
157 files = f['files']
158 files.each do |f|
159 file = "#{File.dirname(__FILE__)}/test/files/#{f}"
160 recipes.each do |recipe|
161 transcode_single_job(recipe, file)
162 end
163 end
164 end
165
166 def transcode_single_job(recipe, input_file)
167 puts "Transcoding #{File.basename(input_file)} to #{recipe}"
168 r = YAML::load(File.open(File.dirname(__FILE__) + '/test/recipes.yml'))[recipe]
169 transcoder = RVideo::Transcoder.new(input_file)
170 output_file = "#{TEMP_PATH}/#{File.basename(input_file, ".*")}-#{recipe}.#{r['extension']}"
171 FileUtils.mkdir_p(File.dirname(output_file))
172 begin
173 transcoder.execute(r['command'], {:output_file => output_file}.merge(r))
174 puts "Finished #{File.basename(output_file)} in #{transcoder.total_time}"
175 rescue StandardError => e
176 puts "Error transcoding #{File.basename(output_file)} - #{e.class} (#{e.message}\n#{e.backtrace})"
177 end
178 end
Something went wrong with that request. Please try again.