agile-cli 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 13b04ca67f9a464a663e5660fb6754f85b83708c7120c3b6944ec3ddb022ef19
4
- data.tar.gz: 84706f2a92b9fa946e9d064e8839a9592242d2b10f159c5316e5642e7ef3838e
3
+ metadata.gz: da7e64a0b4a6304722aea1701cab922e81e381a2a1650ecfd2d8f1f7939be2ff
4
+ data.tar.gz: 61fbe335a433053cc089c1ca31eda08b15b4b46bf92fdceb8e2faaa87a3b13cb
5
5
  SHA512:
6
- metadata.gz: b053d4681f2208eec6c08dfd3703bfd53a4c5b595a09cb79e5ff2b3da7fbcfbfa36b75153a06461bebe31bdd9b30617fcca2f65cc6a6825cf0589da3ccb5a838
7
- data.tar.gz: 16dd40eb7b911f3282e95caffe586aff1b5eeadbc30fdff9c36a77cd3999ba2a44a80fb08f1e6c93ea923c94240f796816f0e3a3dadf5850cea62a91f24f9bf5
6
+ metadata.gz: 4ab2a72ddaf79eedf8067a6f39efa41bb7d36859e00674fce37c0613ba88abe2be10f7b7d88ca9b8b024c932dc3e49758ac6ef1a24bb680222e8113ea6c5287b
7
+ data.tar.gz: bdcc3196486cd0cfae0ac88164b46ae726e0211da344b92539625941353f2d070697176191ec83df944cb890d3eded926b89c2b422e3c96beff6872a04616c02
@@ -0,0 +1,86 @@
1
+ module Agile
2
+ class Events < Thor
3
+ desc "create", "Add new event"
4
+ def create
5
+ cli = HighLine.new
6
+ event_description = cli.ask("description for event: ", String)
7
+ RestClient.post"#{CONFIG['current_remote']}/api/v1/events/",
8
+ event_type: type_cli, frequency: frequency_cli, date: date_cli,
9
+ start_time: start_time_cli, end_time: end_time_cli, desc: event_description,
10
+ current_user: CONFIG["current_user"]
11
+ say "Successfully added new event!"
12
+ end
13
+
14
+ desc "list", "Show all events"
15
+ def list
16
+ response = RestClient.get "#{CONFIG['current_remote']}/api/v1/events/"
17
+ say "<<Project events>>"
18
+ JSON.parse(response).each do |event|
19
+ if event["project_id"] == CONFIG["current_project_id"]
20
+ info = parse_info(event)
21
+ puts "#{event['event_type']} starting #{parse_date(event)} at #{info[:start]} and end at #{info[:end]}"
22
+ end
23
+ end
24
+ end
25
+
26
+ desc "show <date (yyyy-mm-dd)>", "Show event"
27
+ # :reek:ControlParameter
28
+ def show(date)
29
+ response = RestClient.get "#{CONFIG['current_remote']}/api/v1/events/"
30
+ JSON.parse(response).each { |event| puts_info(event) if event["date"] == date }
31
+ end
32
+
33
+ private
34
+
35
+ def puts_info(event)
36
+ say "Type of event: #{event['event_type']}\nDescription: #{event['description']}"
37
+ say "Start at #{norm_time(event['start_time'])}\nEnd at #{norm_time(event['end_time'])}"
38
+ puts ""
39
+ end
40
+
41
+ def parse_info(event)
42
+ { start: norm_time(event["start_time"]),
43
+ end: norm_time(event["end_time"]) }
44
+ end
45
+
46
+ def parse_date(event)
47
+ Date.parse(event["date"]).strftime("%d %B")
48
+ end
49
+
50
+ def norm_time(param)
51
+ Time.parse(param).strftime("%I:%M")
52
+ end
53
+
54
+ def type_cli
55
+ cli = HighLine.new
56
+ puts "0 - scrum\n1 - retro\n2 - planning\n3 - review"
57
+ cli.ask("Choose type of event (select number): ", Integer)
58
+ end
59
+
60
+ def frequency_cli
61
+ cli = HighLine.new
62
+ say "0 - daily\n1 - weekly\n2 - monthly\n3 - not regular"
63
+ cli.ask("Choose frequency for event: ", Integer)
64
+ end
65
+
66
+ def date_cli
67
+ cli = HighLine.new
68
+ cli.ask("Select data for event (yyyy.mm.dd): ", String)
69
+ end
70
+
71
+ def start_time_cli
72
+ cli = HighLine.new
73
+ cli.ask("Select start time for event (hh:mm): ", String)
74
+ end
75
+
76
+ def end_time_cli
77
+ cli = HighLine.new
78
+ cli.ask("Select end time for event (hh:mm): ", String)
79
+ end
80
+ end
81
+
82
+ class CLI < Thor
83
+ desc Rainbow("events SUBCOMMAND ...ARGS").cornflower, Rainbow("Command for work with events").darkgoldenrod
84
+ subcommand "events", Events
85
+ end
86
+ end
@@ -19,10 +19,22 @@ module Agile
19
19
  response = RestClient.get "#{CONFIG['current_remote']}/api/v1/userproject/#{CONFIG['current_user']}"
