maestro_plugin 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- jruby-1.7.4
1
+ jruby-1.6.8
@@ -3,12 +3,15 @@ require 'logging'
3
3
 
4
4
  module Maestro
5
5
 
6
- module Logging
6
+ unless Maestro.const_defined?('Logging')
7
7
 
8
- def log
9
- ::Logging::Logger.new(STDOUT)
10
- end
8
+ module Logging
9
+
10
+ def log
11
+ ::Logging::Logger.new(STDOUT)
12
+ end
11
13
 
14
+ end
12
15
  end
13
16
 
14
17
  class << self
@@ -202,7 +202,12 @@ module Maestro
202
202
  end
203
203
 
204
204
  def output
205
- workitem[OUTPUT_META]
205
+ if MaestroWorker.mock?
206
+ workitem[OUTPUT_META]
207
+ else
208
+ Maestro.log.warn "Output is only accessible when mock is enabled in tests. Otherwise is directly sent to Maestro"
209
+ nil
210
+ end
206
211
  end
207
212
 
208
213
  def error
@@ -1,5 +1,5 @@
1
1
  module Maestro
2
2
  module Plugin
3
- VERSION = '0.0.15'
3
+ VERSION = '0.0.16'
4
4
  end
5
5
  end
@@ -2,168 +2,149 @@ require 'spec_helper'
2
2
 
3
3
  describe Maestro::MaestroWorker do
4
4
 
5
- describe 'Mock' do
6
-
7
- before :each do
8
- Maestro::MaestroWorker.mock!
9
- end
5
+ let(:workitem) {{'fields' => {}}}
6
+ before { subject.workitem = workitem }
10
7
 
11
- after :each do
12
- Maestro::MaestroWorker.unmock!
13
- end
8
+ describe 'Mock' do
9
+ before { Maestro::MaestroWorker.mock! }
10
+ after { Maestro::MaestroWorker.unmock! }
14
11
 
15
12
  it 'should mock send_workitem_message calls' do
16
- @workitem = {'fields' => {}}
17
-
18
- @worker = Maestro::MaestroWorker.new
19
- @worker.stub(:workitem => @workitem)
20
- @worker.should_not_receive(:ruote_participant)
21
-
22
- @worker.write_output('Some test string')
23
-
13
+ subject.should_not_receive(:ruote_participant)
14
+ subject.write_output('Some test string')
15
+ end
16
+ context 'when accessing output' do
17
+ before { subject.write_output("xxx") }
18
+ its(:output) { should eq("xxx") }
24
19
  end
25
-
26
20
  end
27
21
 
28
22
  describe 'Messaging' do
29
- before :each do
30
- @workitem = {'fields' => {}}
31
- @ruote_participants = double("ruote_participants")
32
- @ruote_participants.should_receive(:send_workitem_message).at_least(:once).with(@workitem)
33
-
34
- @worker = Maestro::MaestroWorker.new
35
- @worker.stub(:ruote_participants => @ruote_participants)
36
- @worker.stub(:workitem => @workitem)
37
- @worker.should_receive(:send_workitem_message).at_least(:once).and_call_original
23
+ let(:ruote_participants) { double("ruote_participants") }
38
24
 
25
+ before :each do
26
+ ruote_participants.should_receive(:send_workitem_message).at_least(:once).with(workitem)
27
+ subject.stub(:ruote_participants => ruote_participants)
28
+ subject.should_receive(:send_workitem_message).at_least(:once).and_call_original
39
29
  end
40
30
 
41
- it 'should send a write_output message' do
42
- @worker.write_output('Some Silly String')
43
- @worker.workitem['__output__'].should eql('Some Silly String')
44
- @worker.workitem['__streaming__'].should be_nil
31
+ context 'when sending a write_output message' do
32
+ before { subject.write_output('Some Silly String') }
33
+ it { subject.workitem['__output__'].should eql('Some Silly String') }
34
+ it { subject.workitem['__streaming__'].should be_nil }
35
+ it("output should not be accesible without mock!") { expect(subject.output).to be_nil }
45
36
  end
46
37
 
47
38
  it 'should aggregate output' do
48
- @worker.write_output('Some Silly String')
49
- @worker.workitem['__output__'].should eql('Some Silly String')
50
- @worker.workitem['__streaming__'].should be_nil
39
+ subject.write_output('Some Silly String')
40
+ subject.workitem['__output__'].should eql('Some Silly String')
41
+ subject.workitem['__streaming__'].should be_nil
51
42
 
