Rename Worker class as Interpreter
This commit is contained in:
		| @@ -10,4 +10,4 @@ require 'producer/core/remote' | ||||
| require 'producer/core/task' | ||||
| require 'producer/core/task/dsl' | ||||
| require 'producer/core/version' | ||||
| require 'producer/core/worker' | ||||
| require 'producer/core/interpreter' | ||||
|   | ||||
| @@ -12,7 +12,7 @@ module Producer | ||||
|  | ||||
|       def run! | ||||
|         check_arguments! | ||||
|         worker.process recipe.tasks | ||||
|         interpreter.process recipe.tasks | ||||
|       end | ||||
|  | ||||
|       def check_arguments! | ||||
| @@ -27,8 +27,8 @@ module Producer | ||||
|         @recipe ||= Recipe.evaluate_from_file(@arguments.first, env) | ||||
|       end | ||||
|  | ||||
|       def worker | ||||
|         @worker ||= Worker.new | ||||
|       def interpreter | ||||
|         @interpreter ||= Interpreter.new | ||||
|       end | ||||
|  | ||||
|       private | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| module Producer | ||||
|   module Core | ||||
|     class Worker | ||||
|     class Interpreter | ||||
|       def process(tasks) | ||||
|         tasks.each { |t| process_task t } | ||||
|       end | ||||
| @@ -27,9 +27,9 @@ module Producer::Core | ||||
|         cli.run! | ||||
|       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] } | ||||
|         expect(cli.worker).to receive(:process).with([:some_task]) | ||||
|         expect(cli.interpreter).to receive(:process).with([:some_task]) | ||||
|         cli.run! | ||||
|       end | ||||
|     end | ||||
| @@ -86,16 +86,16 @@ module Producer::Core | ||||
|       end | ||||
|     end | ||||
|  | ||||
|     describe '#worker' do | ||||
|       it 'builds a worker' do | ||||
|         expect(Worker).to receive(:new) | ||||
|         cli.worker | ||||
|     describe '#interpreter' do | ||||
|       it 'builds a interpreter' do | ||||
|         expect(Interpreter).to receive(:new) | ||||
|         cli.interpreter | ||||
|       end | ||||
|  | ||||
|       it 'returns the worker' do | ||||
|         worker = double('worker') | ||||
|         allow(Worker).to receive(:new) { worker } | ||||
|         expect(cli.worker).to be worker | ||||
|       it 'returns the interpreter' do | ||||
|         interpreter = double('interpreter') | ||||
|         allow(Interpreter).to receive(:new) { interpreter } | ||||
|         expect(cli.interpreter).to be interpreter | ||||
|       end | ||||
|     end | ||||
|   end | ||||
|   | ||||
| @@ -1,13 +1,13 @@ | ||||
| require 'spec_helper' | ||||
| 
 | ||||
| module Producer::Core | ||||
|   describe Worker do | ||||
|     subject(:worker) { Worker.new } | ||||
|   describe Interpreter do | ||||
|     subject(:interpreter) { Interpreter.new } | ||||
| 
 | ||||
|     describe '#process' do | ||||
|       it 'processes each task' do | ||||
|         expect(worker).to receive(:process_task).with(:some_task) | ||||
|         worker.process [:some_task] | ||||
|         expect(interpreter).to receive(:process_task).with(:some_task) | ||||
|         interpreter.process [:some_task] | ||||
|       end | ||||
|     end | ||||
| 
 | ||||
| @@ -17,7 +17,7 @@ module Producer::Core | ||||
|         task = double('task') | ||||
|         allow(task).to receive(:actions) { [action] } | ||||
|         expect(action).to receive(:apply) | ||||
|         worker.process_task(task) | ||||
|         interpreter.process_task(task) | ||||
|       end | ||||
|     end | ||||
|   end | ||||
		Reference in New Issue
	
	Block a user