class Tempo::Controllers::Projects
Public Class Methods
add(options, args, tags=nil)
click to toggle source
# File lib/tempo/controllers/projects_controller.rb, line 45 def add(options, args, tags=nil) request = reassemble_the args if @projects.include? request Views::already_exists_error "project", request else project = @projects.new({ title: request, tags: tags }) if @projects.index.length == 1 @projects.current = project # arrange the project as the child of the current project elsif options[:child] @projects.current << project end @projects.save_to_file options Views::project_added project end end
delete(options, args)
click to toggle source
# File lib/tempo/controllers/projects_controller.rb, line 68 def delete(options, args) reassemble_the args, options[:delete] match = match_project :delete, options, args if match if match == @projects.current return Views::ViewRecords::Message.new "cannot delete the active project", category: :error end if @projects.index.include?(match) match.delete @projects.save_to_file options Views::projects_list_view if options[:list] Views::project_deleted match end end end
index(options, args)
click to toggle source
# File lib/tempo/controllers/projects_controller.rb, line 17 def index(options, args) request = reassemble_the args if args.empty? Views::projects_list_view else matches = filter_projects_by_title options, args if matches.empty? Views::no_match_error "projects", request else Views::projects_list_view matches end end end
load(options={})
click to toggle source
# File lib/tempo/controllers/projects_controller.rb, line 8 def load(options={}) directory = options.fetch( :directory, ENV['HOME']) if File.exists?( File.join( directory, 'tempo', @projects.file )) @projects.read_from_file options end end
show_active()
click to toggle source
# File lib/tempo/controllers/projects_controller.rb, line 36 def show_active if @projects.index.empty? Views::no_items "projects" else Views::Reporter.add_options active: true Views::project_view @projects.current end end
tag(options, args)
click to toggle source
add a project with tags, or tag or untag an existing project
# File lib/tempo/controllers/projects_controller.rb, line 88 def tag(options, args) # TODO @projects_find_by_tag if args.empty? tags = options[:tag].split if options[:tag] untags = options[:untag].split if options[:untag] # add a new project if options[:add] add options, args, tags else command = options[:tag] ? "tag" : "untag" match = match_project command, options, args if match match.tag tags match.untag untags @projects.save_to_file options Views::project_tags match end end end