Skip to content

Commit

Permalink
Fix to support windows (#164)
Browse files Browse the repository at this point in the history
* Don't use awk/grep/sed when detecing openssldir

* Use OpenSSL::X509::DEFAULT_CERT_DIR and OpenSSL::X509::DEFAULT_CERT_FILE

* Update changelog

* Use code for constants in changelog

* Set ca_path and ca_file to nil if OpenSSL is undefined

* Update changelog format

* Use if instead of unless

* require in slack-ruby-client instead of slack/web/config

* Rubocopping
  • Loading branch information
leifcr authored and dblock committed Sep 13, 2017
1 parent 3fbcebf commit 385b30b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
20 changes: 10 additions & 10 deletions .rubocop_todo.yml
@@ -1,12 +1,12 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2017-04-30 12:02:22 -0400 using RuboCop version 0.35.0.
# on 2017-09-13 09:10:02 +0200 using RuboCop version 0.35.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
# versions of RuboCop, may require this file to be generated again.

# Offense count: 3
# Offense count: 4
Lint/HandleExceptions:
Exclude:
- 'lib/slack-ruby-client.rb'
Expand All @@ -20,7 +20,7 @@ Lint/UnusedBlockArgument:
Exclude:
- 'lib/slack/messages/formatting.rb'

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

Expand All @@ -29,25 +29,25 @@ Metrics/AbcSize:
Metrics/ClassLength:
Max: 165

# Offense count: 3
# Offense count: 4
Metrics/CyclomaticComplexity:
Max: 9

# Offense count: 720
# Offense count: 615
# Configuration parameters: AllowURI, URISchemes.
Metrics/LineLength:
Max: 288
Max: 266

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

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

# Offense count: 59
# Offense count: 63
# Configuration parameters: Exclude.
Style/Documentation:
Enabled: false
Expand All @@ -58,12 +58,12 @@ Style/FileName:
Exclude:
- 'lib/slack-ruby-client.rb'

# Offense count: 116
# Offense count: 120
# Configuration parameters: AllowedVariables.
Style/GlobalVars:
Enabled: false

# Offense count: 21
# Offense count: 22
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/MethodName:
Enabled: false
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,5 +1,6 @@
### 0.9.2 (Next)

* [#163](https://github.com/slack-ruby/slack-ruby-client/pull/164): Use `OpenSSL::X509::DEFAULT_CERT_DIR` and `OpenSSL::X509::DEFAULT_CERT_FILE` for default ca_cert and ca_file - [@leifcr](https://github.com/leifcr).
* [#161](https://github.com/slack-ruby/slack-ruby-client/pull/161): Added support for cursor pagination - [@dblock](https://github.com/dblock).
* Your contribution here.

Expand Down
5 changes: 5 additions & 0 deletions lib/slack-ruby-client.rb
Expand Up @@ -17,6 +17,11 @@
rescue LoadError
# ignore, only used in users_search
end
begin
require 'openssl'
rescue LoadError
# Used in slack/web/config
end
require_relative 'slack/web/config'
require_relative 'slack/web/api/errors/slack_error'
require_relative 'slack/web/api/errors/too_many_requests_error'
Expand Down
4 changes: 2 additions & 2 deletions lib/slack/web/config.rb
Expand Up @@ -21,8 +21,8 @@ module Config
def reset
self.endpoint = 'https://slack.com/api/'
self.user_agent = "Slack Ruby Client/#{Slack::VERSION}"
self.ca_path = `openssl version -a | grep OPENSSLDIR | awk '{print $2}'|sed -e 's/\"//g'`
self.ca_file = "#{ca_path}/ca-certificates.crt"
self.ca_path = defined?(OpenSSL) ? OpenSSL::X509::DEFAULT_CERT_DIR : nil
self.ca_file = defined?(OpenSSL) ? OpenSSL::X509::DEFAULT_CERT_FILE : nil
self.token = nil
self.proxy = nil
self.logger = nil
Expand Down
2 changes: 1 addition & 1 deletion lib/slack/web/faraday/connection.rb
Expand Up @@ -11,7 +11,7 @@ def connection

options[:headers]['User-Agent'] = user_agent if user_agent
options[:proxy] = proxy if proxy
options[:ssl] = { ca_path: ca_path, ca_file: ca_file }
options[:ssl] = { ca_path: ca_path, ca_file: ca_file } if ca_path || ca_file

request_options = {}
request_options[:timeout] = timeout if timeout
Expand Down

0 comments on commit 385b30b

Please sign in to comment.