Class: Agile::Projects

Inherits:
Thor
  • Object
show all
Defined in:
lib/agile/commands/projects.rb

Instance Method Summary collapse

Instance Method Details

#create(project_name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/agile/commands/projects.rb', line 5

def create(project_name)
  error_checking_projects
  response = RestClient.post "#{CONFIG['current_remote']}/api/v1/projects/",
                             name: project_name, current_user: CONFIG["current_user"]
  if response.body
    say "Successfully created project #{project_name}"
  else
    say "Try again"
  end
end

#listObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/agile/commands/projects.rb', line 17

def list
  error_checking_projects
  response = RestClient.get "#{CONFIG['current_remote']}/api/v1/userproject/#{CONFIG['current_user']}"
  say Rainbow("<<Your Projects>>").cornflower
  JSON.parse(response).each do |proj|
    if proj.first.values[1] == CONFIG["current_project"]
      say "* #{proj.first.values[1]}"
    else
      say proj.first.values[1]
    end
  end
end

#show(project) ⇒ Object



31
32
33
34
35
36
# File 'lib/agile/commands/projects.rb', line 31

def show(project)
  response = RestClient.get "#{CONFIG['current_remote']}/api/v1/projects/#{project}"
  row = JSON.parse(response)
  say "Project: #{row['data']['attributes']['name']}"
  say "Description: #{row['data']['attributes']['description']}"
end

#update(project) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/agile/commands/projects.rb', line 46

def update(project)
  error_checking_projects
  choice = HighLine.new
  answer = choice.ask("Choose what you need to edit : name or description (N or D): ", String)
  if answer == "N"
    update_name(project)
  elsif answer == "D"
    update_description(project)
  else
    say "Try again"
  end
end

#use(project) ⇒ Object



39
40
41
42
43
# File 'lib/agile/commands/projects.rb', line 39

def use(project)
  error_checking_projects
  response = RestClient.get "#{CONFIG['current_remote']}/api/v1/projects/"
  project_search(response, project)
end