burden 0.1.2 → 0.1.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/burden_web/lib/burden_web/version.rb +1 -1
- data/lib/burden/config.rb +7 -4
- data/lib/burden/statistics.rb +17 -22
- data/lib/burden/storage.rb +8 -8
- data/lib/burden/{storage → storage_backends}/abstract/run.rb +1 -1
- data/lib/burden/storage_backends/abstract_backend.rb +18 -0
- data/lib/burden/{storage → storage_backends}/active_record/run.rb +1 -1
- data/lib/burden/storage_backends/active_record_backend.rb +27 -0
- data/lib/burden/{storage → storage_backends}/mongo_mapper/run.rb +1 -1
- data/lib/burden/{storage → storage_backends}/mongoid/run.rb +1 -1
- data/lib/burden/version.rb +1 -1
- data/lib/burden/wrapper.rb +5 -1
- metadata +8 -6
data/lib/burden/config.rb
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
module Burden
|
2
2
|
class Config
|
3
|
-
attr_accessor :storage,
|
4
|
-
:
|
5
|
-
:
|
6
|
-
:
|
3
|
+
attr_accessor :storage, # Storage backend (ActiveRecord, Mongoid, MongoMapper)
|
4
|
+
:storage_config, # Config needed to initialize storage
|
5
|
+
:log_file, # Log file
|
6
|
+
:ignored_tasks, # Do not log this tasks (eg. environment task)
|
7
|
+
:on_success, # Success callback (expected to be a Proc)
|
8
|
+
:on_failure # Failure callback (expected to be a Proc)
|
7
9
|
|
8
10
|
def initialize
|
9
11
|
@storage = :active_record
|
12
|
+
@log_file = 'tmp/rake.log'
|
10
13
|
@ignored_tasks = [/environment/]
|
11
14
|
end
|
12
15
|
|
data/lib/burden/statistics.rb
CHANGED
@@ -10,32 +10,27 @@ module Burden
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def save
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
# FIXME
|
14
|
+
# if Burden.storage.ready?
|
15
|
+
# Burden.storage.runs.create(name: name, success: success, execution_time: execution_time, timestamp: timestamp)
|
16
|
+
# end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
log_to_stdout(:failed)
|
22
|
-
end
|
23
|
-
else
|
24
|
-
log_to_stdout(:no_rails)
|
18
|
+
File.open(Burden.config.log_file, 'a') do |f|
|
19
|
+
f.write(log_message)
|
20
|
+
f.close
|
25
21
|
end
|
26
22
|
end
|
27
23
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
puts "Execution time: #{execution_time.round(4)}"
|
24
|
+
private
|
25
|
+
|
26
|
+
def log_message
|
27
|
+
<<-TEXT
|
28
|
+
Timestamp: #{timestamp}
|
29
|
+
Task: #{name}
|
30
|
+
Execution #{success ? 'finished successfully' : 'failed'}
|
31
|
+
Execution time: #{execution_time.round(4)}
|
32
|
+
|
33
|
+
TEXT
|
39
34
|
end
|
40
35
|
end
|
41
36
|
end
|
data/lib/burden/storage.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
module Burden
|
2
2
|
module Storage
|
3
3
|
module Helper
|
4
|
-
def
|
5
|
-
@
|
4
|
+
def storage
|
5
|
+
@storage ||= begin
|
6
6
|
case Burden.config.storage
|
7
7
|
when :active_record, :activerecord
|
8
|
-
require 'burden/
|
9
|
-
Burden::
|
8
|
+
require 'burden/storage_backends/active_record_backend'
|
9
|
+
Burden::StorageBackends::ActiveRecordBackend.new(Burden.config.storage_config)
|
10
10
|
when :mongoid
|
11
|
-
require 'burden/
|
12
|
-
Burden::
|
11
|
+
require 'burden/storage_backends/mongoid_backend'
|
12
|
+
Burden::StorageBackends::MongoidBackend.new(Burden.config.storage_config)
|
13
13
|
when :mongo_mapper, :mongomapper
|
14
|
-
require 'burden/
|
15
|
-
Burden::
|
14
|
+
require 'burden/storage_backends/mongo_mapper_backend'
|
15
|
+
Burden::StorageBackends::MongoMapperBackend.new(Burden.config.storage_config)
|
16
16
|
else
|
17
17
|
raise Exception.new("Unknown storage: #{storage}")
|
18
18
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'burden/storage_backends/abstract/run'
|
2
|
+
|
3
|
+
module Burden
|
4
|
+
module StorageBackends
|
5
|
+
class AbstractBackend
|
6
|
+
def initialize(config)
|
7
|
+
end
|
8
|
+
|
9
|
+
def ready?
|
10
|
+
raise NotImplementedError.new('Method #ready? must be overwritten')
|
11
|
+
end
|
12
|
+
|
13
|
+
def runs
|
14
|
+
raise NotImplementedError.new('Method #runs must be overwritten')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
require 'burden/storage_backends/active_record/run'
|
3
|
+
|
4
|
+
module Burden
|
5
|
+
module StorageBackends
|
6
|
+
class ActiveRecordBackend
|
7
|
+
attr_reader :connection_success
|
8
|
+
|
9
|
+
def initialize(config)
|
10
|
+
@connection_success = true
|
11
|
+
begin
|
12
|
+
ActiveRecord::Base.establish_connection(config)
|
13
|
+
rescue => e
|
14
|
+
@connection_success = false
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def ready?
|
19
|
+
@connection_success
|
20
|
+
end
|
21
|
+
|
22
|
+
def runs
|
23
|
+
Burden::StorageBackends::ActiveRecord::Run
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/burden/version.rb
CHANGED
data/lib/burden/wrapper.rb
CHANGED
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: burden
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Gregory Eremin
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -184,10 +184,12 @@ files:
|
|
184
184
|
- lib/burden/config.rb
|
185
185
|
- lib/burden/statistics.rb
|
186
186
|
- lib/burden/storage.rb
|
187
|
-
- lib/burden/
|
188
|
-
- lib/burden/
|
189
|
-
- lib/burden/
|
190
|
-
- lib/burden/
|
187
|
+
- lib/burden/storage_backends/abstract/run.rb
|
188
|
+
- lib/burden/storage_backends/abstract_backend.rb
|
189
|
+
- lib/burden/storage_backends/active_record/run.rb
|
190
|
+
- lib/burden/storage_backends/active_record_backend.rb
|
191
|
+
- lib/burden/storage_backends/mongo_mapper/run.rb
|
192
|
+
- lib/burden/storage_backends/mongoid/run.rb
|
191
193
|
- lib/burden/version.rb
|
192
194
|
- lib/burden/wrapper.rb
|
193
195
|
- lib/rails/generators/burden/install/USAGE
|