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

Issue with Webmention command #115

Closed
aarongustafson opened this issue Oct 3, 2018 · 2 comments
Closed

Issue with Webmention command #115

aarongustafson opened this issue Oct 3, 2018 · 2 comments

Comments

@aarongustafson
Copy link
Owner

Getting an error when attempting to make webmentions:

NoMethodError: undefined method `sub’ for nil:NilClass
  /usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-3.4.2/lib/jekyll.rb:170:in `sanitized_path’
  /usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-webmention_io-3.2.0/lib/jekyll/webmention_io.rb:80:in `cache_file’
  /usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-webmention_io-3.2.0/lib/jekyll/commands/webmention.rb:18:in `process’
  /usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-webmention_io-3.2.0/lib/jekyll/commands/webmention.rb:13:in `block (2 levels) in init_with_program’
  /usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute’
  /usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each’
  /usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute’
  /usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go’
  /usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program’
  /usr/local/var/rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-3.4.2/exe/jekyll:13:in `<top (required)>
  /usr/local/var/rbenv/versions/2.4.0/bin/jekyll:23:in `load’
  /usr/local/var/rbenv/versions/2.4.0/bin/jekyll:23:in `<top (required)>

I was not getting this issue prior to some of the recent performance optimizations. My guess is we missed some necessary refactoring as, from the looks of it, Jekyll.sanitized_path() is failing to resolve a clean_path and then the call to sub is failing.

@aarongustafson
Copy link
Owner Author

I took my first stab at addressing this in 4782601. The issue seems to be the command’s ability to access a fully-bootstrapped Jekyll::WebmentionIO in context. Piping in the configuration from the command seems to enable the same functionality, although it seemed to make more sense to separate out the cache setup to its own method that could be called in the initialization of the module or separately from the command.

I’d love to get your thoughts @ashmaroli. Did I miss anything? Could this be simplified?

Worth noting: without access to the Jekyll::Site instance within the command, I had to drop the original path sanitization code in favor of what Jekyll actually uses under the hood. Hopefully that still accomplishes the same goal.

@ashmaroli
Copy link
Contributor

@aarongustafson I've submitted a simplified proposal to resolve this issue in #116
If you can "describe" how a sample site would look like when the jekyll webmention command is to be used, we can setup Travis to test the Command class as well..

Once that is done, we may refactor WebmentionCommand.init_with_program(prog) to change the signature of the process method (if you do not plan to handle args to the command ever)..

    class WebmentionCommand < Command
      def self.init_with_program(prog)
        prog.command(:webmention) do |c|
          c.syntax "webmention"
          c.description "Sends queued webmentions"

          c.action { |_, options| process options }
        end
      end

      def self.process(options = {})
        [...]
      end

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

No branches or pull requests

2 participants