dream-ops 0.6.0 → 0.6.1
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 +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/dream-ops/deployment/base.rb +8 -6
- data/lib/dream-ops/utils/threaded_enum.rb +81 -0
- data/lib/dream-ops/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27d08df0920a99854a22195056728c0532fc10fa
|
4
|
+
data.tar.gz: 7f00fa02c6681181ce6bff20e4e49ce8cbb58312
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29d9d09a2e49a281b95f4331a92f3f0edd2348945f8c0ee80ba2042c4bf145add1e57291a71a6df5dbf6c5ef7dcdfad99c6d6ca227fdd4df1de0cfbb5060891d
|
7
|
+
data.tar.gz: 68b9ff0471cb4327abef80661686d3dd5cc011f216d613db66653c1ccf4eebadbeef94b32bf3301965e13dcd3a50889ea10f18df370a08620bbe49d282518ff8
|
data/CHANGELOG.md
CHANGED
@@ -1,14 +1,16 @@
|
|
1
|
-
require
|
1
|
+
require 'dream-ops/utils/zip'
|
2
|
+
require 'dream-ops/utils/threaded_enum'
|
2
3
|
require 'fileutils'
|
3
4
|
|
4
5
|
module DreamOps
|
5
6
|
class BaseDeployer
|
6
|
-
|
7
|
+
|
8
|
+
@@spinner = ThreadedEnum.new do |e|
|
7
9
|
loop do
|
8
|
-
e
|
9
|
-
e
|
10
|
-
e
|
11
|
-
e
|
10
|
+
e << '|'
|
11
|
+
e << '/'
|
12
|
+
e << '-'
|
13
|
+
e << '\\'
|
12
14
|
end
|
13
15
|
end
|
14
16
|
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# Credit: https://github.com/bittrance/rxruby/blob/master/lib/rx/concurrency/threaded_enumerator.rb
|
2
|
+
#
|
3
|
+
# ThreadedEnum can be used across threads unlike Ruby's default Enumerator
|
4
|
+
# that will throw FiberError if the enumerator is used from more than one
|
5
|
+
# thread.
|
6
|
+
class ThreadedEnum
|
7
|
+
ERROR = Object.new
|
8
|
+
DONE = Object.new
|
9
|
+
|
10
|
+
if RUBY_ENGINE == 'jruby'
|
11
|
+
def self.new(*args, &block)
|
12
|
+
Enumerator.new(*args, &block)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# ThreadedEnum helper class
|
17
|
+
class Yielder
|
18
|
+
def initialize(queue, gate, condition)
|
19
|
+
@queue = queue
|
20
|
+
@gate = gate
|
21
|
+
@condition = condition
|
22
|
+
end
|
23
|
+
|
24
|
+
def <<(e)
|
25
|
+
@queue << e
|
26
|
+
@gate.synchronize do
|
27
|
+
@condition.wait @gate while @queue.size > 0
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# The enumerator can be created with either an enumerable or a block that
|
33
|
+
# receives a yielder object, but not both. Note that the block or enumerable
|
34
|
+
# will be iterated immediately once making it possible to prepare the iterator
|
35
|
+
# e.g. when reading from a file or a socket.
|
36
|
+
def initialize(source_or_size_hint = nil, &block)
|
37
|
+
raise TypeError, 'Size hinting not supported' if source_or_size_hint && block_given?
|
38
|
+
@condition = ConditionVariable.new
|
39
|
+
@gate = Mutex.new
|
40
|
+
@queue = Queue.new
|
41
|
+
@done = false
|
42
|
+
setup_yielder(source_or_size_hint, &block)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Receive the next item from the enumerator or any exception thrown from the
|
46
|
+
# enumerator.
|
47
|
+
def next
|
48
|
+
raise StopIteration if @done
|
49
|
+
@gate.synchronize do
|
50
|
+
@condition.signal
|
51
|
+
end
|
52
|
+
payload, type = @queue.pop
|
53
|
+
case type
|
54
|
+
when DONE
|
55
|
+
@done = true
|
56
|
+
raise StopIteration
|
57
|
+
when ERROR
|
58
|
+
@done = true
|
59
|
+
raise payload
|
60
|
+
end
|
61
|
+
payload
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def setup_yielder(source, &block)
|
67
|
+
yielder = Yielder.new(@queue, @gate, @condition)
|
68
|
+
Thread.new do
|
69
|
+
begin
|
70
|
+
if source
|
71
|
+
source.each { |e| yielder << e }
|
72
|
+
else
|
73
|
+
block.call yielder
|
74
|
+
end
|
75
|
+
rescue => e
|
76
|
+
yielder << [e, ERROR]
|
77
|
+
end
|
78
|
+
yielder << [nil, DONE]
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
data/lib/dream-ops/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dream-ops
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Allen
|
@@ -157,6 +157,7 @@ files:
|
|
157
157
|
- lib/dream-ops/logger.rb
|
158
158
|
- lib/dream-ops/mixin/logging.rb
|
159
159
|
- lib/dream-ops/shell.rb
|
160
|
+
- lib/dream-ops/utils/threaded_enum.rb
|
160
161
|
- lib/dream-ops/utils/zip.rb
|
161
162
|
- lib/dream-ops/version.rb
|
162
163
|
homepage: https://github.com/chris-allen/dream-ops
|