parallel_minion 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c335c7e0f70e6146ac47496db7148e38f3bd65b
4
- data.tar.gz: 69102288e568ff93f50179160ec4ea589289d1a0
3
+ metadata.gz: 982df7415c5b0672c4a8c5d8aa6e32d31677a9b7
4
+ data.tar.gz: cc64cd982068008a6b233eb72339e11892dfee34
5
5
  SHA512:
6
- metadata.gz: c3809ec290a32c2afb8661bc5c926ab9dc386006a5b519f790c5960d01cbdc785b34a902dbf7754b67b3b20584237fe0d51429bfb23457d331e7938e531a9423
7
- data.tar.gz: b519e6ded5b402a48c37cc06ad5727fde6a61f670be000309629a471a292dc36fca1445ed13256828f98a2532a9e4f8f2c379ed8bf504fc5892b023b61814a0a
6
+ metadata.gz: d0ce188896ad20800f4727a02c71985efce109952e7ae1d51bf0e3e35b40928dccf4833b82e96fc9f6595153fde5f5777cbd9d366d2be535609322d4aa8c2551
7
+ data.tar.gz: b4a1c1f63c43f34e8c38d24ae4bb98347566cfceddb856824041541e1cb0eee1562aa4426cb7bbb746b2d43ef64583cc84b854921db1670cabd1d90c1db487f9
@@ -152,7 +152,7 @@ module ParallelMinion
152
152
  logger.info("Started #{@description}")
153
153
 
154
154
  begin
155
- logger.benchmark_info("Completed #{@description}", log_exception: @log_exception) do
155
+ logger.benchmark_info("Completed #{@description}", log_exception: @log_exception, metric: @metric) do
156
156
  # Use the current scope for the duration of the task execution
157
157
  if scopes.nil? || (scopes.size == 0)
158
158
  @result = instance_exec(*args, &block)
@@ -1,3 +1,3 @@
1
1
  module ParallelMinion #:nodoc
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -9,6 +9,11 @@ require 'parallel_minion'
9
9
  SemanticLogger.default_level = :trace
10
10
  SemanticLogger.add_appender('test.log', &SemanticLogger::Appender::Base.colorized_formatter) if SemanticLogger.appenders.size == 0
11
11
 
12
+ # Setup global callback for metric so that it can be tested below
13
+ SemanticLogger.on_metric do |log_struct|
14
+ $log_struct = log_struct.dup
15
+ end
16
+
12
17
  # Test ParallelMinion standalone without Rails
13
18
  # Run this test standalone to verify it has no Rails dependencies
14
19
  class MinionTest < Test::Unit::TestCase
@@ -20,6 +25,7 @@ class MinionTest < Test::Unit::TestCase
20
25
  context ".new with enabled: #{enabled.inspect}" do
21
26
  setup do
22
27
  ParallelMinion::Minion.enabled = enabled
28
+ $log_struct = nil
23
29
  end
24
30
 
25
31
  should 'without parameters' do
@@ -47,15 +53,15 @@ class MinionTest < Test::Unit::TestCase
47
53
  end
48
54
  end
49
55
 
50
- # TODO Blocks still have access to their original scope if variables cannot be
51
- # resolved first by the parameters, then by the values in Minion itself
52
- # should 'not have access to local variables' do
53
- # name = 'Jack'
54
- # minion = ParallelMinion::Minion.new(description: 'Test') { puts name }
55
- # assert_raise NameError do
56
- # minion.result
57
- # end
58
- # end
56
+ # TODO Blocks still have access to their original scope if variables cannot be
57
+ # resolved first by the parameters, then by the values in Minion itself
58
+ # should 'not have access to local variables' do
59
+ # name = 'Jack'
60
+ # minion = ParallelMinion::Minion.new(description: 'Test') { puts name }
61
+ # assert_raise NameError do
62
+ # minion.result
63
+ # end
64
+ # end
59
65
 
60
66
  should 'run minion' do
61
67
  hash = { value: 23 }
@@ -81,6 +87,22 @@ class MinionTest < Test::Unit::TestCase
81
87
  assert_equal 'TAG', minion.result
82
88
  end
83
89
 
90
+ should 'include metric' do
91
+ metric_name = '/Custom/metric'
92
+ hash = { value: 23 }
93
+ value = 47
94
+ minion = ParallelMinion::Minion.new(hash, description: 'Test', metric: metric_name) do |h|
95
+ value = 321
96
+ h[:value] = 123
97
+ 456
98
+ end
99
+ assert_equal 456, minion.result
100
+ assert_equal 123, hash[:value]
101
+ assert_equal 321, value
102
+ SemanticLogger.flush
103
+ assert_equal metric_name, $log_struct.metric
104
+ end
105
+
84
106
  should 'handle multiple minions concurrently' do
85
107
  # Start 10 minions
86
108
  minions = 10.times.collect do |i|
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parallel_minion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reid Morrison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-14 00:00:00.000000000 Z
11
+ date: 2014-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: semantic_logger