Class: Provideous::Builder
- Inherits:
-
Object
- Object
- Provideous::Builder
- Defined in:
- lib/provideous.rb
Instance Method Summary collapse
- #cd_to_project ⇒ Object
- #clean_up_old_video ⇒ Object
- #compile_erb_templates ⇒ Object
- #compress_video ⇒ Object
- #copy_files ⇒ Object
- #copy_video ⇒ Object
- #create_poster ⇒ Object
- #create_project(options) ⇒ Object
- #make_dir ⇒ Object
- #open_file ⇒ Object
- #print_usage ⇒ Object
Instance Method Details
#cd_to_project ⇒ Object
34 35 36 |
# File 'lib/provideous.rb', line 34 def cd_to_project FileUtils.cd [:project] end |
#clean_up_old_video ⇒ Object
51 52 53 |
# File 'lib/provideous.rb', line 51 def clean_up_old_video FileUtils.rm [:vid_file] end |
#compile_erb_templates ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/provideous.rb', line 61 def compile_erb_templates title = [:project] video = @web poster = @poster template_file = File.join(File.dirname(File.(__FILE__)), "templates/index.html.erb") template = "" File.open( template_file, 'r') {|f| template = ERB.new(f.read()) } File.open( "index.html", 'w') {|f| f.write(template.result(binding) )} end |
#compress_video ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/provideous.rb', line 38 def compress_video if [:skip] != true puts "Using 'videously' to compress and normalize file" file = [:vid_file] @web = File.basename( file, ".*") @web = "web_#{@web}.mp4" system "videously #{file} #{@web}" clean_up_old_video else @web = [:vid_file] end end |
#copy_files ⇒ Object
71 72 73 74 |
# File 'lib/provideous.rb', line 71 def copy_files assets_dir = File.join(File.dirname(File.(__FILE__)), "assets") FileUtils.cp_r "#{assets_dir}/.", "." end |
#copy_video ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/provideous.rb', line 26 def copy_video vid_file = File.new( [:vid_file] ) if (File.file? vid_file) filename = File.basename [:vid_file] FileUtils.cp [:vid_file], "#{@options[:project]}/#{filename}" end end |
#create_poster ⇒ Object
55 56 57 58 59 |
# File 'lib/provideous.rb', line 55 def create_poster @poster = File.basename( @web, ".*") @poster = "#{@poster}.jpg" `ffmpeg -ss 00:00:01.01 -i #{@web} -y -f image2 -vcodec mjpeg -vframes 1 -loglevel panic #{@poster}` end |
#create_project(options) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/provideous.rb', line 9 def create_project = puts "Creating project #{options[:project]}" make_dir copy_video cd_to_project compress_video create_poster compile_erb_templates copy_files open_file end |
#make_dir ⇒ Object
22 23 24 |
# File 'lib/provideous.rb', line 22 def make_dir FileUtils.mkdir [:project] end |
#open_file ⇒ Object
76 77 78 |
# File 'lib/provideous.rb', line 76 def open_file `open index.html` end |
#print_usage ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/provideous.rb', line 80 def print_usage puts "Usage:" puts "====================================" puts "** Create a new project **" puts "====================================" puts "" puts " provideous project_name vid_file" puts "" puts "" end |