Rename Worker class as Interpreter

This commit is contained in:
Thibault Jouan 2013-08-16 19:30:51 +00:00
parent 5a4c8c02bc
commit e4a4211a7b
5 changed files with 20 additions and 20 deletions

View File

@ -10,4 +10,4 @@ require 'producer/core/remote'
require 'producer/core/task' require 'producer/core/task'
require 'producer/core/task/dsl' require 'producer/core/task/dsl'
require 'producer/core/version' require 'producer/core/version'
require 'producer/core/worker' require 'producer/core/interpreter'

View File

@ -12,7 +12,7 @@ module Producer
def run! def run!
check_arguments! check_arguments!
worker.process recipe.tasks interpreter.process recipe.tasks
end end
def check_arguments! def check_arguments!
@ -27,8 +27,8 @@ module Producer
@recipe ||= Recipe.evaluate_from_file(@arguments.first, env) @recipe ||= Recipe.evaluate_from_file(@arguments.first, env)
end end
def worker def interpreter
@worker ||= Worker.new @interpreter ||= Interpreter.new
end end
private private

View File

@ -1,6 +1,6 @@
module Producer module Producer
module Core module Core
class Worker class Interpreter
def process(tasks) def process(tasks)
tasks.each { |t| process_task t } tasks.each { |t| process_task t }
end end

View File

@ -27,9 +27,9 @@ module Producer::Core
cli.run! cli.run!
end end
it 'processes the tasks with the worker' do it 'processes the tasks with the interpreter' do
allow(cli.recipe).to receive(:tasks) { [:some_task] } allow(cli.recipe).to receive(:tasks) { [:some_task] }
expect(cli.worker).to receive(:process).with([:some_task]) expect(cli.interpreter).to receive(:process).with([:some_task])
cli.run! cli.run!
end end
end end
@ -86,16 +86,16 @@ module Producer::Core
end end
end end
describe '#worker' do describe '#interpreter' do
it 'builds a worker' do it 'builds a interpreter' do
expect(Worker).to receive(:new) expect(Interpreter).to receive(:new)
cli.worker cli.interpreter
end end
it 'returns the worker' do it 'returns the interpreter' do
worker = double('worker') interpreter = double('interpreter')
allow(Worker).to receive(:new) { worker } allow(Interpreter).to receive(:new) { interpreter }
expect(cli.worker).to be worker expect(cli.interpreter).to be interpreter
end end
end end
end end

View File

@ -1,13 +1,13 @@
require 'spec_helper' require 'spec_helper'
module Producer::Core module Producer::Core
describe Worker do describe Interpreter do
subject(:worker) { Worker.new } subject(:interpreter) { Interpreter.new }
describe '#process' do describe '#process' do
it 'processes each task' do it 'processes each task' do
expect(worker).to receive(:process_task).with(:some_task) expect(interpreter).to receive(:process_task).with(:some_task)
worker.process [:some_task] interpreter.process [:some_task]
end end
end end
@ -17,7 +17,7 @@ module Producer::Core
task = double('task') task = double('task')
allow(task).to receive(:actions) { [action] } allow(task).to receive(:actions) { [action] }
expect(action).to receive(:apply) expect(action).to receive(:apply)
worker.process_task(task) interpreter.process_task(task)
end end
end end
end end