class Agile::Events
Public Instance Methods
create()
click to toggle source
# File lib/agile/commands/events.rb, line 4 def create error_checking_events cli = HighLine.new event_description = cli.ask("description for event: ", String) RestClient.post"#{CONFIG['current_remote']}/api/v1/events/", event_type: type_cli, date: date_cli, start_time: start_time_cli, end_time: end_time_cli, desc: event_description, current_user: CONFIG["current_user"], project_id: CONFIG["current_project_id"] say "Successfully added new event!" end
list()
click to toggle source
# File lib/agile/commands/events.rb, line 16 def list error_checking_events response = RestClient.get "#{CONFIG['current_remote']}/api/v1/events/" say "<<Project events>>" JSON.parse(response).each do |event| if event["project_id"] == CONFIG["current_project_id"] info = parse_info(event) say "#{(event['event_type']).upcase} starts at #{parse_date(event)} #{info[:start]} and ends at #{info[:end]}" end end end
show(date)
click to toggle source
:reek: ControlParameter
# File lib/agile/commands/events.rb, line 30 def show(date) error_checking_events response = RestClient.get "#{CONFIG['current_remote']}/api/v1/events/" JSON.parse(response).each { |event| puts_info(event) if event["date"] == date } end
Private Instance Methods
date_cli()
click to toggle source
# File lib/agile/commands/events.rb, line 69 def date_cli cli = HighLine.new cli.ask("Select data for event (yyyy.mm.dd): ", String) end
end_time_cli()
click to toggle source
# File lib/agile/commands/events.rb, line 79 def end_time_cli cli = HighLine.new cli.ask("Select end time for event (hh:mm): ", String) end
error_checking_events()
click to toggle source
# File lib/agile/commands/events.rb, line 38 def error_checking_events abort "You haven't done init yet!" unless CONFIG["current_remote"] abort "Please, log in!" unless CONFIG["current_user"] abort "Please, choose a project to work with!" unless CONFIG["current_project"] end
norm_time(param)
click to toggle source
# File lib/agile/commands/events.rb, line 59 def norm_time(param) Time.parse(param).strftime("%I:%M") end
parse_date(event)
click to toggle source
# File lib/agile/commands/events.rb, line 55 def parse_date(event) Date.parse(event["date"]).strftime("%B %d") end
parse_info(event)
click to toggle source
# File lib/agile/commands/events.rb, line 50 def parse_info(event) { start: norm_time(event["start_time"]), end: norm_time(event["end_time"]) } end
puts_info(event)
click to toggle source
# File lib/agile/commands/events.rb, line 44 def puts_info(event) say "Type of event: #{event['event_type']}\nDescription: #{event['description']}" say "Start at #{norm_time(event['start_time'])}\nEnd at #{norm_time(event['end_time'])}" puts "" end
start_time_cli()
click to toggle source
# File lib/agile/commands/events.rb, line 74 def start_time_cli cli = HighLine.new cli.ask("Select start time for event (hh:mm): ", String) end
type_cli()
click to toggle source
# File lib/agile/commands/events.rb, line 63 def type_cli cli = HighLine.new puts "0 - scrum\n1 - retro\n2 - planning\n3 - review" cli.ask("Choose type of event (select number): ", Integer) end