exel 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 85ab889713fbe1368ad2e1e3186f16fb1fe39ac5
4
- data.tar.gz: ed633de60e0cdbf125bfe5a1cfd21d110341c43e
3
+ metadata.gz: 1c9430975944c61a336b74ec445fc85836c64827
4
+ data.tar.gz: c0189c97975d51869f45300c7a08d50a6f41c0f3
5
5
  SHA512:
6
- metadata.gz: 3e739773310941eac8d09ac6793bb5d9b296c1cb22b7015f1c467ed4c14cbe12a3d92ca30cdb7fc39d7e676a12af30f2502bdd3a1dc395c2cce67673abbaed20
7
- data.tar.gz: 316c744a8f814dec1191bbfd7964a28bb7c2628ae7bb2726ce0884a4d8392b71338364aa14be51a7c6524a9489cd7c1089a29e86801544dfa08e65576f6d8986
6
+ metadata.gz: 5391eead9f34042b4e4e4fb22c5d19871b69a51371691ccea5d869a664d0a2d6f2dca408cb787eb0b1342b21a97250079e4551cd4bca8579b63012f8a39d3ae2
7
+ data.tar.gz: 46d654603de7860071251878716647dfcce4199ab858cb6d852156dc79f3258d4486e5202e52b543af53141d8dfda7e4e64e553ca9636a8648c7b60c2797ae96
data/.rubocop_todo.yml CHANGED
@@ -16,7 +16,6 @@ RSpec/ExampleWording:
16
16
  - 'spec/exel/handlers/s3_handler_spec.rb'
17
17
  - 'spec/exel/instruction_node_spec.rb'
18
18
  - 'spec/exel/instruction_spec.rb'
19
- - 'spec/exel/job_spec.rb'
20
19
  - 'spec/exel/logging_spec.rb'
21
20
  - 'spec/exel/processors/split_processor_spec.rb'
22
21
  - 'spec/exel/resource_spec.rb'
data/lib/exel/job.rb CHANGED
@@ -57,6 +57,10 @@ module EXEL
57
57
  add_instruction_node('split', Processors::SplitProcessor, block, options)
58
58
  end
59
59
 
60
+ def run(options = {}, &block)
61
+ add_instruction_node('run', Processors::RunProcessor, block, options)
62
+ end
63
+
60
64
  def context
61
65
  DeferredContextValue.new
62
66
  end
@@ -0,0 +1,19 @@
1
+ require_relative '../processor_helper'
2
+
3
+ module EXEL
4
+ module Processors
5
+ class RunProcessor
6
+ include EXEL::ProcessorHelper
7
+
8
+ def initialize(context)
9
+ @context = context
10
+ end
11
+
12
+ def process(_block = nil)
13
+ log_process "running job #{@context[:job]}" do
14
+ EXEL::Job.run(@context[:job], @context)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
data/lib/exel/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module EXEL
2
- VERSION = '1.0.1'
2
+ VERSION = '1.1.0'
3
3
  end
@@ -6,12 +6,12 @@ module EXEL
6
6
 
7
7
  after { Job.registry.clear }
8
8
 
9
- it 'should register job definitions' do
9
+ it 'registers job definitions' do
10
10
  Job.define :test_job, &block
11
11
  expect(Job.registry[:test_job]).to eq(block)
12
12
  end
13
13
 
14
- it 'should raise an exception if a job name is already in use' do
14
+ it 'raises an exception if a job name is already in use' do
15
15
  Job.define :test_job, &block
16
16
  expect { Job.define :test_job, &block }.to raise_error 'Job :test_job is already defined'
17
17
  end
@@ -22,13 +22,13 @@ module EXEL
22
22
  let(:context) { instance_double(Context) }
23
23
 
24
24
  context 'with a string of DSL code' do
25
- it 'should parse the code' do
25
+ it 'parses the code' do
26
26
  dsl_code = 'code'
27
27
  expect(Job::Parser).to receive(:parse).with(dsl_code).and_return(ast)
28
28
  Job.run(dsl_code, context)
29
29
  end
30
30
 
31
- it 'should run ast returned by the parser' do
31
+ it 'runs the AST returned by the parser' do
32
32
  allow(Job::Parser).to receive(:parse).and_return(ast)
33
33
  expect(ast).to receive(:start).with(context)
34
34
  Job.run('code', context)
@@ -43,7 +43,7 @@ module EXEL
43
43
  allow(Job).to receive(:registry).and_return(test_job: block)
44
44
  end
45
45
 
46
- it 'should run the job' do
46
+ it 'runs the job' do
47
47
  expect(Job::Parser).to receive(:parse).with(block).and_return(ast)
48
48
  expect(ast).to receive(:start).with(context)
49
49
  Job.run(:test_job, context)
@@ -51,7 +51,7 @@ module EXEL
51
51
  end
52
52
 
53
53
  context 'of a undefined job' do
54
- it 'should return nil' do
54
+ it 'returns nil' do
55
55
  expect { Job.run(:test_job, context) }.to raise_error('Job "test_job" not found')
56
56
  end
57
57
  end
@@ -64,11 +64,11 @@ module EXEL
64
64
  context[:array] << context[:arg]
65
65
  end
66
66
 
67
- def process(callback)
67
+ def process(_callback)
68
68
  end
69
69
  end
70
70
 
71
- it 'should not persist between runs' do
71
+ it 'does not persist between runs' do
72
72
  Job.define :test do
73
73
  process with: TestProcessor, array: [], arg: context[:value]
74
74
  end
@@ -89,7 +89,7 @@ module EXEL
89
89
  let(:ast) { instance_double(SequenceNode, run: nil) }
90
90
 
91
91
  describe '#initialize' do
92
- it 'should initialize a sequence node' do
92
+ it 'initializes a sequence node' do
93
93
  expect(parser.ast).to be_kind_of(SequenceNode)
94
94
  end
95
95
  end
@@ -102,7 +102,7 @@ module EXEL
102
102
  end
103
103
 
104
104
  context 'given DSL code as a proc' do
105
- it 'should eval the code as a block' do
105
+ it 'evals the code as a block' do
106
106
  dsl_proc = proc {}
107
107
  expect(parser).to receive(:instance_eval) do |*_args, &block|
108
108
  expect(block).to eq(dsl_proc)
@@ -113,7 +113,7 @@ module EXEL
113
113
  end
114
114
 
115
115
  context 'given DSL code as a string' do
116
- it 'should eval the code as a string' do
116
+ it 'evals the code as a string' do
117
117
  dsl_code = 'code'
118
118
  expect(parser).to receive(:instance_eval).with(dsl_code)
119
119
 
@@ -121,7 +121,7 @@ module EXEL
121
121
  end
122
122
  end
123
123
 
124
- it 'should return the parsed AST' do
124
+ it 'returns the parsed AST' do
125
125
  expect(Job::Parser.parse(proc {})).to eq(ast)
126
126
  end
127
127
  end
@@ -134,14 +134,14 @@ module EXEL
134
134
  end
135
135
 
136
136
  context 'without a block' do
137
- it 'should create a process instruction' do
137
+ it 'creates a process instruction' do
138
138
  processor_class = double(:processor_class)
139
139
  expect(Instruction).to receive(:new).with('process', processor_class, {arg1: 'arg1_value'}, nil)
140
140
 
141
141
  parser.process with: processor_class, arg1: 'arg1_value'
142
142
  end
143
143
 
144
- it 'should append an instruction node to the AST with no children' do
144
+ it 'appends an instruction node to the AST with no children' do
145
145
  expect(parser.ast).to receive(:add_child) do |node|
146
146
  expect(node).to be_a_kind_of(InstructionNode)
147
147
  expect(node.instruction.name).to eq('process')
@@ -153,7 +153,7 @@ module EXEL
153
153
  end
154
154
 
155
155
  context 'with a block' do
156
- it 'should pass the parsed subtree to the instruction' do
156
+ it 'passes the parsed subtree to the instruction' do
157
157
  processor_class = double(:processor_class)
158
158
  expect(Job::Parser).to receive(:parse).with(block).and_return(ast)
159
159
  expect(Instruction).to receive(:new).with('process', processor_class, {arg1: 'arg1_value'}, ast)
@@ -161,7 +161,7 @@ module EXEL
161
161
  parser.process with: processor_class, arg1: 'arg1_value', &block
162
162
  end
163
163
 
