Class: Tempo::Controllers::Records
- Inherits:
-
Base
- Object
- Base
- Tempo::Controllers::Records
show all
- Defined in:
- lib/tempo/controllers/records_controller.rb
Class Method Summary
collapse
Methods inherited from Base
filter_projects_by_title, fuzzy_match, reassemble_the
Class Method Details
.backup_records(options, args) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/tempo/controllers/records_controller.rb', line 19
def backup_records(options, args)
dir = options.fetch( :directory, ENV['HOME'])
Views::interactive_progress "\nBacking up #{dir}/tempo"
if File.exist?(File.join(dir, 'tempo'))
dest = FileRecord::Directory.backup directory: dir
Views::interactive_progress "Sucessfully created #{dest}"
else
Views::no_items("directory #{dir}/tempo", :error)
end
end
|
.clean_records(options, args) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/tempo/controllers/records_controller.rb', line 41
def clean_records(options, args)
dir = File.join( options.fetch( :directory, ENV['HOME']), "tempo", "tempo_time_records")
if old_records_present? options
confirm = Tempo::Views::interactive_confirm_move_old_records
if confirm.positive_response?
move_old_records options
end
end
Views::interactive_progress "Loading records from #{dir}"
days = Model::TimeRecord.record_d_ids(options)
days.each do |d_id|
begin
date = "#{d_id[4..5].to_i}/#{d_id[6..7]}/#{d_id[0..3]}"
Views::interactive_progress_partial date
Model::TimeRecord.load_day_record(d_id, options)
Model::TimeRecord.save_to_file(options)
Model::TimeRecord.clear_all
rescue TimeConflictError => e
Views::message " exiting on error..."
Views::message "\nAn error occurred which prevented cleaning all the records on #{date}"
Views::message "Please repair the records in file #{dir}/#{Model::TimeRecord.file(d_id)}"
return Views::error e
end
end
Views::message "\nSuccess -- all files are clean!"
end
|
.initialize_from_records(options, args) ⇒ Object
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/tempo/controllers/records_controller.rb', line 8
def initialize_from_records(options, args)
dir = options.fetch( :directory, ENV['HOME'])
if File.exist?(File.join(dir, 'tempo'))
Tempo::Controllers::Projects.load directory: dir
else
FileRecord::Directory.create_new directory: dir
end
end
|
.move_old_records(options) ⇒ Object
36
37
38
39
|
# File 'lib/tempo/controllers/records_controller.rb', line 36
def move_old_records(options)
file_utility = FileRecord::FileUtility.new(Tempo::Model::TimeRecord, options)
file_utility.move_old_records
end
|
.old_records_present?(options) ⇒ Boolean
31
32
33
34
|
# File 'lib/tempo/controllers/records_controller.rb', line 31
def old_records_present?(options)
file_utility = FileRecord::FileUtility.new(Tempo::Model::TimeRecord, options)
file_utility.old_style_log_records_exists?
end
|