-
Notifications
You must be signed in to change notification settings - Fork 79
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
[MiqFileStorage] Add #magic_number_for #401
[MiqFileStorage] Add #magic_number_for #401
Conversation
@miq-bot add_label enhancement, hammer/yes |
55f5f81
to
57d5549
Compare
57d5549
to
909e42c
Compare
end | ||
|
||
describe "with a hash of accepted magics" do | ||
it "returns key for the passed in" do |
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'm not sure what this spec name means. Is there a typo here somewhere or maybe some missing words?
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.
"Nick (LaMuro), you're drunk... go home..."
- Nick (Carboni)
Yeah... let me fix that...
909e42c
to
19f754c
Compare
|
||
if (magics = options[:accepted]) | ||
result = magics.detect do |_, magic| | ||
uri_data.force_encoding(magic.encoding).start_with?(magic) |
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.
@carbonin Just an FYI, this also changed as part of my recent push of commits, since I ran into an issue without it.
Prior, this line was just:
result = magics.detect { |_, magic| ri_data.start_with?(magic) }
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.
Can we keep this as a single line? Code Climate is complaining about the alignment of the end and even though the line would be over 80 characters I think it would be more readable as a single line rather than dealing with the weird spacing caused by the assignment.
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.
Sure. No prob.
Used to determine the magic number for a remote uri. Relies on `#download_single` being able to support a specific `@byte_count` to download only what is necessary and writing to a StringIO.
Since we need a connection for any download/upload to work (sets @ftp on the instance), we need a slight override of `#magic_number_for` to wrap it with a connection.
19f754c
to
f70c48d
Compare
Checked commits NickLaMuro/manageiq-gems-pending@a24d703~...f70c48d with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 lib/gems/pending/util/miq_file_storage.rb
|
…ile-storage [MiqFileStorage] Add #magic_number_for (cherry picked from commit b3f99e1)
Hammer backport details:
|
Used to determine the magic number for a remote uri.
Implementation Notes/Details:
:accepted
param can be passed, which allows you to pass a hash with the values of the hash being the magic values (returns matching key)#download_single
being able to support a specific@byte_count
to download only what is necessary and writing to aStringIO
.Links