Class: Willpower::Events
- Inherits:
-
Thor
- Object
- Thor
- Willpower::Events
- Defined in:
- lib/willpower/commands/events.rb
Instance Method Summary collapse
- #create ⇒ Object
- #list ⇒ Object
-
#show(date) ⇒ Object
:reek:ControlParameter.
Instance Method Details
#create ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/willpower/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 ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/willpower/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) ⇒ Object
:reek:ControlParameter
30 31 32 33 34 |
# File 'lib/willpower/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 |