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

Serve files without using FileStreamer-like object #1321

Merged
merged 1 commit into from
Mar 15, 2016

Conversation

lfidnl
Copy link
Contributor

@lfidnl lfidnl commented Mar 14, 2016

Hello!

I've implemented serving file without using FileStremer-like object. Now user can use only path to file and Grape send file directly or will use Rack::Sendfile middleware if it turned on.

I've saved backward compatibility with FileStreamer-like object with displaying deprecation warning.

@@ -42,6 +42,8 @@ Metrics/MethodLength:
# Configuration parameters: CountComments.
Metrics/ModuleLength:
Max: 272
Exclude:
Copy link
Member

Choose a reason for hiding this comment

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

You might want to just run rubocop --auto-gen-config for this.

@dblock
Copy link
Member

dblock commented Mar 14, 2016

Looks great. Needs a CHANGELOG entry please.

@lfidnl
Copy link
Contributor Author

lfidnl commented Mar 14, 2016

Thanks for response! Ohhh sorry, forgot about CHANGELOG

@lfidnl lfidnl force-pushed the serve_file branch 3 times, most recently from d3641b5 to 613f055 Compare March 14, 2016 19:47
@lfidnl
Copy link
Contributor Author

lfidnl commented Mar 14, 2016

Updated according to your comments

file_body = Grape::ServeFile::FileBody.new(value)
@file = Grape::ServeFile::FileResponse.new(file_body)
elsif !value.is_a?(NilClass)
warn '[DEPRECATION] Argument as FileStreamer-like object will be deprecated. Use path to file instead'
Copy link
Member

Choose a reason for hiding this comment

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

In other places we say "is deprecated", not "will be" and usually make this a full sentence with a period in the end. Like this:

warn '[DEPRECATION] Passing a options hash and a block to `desc` is deprecated. Move all hash options to block.'
.

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 mean that support of argument as FileSteam-like object will be removed from Grape in next version after 0.15.1 or 0.16.0. After releasing 0.15.1 or 0.16.0 I would like to remove it at all. Sorry for my English :)
OK, I'll replace it with:

[DEPRECATION] Argument as FileStreamer-like object is deprecated. Use path to file instead.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks. If you're rubbing the bext version the old code is already deprecated but it does work with a warning. I think present tense is correct :) thanks for making the changes!

@dblock
Copy link
Member

dblock commented Mar 15, 2016

One last thing this needs is an entry in UPGRADING.md, please.

@dblock
Copy link
Member

dblock commented Mar 15, 2016

Last thought, don't feel that strongly about it, but maybe ServeFile should just be File?

@lfidnl
Copy link
Contributor Author

lfidnl commented Mar 15, 2016

I chose ServeFile to avoid confusion with the regular ruby File class. I know that we have namespaces and etc, but I think it will be better :)

@dblock
Copy link
Member

dblock commented Mar 15, 2016

👍


Now to serve files via Grape just pass the path to the file. Functionality with FileStreamer-like objects is deprecated.

Please, replace your FileStreamer-like objects with paths of served files.
Copy link
Member

Choose a reason for hiding this comment

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

Care to provide an example here? Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem :)

dblock added a commit that referenced this pull request Mar 15, 2016
Serve files without using FileStreamer-like object
@dblock dblock merged commit 1097eb1 into ruby-grape:master Mar 15, 2016
@dblock
Copy link
Member

dblock commented Mar 15, 2016

Merged, thanks.

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.

2 participants