164
- it 'should append an instruction node to the AST with the parsed block as its subtree' do
164
+ it 'appends an instruction node to the AST with the parsed block as its subtree' do
165
165
  expect(parser.ast).to receive(:add_child) do |node|
166
166
  expect(node).to be_a_kind_of(InstructionNode)
167
167
  expect(node.instruction.name).to eq('process')
@@ -175,26 +175,27 @@ module EXEL
175
175
 
176
176
  [
177
177
  {method: :async, processor: Processors::AsyncProcessor},
178
- {method: :split, processor: Processors::SplitProcessor}
178
+ {method: :split, processor: Processors::SplitProcessor},
179
+ {method: :run, processor: Processors::RunProcessor}
179
180
  ].each do |data|
180
181
  describe "##{data[:method]}" do
181
182
  before do
182
183
  allow(Job::Parser).to receive(:parse).and_return(ast)
183
184
  end
184
185
 
185
- it "should create a #{data[:method]} instruction" do
186
+ it "creates a #{data[:method]} instruction" do
186
187
  expect(Instruction).to receive(:new).with(data[:method].to_s, data[:processor], {arg1: 'arg1_value'}, ast)
187
188
  parser.send(data[:method], arg1: 'arg1_value') {}
188
189
  end
189
190
 
190
- it 'should parse the block given' do
191
+ it 'parses the block given' do
191
192
  block = -> {}
192
193
  expect(Job::Parser).to receive(:parse).with(block).and_return(ast)
193
194
 
194
195
  parser.send(data[:method], &block)
195
196
  end
196
197
 
197
- it 'should add parsed subtree and instruction to the AST' do
198
+ it 'adds parsed subtree and instruction to the AST' do
198
199
  expect(parser.ast).to receive(:add_child) do |node|
199
200
  expect(node).to be_a_kind_of(InstructionNode)
200
201
  expect(node.instruction.name).to eq(data[:method].to_s)
@@ -207,7 +208,7 @@ module EXEL
207
208
  end
208
209
 
209
210
  describe '#context' do
210
- it 'should return a DeferredContextValue' do
211
+ it 'returns a DeferredContextValue' do
211
212
  expect(parser.context).to be_a_kind_of(DeferredContextValue)
212
213
  end
213
214
  end
@@ -0,0 +1,15 @@
1
+ module EXEL
2
+ module Processors
3
+ describe RunProcessor do
4
+ subject { RunProcessor.new(context) }
5
+ let(:context) { EXEL::Context.new(job: :test_job) }
6
+
7
+ describe '#process' do
8
+ it 'runs the job named in context[:job] with the current context' do
9
+ expect(EXEL::Job).to receive(:run).with(:test_job, context)
10
+ subject.process
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - yroo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-08 00:00:00.000000000 Z
11
+ date: 2016-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -194,6 +194,7 @@ files:
194
194
  - lib/exel/null_instruction.rb
195
195
  - lib/exel/processor_helper.rb
196
196
  - lib/exel/processors/async_processor.rb
197
+ - lib/exel/processors/run_processor.rb
197
198
  - lib/exel/processors/split_processor.rb
198
199
  - lib/exel/providers/local_file_provider.rb
199
200
  - lib/exel/providers/threaded_async_provider.rb
@@ -209,6 +210,7 @@ files:
209
210
  - spec/exel/logging_spec.rb
210
211
  - spec/exel/null_instruction_spec.rb
211
212
  - spec/exel/processors/async_processor_spec.rb
213
+ - spec/exel/processors/run_processor_spec.rb
212
214
  - spec/exel/processors/split_processor_spec.rb
213
215
  - spec/exel/providers/local_file_provider_spec.rb
214
216
  - spec/exel/providers/threaded_async_provider_spec.rb
@@ -250,6 +252,7 @@ test_files:
250
252
  - spec/exel/logging_spec.rb
251
253
  - spec/exel/null_instruction_spec.rb
252
254
  - spec/exel/processors/async_processor_spec.rb
255
+ - spec/exel/processors/run_processor_spec.rb
253
256
  - spec/exel/processors/split_processor_spec.rb
254
257
  - spec/exel/providers/local_file_provider_spec.rb
255
258
  - spec/exel/providers/threaded_async_provider_spec.rb