20
20
  say Rainbow("<<Your Projects>>").cornflower
21
21
  JSON.parse(response).each do |proj|
22
- say proj.first.values[1]
22
+ if proj.first.values[1] == CONFIG["current_project"]
23
+ say "* #{proj.first.values[1]}"
24
+ else
25
+ say proj.first.values[1]
26
+ end
23
27
  end
24
28
  end
25
29
 
30
+ desc "show <project>", "Show project"
31
+ def show(project)
32
+ response = RestClient.get "#{CONFIG['current_remote']}/api/v1/projects/#{project}"
33
+ row = JSON.parse(response)
34
+ say "Project: #{row['data']['attributes']['name']}"
35
+ say "Description: #{row['data']['attributes']['description']}"
36
+ end
37
+
26
38
  desc "use <project>", "Select current project"
27
39
  def use(project)
28
40
  error_checking_projects
@@ -30,36 +42,72 @@ module Agile
30
42
  project_search(response, project)
31
43
  end
32
44
 
33
- desc "update <project_name> <new_project_name>", "Update project name"
34
- def update(project, new_project)
45
+ desc "update <project_name> ", "Update project"
46
+ def update(project)
35
47
  error_checking_projects
36
- resp = RestClient.get "#{CONFIG['current_remote']}/api/v1/userproject/#{CONFIG['current_user']}"
37
- pr_list = JSON.parse(resp).map { |array| array.map { |hash| hash.values_at("name").include?(project) } }
38
- if pr_list.include?([true])
39
- RestClient.put "#{CONFIG['current_remote']}/api/v1/projects/#{project}", name: project, new_name: new_project
40
- say "Updated from #{project} to #{new_project}"
48
+ choice = HighLine.new
49
+ answer = choice.ask("Choose what you need to edit : name or description (N or D): ", String)
50
+ if answer == "N"
51
+ update_name(project)
52
+ elsif answer == "D"
53
+ update_description(project)
41
54
  else
42
- say "Error"
55
+ say "Try again"
43
56
  end
44
57
  end
45
58
 
59
+ # def update(project, new_project)
60
+ # error_checking_projects
61
+ # resp = RestClient.get "#{CONFIG['current_remote']}/api/v1/userproject/#{CONFIG['current_user']}"
62
+ # pr_list = JSON.parse(resp).map { |array| array.map { |hash| hash.values_at("name").include?(project) } }
63
+ # if pr_list.include?([true])
64
+ # RestClient.put "#{CONFIG['current_remote']}/api/v1/projects/#{project}", name: project, new_name: new_project
65
+ # say "Updated from #{project} to #{new_project}"
66
+ # else
67
+ # say "Error"
68
+ # end
69
+ # end
70
+
46
71
  private
47
72
 
73
+ def update_name(project)
74
+ choice = HighLine.new
75
+ new_project = choice.ask("Enter new name of project: ", String)
76
+ RestClient.put "#{CONFIG['current_remote']}/api/v1/projects/#{project}",
77
+ name: project, new_name: new_project, type: 1
78
+ say "Updated from #{project} to #{new_project}"
79
+ end
80
+
81
+ def update_description(project)
82
+ choice = HighLine.new
83
+ new_description = choice.ask("Enter new description for project: ", String)
84
+ RestClient.put "#{CONFIG['current_remote']}/api/v1/projects/#{project}",
85
+ name: project, new_description: new_description
86
+ say "Updated description to #{new_description}"
87
+ end
88
+
48
89
  def error_checking_projects
49
90
  abort "You haven't done init yet!" unless CONFIG["current_remote"]
50
91
  abort "Please, log in!" unless CONFIG["current_user"]
51
92
  end
52
93
 
53
94
  def project_search(response, project)
54
- info = JSON.parse(response).map { |hash| hash.values[1] }
55
- if info.include?(project)
56
- CONFIG["current_project"] = project
57
- File.write("#{GEM_PATH}.config.json", JSON.generate(CONFIG))
58
- say "Your project: #{project}"
59
- else
95
+ info = JSON.parse(response).map(&:values)
96
+ id_pr = info.map { |arr| arr[0] if arr[1] == project }
97
+ id_pr.delete_if(&:nil?)
98
+ if id_pr.empty?
60
99
  say "Such project does not exist. Try again"
100
+ else
101
+ write_to_config(id_pr, project)
102
+ say "Your project: #{project}"
61
103
  end
62
104
  end
105
+
106
+ def write_to_config(id_pr, project)
107
+ CONFIG["current_project_id"] = id_pr.first
108
+ CONFIG["current_project"] = project
109
+ File.write("#{GEM_PATH}.config.json", JSON.generate(CONFIG))
110
+ end
63
111
  end
64
112
 
65
113
  class CLI < Thor
@@ -0,0 +1,87 @@
1
+ module Agile
2
+ class Tickets < Thor
3
+ desc "create <ticket>", "Add new ticket"
4
+ def create(ticket)
5
+ ticket_name = ticket
6
+ cli = HighLine.new
7
+ ticket_description = cli.ask("description for ticket: ", String)
8
+ RestClient.post"#{CONFIG['current_remote']}/api/v1/tickets/",
9
+ project_id: CONFIG["current_project_id"], name: ticket_name,
10
+ user: CONFIG["current_user"], desc: ticket_description
11
+ say "Successfully added new ticket!"
12
+ end
13
+
14
+ desc "list", "Tickets list"
15
+ def list
16
+ response = RestClient.get "#{CONFIG['current_remote']}/api/v1/tickets/"
17
+ info = JSON.parse(response)
18
+ say Rainbow("<<All tickets>>").cornflower
19
+ info.each { |ticket| puts_tickets(info) if ticket["project_id"] == CONFIG["current_project_id"] }
20
+ end
21
+
22
+ desc "show <name_ticket>", "Show ticket"
23
+ def show(ticket)
24
+ response = RestClient.get "#{CONFIG['current_remote']}/api/v1/tickets/#{ticket}"
25
+ row = JSON.parse(response)
26
+ say "Ticket: #{row['data']['attributes']['name']}"
27
+ say "Description: #{row['data']['attributes']['description']}"
28
+ end
29
+
30
+ desc "update <ticket>", "update ticket"
31
+ def update(ticket)
32
+ choice = HighLine.new
33
+ answer = choice.ask("Choose what you need to edit : name or description (N or D): ", String)
34
+ if answer == "N"
35
+ update_name(ticket)
36
+ elsif answer == "D"
37
+ update_description(ticket)
38
+ else
39
+ say "Try again"
40
+ end
41
+ end
42
+
43
+ # desc "take <ticket>", "Take ticket"
44
+ # def take(ticket)
45
+ # # call api to take ticket
46
+ # CONFIG["tickets"].push(ticket)
47
+ # File.write("#{GEM_PATH}.config.json", JSON.generate(CONFIG))
48
+ # puts "you take ticket"
49
+ # end
50
+ #
51
+ # desc "my_list", "Your tickets list"
52
+ # def my_list
53
+ # CONFIG["tickets"].each do |name|
54
+ # if name == CONFIG["tickets"]
55
+ # say "* #{name}"
56
+ # else
57
+ # say name
58
+ # end
59
+ # end
60
+ # end
61
+ private
62
+
63
+ def puts_tickets(info)
64
+ info.each { |ticket| puts ticket["name"] }
65
+ end
66
+
67
+ def update_name(ticket)
68
+ choice = HighLine.new
69
+ new_ticket = choice.ask("Enter new name of ticket: ", String)
70
+ RestClient.put "#{CONFIG['current_remote']}/api/v1/tickets/#{ticket}", name: ticket, new_name: new_ticket, type: 1
71
+ say "Updated from #{ticket} to #{new_ticket}"
72
+ end
73
+
74
+ def update_description(ticket)
75
+ choice = HighLine.new
76
+ new_description = choice.ask("Enter new description of ticket: ", String)
77
+ RestClient.put "#{CONFIG['current_remote']}/api/v1/tickets/#{ticket}",
78
+ name: ticket, new_description: new_description
79
+ say "Updated description to #{new_description}"
80
+ end
81
+ end
82
+
83
+ class CLI < Thor
84
+ desc Rainbow("tickets SUBCOMMAND ...ARGS").cornflower, Rainbow("Command for work with tickets").darkgoldenrod
85
+ subcommand "tickets", Tickets
86
+ end
87
+ end
@@ -1,5 +1,5 @@
1
1
  module Agile
2
- VERSION = "0.0.14".freeze
2
+ VERSION = "0.0.15".freeze
3
3
  GITHUB_URL = %(https://github.com/login).freeze
4
4
  TERMINAL_STYLE = { border_x: "=", border_i: "x", padding_left: 3 }.freeze
5
5
  CLIENT_ID = "8bf42da7e4f9032ac5d8".freeze
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agile-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - rubizza-camp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-26 00:00:00.000000000 Z
11
+ date: 2019-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline
@@ -235,6 +235,7 @@ files:
235
235
  - lib/agile/assets/manifesto.txt
236
236
  - lib/agile/commands/dod.rb
237
237
  - lib/agile/commands/dor.rb
238
+ - lib/agile/commands/events.rb
238
239
  - lib/agile/commands/hello.rb
239
240
  - lib/agile/commands/help.rb
240
241
  - lib/agile/commands/init.rb
@@ -243,6 +244,7 @@ files:
243
244
  - lib/agile/commands/principles.rb
244
245
  - lib/agile/commands/projects.rb
245
246
  - lib/agile/commands/remotes.rb
247
+ - lib/agile/commands/tickets.rb
246
248
  - lib/agile/commands/values.rb
247
249
  - lib/agile/commands/version.rb
248
250
  - lib/agile/constants.rb