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

(Tumblr) Add nil check to prevent undefined method error (fixes #29) #179

Merged
merged 4 commits into from May 7, 2015

Conversation

Projects
None yet
5 participants
@paramaggarwal
Contributor

paramaggarwal commented Jan 8, 2015

Fix for this error when importing a Tumblr blog with video posts with empty video-player field:

Fetching http://paramaggarwal.com/api/read/json/?num=50&start=0
Page: 1 - Posts: 50
/usr/local/lib/ruby/gems/2.2.0/gems/jekyll-import-0.5.3/lib/jekyll-import/importers/tumblr.rb:136:in `post_to_hash': undefined method `<<' for false:FalseClass (NoMethodError)
    from /usr/local/lib/ruby/gems/2.2.0/gems/jekyll-import-0.5.3/lib/jekyll-import/importers/tumblr.rb:47:in `block in process'
    from /usr/local/lib/ruby/gems/2.2.0/gems/jekyll-import-0.5.3/lib/jekyll-import/importers/tumblr.rb:47:in `map'
    from /usr/local/lib/ruby/gems/2.2.0/gems/jekyll-import-0.5.3/lib/jekyll-import/importers/tumblr.rb:47:in `process'
    from /usr/local/lib/ruby/gems/2.2.0/gems/jekyll-import-0.5.3/lib/jekyll-import/importer.rb:23:in `run'
    from -e:2:in `<main>'
@parkr

This comment has been minimized.

Show comment
Hide comment
@parkr

parkr Jan 10, 2015

Member

I don't think this will fix the error you got. You got an error because content was false.

Member

parkr commented Jan 10, 2015

I don't think this will fix the error you got. You got an error because content was false.

@paramaggarwal

This comment has been minimized.

Show comment
Hide comment
@paramaggarwal

paramaggarwal Jan 10, 2015

Contributor

Yes, you are right! I ran the importer after this change and it worked so I thought this fixed it. Now I'm confused.

Contributor

paramaggarwal commented Jan 10, 2015

Yes, you are right! I ran the importer after this change and it worked so I thought this fixed it. Now I'm confused.

Show outdated Hide outdated lib/jekyll-import/importers/tumblr.rb
@@ -131,8 +131,10 @@ def self.post_to_hash(post, format)
when "video"
title = post["video-title"]
content = post["video-player"]

This comment has been minimized.

@parkr

parkr Jan 10, 2015

Member

If content is false, then it means something went wrong here.

@parkr

parkr Jan 10, 2015

Member

If content is false, then it means something went wrong here.

@parkr

This comment has been minimized.

Show comment
Hide comment
@parkr

parkr Jan 10, 2015

Member

it worked so I thought this fixed it.

It could have been that it also had no video-caption, so it never called #<< on content.

Member

parkr commented Jan 10, 2015

it worked so I thought this fixed it.

It could have been that it also had no video-caption, so it never called #<< on content.

@octalmage

This comment has been minimized.

Show comment
Hide comment
@octalmage

octalmage Mar 31, 2015

This fixed the errors I was getting:

/Users/jasonstallings/.rvm/rubies/ruby-2.1.4/lib/ruby/gems/2.1.0/gems/jekyll-import-0.6.0/lib/jekyll-import/importers/tumblr.rb:135:in `post_to_hash': undefined method `<<' for false:FalseClass (NoMethodError)
        from /Users/jasonstallings/.rvm/rubies/ruby-2.1.4/lib/ruby/gems/2.1.0/gems/jekyll-import-0.6.0/lib/jekyll-import/importers/tumblr.rb:47:in `block in process'
        from /Users/jasonstallings/.rvm/rubies/ruby-2.1.4/lib/ruby/gems/2.1.0/gems/jekyll-import-0.6.0/lib/jekyll-import/importers/tumblr.rb:47:in `map'
        from /Users/jasonstallings/.rvm/rubies/ruby-2.1.4/lib/ruby/gems/2.1.0/gems/jekyll-import-0.6.0/lib/jekyll-import/importers/tumblr.rb:47:in `process'
        from /Users/jasonstallings/.rvm/rubies/ruby-2.1.4/lib/ruby/gems/2.1.0/gems/jekyll-import-0.6.0/lib/jekyll-import/importer.rb:23:in `run'
        from -e:2:in `<main>'

Import process worked without error with this change.

This fixed the errors I was getting:

/Users/jasonstallings/.rvm/rubies/ruby-2.1.4/lib/ruby/gems/2.1.0/gems/jekyll-import-0.6.0/lib/jekyll-import/importers/tumblr.rb:135:in `post_to_hash': undefined method `<<' for false:FalseClass (NoMethodError)
        from /Users/jasonstallings/.rvm/rubies/ruby-2.1.4/lib/ruby/gems/2.1.0/gems/jekyll-import-0.6.0/lib/jekyll-import/importers/tumblr.rb:47:in `block in process'
        from /Users/jasonstallings/.rvm/rubies/ruby-2.1.4/lib/ruby/gems/2.1.0/gems/jekyll-import-0.6.0/lib/jekyll-import/importers/tumblr.rb:47:in `map'
        from /Users/jasonstallings/.rvm/rubies/ruby-2.1.4/lib/ruby/gems/2.1.0/gems/jekyll-import-0.6.0/lib/jekyll-import/importers/tumblr.rb:47:in `process'
        from /Users/jasonstallings/.rvm/rubies/ruby-2.1.4/lib/ruby/gems/2.1.0/gems/jekyll-import-0.6.0/lib/jekyll-import/importer.rb:23:in `run'
        from -e:2:in `<main>'

Import process worked without error with this change.

Show outdated Hide outdated lib/jekyll-import/importers/tumblr.rb
@@ -131,8 +131,10 @@ def self.post_to_hash(post, format)
when "video"
title = post["video-title"]
content = post["video-player"]
unless post["video-caption"].nil?
content << "<br/>" + post["video-caption"]
unless post[:content].nil?

This comment has been minimized.

@parkr

parkr Mar 31, 2015

Member

Shouldn't this check content?

unless content.nil? || post["video-caption"].nil?
  content << "<br/>" + post["video-caption"]
end
@parkr

parkr Mar 31, 2015

Member

Shouldn't this check content?

unless content.nil? || post["video-caption"].nil?
  content << "<br/>" + post["video-caption"]
end

This comment has been minimized.

@paramaggarwal

paramaggarwal Apr 20, 2015

Contributor

Makes sense, would you like me to make this change to the PR? Unfortunately, I would have no way to try it out though...

@paramaggarwal

paramaggarwal Apr 20, 2015

Contributor

Makes sense, would you like me to make this change to the PR? Unfortunately, I would have no way to try it out though...

This comment has been minimized.

@parkr

parkr Apr 20, 2015

Member

Yes please! :)

@parkr

parkr Apr 20, 2015

Member

Yes please! :)

@a2z9

This comment has been minimized.

Show comment
Hide comment
@a2z9

a2z9 Apr 21, 2015

please help me to create structured data markup

please help me to create structured data markup

@paramaggarwal

This comment has been minimized.

Show comment
Hide comment
@paramaggarwal

paramaggarwal May 6, 2015

Contributor

@parkr Updated the PR with your review comments. Sorry for the immense delay for making this change...

Contributor

paramaggarwal commented May 6, 2015

@parkr Updated the PR with your review comments. Sorry for the immense delay for making this change...

Show outdated Hide outdated lib/jekyll-import/importers/tumblr.rb
@@ -131,7 +131,7 @@ def self.post_to_hash(post, format)
when "video"
title = post["video-title"]
content = post["video-player"]
unless post["video-caption"].nil?
unless content.nil? || post["video-caption"].nil?
content << "<br/>" + post["video-caption"]
end

This comment has been minimized.

@parkr

parkr May 6, 2015

Member

if content is nil, should we say content = post["video-caption"]?

@parkr

parkr May 6, 2015

Member

if content is nil, should we say content = post["video-caption"]?

@paramaggarwal

This comment has been minimized.

Show comment
Hide comment
@paramaggarwal

paramaggarwal May 7, 2015

Contributor

@parkr Makes sense! Updated PR.

Contributor

paramaggarwal commented May 7, 2015

@parkr Makes sense! Updated PR.

@parkr

This comment has been minimized.

Show comment
Hide comment
@parkr

parkr May 7, 2015

Member

🎉

Member

parkr commented May 7, 2015

🎉

parkr added a commit that referenced this pull request May 7, 2015

@parkr parkr merged commit fc3c1ff into jekyll:master May 7, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@paramaggarwal paramaggarwal deleted the paramaggarwal:patch-1 branch May 7, 2015

parkr added a commit that referenced this pull request May 7, 2015

@jekyll jekyll locked and limited conversation to collaborators Feb 27, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.