Module: Rtt
- Extended by:
- Rtt, CmdLineParser, QueryBuilder, ReportGenerator, Storage
- Included in:
- Rtt
- Defined in:
- lib/rtt.rb,
lib/rtt/task.rb,
lib/rtt/user.rb,
lib/rtt/client.rb,
lib/rtt/project.rb,
lib/rtt/storage.rb,
lib/rtt/query_builder.rb,
lib/rtt/cmd_line_parser.rb,
lib/rtt/report_generator.rb,
lib/rtt/interactive_configurator.rb
Defined Under Namespace
Modules: CmdLineParser, InteractiveConfigurator, QueryBuilder, ReportGenerator, Storage Classes: Client, Command, CommandNotFoundError, ConfigureCommand, DeleteCommand, ExportCommand, ImportCommand, ParametersNotMatchCommandSignatureError, PauseCommand, Project, QueryCommand, RenameCommand, ReportCommand, SetClientCommand, SetProjectCommand, SetUserCommand, StartCommand, StopCommand, Task, TaskNotStartedError, User
Constant Summary collapse
- VERSION =
'1.0'
Constants included from Storage
Constants included from ReportGenerator
ReportGenerator::DEFAULT_FILENAME, ReportGenerator::FIXED_FIELDS, ReportGenerator::FORMATS_ACCEPTED, ReportGenerator::REPORT_FIELDS, ReportGenerator::REPORT_FIELD_OUTPUT
Constants included from CmdLineParser
CmdLineParser::COMMAND_MAPPING
Instance Attribute Summary
Attributes included from ReportGenerator
Class Method Summary collapse
- .current_client ⇒ Object
- .current_project ⇒ Object
- .current_task ⇒ Object
- .current_user ⇒ Object
- .delete(options = {}) ⇒ Object
-
.list(options = {}) ⇒ Object
Lists all entries filtered by parameters.
-
.pause ⇒ Object
Used to set the client at system level.
-
.rename(task_name) ⇒ Object
Change the name of the current task.
-
.set_client(name = nil, configure = false) ⇒ Object
Used to set the client at system level.
- .set_project(project_name = nil, client_name = nil, configure = false) ⇒ Object
- .set_user(nickname = nil, configure = false) ⇒ Object
-
.start(task_name = nil) ⇒ Object
Starts a new timer.
-
.stop ⇒ Object
Stops the current task.
- .update_task(name, conditions) ⇒ Object
Methods included from Storage
export, import, init, migrate, missing_tables
Methods included from ReportGenerator
column_widths, custom_user_is_defined?, fill_user_information, fixed_fields_for_current_data, fixed_value, full_path, has_default_value?, report
Methods included from QueryBuilder
Methods included from CmdLineParser
capture, env_filters, env_variable, execute, execute_single, handle_error, puts_usage
Class Method Details
.current_client ⇒ Object
151 152 153 |
# File 'lib/rtt.rb', line 151 def current_client Client.first :active => true end |
.current_project ⇒ Object
155 156 157 |
# File 'lib/rtt.rb', line 155 def current_project Project.first :active => true end |
.current_task ⇒ Object
159 160 161 |
# File 'lib/rtt.rb', line 159 def current_task Task.first :active => true end |
.current_user ⇒ Object
25 26 27 28 29 |
# File 'lib/rtt.rb', line 25 def current_user active = User.first :active => true return active if active.present? User.find_or_create_active end |
.delete(options = {}) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/rtt.rb', line 31 def delete( = {}) if current_task && .blank? current_task.destroy else query().map(&:destroy) end end |
.list(options = {}) ⇒ Object
Lists all entries filtered by parameters
For example:
Rtt.list :from => '2010-5-3', :to => '2010-5-20'
73 74 75 76 77 78 79 |
# File 'lib/rtt.rb', line 73 def list = {} say 'Task List' say '=========' query().each do |task| say "Task: #{task.name} || Client: #{task.client.name} || Project: #{task.project.name} || User: #{task.user.nickname} || Elapsed time: #{task.duration} #{'[ACTIVE]' if task.active} \n" end end |
.pause ⇒ Object
Used to set the client at system level.
Usage
pause
87 88 89 |
# File 'lib/rtt.rb', line 87 def pause current_task.pause if current_task end |
.rename(task_name) ⇒ Object
Change the name of the current task.
Usage
rename ‘new_timer_name’ => Doesn’t change task#start_at
60 61 62 63 64 65 66 |
# File 'lib/rtt.rb', line 60 def rename task_name task = current_task if task task.name = task_name task.save end end |
.set_client(name = nil, configure = false) ⇒ Object
Used to set the client at system level.
Usage
set_client name
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/rtt.rb', line 97 def set_client(name = nil, configure = false) if name.blank? || configure extend(InteractiveConfigurator) configure_client(name) else raise ParametersNotMatchCommandSignatureError if name.blank? deactivate_current_client if current_client client = client(name) unless client.active client.activate else client.save end end end |
.set_project(project_name = nil, client_name = nil, configure = false) ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/rtt.rb', line 113 def set_project(project_name = nil, client_name = nil, configure = false) if project_name.blank? || configure extend(InteractiveConfigurator) configure_project(project_name, client_name) else raise ParametersNotMatchCommandSignatureError if project_name.blank? deactivate_current_project if current_project client = client(client_name) unless client_name.nil? project = Project.first_or_create :name => project_name project.client = client project.description = project_name unless project.active project.activate else project.save end end end |
.set_user(nickname = nil, configure = false) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rtt.rb', line 39 def set_user(nickname = nil, configure = false) user = if nickname.blank? current_user else User.first(:nickname => nickname) end current_user.deactivate if current_user if user.blank? || configure extend(InteractiveConfigurator) configure_user(nickname) else user.activate end end |
.start(task_name = nil) ⇒ Object
Starts a new timer. It stops the current task if there is any.
Usage
start a time new:
start ‘new_task’ TODO: Make it start PAUSED TASKS!
140 141 142 143 |
# File 'lib/rtt.rb', line 140 def start(task_name = nil) current_task.stop if current_task.present? && task_name.present? Task::task(task_name).start end |
.stop ⇒ Object
Stops the current task.
147 148 149 |
# File 'lib/rtt.rb', line 147 def stop current_task.stop if current_task end |
.update_task(name, conditions) ⇒ Object
20 21 22 23 |
# File 'lib/rtt.rb', line 20 def update_task(name, conditions) extend(InteractiveConfigurator) configure_task(name, conditions) end |