Class: ActiveEncode::EngineAdapters::MatterhornAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/active_encode/engine_adapters/matterhorn_adapter.rb

Constant Summary collapse

DEFAULT_ARGS =
{ 'flavor' => 'presenter/source' }.freeze

Instance Method Summary collapse

Instance Method Details

#cancel(encode) ⇒ Object


26
27
28
29
# File 'lib/active_encode/engine_adapters/matterhorn_adapter.rb', line 26

def cancel(encode)
  workflow_om = Rubyhorn.client.stop(encode.id)
  build_encode(get_workflow(workflow_om), encode.class)
end

#create(encode) ⇒ Object


8
9
10
11
12
13
14
15
16
# File 'lib/active_encode/engine_adapters/matterhorn_adapter.rb', line 8

def create(encode)
  workflow_id = encode.options[:preset] || "full"
  workflow_om = if encode.input.is_a? Hash
                  create_multiple_files(encode.input, workflow_id)
                else
                  Rubyhorn.client.addMediaPackageWithUrl(DEFAULT_ARGS.merge('workflow' => workflow_id, 'url' => encode.input, 'filename' => File.basename(encode.input), 'title' => File.basename(encode.input)))
                end
  build_encode(get_workflow(workflow_om), encode.class)
end

#find(id, opts = {}) ⇒ Object


18
19
20
# File 'lib/active_encode/engine_adapters/matterhorn_adapter.rb', line 18

def find(id, opts = {})
  build_encode(fetch_workflow(id), opts[:cast])
end

#list(*_filters) ⇒ Object

Raises:

  • (NotImplementedError)

22
23
24
# File 'lib/active_encode/engine_adapters/matterhorn_adapter.rb', line 22

def list(*_filters)
  raise NotImplementedError # TODO: implement this
end

#purge(encode) ⇒ Object


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/active_encode/engine_adapters/matterhorn_adapter.rb', line 31

def purge(encode)
  workflow_om = begin
                  Rubyhorn.client.stop(encode.id)
                rescue
                  nil
                end
  workflow_om ||= begin
                    Rubyhorn.client.get_stopped_workflow(encode.id)
                  rescue
                    nil
                  end
  purged_workflow = purge_outputs(get_workflow(workflow_om))
  # Rubyhorn.client.delete_instance(encode.id) #Delete is not working so workflow instances can always be retrieved later!
  build_encode(purged_workflow, encode.class)
end

#remove_output(encode, output_id) ⇒ Object


47
48
49
50
51
52
53
# File 'lib/active_encode/engine_adapters/matterhorn_adapter.rb', line 47

def remove_output(encode, output_id)
  workflow = fetch_workflow(encode.id)
  output = encode.output.find { |o| o[:id] == output_id }
  return if output.nil?
  purge_output(workflow, output_id)
  output
end