refinery 0.12.2 → 1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/lib/refinery.rb +1 -99
  2. data/refinery.gemspec +16 -117
  3. metadata +39 -118
  4. data/.gitignore +0 -6
  5. data/CHANGELOG +0 -2
  6. data/LICENSE +0 -21
  7. data/README.rdoc +0 -58
  8. data/README.textile +0 -58
  9. data/Rakefile +0 -43
  10. data/VERSION +0 -1
  11. data/bin/epub +0 -64
  12. data/bin/monitor +0 -47
  13. data/bin/pubnow +0 -61
  14. data/bin/refinery +0 -64
  15. data/config/config.example.yml +0 -21
  16. data/lib/refinery/beanstalk_queue.rb +0 -36
  17. data/lib/refinery/beanstalk_queue_provider.rb +0 -18
  18. data/lib/refinery/config.rb +0 -48
  19. data/lib/refinery/configurable.rb +0 -15
  20. data/lib/refinery/daemon.rb +0 -148
  21. data/lib/refinery/event_publisher.rb +0 -131
  22. data/lib/refinery/heartbeat.rb +0 -33
  23. data/lib/refinery/loggable.rb +0 -9
  24. data/lib/refinery/monitor.rb +0 -113
  25. data/lib/refinery/processor.rb +0 -55
  26. data/lib/refinery/publisher.rb +0 -42
  27. data/lib/refinery/queueable.rb +0 -48
  28. data/lib/refinery/server.rb +0 -88
  29. data/lib/refinery/statistics.rb +0 -61
  30. data/lib/refinery/stats_server.rb +0 -135
  31. data/lib/refinery/utilities.rb +0 -33
  32. data/lib/refinery/validations.rb +0 -48
  33. data/lib/refinery/worker.rb +0 -65
  34. data/logs/README +0 -1
  35. data/publishers/error.rb +0 -6
  36. data/publishers/sample.rb +0 -6
  37. data/publishers/sleep.rb +0 -5
  38. data/test/config.yml +0 -10
  39. data/test/test_helper.rb +0 -21
  40. data/test/unit/config_test.rb +0 -42
  41. data/test/unit/configurable_test.rb +0 -13
  42. data/test/unit/daemon_test.rb +0 -63
  43. data/test/unit/event_publisher_test.rb +0 -12
  44. data/test/unit/heartbeat_test.rb +0 -25
  45. data/test/unit/loggable_test.rb +0 -12
  46. data/test/unit/processor_test.rb +0 -34
  47. data/test/unit/publisher_test.rb +0 -13
  48. data/test/unit/queueable_test.rb +0 -26
  49. data/test/unit/server_test.rb +0 -34
  50. data/test/unit/statistics_test.rb +0 -44
  51. data/test/unit/utilities_test.rb +0 -25
  52. data/test/unit/validations_test.rb +0 -37
  53. data/test/unit/worker_test.rb +0 -44
  54. data/workers/error.rb +0 -8
  55. data/workers/sample.rb +0 -8
  56. 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
@@ -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
@@ -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
@@ -1,8 +0,0 @@
1
- # This is an example worker that raises an error.
2
- class ErrorWorker < Refinery::Worker
3
- # Execute the work once.
4
- def execute(message)
5
- logger.info "received message: #{message.inspect}"
6
- raise RuntimeError, "processing failure example"
7
- end
8
- end
@@ -1,8 +0,0 @@
1
- # This is a sample worker.
2
- class SampleWorker < Refinery::Worker
3
- # Execute the work once.
4
- def execute(message)
5
- logger.info "received message: #{message.inspect}"
6
- return true
7
- end
8
- end
@@ -1,7 +0,0 @@
1
- class SleepWorker < Refinery::Worker
2
- def execute(message)
3
- logger.info "received message: #{message.inspect}"
4
- sleep(message['seconds'])
5
- return true
6
- end
7
- end