serial-scheduler 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.2.0
@@ -19,6 +19,16 @@ module SerialScheduler
19
19
  add_transaction_tracer :run, :category => :task
20
20
  end
21
21
 
22
+ if defined?(Rails)
23
+ def logger
24
+ Rails.logger
25
+ end
26
+ else
27
+ def logger
28
+ SerialScheduler::Logger
29
+ end
30
+ end
31
+
22
32
  end
23
33
 
24
34
  end
@@ -27,4 +37,5 @@ require "serial_scheduler/date_day_names_core_extension"
27
37
  require "serial_scheduler/converter"
28
38
  require "serial_scheduler/dsl"
29
39
  require "serial_scheduler/runner"
30
- require "serial_scheduler/time_table"
40
+ require "serial_scheduler/time_table"
41
+ require "serial_scheduler/logger"
@@ -0,0 +1,17 @@
1
+ class SerialScheduler::Logger
2
+
3
+ class <<self
4
+
5
+ def log(type, *args)
6
+ puts "[#{type.upcase}] #{args}"
7
+ end
8
+
9
+ %w(debug info warn error fatal).each do |type|
10
+ define_method type do |*args|
11
+ log(type, *args)
12
+ end
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -11,15 +11,18 @@ class SerialScheduler::Runner
11
11
  if options[:dry_run]
12
12
  puts ">> #{job}"
13
13
  else
14
+ SerialScheduler.logger.info("executing '#{job}'", :_job => "#{job}")
15
+ start_time = Time.now
14
16
  job.call
17
+ end_time = Time.now
18
+ SerialScheduler.logger.info("successfully executed '#{job}' in #{(end_time - start_time)} seconds", :_job => "#{job}", :_execution_time => (end_time - start_time))
15
19
  end
16
20
  rescue => e
17
- if defined?(Rails)
18
- raise e if Rails.env.development?
19
- Notifier.deliver_scheduler_error(e, job, time)
20
- end
21
+ SerialScheduler.logger.error(e, :_job => "#{job}", :_execution_time => (start_time ? Time.now - start_time : "?"))
22
+ raise e if defined?(Rails) && Rails.env.development?
21
23
  end
22
24
  end
25
+
23
26
  end
24
27
 
25
28
  def dry_run(time)
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{serial-scheduler}
8
- s.version = "0.1.1"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Andi Bade"]
12
- s.date = %q{2011-02-28}
12
+ s.date = %q{2011-04-18}
13
13
  s.description = %q{Schedule Task – execute all tasks at the same time one after another}
14
14
  s.email = %q{andi@galaxycats.com}
15
15
  s.extra_rdoc_files = [
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
28
28
  "lib/serial_scheduler/converter.rb",
29
29
  "lib/serial_scheduler/date_day_names_core_extension.rb",
30
30
  "lib/serial_scheduler/dsl.rb",
31
+ "lib/serial_scheduler/logger.rb",
31
32
  "lib/serial_scheduler/runner.rb",
32
33
  "lib/serial_scheduler/time_table.rb",
33
34
  "serial-scheduler.gemspec",
data/test/runner_test.rb CHANGED
@@ -35,4 +35,16 @@ class RunnerTest < ActiveSupport::TestCase
35
35
  end
36
36
  end
37
37
 
38
+ test "should log executions to info" do
39
+ SerialScheduler.logger.expects(:info).times(2)
40
+ SerialScheduler::Runner.run("27.12.2010 00:00".to_datetime)
41
+ end
42
+
43
+ test "should log failed-executions to error" do
44
+ exception = NoMethodError.new("this is the no method exception")
45
+ RunnerTest::MockReceiver.expects(:lastminute).raises exception
46
+ SerialScheduler.logger.expects(:info)
47
+ SerialScheduler.logger.expects(:error)
48
+ SerialScheduler::Runner.run("27.12.2010 09:00".to_datetime)
49
+ end
38
50
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
8
- - 1
9
- version: 0.1.1
7
+ - 2
8
+ - 0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Andi Bade
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-02-28 00:00:00 +01:00
17
+ date: 2011-04-18 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -50,6 +50,7 @@ files:
50
50
  - lib/serial_scheduler/converter.rb
51
51
  - lib/serial_scheduler/date_day_names_core_extension.rb
52
52
  - lib/serial_scheduler/dsl.rb
53
+ - lib/serial_scheduler/logger.rb
53
54
  - lib/serial_scheduler/runner.rb
54
55
  - lib/serial_scheduler/time_table.rb
55
56
  - serial-scheduler.gemspec