-
Notifications
You must be signed in to change notification settings - Fork 26
Daniela & Cloudy - Leaves #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…lso, set up test helper with all require_realtives.
…rinted on the screen
slack.rbWhat We're Looking For
|
| @@ -0,0 +1,34 @@ | |||
| #lib/channel.rb | |||
| require 'httparty' | |||
| require 'awesome_print' | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here! Doing this sort of double inclusion causes warnings like this:
/Users/devin/.rbenv/versions/2.5.5/lib/ruby/gems/2.5.0/gems/colorize-0.8.1/lib/colorize/class_methods.rb:97: warning: method redefined; discarding old red /Users/devin/.rbenv/versions/2.5.5/lib/ruby/gems/2.5.0/gems/awesome_print-1.8.0/lib/awesome_print/core_ext/string.rb:19: warning: previous definition of red was here /Users/devin/.rbenv/versions/2.5.5/lib/ruby/gems/2.5.0/gems/colorize-0.8.1/lib/colorize/class_methods.rb:97: warning: method redefined; discarding old green /Users/devin/.rbenv/versions/2.5.5/lib/ruby/gems/2.5.0/gems/awesome_print-1.8.0/lib/awesome_print/core_ext/string.rb:19: warning: previous definition of green was here /Users/devin/.rbenv/versions/2.5.5/lib/ruby/gems/2.5.0/gems/colorize-0.8.1/lib/colorize/class_methods.rb:97: warning: method redefined; discarding old yellow /Users/devin/.rbenv/versions/2.5.5/lib/ruby/gems/2.5.0/gems/awesome_print-1.8.0/lib/awesome_print/core_ext/string.rb:19: warning: previous definition of yellow was here /Users/devin/.rbenv/versions/2.5.5/lib/ruby/gems/2.5.0/gems/colorize-0.8.1/lib/colorize/class_methods.rb:97: warning: method redefined; discarding old blue /Users/devin/.rbenv/versions/2.5.5/lib/ruby/gems/2.5.0/gems/awesome_print-1.8.0/lib/awesome_print/core_ext/string.rb:19: warning: previous definition of blue was here /Users/devin/.rbenv/versions/2.5.5/lib/ruby/gems/2.5.0/gems/colorize-0.8.1/lib/colorize/class_methods.rb:97: warning: method redefined; discarding old cyan /Users/devin/.rbenv/versions/2.5.5/lib/ruby/gems/2.5.0/gems/awesome_print-1.8.0/lib/awesome_print/core_ext/string.rb:19: warning: previous definition of cyan was here /Users/devin/.rbenv/versions/2.5.5/lib/ruby/gems/2.5.0/gems/colorize-0.8.1/lib/colorize/class_methods.rb:97: warning: method redefined; discarding old white /Users/devin/.rbenv/versions/2.5.5/lib/ruby/gems/2.5.0/gems/awesome_print-1.8.0/lib/awesome_print/core_ext/string.rb:19: warning: previous definition of white was here /Users/devin/.rbenv/versions/2.5.5/lib/ruby/gems/2.5.0/gems/table_print-1.5.6/lib/table_print/column.rb:13: warning: method redefined; discarding old name= /Users/devin/.rbenv/versions/2.5.5/lib/ruby/gems/2.5.0/gems/table_print-1.5.6/lib/table_print/row_group.rb:224: warning: shadowing outer local variable - value /Users/devin/.rbenv/versions/2.5.5/lib/ruby/gems/2.5.0/gems/table_print-1.5.6/lib/table_print/returnable.rb:27: warning: mismatched indentations at 'end' with 'def' at 25 /Users/devin/Documents/Ada/c12/slack-cli/test/message_test.rb:20: warning: assigned but unused variable - response
Which are messy and make it hard to debug, but also often hint at bigger problems with code.
| require "httparty" | ||
| require "awesome_print" | ||
| require "colorize" | ||
| require "table_print" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've included this here...
| @workspace = Slack::Workspace.new() | ||
| while true | ||
| puts "Welcome to the Ada Slack CLI!".colorize(:color => :orange, :mode => :bold) | ||
| puts "\nPlease Choose from the following options: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two lines print every time you come back to the top of the loop, but it would make more sense for them to only print when the CLI starts.
| when "select user", "3" | ||
| puts "Please enter username or Slack ID" | ||
| user_selection = gets.chomp | ||
| @workspace.select_user(user_selection) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd love to see some sort of confirmation message if things went right here.
| elsif recipient.class == Slack::User | ||
| print "Please enter the message: " | ||
| message = gets.chomp | ||
| id = recipient.id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider breaking these larger blocks out into helper methods so that this logic is easier to read!
| class SlackApiError < StandardError ; end | ||
|
|
||
| module Slack | ||
| def self.send_msg(message, channel) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're going to go the route of making an API wrapper, move all of the messages into the wrapper!
|
|
||
| def self.channels_list | ||
| channels = [] | ||
| response = HTTParty.get("#{CHANNEL_URI}/channels.list", query: {token: CHANNEL_KEY}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The route I'd rather see you go here is to have a generic list method for both channels and users that you implement in recipient, which could call a method that actually parses the response appropriately, similar to what csv_record did in OO ride share
| attr_reader :name, :id | ||
| def initialize(name, id) | ||
| @name = name | ||
| @id = id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're writing a class this short, ask yourself 2 questions:
- If it's this short, do I need it?
- If it's needed, is someone else doing its job?
| @@ -0,0 +1,23 @@ | |||
| require_relative "test_helper" | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd call this file 'slackapi_wrapper_test
| @@ -0,0 +1,25 @@ | |||
| #lib/message.rb | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't really a message class, it's a slackapi_wrapper class. This holds a bunch of information about how to contact the slack API
slack.rb
Congratulations! You're submitting your assignment!
You and your partner should collaborate on the answers to these questions.
Comprehension Questions