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 extra / if passed with --url #378

Merged
merged 1 commit into from Dec 19, 2018
Merged

Conversation

joshgoebel
Copy link
Contributor

No description provided.

@ashmaroli
Copy link
Member

ashmaroli commented Dec 11, 2018

@yyyc514 I understand the reason behind this.
Since chomp! will strip only the trailing slash once, --url=http://myblog.tumblr.com// will not be cleansed as expected.

The simplest solution for the moment is to delegate to Ruby's File class:

url = File.join(url, "/api/read/json/")

Additionally, it'd be better if you can add a test for this as well..
Thank you.

@joshgoebel
Copy link
Contributor Author

HAHA, that's a typo vs an actual expected mistake, but I hear you. Might take me a day or two to circle back but sure we can use File.join and I'll see about a test also.

@joshgoebel
Copy link
Contributor Author

Better?

@ashmaroli
Copy link
Member

@yyyc514 Yes, it is much better now. Thank you.

Technically, your api_feed_url method has not been declared as a private method. But your tests indicate that you intended it to be a private_class_method nonetheless.

So I suggest that you declare it explicitly:

class << self
  # existing methods in this class

  private # declaration towards the end of the class

  def api_feed_url(url, page, per_page: 50)
    url = File.join(url, "/api/read/json/")
    "#{url}?num=#{per_page}&start=#{page * per_page}"
  end
end

The existing methods cannot be declared as private in this PR..

Additionally, I requested the use of File.join due to its simplicity, in comparison to the use of URI.join or Addressable::URI.join. Feel free to use those if they are more intuitive and better in the current context.

@joshgoebel
Copy link
Contributor Author

assert_equal @posts, Importers::Tumblr.send(:extract_json, @payload)

Why are we using send here? That tripped me up and caused me to not even consider whether it was private or not.

@ashmaroli
Copy link
Member

Why are we using send here?

Because at the time when the test was authored, the method was indeed private

But private became redundant in this change and then eventually got removed automatically by RuboCop in subsequent linting sessions because it was "redundant"...

🤷‍♂️

@joshgoebel
Copy link
Contributor Author

It's redundant because it was outside the class < self, yes? Those methods should still be private as far as I can tell.

@ashmaroli
Copy link
Member

Those methods should still be private as far as I can tell.

Possibly. But there's a catch. Exposing private methods as public will be an enhancement. But hiding public methods as private will be a regression (breaking-change).

So please only convert your method to private as I suggested in a couple of comments above.

@joshgoebel
Copy link
Contributor Author

But hiding public methods as private will be a regression (breaking-change).

Ugh. Indeed. 😐

Copy link
Member

@ashmaroli ashmaroli left a comment

Choose a reason for hiding this comment

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

LGTM! 👍

@ashmaroli ashmaroli requested a review from a team December 12, 2018 18:58
@joshgoebel
Copy link
Contributor Author

Finally. 😇

@DirtyF
Copy link
Member

DirtyF commented Dec 19, 2018

@jekyllbot: merge +minor

@jekyllbot jekyllbot merged commit 5ea357b into jekyll:master Dec 19, 2018
jekyllbot added a commit that referenced this pull request Dec 19, 2018
@DirtyF DirtyF added this to the 0.17.0 milestone Dec 20, 2018
@jekyll jekyll locked and limited conversation to collaborators Dec 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants