Class: VideoTranscoding::Tool

Inherits:
Object
  • Object
show all
Defined in:
lib/video_transcoding/tool.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#propertiesObject (readonly)

Returns the value of attribute properties.



9
10
11
# File 'lib/video_transcoding/tool.rb', line 9

def properties
  @properties
end

Class Method Details

.properties(command_name) ⇒ Object



22
23
24
25
26
# File 'lib/video_transcoding/tool.rb', line 22

def self.properties(command_name)
  fail "#{command_name} not provided" unless @@tools.has_key? command_name
  @@tools[command_name].prepare
  @@tools[command_name].properties
end

.provide(command_name, test_args, &test_block) ⇒ Object



11
12
13
14
# File 'lib/video_transcoding/tool.rb', line 11

def self.provide(command_name, test_args, &test_block)
  fail "#{command_name} already provided" if @@tools.has_key? command_name
  @@tools[command_name] = Tool.new(command_name, test_args, &test_block)
end

.use(command_name) ⇒ Object



16
17
18
19
20
# File 'lib/video_transcoding/tool.rb', line 16

def self.use(command_name)
  fail "#{command_name} not provided" unless @@tools.has_key? command_name
  @@tools[command_name].prepare
  command_name
end

Instance Method Details

#prepareObject



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/video_transcoding/tool.rb', line 28

def prepare
  return if @ready
  output = ''

  begin
    IO.popen([@command_name] + @test_args, :err=>[:child, :out]) { |io| output = io.read }
  rescue Errno::ENOENT
    raise "#{@command_name} not available"
  end

  @test_block.call output, $CHILD_STATUS.exitstatus, @properties
  @ready = true
end