Class: Tempo::Controllers::Projects
- Inherits:
-
Base
- Object
- Base
- Tempo::Controllers::Projects
show all
- Defined in:
- lib/tempo/controllers/projects_controller.rb
Class Method Summary
collapse
Methods inherited from Base
filter_projects_by_title, fuzzy_match, reassemble_the
Class Method Details
.add(options, args, tags = nil) ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/tempo/controllers/projects_controller.rb', line 42
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
end
@projects.save_to_file
Views::project_added project
end
end
|
.delete(options, args) ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/tempo/controllers/projects_controller.rb', line 61
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
Views::projects_list_view if options[:list]
Views::project_deleted match
end
end
end
|
.index(options, args) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/tempo/controllers/projects_controller.rb', line 14
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 ⇒ Object
8
9
10
11
12
|
# File 'lib/tempo/controllers/projects_controller.rb', line 8
def load
if File.exists?( File.join( ENV['HOME'], 'tempo', @projects.file ))
@projects.read_from_file
end
end
|
.tag(options, args) ⇒ Object
add a project with tags, or tag or untag an existing project
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/tempo/controllers/projects_controller.rb', line 81
def tag options, args
tags = options[:tag].split if options[:tag]
untags = options[:untag].split if options[:untag]
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
Views::project_tags match
end
end
end
|