Class: Tempo::Controllers::Arrange

Inherits:
Base
  • Object
show all
Defined in:
lib/tempo/controllers/arrange_controller.rb

Class Method Summary collapse

Methods inherited from Base

filter_projects_by_title, fuzzy_match, reassemble_the

Class Method Details

.make_child_project(options, parent_args, child_args) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/tempo/controllers/arrange_controller.rb', line 44

def make_child_project(options, parent_args, child_args)
  parent = match_project :arrange, options, parent_args
  child = match_project :arrange, options, child_args
  parent << child
  @projects.save_to_file options
  Views::arrange_parent_child parent, child
end

.make_root_project(options, args) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/tempo/controllers/arrange_controller.rb', line 32

def make_root_project(options, args)
  root = match_project :arrange, options, args
  if root.parent == :root
    Views::arrange_already_root root
  else
    parent = match_project :arrange, {id: true}, root.parent
    parent.remove_child root
    @projects.save_to_file options
    Views::arrange_root root
  end
end

.parse(options, args) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/tempo/controllers/arrange_controller.rb', line 8

def parse(options, args)

  return Views.project_assistance if Model::Project.index.empty?

  return Views::arrange_parse_error unless args.include? ":"

  parent_args = []
  child_args = []
  in_parent = true
  args.each do |a|
    if a != ":"
      in_parent ? parent_args << a : child_args << a
    else
      in_parent = false
    end
  end

  if parent_args.empty?
    make_root_project options, child_args
  else
    make_child_project options, parent_args, child_args
  end
end