52
- @worker.write_output("1", :buffer => true)
53
- @worker.workitem['__output__'].should eql('Some Silly String')
54
- @worker.workitem['__streaming__'].should be_nil
55
- @worker.write_output("22", :buffer => true)
56
- @worker.workitem['__output__'].should eql('Some Silly String')
57
- @worker.workitem['__streaming__'].should be_nil
43
+ subject.write_output("1", :buffer => true)
44
+ subject.workitem['__output__'].should eql('Some Silly String')
45
+ subject.workitem['__streaming__'].should be_nil
46
+ subject.write_output("22", :buffer => true)
47
+ subject.workitem['__output__'].should eql('Some Silly String')
48
+ subject.workitem['__streaming__'].should be_nil
58
49
 
59
50
  # Should auto-send after 2 second delay
60
51
  sleep 3
61
- @worker.write_output("333", :buffer => true)
62
- @worker.workitem['__output__'].should eql('122333')
63
- @worker.workitem['__streaming__'].should be_nil
64
- @worker.write_output("4444", :buffer => true)
65
- @worker.workitem['__output__'].should eql('122333')
66
- @worker.workitem['__streaming__'].should be_nil
52
+ subject.write_output("333", :buffer => true)
53
+ subject.workitem['__output__'].should eql('122333')
54
+ subject.workitem['__streaming__'].should be_nil
55
+ subject.write_output("4444", :buffer => true)
56
+ subject.workitem['__output__'].should eql('122333')
57
+ subject.workitem['__streaming__'].should be_nil
67
58
 
68
59
  # When called without aggregate, should purge
69
- @worker.write_output("5555")
70
- @worker.workitem['__output__'].should eql('44445555')
71
- @worker.workitem['__streaming__'].should be_nil
60
+ subject.write_output("5555")
61
+ subject.workitem['__output__'].should eql('44445555')
62
+ subject.workitem['__streaming__'].should be_nil
72
63
  end
73
64
 
74
65
  it 'should send a not needed message' do
75
- @worker.not_needed
76
- @worker.workitem['__not_needed__'].should be_nil
66
+ subject.not_needed
67
+ subject.workitem['__not_needed__'].should be_nil
77
68
  end
78
69
 
79
70
  it 'should send a cancel message' do
80
- @worker.cancel
81
- @worker.workitem['__cancel__'].should be_nil
71
+ subject.cancel
72
+ subject.workitem['__cancel__'].should be_nil
82
73
  end
83
74
 
84
75
  it 'should send a set_waiting message' do
85
76
  # expects already in before :each block, so putting it here too causes test fail
86
- # @ruote_participants.should_receive(:send_workitem_message).with(@workitem)
87
- @worker.set_waiting(true)
88
- @worker.workitem['__waiting__'].should be_true
77
+ # ruote_participants.should_receive(:send_workitem_message).with(@workitem)
78
+ subject.set_waiting(true)
79
+ subject.workitem['__waiting__'].should be_true
89
80
 
90
- @worker.set_waiting(false)
91
- @worker.workitem['__waiting__'].should be_nil
81
+ subject.set_waiting(false)
82
+ subject.workitem['__waiting__'].should be_nil
92
83
  end
93
84
 
94
85
  it 'should send a create record message' do
95
- @worker.create_record_with_fields('cars', ['manu', 'date', 'name'], ['ferrari', '1964', '250 GTO'])
86
+ subject.create_record_with_fields('cars', ['manu', 'date', 'name'], ['ferrari', '1964', '250 GTO'])
96
87
 
97
- @worker.workitem['__model__'].should eql('cars')
98
- @worker.workitem['__record_fields__'].should eql('manu,date,name')
99
- @worker.workitem['__record_values__'].should eql('ferrari,1964,250 GTO')
88
+ subject.workitem['__model__'].should eql('cars')
89
+ subject.workitem['__record_fields__'].should eql('manu,date,name')
90
+ subject.workitem['__record_values__'].should eql('ferrari,1964,250 GTO')
100
91
  end
101
92
 
102
93
  it 'should send a create record message with a hash' do
103
94
  fields = {'manu' => 'ferrari', 'date' => '1964', 'name' => 'GTO'}
