Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2016-02-29 14:50:42 -0500 using RuboCop version 0.35.0.
# on 2016-05-02 12:24:56 +0100 using RuboCop version 0.39.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -21,51 +21,52 @@ Lint/UnusedBlockArgument:
Exclude:
- 'lib/slack/messages/formatting.rb'

# Offense count: 14
# Offense count: 15
Metrics/AbcSize:
Max: 44

# Offense count: 2
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 159
Max: 155

# Offense count: 1
# Offense count: 2
Metrics/CyclomaticComplexity:
Max: 9

# Offense count: 542
# Configuration parameters: AllowURI, URISchemes.
# Offense count: 571
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
# URISchemes: http, https
Metrics/LineLength:
Max: 288

# Offense count: 8
# Offense count: 7
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 32

# Offense count: 1
# Offense count: 2
Metrics/PerceivedComplexity:
Max: 11

# Offense count: 52
# Configuration parameters: Exclude.
# Offense count: 53
Style/Documentation:
Enabled: false

# Offense count: 1
# Configuration parameters: Exclude.
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts.
Style/FileName:
Exclude:
- 'lib/slack-ruby-client.rb'

# Offense count: 92
# Offense count: 95
# Configuration parameters: AllowedVariables.
Style/GlobalVars:
Enabled: false

# Offense count: 17
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: snake_case, camelCase
Style/MethodName:
Enabled: false

Expand All @@ -78,6 +79,7 @@ Style/ModuleFunction:

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: use_perl_names, use_english_names
Style/SpecialGlobalVars:
Exclude:
- 'lib/slack/messages/formatting.rb'
Enabled: false
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### 0.7.1 (Next)

