-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a954d56
commit f5d6506
Showing
18 changed files
with
202 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
chunks_path: /tmp | ||
mixdowns_path: /tmp/mixdowns | ||
public_mixdowns_path: /var/www/balladina/public/mixdowns |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module Balladina | ||
class Configuration | ||
include Singleton | ||
|
||
attr_accessor :mixdowns_path, :public_mixdowns_path, :chunks_path | ||
|
||
def self.load(config_file) | ||
config = self.instance | ||
|
||
YAML.load(open(config_file)).each do |key, value| | ||
config.public_send "#{key}=", value | ||
end | ||
|
||
config | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module Balladina | ||
class Engineer | ||
include Celluloid | ||
include Celluloid::Notifications | ||
include Celluloid::Logger | ||
|
||
def initialize(board, options = {}) | ||
@board = board | ||
@creates_mixdowns = options.fetch(:creates_mixdowns) { Mixdown } | ||
@mixdowns_path = options.fetch(:mixdowns_path) { | ||
Configuration.instance.public_mixdowns_path | ||
} | ||
end | ||
|
||
attr_reader :creates_mixdowns, :board, :mixdowns_path | ||
private :creates_mixdowns, :board, :mixdowns_path | ||
|
||
def mixdown(future_tracks) | ||
tracks_clips = future_tracks.inject({}) { |tcm, t| tcm.merge t.value } | ||
mixdown_path = creates_mixdowns.create_for(board.name, | ||
with_tracks: tracks_clips) | ||
|
||
board.async.mixdown_ready copy_to_public_path(mixdown_path) | ||
end | ||
|
||
def copy_to_public_path(mixdown_path) | ||
public_path = File.join(mixdowns_path, File.basename(mixdown_path)) | ||
FileUtils.cp mixdown_path, public_path | ||
|
||
public_path | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require_relative "../spec_helper" | ||
require "tempfile" | ||
|
||
describe Balladina::Engineer, actor_system: :global do | ||
let(:creates_mixdowns) { double("Mixdown") } | ||
let(:board) { double("board", name: "my-crazy-board") } | ||
let(:temp_path) { File.join(Dir.tmpdir, "balladina-engineer") } | ||
|
||
before do | ||
@engineer = Balladina::Engineer.new(board, creates_mixdowns: creates_mixdowns, | ||
mixdowns_path: temp_path) | ||
FileUtils.mkdir_p temp_path | ||
end | ||
|
||
after do | ||
@engineer.terminate | ||
FileUtils.rm_rf temp_path | ||
end | ||
|
||
describe "coordinating mixdowns" do | ||
let(:track1) { { "track-1" => [:clip] } } | ||
let(:track2) { { "track-2" => [:clip] } } | ||
let(:future_tracks) { [double(value: track1), double(value: track2)] } | ||
|
||
before do | ||
@temp_path = Tempfile.new("a_mixdown") | ||
board.should_receive(:async).and_return board | ||
creates_mixdowns.should_receive(:create_for) | ||
.with("my-crazy-board", with_tracks: track1.merge(track2)) | ||
.and_return @temp_path.path | ||
end | ||
|
||
after do | ||
@temp_path = nil | ||
end | ||
|
||
it "starts a Mixdown and notifies Board when it's finished" do | ||
filename = File.basename(@temp_path.path) | ||
board.should_receive(:mixdown_ready).with File.join(temp_path, filename) | ||
@engineer.mixdown future_tracks | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.