Module: Hekenga
- Defined in:
- lib/hekenga.rb,
lib/hekenga/dsl.rb,
lib/hekenga/log.rb,
lib/hekenga/config.rb,
lib/hekenga/context.rb,
lib/hekenga/failure.rb,
lib/hekenga/invalid.rb,
lib/hekenga/version.rb,
lib/hekenga/scaffold.rb,
lib/hekenga/migration.rb,
lib/hekenga/base_error.rb,
lib/hekenga/id_iterator.rb,
lib/hekenga/simple_task.rb,
lib/hekenga/irreversible.rb,
lib/hekenga/parallel_job.rb,
lib/hekenga/base_iterator.rb,
lib/hekenga/document_task.rb,
lib/hekenga/dsl/migration.rb,
lib/hekenga/failure/error.rb,
lib/hekenga/failure/write.rb,
lib/hekenga/parallel_task.rb,
lib/hekenga/task_splitter.rb,
lib/hekenga/failure_report.rb,
lib/hekenga/master_process.rb,
lib/hekenga/virtual_method.rb,
lib/hekenga/dsl/simple_task.rb,
lib/hekenga/mongoid_iterator.rb,
lib/hekenga/dsl/document_task.rb,
lib/hekenga/failure/cancelled.rb,
lib/hekenga/task_failed_error.rb,
lib/hekenga/failure/validation.rb,
lib/hekenga/document_task_record.rb,
lib/hekenga/document_task_executor.rb
Defined Under Namespace
Classes: BaseError, BaseIterator, Config, Context, DSL, DocumentTask, DocumentTaskExecutor, DocumentTaskRecord, Failure, FailureReport, IdIterator, Invalid, Irreversible, Log, MasterProcess, Migration, MongoidIterator, ParallelJob, ParallelTask, Scaffold, SimpleTask, TaskFailedError, TaskSplitter, VirtualMethod
Constant Summary
collapse
- VERSION =
"2.2.0"
- @@load_all_mutex =
Mutex.new
- @@registry_mutex =
Mutex.new
- @@registry =
[]
Class Method Summary
collapse
Class Method Details
.config ⇒ Object
21
22
23
|
# File 'lib/hekenga.rb', line 21
def config
@config ||= Hekenga::Config.new
end
|
17
18
19
|
# File 'lib/hekenga.rb', line 17
def configure
yield(config)
end
|
.find_migration(key) ⇒ Object
43
44
45
46
47
48
|
# File 'lib/hekenga.rb', line 43
def find_migration(key)
load_all!
registry.detect do |migration|
migration.to_key == key
end
end
|
.load_all! ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/hekenga.rb', line 25
def load_all!
return if @loaded
@@load_all_mutex.synchronize do
Dir.glob(File.join(config.abs_dir, "*.rb")).each do |path|
require path
end
@loaded = true
end
end
|
.log(str) ⇒ Object
69
70
71
|
# File 'lib/hekenga.rb', line 69
def log(str)
print str.to_s+"\n"
end
|
.migration(&block) ⇒ Object
37
38
39
40
41
|
# File 'lib/hekenga.rb', line 37
def migration(&block)
Hekenga::DSL::Migration.new(&block).object.tap do |obj|
@@registry_mutex.synchronize { registry.push(obj) }
end
end
|
.registry ⇒ Object
50
51
52
|
# File 'lib/hekenga.rb', line 50
def registry
@@registry
end
|
.reset_registry ⇒ Object
54
55
56
|
# File 'lib/hekenga.rb', line 54
def reset_registry
@@registry_mutex.synchronize { @@registry = [] }
end
|
.status(migration) ⇒ Object
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/hekenga.rb', line 58
def status(migration)
logs = Hekenga::Log.where(
pkey: migration.to_key
).to_a
return :naught if logs.empty?
return :skipped if logs.any? {|x| x.skip}
return :failed if logs.any? {|x| x.cancel}
return :complete if logs.all? {|x| x.done} && logs.length == migration.tasks.length
return :running
end
|