refinery 0.12.2 → 1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/refinery.rb +1 -99
- data/refinery.gemspec +16 -117
- metadata +39 -118
- data/.gitignore +0 -6
- data/CHANGELOG +0 -2
- data/LICENSE +0 -21
- data/README.rdoc +0 -58
- data/README.textile +0 -58
- data/Rakefile +0 -43
- data/VERSION +0 -1
- data/bin/epub +0 -64
- data/bin/monitor +0 -47
- data/bin/pubnow +0 -61
- data/bin/refinery +0 -64
- data/config/config.example.yml +0 -21
- data/lib/refinery/beanstalk_queue.rb +0 -36
- data/lib/refinery/beanstalk_queue_provider.rb +0 -18
- data/lib/refinery/config.rb +0 -48
- data/lib/refinery/configurable.rb +0 -15
- data/lib/refinery/daemon.rb +0 -148
- data/lib/refinery/event_publisher.rb +0 -131
- data/lib/refinery/heartbeat.rb +0 -33
- data/lib/refinery/loggable.rb +0 -9
- data/lib/refinery/monitor.rb +0 -113
- data/lib/refinery/processor.rb +0 -55
- data/lib/refinery/publisher.rb +0 -42
- data/lib/refinery/queueable.rb +0 -48
- data/lib/refinery/server.rb +0 -88
- data/lib/refinery/statistics.rb +0 -61
- data/lib/refinery/stats_server.rb +0 -135
- data/lib/refinery/utilities.rb +0 -33
- data/lib/refinery/validations.rb +0 -48
- data/lib/refinery/worker.rb +0 -65
- data/logs/README +0 -1
- data/publishers/error.rb +0 -6
- data/publishers/sample.rb +0 -6
- data/publishers/sleep.rb +0 -5
- data/test/config.yml +0 -10
- data/test/test_helper.rb +0 -21
- data/test/unit/config_test.rb +0 -42
- data/test/unit/configurable_test.rb +0 -13
- data/test/unit/daemon_test.rb +0 -63
- data/test/unit/event_publisher_test.rb +0 -12
- data/test/unit/heartbeat_test.rb +0 -25
- data/test/unit/loggable_test.rb +0 -12
- data/test/unit/processor_test.rb +0 -34
- data/test/unit/publisher_test.rb +0 -13
- data/test/unit/queueable_test.rb +0 -26
- data/test/unit/server_test.rb +0 -34
- data/test/unit/statistics_test.rb +0 -44
- data/test/unit/utilities_test.rb +0 -25
- data/test/unit/validations_test.rb +0 -37
- data/test/unit/worker_test.rb +0 -44
- data/workers/error.rb +0 -8
- data/workers/sample.rb +0 -8
- data/workers/sleep.rb +0 -7
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
if defined?(Sequel)
|
4
|
-
class StatisticsTest < Test::Unit::TestCase
|
5
|
-
context "a statistics instance" do
|
6
|
-
should "record a done message" do
|
7
|
-
|
8
|
-
dataset = stub('dataset')
|
9
|
-
dataset.expects(:<<) # TODO: improve this expectation
|
10
|
-
|
11
|
-
db = stub('db')
|
12
|
-
db.stubs(:table_exists?).returns(true)
|
13
|
-
db.stubs(:[]).with(:completed_jobs).returns(dataset)
|
14
|
-
|
15
|
-
Sequel.expects(:connect).with('sqlite://stats.db').returns(db)
|
16
|
-
|
17
|
-
message = {
|
18
|
-
'host_info' => {'hostname' => 'test', 'pid' => 1},
|
19
|
-
'run_time' => 1,
|
20
|
-
'original' => ''
|
21
|
-
}
|
22
|
-
Refinery::Statistics.new.record_done(message)
|
23
|
-
end
|
24
|
-
|
25
|
-
should "record an error message" do
|
26
|
-
dataset = stub('dataset')
|
27
|
-
dataset.expects(:<<) # TODO: improve this expectation
|
28
|
-
|
29
|
-
db = stub('db')
|
30
|
-
db.stubs(:table_exists?).returns(true)
|
31
|
-
db.stubs(:[]).with(:errors).returns(dataset)
|
32
|
-
|
33
|
-
Sequel.expects(:connect).with('sqlite://stats.db').returns(db)
|
34
|
-
|
35
|
-
message = {
|
36
|
-
'host_info' => {'hostname' => 'test', 'pid' => 1},
|
37
|
-
'error' => {'class' => 'Error', 'message' => 'An error occurred.'},
|
38
|
-
'original' => ''
|
39
|
-
}
|
40
|
-
Refinery::Statistics.new.record_error(message)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
data/test/unit/utilities_test.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class UtilitiesIncluded
|
4
|
-
include Refinery::Utilities
|
5
|
-
end
|
6
|
-
|
7
|
-
class UtilitiesTest < Test::Unit::TestCase
|
8
|
-
context "a class with utilities included" do
|
9
|
-
setup do
|
10
|
-
@o = UtilitiesIncluded.new
|
11
|
-
end
|
12
|
-
should "camelize a word" do
|
13
|
-
|
14
|
-
assert_equal 'ClassName', @o.camelize('class_name')
|
15
|
-
end
|
16
|
-
should "encode and decode message" do
|
17
|
-
message = {'some' => 'message'}
|
18
|
-
assert_equal message, @o.decode_message(@o.encode_message(message))
|
19
|
-
end
|
20
|
-
should "provide host info" do
|
21
|
-
assert_not_nil @o.host_info['pid']
|
22
|
-
assert_not_nil @o.host_info['hostname']
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class ValidatedWorker < Refinery::Worker
|
4
|
-
include Refinery::Validations
|
5
|
-
validate_with do |message|
|
6
|
-
raise Refinery::InvalidMessageError, "A message is required" unless message
|
7
|
-
end
|
8
|
-
validates_key_exists :test
|
9
|
-
|
10
|
-
def execute(message)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
class ValidationsTest < Test::Unit::TestCase
|
14
|
-
context "a validated worker" do
|
15
|
-
setup do
|
16
|
-
daemon = stub('daemon')
|
17
|
-
@worker = ValidatedWorker.new(daemon)
|
18
|
-
end
|
19
|
-
should "raise a validation error if the key does not exist" do
|
20
|
-
message = {}
|
21
|
-
assert_raise Refinery::InvalidMessageError do
|
22
|
-
@worker.run(message)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
should "not raise a validation error if the key does exist" do
|
26
|
-
message = {:test => 'ding!'}
|
27
|
-
assert_nothing_raised do
|
28
|
-
@worker.run(message)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
should "raise a validation error if the message is nil" do
|
32
|
-
assert_raise Refinery::InvalidMessageError do
|
33
|
-
@worker.run(nil)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
data/test/unit/worker_test.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class SampleWorker < Refinery::Worker
|
4
|
-
attr_reader :message
|
5
|
-
def execute(message)
|
6
|
-
@message = message
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
class WorkerTest < Test::Unit::TestCase
|
11
|
-
context "a worker" do
|
12
|
-
setup do
|
13
|
-
daemon = stub('daemon')
|
14
|
-
@worker = SampleWorker.new(daemon)
|
15
|
-
@message = {'test' => 'value'}
|
16
|
-
end
|
17
|
-
should "run" do
|
18
|
-
@worker.run(@message)
|
19
|
-
assert_equal @message, @worker.message
|
20
|
-
end
|
21
|
-
should "provide a data store" do
|
22
|
-
options = {:bucket => 'bucket'}
|
23
|
-
|
24
|
-
data_store = stub('data store')
|
25
|
-
|
26
|
-
Moneta::S3.expects(:new).with(
|
27
|
-
:access_key_id => 'aki',
|
28
|
-
:secret_access_key => 'sak',
|
29
|
-
:bucket => options[:bucket],
|
30
|
-
:multi_thread => true
|
31
|
-
).returns(data_store)
|
32
|
-
|
33
|
-
setup_default_config
|
34
|
-
assert_not_nil @worker.data_store(options)
|
35
|
-
end
|
36
|
-
should "provide a queue" do
|
37
|
-
queue = stub('queue')
|
38
|
-
queue_provider = stub('queue provider')
|
39
|
-
queue_provider.expects(:queue).with('a_queue').returns(queue)
|
40
|
-
@worker.expects(:queue_provider).returns(queue_provider)
|
41
|
-
assert_not_nil @worker.queue('a_queue')
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
data/workers/error.rb
DELETED
data/workers/sample.rb
DELETED