* Your contribution here.
* [#82](https://github.com/dblock/slack-ruby-client/pull/82): Fix `usergroups.users.{list,update}` and `files.comments.{add,edit,delete}` APIs - [@masatomo](https://github.com/masatomo).
* [#73](https://github.com/dblock/slack-ruby-client/issues/73): Add a `closed` event - [@rkadyb](https://github.com/rkadyb).
* [#69](https://github.com/dblock/slack-ruby-client/issues/69): Add attachments support for `Slack::Web::Api::Endpoints::Chat.chat_update` - [@nicka](https://github.com/nicka).

Expand Down
2 changes: 2 additions & 0 deletions bin/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
require 'commands/chat'
require 'commands/dnd'
require 'commands/emoji'
require 'commands/files_comments'
require 'commands/files'
require 'commands/groups'
require 'commands/im'
Expand All @@ -18,4 +19,5 @@
require 'commands/stars'
require 'commands/team'
require 'commands/usergroups'
require 'commands/usergroups_users'
require 'commands/users'
11 changes: 0 additions & 11 deletions bin/commands/files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,6 @@

desc 'Get info on files uploaded to Slack, upload new files to Slack.'
command 'files' do |g|
g.desc 'Edit an existing comment on a file. Only the user who created a comment may make edits. Teams may configure a limited time window during which file comment edits are allowed.'
g.long_desc %( Edit an existing comment on a file. Only the user who created a comment may make edits. Teams may configure a limited time window during which file comment edits are allowed. )
g.command 'comments' do |c|
c.flag 'file', desc: 'File containing the comment to edit.'
c.flag 'id', desc: 'The comment to edit.'
c.flag 'comment', desc: 'Text of the comment to edit.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.files_comments(options))
end
end

g.desc 'This method deletes a file from your team.'
g.long_desc %( This method deletes a file from your team. )
g.command 'delete' do |c|
Expand Down
35 changes: 35 additions & 0 deletions bin/commands/files_comments.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This file was auto-generated by lib/tasks/web.rake

desc 'FilesComments methods.'
command 'files_comments' do |g|
g.desc 'Add a comment to an existing file.'
g.long_desc %( Add a comment to an existing file. )
g.command 'add' do |c|
c.flag 'file', desc: 'File to add a comment to.'
c.flag 'comment', desc: 'Text of the comment to add.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.files_comments_add(options))
end
end

g.desc 'Delete an existing comment on a file. Only the original author of the comment or a Team Administrator may delete a file comment.'
g.long_desc %( Delete an existing comment on a file. Only the original author of the comment or a Team Administrator may delete a file comment. )
g.command 'delete' do |c|
c.flag 'file', desc: 'File to delete a comment from.'
c.flag 'id', desc: 'The comment to delete.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.files_comments_delete(options))
end
end

g.desc 'Edit an existing comment on a file. Only the user who created a comment may make edits. Teams may configure a limited time window during which file comment edits are allowed.'
g.long_desc %( Edit an existing comment on a file. Only the user who created a comment may make edits. Teams may configure a limited time window during which file comment edits are allowed. )
g.command 'edit' do |c|
c.flag 'file', desc: 'File containing the comment to edit.'
c.flag 'id', desc: 'The comment to edit.'
c.flag 'comment', desc: 'Text of the comment to edit.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.files_comments_edit(options))
end
end
end
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this files comments edit instead of files_comments edit? These commands can nest multiple levels.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I'll take it back. Ignore me this is right.

11 changes: 0 additions & 11 deletions bin/commands/usergroups.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,4 @@
puts JSON.dump($client.usergroups_update(options))
end
end

g.desc 'This method updates the list of users that belong to a User Group. This method replaces all users in a User Group with the list of users provided in the users parameter.'
g.long_desc %( This method updates the list of users that belong to a User Group. This method replaces all users in a User Group with the list of users provided in the users parameter. )
g.command 'users' do |c|
c.flag 'usergroup', desc: 'The encoded ID of the User Group to update.'
c.flag 'users', desc: 'A comma separated string of encoded user IDs that represent the entire list of users for the User Group.'
c.flag 'include_count', desc: 'Include the number of users in the User Group.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.usergroups_users(options))
end
end
end
25 changes: 25 additions & 0 deletions bin/commands/usergroups_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This file was auto-generated by lib/tasks/web.rake

desc 'UsergroupsUsers methods.'
command 'usergroups_users' do |g|
g.desc 'This method returns a list of all users within a User Group.'
g.long_desc %( This method returns a list of all users within a User Group. )
g.command 'list' do |c|
c.flag 'usergroup', desc: 'The encoded ID of the User Group to update.'
c.flag 'include_disabled', desc: 'Allow results that involve disabled User Groups.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.usergroups_users_list(options))
end
end

g.desc 'This method updates the list of users that belong to a User Group. This method replaces all users in a User Group with the list of users provided in the users parameter.'
g.long_desc %( This method updates the list of users that belong to a User Group. This method replaces all users in a User Group with the list of users provided in the users parameter. )
g.command 'update' do |c|
c.flag 'usergroup', desc: 'The encoded ID of the User Group to update.'
c.flag 'users', desc: 'A comma separated string of encoded user IDs that represent the entire list of users for the User Group.'
c.flag 'include_count', desc: 'Include the number of users in the User Group.'
c.action do |_global_options, options, _args|
puts JSON.dump($client.usergroups_users_update(options))
end
end
end
2 changes: 1 addition & 1 deletion bin/slack
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ flag ['vcr-cassette-name'], desc: 'Offline VCR cassette.'
pre do |global_options, _command, options, _args|
# global Slack configuration
Slack.config.token = global_options['slack-api-token']
help_now! 'Set Slack API token via --slack-api-token or SLACK_API_TOKEN.' unless Slack.config.token && Slack.config.token.length > 0
help_now! 'Set Slack API token via --slack-api-token or SLACK_API_TOKEN.' unless Slack.config.token && !Slack.config.token.empty?

if global_options['debug']
require 'logger'
Expand Down
2 changes: 1 addition & 1 deletion examples/hi_real_time/hi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
config.token = ENV['SLACK_API_TOKEN']
config.logger = Logger.new(STDOUT)
config.logger.level = Logger::WARN
fail 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
raise 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
end

client = Slack::RealTime::Client.new
Expand Down
2 changes: 1 addition & 1 deletion examples/hi_real_time_and_web/hi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Slack.configure do |config|
config.token = ENV['SLACK_API_TOKEN']
fail 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
raise 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
end

client = Slack::RealTime::Client.new
Expand Down
2 changes: 1 addition & 1 deletion examples/hi_real_time_async/hi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Slack.configure do |config|
config.token = ENV['SLACK_API_TOKEN']
fail 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
raise 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
end

client = Slack::RealTime::Client.new
Expand Down
2 changes: 1 addition & 1 deletion examples/hi_web/hi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Slack.configure do |config|
config.token = ENV['SLACK_API_TOKEN']
fail 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
raise 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
end

client = Slack::Web::Client.new
Expand Down
2 changes: 1 addition & 1 deletion examples/new_ticket/new_ticket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Slack.configure do |config|
config.token = ENV['SLACK_API_TOKEN']
fail 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
raise 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
end

client = Slack::Web::Client.new
Expand Down
6 changes: 3 additions & 3 deletions lib/slack/real_time/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def start_async(&block)
end

def stop!
fail ClientNotStartedError unless started?
raise ClientNotStartedError unless started?
@socket.disconnect! if @socket
end

Expand All @@ -82,7 +82,7 @@ def config

# @return [Slack::RealTime::Socket]
def build_socket
fail ClientAlreadyStartedError if started?
raise ClientAlreadyStartedError if started?
start = web_client.rtm_start(start_options)
data = Slack::Messages::Message.new(start)
@url = data.url
Expand Down Expand Up @@ -130,7 +130,7 @@ def socket_class
end

def send_json(data)
fail ClientNotStartedError unless started?
raise ClientNotStartedError unless started?
logger.debug("#{self.class}##{__method__}") { data }
@socket.send_data(data.to_json)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/slack/real_time/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class NoConcurrencyError < StandardError; end
:start_options,
:store_class,
:logger
]
].freeze

attr_accessor(*Config::ATTRIBUTES)

Expand Down Expand Up @@ -42,7 +42,7 @@ def detect_concurrency
end
end

fail NoConcurrencyError, 'Missing concurrency. Add faye-websocket or celluloid-io to your Gemfile.'
raise NoConcurrencyError, 'Missing concurrency. Add faye-websocket or celluloid-io to your Gemfile.'
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/slack/real_time/socket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def start_sync(&block)

# @return [#join]
def start_async
fail NotImplementedError, "Expected #{self.class} to implement #{__method__}."
raise NotImplementedError, "Expected #{self.class} to implement #{__method__}."
end

protected
Expand All @@ -75,7 +75,7 @@ def port
end

def connect
fail NotImplementedError, "Expected #{self.class} to implement #{__method__}."
raise NotImplementedError, "Expected #{self.class} to implement #{__method__}."
end

def close(_event)
Expand Down
2 changes: 1 addition & 1 deletion lib/slack/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Slack
VERSION = '0.7.1'
VERSION = '0.7.1'.freeze
end
4 changes: 4 additions & 0 deletions lib/slack/web/api/endpoints.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
require 'slack/web/api/endpoints/chat'
require 'slack/web/api/endpoints/dnd'
require 'slack/web/api/endpoints/emoji'
require 'slack/web/api/endpoints/files_comments'
require 'slack/web/api/endpoints/files'
require 'slack/web/api/endpoints/groups'
require 'slack/web/api/endpoints/im'
Expand All @@ -18,6 +19,7 @@
require 'slack/web/api/endpoints/stars'
require 'slack/web/api/endpoints/team'
require 'slack/web/api/endpoints/usergroups'
require 'slack/web/api/endpoints/usergroups_users'
require 'slack/web/api/endpoints/users'

module Slack
Expand All @@ -34,6 +36,7 @@ module Endpoints
include Chat
include Dnd
include Emoji
include FilesComments
include Files
include Groups
include Im
Expand All @@ -46,6 +49,7 @@ module Endpoints
include Stars
include Team
include Usergroups
include UsergroupsUsers
include Users
end
end
Expand Down
18 changes: 0 additions & 18 deletions lib/slack/web/api/endpoints/files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,6 @@ module Web
module Api
module Endpoints
module Files
#
# Edit an existing comment on a file. Only the user who created a comment may make edits. Teams may configure a limited time window during which file comment edits are allowed.
#
# @option options [file] :file
# File containing the comment to edit.
# @option options [Object] :id
# The comment to edit.
# @option options [Object] :comment
# Text of the comment to edit.
# @see https://api.slack.com/methods/files.comments
# @see https://github.com/dblock/slack-api-ref/blob/master/methods/files/files.comments.json
def files_comments(options = {})
throw ArgumentError.new('Required arguments :file missing') if options[:file].nil?
throw ArgumentError.new('Required arguments :id missing') if options[:id].nil?
throw ArgumentError.new('Required arguments :comment missing') if options[:comment].nil?
post('files.comments', options)
end

#
# This method deletes a file from your team.
#
Expand Down
Loading