ford 0.0.2 → 0.0.3
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.
- data/lib/ford/stage.rb +16 -16
- data/lib/ford/version.rb +1 -1
- metadata +2 -2
data/lib/ford/stage.rb
CHANGED
@@ -24,7 +24,7 @@ module Ford
|
|
24
24
|
#
|
25
25
|
class Stage
|
26
26
|
|
27
|
-
attr_accessor :config, :logger, :
|
27
|
+
attr_accessor :config, :logger, :item
|
28
28
|
|
29
29
|
#
|
30
30
|
# Create a queue for each Stage subclass
|
@@ -62,7 +62,7 @@ module Ford
|
|
62
62
|
obj.run
|
63
63
|
rescue Exception => exc
|
64
64
|
obj.logger.fatal("\nFailed to execute the #{self.class}'s thread (#{tid})")
|
65
|
-
obj.logger.fatal("was consuming: #{obj.
|
65
|
+
obj.logger.fatal("was consuming: #{obj.item}")
|
66
66
|
obj.logger.fatal("#{exc}\n#{exc.backtrace.join("\n")}")
|
67
67
|
end
|
68
68
|
}
|
@@ -81,7 +81,7 @@ module Ford
|
|
81
81
|
data = {
|
82
82
|
:debug => false, # If true, logs messages during execution
|
83
83
|
:log_to => STDOUT, # Logging path or IO instance
|
84
|
-
:
|
84
|
+
:from_stage => self.class # Reference of the Stage that is used as data input (normally, itself). Will load items from its queue.
|
85
85
|
}.merge(options)
|
86
86
|
|
87
87
|
@config = Ford::Config.new(data) # instance configuration
|
@@ -93,43 +93,43 @@ module Ford
|
|
93
93
|
# Run the stage
|
94
94
|
#
|
95
95
|
def run
|
96
|
-
while (@
|
96
|
+
while (@item = pop_item)
|
97
97
|
start_consume_at = Time.now
|
98
98
|
|
99
99
|
logger.debug("Consuming...(#{config.thread_id})")
|
100
|
-
|
100
|
+
consume
|
101
101
|
|
102
102
|
logger.debug("Consumed in #{Time.now - start_consume_at} seconds (#{config.thread_id})")
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
106
|
#
|
107
|
-
# When using the default run,
|
107
|
+
# When using the default run, consume should be implemented.
|
108
108
|
#
|
109
|
-
def
|
109
|
+
def consume
|
110
110
|
raise 'Must implement!'
|
111
111
|
end
|
112
112
|
|
113
113
|
#
|
114
|
-
# Pop an
|
114
|
+
# Pop an item from the queue
|
115
115
|
#
|
116
|
-
def
|
117
|
-
@config.
|
116
|
+
def pop_item
|
117
|
+
@config.from_stage.queue.pop
|
118
118
|
end
|
119
119
|
|
120
120
|
#
|
121
|
-
# Enqueue an
|
121
|
+
# Enqueue an item in the stage's queue
|
122
122
|
#
|
123
|
-
def
|
124
|
-
stage_class.queue.push
|
123
|
+
def send_to(stage_class, item)
|
124
|
+
stage_class.queue.push item
|
125
125
|
logger.debug("Enqueued into #{stage_class}'s queue (#{config.thread_id})")
|
126
126
|
end
|
127
127
|
|
128
128
|
#
|
129
|
-
# Enqueue an
|
129
|
+
# Enqueue an item in the current stage's queue
|
130
130
|
#
|
131
|
-
def
|
132
|
-
self.class.queue.push
|
131
|
+
def send_back(item)
|
132
|
+
self.class.queue.push item
|
133
133
|
logger.debug("Enqueued back (#{config.thread_id})")
|
134
134
|
end
|
135
135
|
|
data/lib/ford/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: ford
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Bruno Bueno
|
@@ -13,7 +13,7 @@ autorequire:
|
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
15
|
|
16
|
-
date: 2011-07-
|
16
|
+
date: 2011-07-18 00:00:00 -03:00
|
17
17
|
default_executable:
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|