104
- @worker.create_record_with_fields('cars', fields)
105
- @worker.workitem['__model__'].should eql('cars')
106
- @worker.workitem['__record_fields__'].should eql(fields)
95
+ subject.create_record_with_fields('cars', fields)
96
+ subject.workitem['__model__'].should eql('cars')
97
+ subject.workitem['__record_fields__'].should eql(fields)
107
98
  end
108
99
 
109
100
  it 'should send an update record-field message' do
110
- @worker.update_fields_in_record('animal', 'donkey', 'name', 'e-or')
101
+ subject.update_fields_in_record('animal', 'donkey', 'name', 'e-or')
111
102
 
112
- @worker.workitem['__model__'].should eql('animal')
113
- @worker.workitem['__record_id__'].should eql('donkey')
114
- @worker.workitem['__record_field__'].should eql('name')
115
- @worker.workitem['__record_value__'].should eql('e-or')
103
+ subject.workitem['__model__'].should eql('animal')
104
+ subject.workitem['__record_id__'].should eql('donkey')
105
+ subject.workitem['__record_field__'].should eql('name')
106
+ subject.workitem['__record_value__'].should eql('e-or')
116
107
  end
117
108
 
118
109
  it 'should send a delete record message' do
119
- @worker.delete_record('animal', 1)
120
- @worker.workitem['__model__'].should eql('animal')
121
- @worker.workitem['__name__'].should eql('1')
122
- @worker.workitem['__filter__'].should be_nil
110
+ subject.delete_record('animal', 1)
111
+ subject.workitem['__model__'].should eql('animal')
112
+ subject.workitem['__name__'].should eql('1')
113
+ subject.workitem['__filter__'].should be_nil
123
114
  end
124
115
 
125
116
  it 'should send a delete record message with a filter' do
126
117
  filter = {'type' => 1}
127
- @worker.delete_record('animal', filter)
128
- @worker.workitem['__model__'].should eql('animal')
129
- @worker.workitem['__filter__'].should eql(filter)
130
- @worker.workitem['__name__'].should be_nil
118
+ subject.delete_record('animal', filter)
119
+ subject.workitem['__model__'].should eql('animal')
120
+ subject.workitem['__filter__'].should eql(filter)
121
+ subject.workitem['__name__'].should be_nil
131
122
  end
132
123
  end
133
124
 
134
125
  describe 'Field handling' do
135
- before :each do
136
- @worker = Maestro::MaestroWorker.new
137
- @worker.workitem = {'fields' => {}}
138
- end
126
+ let(:workitem) {{'fields' => {'a' => 'a'}}}
139
127
 
140
128
  it 'should set and get errors' do
141
- @worker.workitem['__error__'].should be_nil
142
- @worker.error?.should be_false
143
- @worker.set_error 'myerror'
144
- @worker.error?.should be_true
145
- @worker.workitem['fields']['__error__'].should eq('myerror')
129
+ subject.workitem['__error__'].should be_nil
130
+ subject.error?.should be_false
131
+ subject.set_error 'myerror'
132
+ subject.error?.should be_true
133
+ subject.workitem['fields']['__error__'].should eq('myerror')
146
134
  end
147
135
 
148
136
  it 'should set fields' do
149
- @worker.workitem = {'fields' => {'a' => 'a'}}
150
- @worker.fields['a'].should eq('a')
151
- @worker.fields['b'] = 'b'
152
- @worker.fields['b'].should eq('b')
137
+ subject.fields['a'].should eq('a')
138
+ subject.fields['b'] = 'b'
139
+ subject.fields['b'].should eq('b')
153
140
  end
154
141
  end
155
142
 
156
143
  describe 'Helpers' do
157
- before :each do
158
- @worker = Maestro::MaestroWorker.new
159
- @worker.workitem = {'fields' => {}}
160
- end
161
-
162
144
  it 'should validate JSON data contained in strings' do
163
- @worker.is_json?('{"key": "a string"}').should be_true
164
- @worker.is_json?('a string').should be_false
145
+ subject.is_json?('{"key": "a string"}').should be_true
146
+ subject.is_json?('a string').should be_false
165
147
  end
166
-
167
148
  end
168
149
 
169
150
  describe 'Errors' do
@@ -181,30 +162,22 @@ describe Maestro::MaestroWorker do
181
162
  end
182
163
  end
183
164
 
