Class: HBQueue

Inherits:
YAMLConfig show all
Defined in:
lib/hb-runner/hb_queue.rb

Overview

This class processes a yaml file queue of items with handbrake, using the given HBConfig configuration

Instance Attribute Summary collapse

Attributes inherited from YAMLConfig

#file

Instance Method Summary collapse

Methods inherited from YAMLConfig

#filename, #initialize, #to_s

Constructor Details

This class inherits a constructor from YAMLConfig

Instance Attribute Details

#queueObject

Returns the value of attribute queue.



5
6
7
# File 'lib/hb-runner/hb_queue.rb', line 5

def queue
  @queue
end

Instance Method Details

#executableObject



7
8
9
# File 'lib/hb-runner/hb_queue.rb', line 7

def executable
  'HandBrakeCLI'
end

#readObject



11
12
13
14
# File 'lib/hb-runner/hb_queue.rb', line 11

def read
  @queue ||= open(filename) { |f| YAML.load f }
  puts "#{queue.size} item(s) in the queue."
end

#runObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/hb-runner/hb_queue.rb', line 16

def run
  queue.each do |q|
    markers = q.delete 'markers'

    q['input']  = File.expand_path q['input']  if q['input']
    q['output'] = File.expand_path q['output'] if q['output']

    item_options = q.map { |k,v| "--#{k} #{v.inspect}" }.join(' ').gsub('true', '')

    if markers and markers == true
      item_options += ' --markers'
    elsif markers
      item_options += " --markers=#{ markers }"
    end

    execute "#{ executable } #{ item_options } #{ @options }"
  end
end