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

Make it possible to work without Nokogiri #107

Merged
merged 1 commit into from
Aug 2, 2024

Conversation

daipom
Copy link
Contributor

@daipom daipom commented Jun 7, 2024

Nokogiri is not a mandatory dependency for this plugin, so this plugin should work without it.

Currently, we need to install Nokogiri manually.
Otherwise, the following LoadError occurs:

<internal:/path/to/rubygems/core_ext/kernel_require.rb>:88:in `require': cannot load such file -- nokogiri (LoadError)
    from <internal:/path/to/rubygems/core_ext/kernel_require.rb>:88:in `require'
    from /path/to/gems/fluent-plugin-windows-eventlog-0.8.3/lib/fluent/plugin/bookmark_sax_parser.rb:1:in `<top (required)>'
    ...

We can consider making this work with rexml if Nokogiri is not available.
On the other hand, this PR is based on the idea that we don't have to go that far now.

At least, we should be able to judge if the bookmark is empty or not for #40.
We wouldn't necessarily need an XML parser for this.
(Of course it is preferable to parse it properly, but it wouldn't be as much to make Nokogiri a mandatory dependency just for that purpose.)

Nokogiri is not a mandatory dependency for this plugin, so this should
work without it.

Currently, we need to install Nokogiri manually.
Otherwise, the following LoadError occurs:

    <internal:/path/to/rubygems/core_ext/kernel_require.rb>:88:in `require': cannot load such file -- nokogiri (LoadError)
        from <internal:/path/to/rubygems/core_ext/kernel_require.rb>:88:in `require'
        from /path/to/gems/fluent-plugin-windows-eventlog-0.8.3/lib/fluent/plugin/bookmark_sax_parser.rb:1:in `<top (required)>'
        ...

Signed-off-by: Daijiro Fukuda <[email protected]>
def bookmarklist_is_not_empty?(bookmarkXml, channel)
# Empty example: "<BookmarkList>\r\n</BookmarkList>"
# Not empty example: "<BookmarkList>\r\n <Bookmark Channel='Setup' RecordId='777' IsCurrent='true'/>\r\n</BookmarkList>"
bookmarkXml.include?("Channel")
Copy link
Member

@ashie ashie Jun 8, 2024

Choose a reason for hiding this comment

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

Although it's better than depending nokogiri mandatory, it might be better to do more something here.

In addition, I've noticed that winevt_c should check GetLastError() when it fails on EvtCreateBookmark(): https://github.com/fluent-plugins-nursery/winevt_c/blob/9dd9c81432b1e0180c7abc19de8415bb42db2e49/ext/winevt/winevt_bookmark.c#L93

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

It's worth to merge even without ↑
We'll tackle on it in another PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Sorry I could not make time for this.
Yes, we'll tackle on it in another PR.

@ashie ashie merged commit e233b60 into master Aug 2, 2024
6 checks passed
@ashie ashie deleted the make-work-without-nokogiri branch August 2, 2024 02:39
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