Skip to content
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

Remove activesupport dependency #325

Closed

Conversation

ianks
Copy link
Contributor

@ianks ianks commented May 28, 2020

For non-rails shops, depending on AS can be a non-starter. Luckily, this gem only relied on two small AS features from what I can tell: class_attribute, String#blank? and one occasion of ActiveSupport#HashWithIndifferentAccess. It was easy to adjust and as a result, it should be easier to adopt.

Thank you for this gem, our team is very excited to start using it!

Copy link
Collaborator

@dblock dblock left a comment

Choose a reason for hiding this comment

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

I am open to this. See minor comments + there needs to be an UPGRADING entry as someone might be bringing in AS via this gem, and a major version bump.


namespace :slack do
namespace :web do
namespace :api do
desc 'Update Web API.'
task update: [:git_update] do
require 'active_support'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should be a developement dependency for this, otherwise the task will fail anyway without the gem installed separately. Also, maybe code can be fixed not to need it either?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since I don't know what this task is supposed to do, I do not feel comfortable refactoring it. But I will make it a development dependency 😄

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you should give it a shot. It updates the web API from its reference, and shouldn't need AS either. As long as you can run it and it succeeds and produces no diff, we're good.

@@ -2,10 +2,6 @@
module Slack
module Messages
class Message < Hashie::Mash
def presence
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is an actual Slack field. Aren't we breaking an API here? Should have had tests for it though either way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I checked this a few times, and all the specs are indeed passing, and behavior seems correct.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we're missing a spec. This overrides Object#presence, so when there's a presence field in the result you get its value and not the return of that object. Either way, why remove it? I think you should put this code back, and if you care write a spec or open an issue and I will get to it.

@dblock
Copy link
Collaborator

dblock commented Jun 8, 2020

@ianks Want to finish this?

@ianks ianks force-pushed the remove-activesupport-dependency branch from 94ba04d to 987ad2a Compare June 9, 2020 21:15
@ianks ianks requested a review from dblock June 9, 2020 21:15
Copy link
Collaborator

@dblock dblock left a comment

Choose a reason for hiding this comment

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

I am still uncomfortable with the presence changes and I think you should fix the update task so we can really get rid of AS.

@@ -2,10 +2,6 @@
module Slack
module Messages
class Message < Hashie::Mash
def presence
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we're missing a spec. This overrides Object#presence, so when there's a presence field in the result you get its value and not the return of that object. Either way, why remove it? I think you should put this code back, and if you care write a spec or open an issue and I will get to it.

@@ -32,14 +32,14 @@ def each

client.logger.debug("#{self.class}##{__method__}") { e.to_s }
retry_count += 1
sleep(e.retry_after.seconds)
sleep(e.retry_after)
Copy link
Collaborator

Choose a reason for hiding this comment

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

How did the type of retry_after change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

retry_after is an integer, so calling .seconds was effectively a no-op.


namespace :slack do
namespace :web do
namespace :api do
desc 'Update Web API.'
task update: [:git_update] do
require 'active_support'
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you should give it a shot. It updates the web API from its reference, and shouldn't need AS either. As long as you can run it and it succeeds and produces no diff, we're good.

UPGRADING.md Outdated

See [#325](https://github.com/slack-ruby/slack-ruby-client/pull/325) for more information.

```
Copy link
Collaborator

Choose a reason for hiding this comment

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

Bad copy-paste?

@ianks
Copy link
Contributor Author

ianks commented Jun 16, 2020

I think we're missing a spec. This overrides Object#presence, so when there's a presence field in the result you get its value and not the return of that object. Either way, why remove it? I think you should put this code back, and if you care write a spec or open an issue and I will get to it.

@dblock All specs pass without the presence method, but when I attempt to define it myself, I cannot get the specs to pass regardless of whether I use :presence or 'presence'. Object#presence is an ActiveSupport method, FWIW

Depending on the context, things break. Could you could clone down to take a look?

@ianks ianks requested a review from dblock June 16, 2020 16:54
Copy link
Collaborator

@dblock dblock left a comment

Choose a reason for hiding this comment

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

@dblock All specs pass without the presence method, but when I attempt to define it myself, I cannot get the specs to pass regardless of whether I use :presence or 'presence'. Object#presence is an ActiveSupport method, FWIW

OK, I get it, this is why we put it here, to override the behavior that AS was bringing

@@ -1,6 +1,19 @@
Upgrading Slack-Ruby-Client
===========================

### Upgrading to >= 0.16.0

As of 0.16.0, we no longer depend on `activesupport` as a dependency. This means that if you were relying on `activesupport` functionality unintentionally, certain things in you code may break. To fix this, you have two options:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's say this simpler

As of 0.16.0 slack-ruby-client no longer requires activesupport. If you are using activesupport, add gem 'activesupport' to your Gemfile..


As of 0.16.0, we no longer depend on `activesupport` as a dependency. This means that if you were relying on `activesupport` functionality unintentionally, certain things in you code may break. To fix this, you have two options:

1. Update your code to use pure Ruby, without ActiveSupport methods (*recommended*).
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is really none of our business in this library :)

Copy link
Collaborator

@dblock dblock left a comment

Choose a reason for hiding this comment

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

I'm good with this. Can you please use my shorter suggested UPGRADING note and I'll merge. Feel free to squash too.

@@ -1,5 +1,7 @@
### 0.15.0 (Next)

* [#325](https://github.com/slack-ruby/slack-ruby-client/pull/325): Remove activesupport dependency - [@ianks](https://github.com/ianks).
* [#326](https://github.com/slack-ruby/slack-ruby-client/pull/326): Update new methods - [@wasabigeek](https://github.com/wasabigeek).
Copy link
Collaborator

Choose a reason for hiding this comment

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

This shouldn't be in this PR. remove and rebase.

@@ -1,6 +1,19 @@
Upgrading Slack-Ruby-Client
===========================

### Upgrading to >= 0.16.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be 0.15.0 AFAIK, not 0.16.0.

@dblock
Copy link
Collaborator

dblock commented Jun 28, 2020

Merged via 7494411

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants