bumbleworks 0.0.77 → 0.0.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 254297411d25a5989d7d68c88ed379d00c9681e0
4
- data.tar.gz: 66da97a771e31fd0331a57700ef6e6f7a355cb5a
3
+ metadata.gz: 93db3b577ea6a3ae073459e9fd407d9aeb217c40
4
+ data.tar.gz: 20fae058c24f92274ebe9ba5d1929e9ac972960c
5
5
  SHA512:
6
- metadata.gz: 24bdafeabc61fc526a082431d7bb270df5de0cbadee269e3893013eac6153361b66cfe1bb4c76f1399815c7437392df704c4c5d20e048ba1a0358a6e50ec3dd8
7
- data.tar.gz: c4dd85254421cfb102ac276882afd8a8dfd100e9240452f6b3f85458f85c991c5a7c99c787ca4c3afec75944d45f96377ddaf6a9abeceb4adea4632fb0d45b30
6
+ metadata.gz: 90190f2f09fdd353d63dcd4fc9d5bf7b2a78df2952993b791dbdddf940b933f74494dec8c7ed69229bb5e9902b2cb98b7831eb2771687edf3fc4e8cc12e3009a
7
+ data.tar.gz: 5ad45cb7eb9e3d7574deb08f17f0662b7a777e9de5f366f142056db0eb22dc04f120e135f242001e8bd3ff3a3a8262455a4bd1114984f850d6ba162748a36331
@@ -46,14 +46,19 @@ module Bumbleworks
46
46
  processes_by_name.values.compact
47
47
  end
48
48
 
49
+ def cancel_process!(process_name, options = {})
50
+ process = processes_by_name[process_name.to_sym]
51
+ return nil unless process
52
+ process.cancel!
53
+ unless options[:clear_identifiers] == false
54
+ identifier_attribute = attribute_for_process_name(process_name.to_sym)
55
+ persist_process_identifier(identifier_attribute, nil)
56
+ end
57
+ end
58
+
49
59
  def cancel_all_processes!(options = {})
50
- processes_by_name.each do |name, process|
51
- next unless process
52
- process.cancel!
53
- unless options[:clear_identifiers] == false
54
- identifier_attribute = attribute_for_process_name(name)
55
- persist_process_identifier(identifier_attribute, nil)
56
- end
60
+ processes_by_name.keys.each do |process_name|
61
+ cancel_process!(process_name, options)
57
62
  end
58
63
  end
59
64
 
@@ -1,3 +1,3 @@
1
1
  module Bumbleworks
2
- VERSION = "0.0.77"
2
+ VERSION = "0.0.78"
3
3
  end
@@ -60,19 +60,25 @@ describe Bumbleworks::Entity do
60
60
  end
61
61
  end
62
62
 
63
- describe '#cancel_all_processes!' do
64
- it 'cancels all processes with registered identifiers' do
63
+ describe '#cancel_processes!' do
64
+ it 'cancels process with given name' do
65
65
  entity = entity_class.new
66
66
  allow(entity).to receive_messages(:processes_by_name => {
67
- :foof => bp1 = Bumbleworks::Process.new('1234'),
68
- :nook => bp2 = Bumbleworks::Process.new('pickles')
67
+ :foof => bp = Bumbleworks::Process.new('1234')
69
68
  })
70
- expect(bp1).to receive(:cancel!)
71
- expect(bp2).to receive(:cancel!)
72
- allow(entity).to receive(:attribute_for_process_name) { |name| :"#{name}_pid" }
69
+ expect(bp).to receive(:cancel!)
70
+ allow(entity).to receive(:attribute_for_process_name).
71
+ with(:foof).and_return(:foof_pid)
73
72
  expect(entity).to receive(:update).with(:foof_pid => nil)
74
- expect(entity).to receive(:update).with(:nook_pid => nil)
75
- entity.cancel_all_processes!
73
+ entity.cancel_process!('foof')
74
+ end
75
+
76
+ it 'does nothing if no process for given name' do
77
+ entity = entity_class.new
78
+ allow(entity).to receive_messages(:processes_by_name => {})
79
+ expect {
80
+ entity.cancel_process!('snord')
81
+ }.not_to raise_error
76
82
  end
77
83
 
78
84
  it 'does not clear identifiers if clear_identifiers option is false' do
@@ -82,7 +88,22 @@ describe Bumbleworks::Entity do
82
88
  })
83
89
  expect(bp).to receive(:cancel!)
84
90
  expect(entity).to receive(:update).never
85
- entity.cancel_all_processes!(:clear_identifiers => false)
91
+ entity.cancel_process!(:foof, :clear_identifiers => false)
92
+ end
93
+ end
94
+
95
+ describe '#cancel_all_processes!' do
96
+ it 'cancels all processes' do
97
+ entity = entity_class.new
98
+ allow(entity).to receive_messages(:processes_by_name => {
99
+ :foof => bp1 = Bumbleworks::Process.new('1234'),
100
+ :nook => bp2 = Bumbleworks::Process.new('pickles'),
101
+ :thulf => nil
102
+ })
103
+ expect(entity).to receive(:cancel_process!).with(:foof, :the_options)
104
+ expect(entity).to receive(:cancel_process!).with(:nook, :the_options)
105
+ expect(entity).to receive(:cancel_process!).with(:thulf, :the_options)
106
+ entity.cancel_all_processes!(:the_options)
86
107
  end
87
108
  end
88
109
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bumbleworks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.77
4
+ version: 0.0.78
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maher Hawash
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-07-24 00:00:00.000000000 Z
14
+ date: 2014-08-03 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: ruote