Module: Tempo::Views
- Defined in:
- lib/tempo/views/base.rb,
lib/tempo/views/reporter.rb,
lib/tempo/views/interactive.rb,
lib/tempo/views/report_view.rb,
lib/tempo/views/arrange_view.rb,
lib/tempo/views/projects_view.rb,
lib/tempo/views/formatters/base.rb,
lib/tempo/views/time_record_view.rb,
lib/tempo/views/view_records/log.rb,
lib/tempo/views/formatters/screen.rb,
lib/tempo/views/view_records/base.rb,
lib/tempo/views/view_records/project.rb,
lib/tempo/views/formatters/interactive.rb,
lib/tempo/views/view_records/composite.rb,
lib/tempo/views/view_records/container.rb,
lib/tempo/views/view_records/container.rb,
lib/tempo/views/view_records/time_record.rb
Defined Under Namespace
Modules: Formatters, ViewRecords
Classes: Reporter
Class Method Summary
collapse
-
.already_exists_error(item, request) ⇒ Object
-
.ambiguous_project(matches, command) ⇒ Object
-
.arrange_already_root(project) ⇒ Object
-
.arrange_parent_child(parent, child) ⇒ Object
-
.arrange_parse_error ⇒ Object
-
.arrange_root(project) ⇒ Object
-
.checkout_assistance(options = {}) ⇒ Object
-
.delete_time_record_view(time_record) ⇒ Object
-
.end_time_record_view(time_record) ⇒ Object
-
.error(message) ⇒ Object
-
.initialize_view_options(command, global_options, options) ⇒ Object
called in the pre block, pushes relavent options to the reporter.
-
.interactive_confirm_clean ⇒ Object
-
.interactive_confirm_move_old_records ⇒ Object
-
.interactive_progress(message) ⇒ Object
-
.interactive_progress_partial(message) ⇒ Object
-
.interactive_query(query) ⇒ Object
Must be allowed to return results.
-
.message(message, category = :info) ⇒ Object
-
.no_items(items, category = :info) ⇒ Object
-
.no_match_error(items, request, plural = true) ⇒ Object
-
.options_report(command, global_options, options, args) ⇒ Object
called in the preblock when verbose = true.
-
.project_added(project) ⇒ Object
-
.project_already_current(project) ⇒ Object
-
.project_assistance ⇒ Object
-
.project_checkout(project) ⇒ Object
-
.project_deleted(project) ⇒ Object
-
.project_tags(project) ⇒ Object
-
.project_view(project, depth = 0) ⇒ Object
-
.projects_flat_list_view(projects = Tempo::Model::Project.index) ⇒ Object
list of sorted projects, no hierarchy.
-
.projects_list_view(projects = Tempo::Model::Project.index, parent = :root, depth = 0) ⇒ Object
-
.report_records_view(options = {}) ⇒ Object
-
.start_time_record_view(time_record) ⇒ Object
-
.time_record_view(time_record, options = {}) ⇒ Object
Container sends postpone: true through options.
-
.update_time_record_view(time_record) ⇒ Object
-
.warning(message) ⇒ Object
Class Method Details
.already_exists_error(item, request) ⇒ Object
73
74
75
|
# File 'lib/tempo/views/base.rb', line 73
def already_exists_error(item, request)
ViewRecords::Message.new "#{item} '#{request}' already exists", category: :error
end
|
.ambiguous_project(matches, command) ⇒ Object
.arrange_already_root(project) ⇒ Object
.arrange_parent_child(parent, child) ⇒ Object
.arrange_parse_error ⇒ Object
22
23
24
|
# File 'lib/tempo/views/arrange_view.rb', line 22
def arrange_parse_error
ViewRecords::Message.new "arrange requires a colon (:) in the arguments", category: :error
end
|
.arrange_root(project) ⇒ Object
.checkout_assistance(options = {}) ⇒ Object
.delete_time_record_view(time_record) ⇒ Object
25
26
27
28
|
# File 'lib/tempo/views/time_record_view.rb', line 25
def delete_time_record_view(time_record)
ViewRecords::Message.new "time record deleted:"
time_record_view time_record
end
|
.end_time_record_view(time_record) ⇒ Object
15
16
17
18
|
# File 'lib/tempo/views/time_record_view.rb', line 15
def end_time_record_view(time_record)
ViewRecords::Message.new "time record ended:"
time_record_view time_record
end
|
.error(message) ⇒ Object
64
65
66
|
# File 'lib/tempo/views/base.rb', line 64
def error(message)
ViewRecords::Message.new message, category: :error
end
|
.initialize_view_options(command, global_options, options) ⇒ Object
called in the pre block, pushes relavent options to the reporter
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/tempo/views/base.rb', line 6
def initialize_view_options(command, global_options, options)
view_opts = {}
view_opts[:verbose] = global_options[:verbose]
view_opts[:id] = global_options[:id]
case command
when :project, :p
if global_options[:verbose]
view_opts[:id] = true
view_opts[:tags] = true
view_opts[:active] = true
view_opts[:depth] = true
else
if options[:list]
view_opts[:depth] = true
view_opts[:active] = true
end
view_opts[:tags] = options[:tag] || options[:untag] ? true : false
view_opts[:id] = global_options[:id] || options[:id] ? true : false
end
when :report, :r
if /^p(roject)?$/.match(options[:order]) && ! global_options[:verbose]
view_opts[:bullet_report] = true
end
end
Tempo::Views::Reporter.add_options view_opts
end
|
.interactive_confirm_clean ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/tempo/views/interactive.rb', line 18
def interactive_confirm_clean
query = "\nCleaning Tempo records resaves all records, looking for errors.\n" +
"In the event that a record cannot be corrected, you wil be prompted to repair the record manually.\n" +
"A backup of the records will also be created before any changes are made.\n\n" +
"Do you wish to continue? [YyNn]"
interactive_query(query)
end
|
.interactive_confirm_move_old_records ⇒ Object
26
27
28
29
|
# File 'lib/tempo/views/interactive.rb', line 26
def interactive_confirm_move_old_records
query = "\nYou have files which match an older file structure, do you want to move them so they will be included in your records? [YyNn]"
interactive_query(query)
end
|
.interactive_progress(message) ⇒ Object
10
11
12
|
# File 'lib/tempo/views/interactive.rb', line 10
def interactive_progress(message)
ViewRecords::Message.new message, category: :progress
end
|
.interactive_progress_partial(message) ⇒ Object
14
15
16
|
# File 'lib/tempo/views/interactive.rb', line 14
def interactive_progress_partial(message)
ViewRecords::Message.new message, category: :progress_partial
end
|
.interactive_query(query) ⇒ Object
Must be allowed to return results
6
7
8
|
# File 'lib/tempo/views/interactive.rb', line 6
def interactive_query(query)
ViewRecords::Query.new query
end
|
.message(message, category = :info) ⇒ Object
56
57
58
|
# File 'lib/tempo/views/base.rb', line 56
def message(message, category=:info)
ViewRecords::Message.new message, category: category
end
|
.no_items(items, category = :info) ⇒ Object
48
49
50
51
52
53
54
|
# File 'lib/tempo/views/base.rb', line 48
def no_items(items, category=:info)
ViewRecords::Message.new "no #{items} exist", category: category
if items == "projects"
ViewRecords::Message.new "You must create at least one project before you can begin tracking time"
ViewRecords::Message.new "run `tempo project --help` for more information"
end
end
|
.no_match_error(items, request, plural = true) ⇒ Object
68
69
70
71
|
# File 'lib/tempo/views/base.rb', line 68
def no_match_error(items, request, plural=true)
match = plural ? "match" : "matches"
ViewRecords::Message.new "no #{items} #{match} the request: #{request}", category: :error
end
|
.options_report(command, global_options, options, args) ⇒ Object
called in the preblock when verbose = true
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/tempo/views/base.rb', line 34
def options_report(command, global_options, options, args)
globals_list = "global options: "
global_options.each {|k,v| globals_list += "#{k} = #{v}, " if k.kind_of? String and k.length > 1 and !v.nil? }
ViewRecords::Message.new globals_list[0..-2], category: :debug
options_list = "command options: "
options.each {|k,v| options_list += "#{k} = #{v}, " if k.kind_of? String and k.length > 1 and !v.nil? }
ViewRecords::Message.new options_list[0..-2], category: :debug
ViewRecords::Message.new "command: #{command}", category: :debug
ViewRecords::Message.new "args: #{args}", category: :debug
end
|
.project_added(project) ⇒ Object
38
39
40
41
|
# File 'lib/tempo/views/projects_view.rb', line 38
def project_added(project)
ViewRecords::Message.new "added project:"
project_view project
end
|
.project_already_current(project) ⇒ Object
53
54
55
56
|
# File 'lib/tempo/views/projects_view.rb', line 53
def project_already_current(project)
ViewRecords::Message.new "already on project:"
project_view project
end
|
.project_assistance ⇒ Object
75
76
77
78
79
|
# File 'lib/tempo/views/projects_view.rb', line 75
def project_assistance
ViewRecords::Message.new "you need to set up a new project before running your command"
ViewRecords::Message.new "run`tempo project --help` for more information"
no_items "projects", :error
end
|
.project_checkout(project) ⇒ Object
48
49
50
51
|
# File 'lib/tempo/views/projects_view.rb', line 48
def project_checkout(project)
ViewRecords::Message.new "switched to project:"
project_view project
end
|
.project_deleted(project) ⇒ Object
43
44
45
46
|
# File 'lib/tempo/views/projects_view.rb', line 43
def project_deleted(project)
ViewRecords::Message.new "deleted project:"
project_view project
end
|
58
59
60
61
|
# File 'lib/tempo/views/projects_view.rb', line 58
def project_tags(project)
ViewRecords::Message.new "altered project tags:"
project_view project
end
|
.project_view(project, depth = 0) ⇒ Object
5
6
7
|
# File 'lib/tempo/views/projects_view.rb', line 5
def project_view project, depth=0
ViewRecords::Project.new project, depth: depth
end
|
.projects_flat_list_view(projects = Tempo::Model::Project.index) ⇒ Object
list of sorted projects, no hierarchy
29
30
31
32
33
34
35
36
|
# File 'lib/tempo/views/projects_view.rb', line 29
def projects_flat_list_view(projects=Tempo::Model::Project.index)
Tempo::Model::Project.sort_by_title projects do |projects|
projects.each do |p|
project_view p
end
end
end
|
.projects_list_view(projects = Tempo::Model::Project.index, parent = :root, depth = 0) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/tempo/views/projects_view.rb', line 9
def projects_list_view(projects=Tempo::Model::Project.index, parent=:root, depth=0)
return no_items( "projects" ) if projects.empty?
Tempo::Model::Project.sort_by_title projects do |projects|
projects.each do |p|
if p.parent == parent
project_view p, depth
if not p.children.empty?
next_depth = depth + 1
next_parent = p.id
child_array = projects_list_view projects, next_parent, next_depth
end
end
end
end
end
|
.report_records_view(options = {}) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/tempo/views/report_view.rb', line 5
def report_records_view(options={})
projects = options.fetch(:projects, Tempo::Model::Project.index)
return no_items("projects") if projects.empty?
time_records = options.fetch( :time_records, Tempo::Model::TimeRecord.days_index )
return no_items("time records") if time_records.empty?
if options[:order] == "date" || options[:order] == "d"
order_by_date time_records
elsif options[:order] == "project" || options[:order] == "p"
order_by_project projects, time_records
else
return error "Unable to report time records sorted by '#{options[:order]}'"
end
end
|
.start_time_record_view(time_record) ⇒ Object
10
11
12
13
|
# File 'lib/tempo/views/time_record_view.rb', line 10
def start_time_record_view(time_record)
ViewRecords::Message.new "time record started:"
time_record_view time_record
end
|
.time_record_view(time_record, options = {}) ⇒ Object
Container sends postpone: true through options
6
7
8
|
# File 'lib/tempo/views/time_record_view.rb', line 6
def time_record_view(time_record, options={})
ViewRecords::TimeRecord.new time_record, options
end
|
.update_time_record_view(time_record) ⇒ Object
20
21
22
23
|
# File 'lib/tempo/views/time_record_view.rb', line 20
def update_time_record_view(time_record)
ViewRecords::Message.new "time record updated:"
time_record_view time_record
end
|
.warning(message) ⇒ Object
60
61
62
|
# File 'lib/tempo/views/base.rb', line 60
def warning(message)
ViewRecords::Message.new message, category: :warning
end
|