184
- before :each do
185
- @worker = ErrorTestWorker.new
186
- end
165
+ subject { ErrorTestWorker.new }
187
166
 
188
167
  it 'should handle a ConfigError for bad config' do
189
- workitem = {'fields' => {}}
190
-
191
- @worker.perform(:configerror_test, workitem)
168
+ subject.perform(:configerror_test, workitem)
192
169
  workitem['fields']['__error__'].should include('Bad Config')
193
170
  workitem['__output__'].should be_nil
194
171
  end
195
172
 
196
173
  it 'should handle a PluginError' do
197
- workitem = {'fields' => {}}
198
-
199
- @worker.perform(:pluginerror_test, workitem)
174
+ subject.perform(:pluginerror_test, workitem)
200
175
  workitem['fields']['__error__'].should include('PluginError - I had a problem')
201
176
  workitem['__output__'].should be_nil
202
177
  end
203
178
 
204
179
  it 'should handle an unexpected Error' do
205
- workitem = {'fields' => {}}
206
-
207
- @worker.perform(:error_test, workitem)
180
+ subject.perform(:error_test, workitem)
208
181
  workitem['fields']['__error__'].should include('Unexpected error executing task: Exception noooo')
209
182
  workitem['__output__'].should be_nil
210
183
  end
metadata CHANGED
@@ -1,157 +1,144 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: maestro_plugin
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.15
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.16
5
6
  platform: ruby
6
- authors:
7
- - Etienne Pelletier
8
- autorequire:
7
+ authors:
8
+ - Etienne Pelletier
9
+ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-08-06 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: logging
15
- version_requirements: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '='
18
- - !ruby/object:Gem::Version
19
- version: 1.8.0
20
- requirement: !ruby/object:Gem::Requirement
21
- requirements:
22
- - - '='
23
- - !ruby/object:Gem::Version
24
- version: 1.8.0
25
- prerelease: false
26
- type: :runtime
27
- - !ruby/object:Gem::Dependency
28
- name: rubyzip
29
- version_requirements: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - '='
32
- - !ruby/object:Gem::Version
33
- version: 0.9.8
34
- requirement: !ruby/object:Gem::Requirement
35
- requirements:
36
- - - '='
37
- - !ruby/object:Gem::Version
38
- version: 0.9.8
39
- prerelease: false
40
- type: :runtime
41
- - !ruby/object:Gem::Dependency
42
- name: json
43
- version_requirements: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - '>='
46
- - !ruby/object:Gem::Version
47
- version: 1.4.6
48
- requirement: !ruby/object:Gem::Requirement
49
- requirements:
50
- - - '>='
51
- - !ruby/object:Gem::Version
52
- version: 1.4.6
53
- prerelease: false
54
- type: :runtime
55
- - !ruby/object:Gem::Dependency
56
- name: bundler
57
- version_requirements: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- version: '1.3'
62
- requirement: !ruby/object:Gem::Requirement
63
- requirements:
64
- - - ~>
65
- - !ruby/object:Gem::Version
66
- version: '1.3'
67
- prerelease: false
68
- type: :development
69
- - !ruby/object:Gem::Dependency
70
- name: rake
71
- version_requirements: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - '>='
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- requirement: !ruby/object:Gem::Requirement
77
- requirements:
78
- - - '>='
79
- - !ruby/object:Gem::Version
80
- version: '0'
81
- prerelease: false
82
- type: :development
83
- - !ruby/object:Gem::Dependency
84
- name: jruby-openssl
85
- version_requirements: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - '>='
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- requirement: !ruby/object:Gem::Requirement
91
- requirements:
92
- - - '>='
93
- - !ruby/object:Gem::Version
94
- version: '0'
95
- prerelease: false
96
- type: :development
97
- - !ruby/object:Gem::Dependency
98
- name: rspec
99
- version_requirements: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ~>
102
- - !ruby/object:Gem::Version
103
- version: 2.13.0
104
- requirement: !ruby/object:Gem::Requirement
105
- requirements:
106
- - - ~>
107
- - !ruby/object:Gem::Version
108
- version: 2.13.0
109
- prerelease: false
110
- type: :development
12
+
13
+ date: 2013-08-11 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: logging
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - "="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.8.0
24
+ type: :runtime
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: rubyzip
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - "="
33
+ - !ruby/object:Gem::Version
34
+ version: 0.9.8
35
+ type: :runtime
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: json
39
+ prerelease: false
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 1.4.6
46
+ type: :runtime
47
+ version_requirements: *id003
48
+ - !ruby/object:Gem::Dependency
49
+ name: bundler
50
+ prerelease: false
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ~>
55
+ - !ruby/object:Gem::Version
56
+ version: "1.3"
57
+ type: :development
58
+ version_requirements: *id004
59
+ - !ruby/object:Gem::Dependency
60
+ name: rake
61
+ prerelease: false
62
+ requirement: &id005 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: "0"
68
+ type: :development
69
+ version_requirements: *id005
70
+ - !ruby/object:Gem::Dependency
71
+ name: jruby-openssl
72
+ prerelease: false
73
+ requirement: &id006 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ type: :development
80
+ version_requirements: *id006
81
+ - !ruby/object:Gem::Dependency
82
+ name: rspec
83
+ prerelease: false
84
+ requirement: &id007 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 2.13.0
90
+ type: :development
91
+ version_requirements: *id007
111
92
  description: A ruby library to help with the creation of Maestro plugins
112
- email:
113
- - epelletier@maestrodev.com
93
+ email:
94
+ - epelletier@maestrodev.com
114
95
  executables: []
96
+
115
97
  extensions: []
98
+
116
99
  extra_rdoc_files: []
117
- files:
118
- - .gitignore
119
- - .ruby-version
120
- - Gemfile
121
- - LICENSE.txt
122
- - README.md
123
- - Rakefile
124
- - lib/maestro_plugin.rb
125
- - lib/maestro_plugin/logging.rb
126
- - lib/maestro_plugin/maestro_worker.rb
127
- - lib/maestro_plugin/version.rb
128
- - maestro_plugin.gemspec
129
- - spec/maestro_worker_spec.rb
130
- - spec/spec_helper.rb
100
+
101
+ files:
102
+ - .gitignore
103
+ - .ruby-version
104
+ - Gemfile
105
+ - LICENSE.txt
106
+ - README.md
107
+ - Rakefile
108
+ - lib/maestro_plugin.rb
109
+ - lib/maestro_plugin/logging.rb
110
+ - lib/maestro_plugin/maestro_worker.rb
111
+ - lib/maestro_plugin/version.rb
112
+ - maestro_plugin.gemspec
113
+ - spec/maestro_worker_spec.rb
114
+ - spec/spec_helper.rb
131
115
  homepage: https://github.com/maestrodev/maestro-ruby-plugin
132
- licenses:
133
- - Apache 2.0
134
- metadata: {}
135
- post_install_message:
116
+ licenses:
117
+ - Apache 2.0
118
+ post_install_message:
136
119
  rdoc_options: []
137
- require_paths:
138
- - lib
139
- required_ruby_version: !ruby/object:Gem::Requirement
140
- requirements:
141
- - - '>='
142
- - !ruby/object:Gem::Version
143
- version: '0'
144
- required_rubygems_version: !ruby/object:Gem::Requirement
145
- requirements:
146
- - - '>='
147
- - !ruby/object:Gem::Version
148
- version: '0'
120
+
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ none: false
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: "0"
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: "0"
149
135
  requirements: []
150
- rubyforge_project:
151
- rubygems_version: 2.0.3
152
- signing_key:
153
- specification_version: 4
136
+
137
+ rubyforge_project:
138
+ rubygems_version: 1.8.24
139
+ signing_key:
140
+ specification_version: 3
154
141
  summary: Maestro ruby plugin
155
- test_files:
156
- - spec/maestro_worker_spec.rb
157
- - spec/spec_helper.rb
142
+ test_files:
143
+ - spec/maestro_worker_spec.rb
144
+ - spec/spec_helper.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: e11866b367ab7fa42da98d6b51d1ecd4c23f988e
4
- data.tar.gz: a4ad35e37e462e1659ae1e1fa72852af5ababe28
5
- SHA512:
6
- metadata.gz: b40fdcdec594bb9d6b56445322788dff8eb697b512cc1b2372bfe030eb242b3ca16424692099534f857b070e712a960e58a1e54400e9fd832e5606c397c6b7bc
7
- data.tar.gz: e9adec57b9053b60c76badc0b6aa1a240d28188a0cedaa8f0addf48cdcdcd8f6dce7aef67eda8ca80657a72915506e2107bcd89566be43130c266a24d3c9a4f8