nautilfer
nautilfer is a gem that allows you to parse and analyze web pages, extracting key statistics and information for further use within your projects.
Requirements
- Ruby >= 4.0
Installation
Add this line to your application's Gemfile:
gem 'nautilfer'And then execute:
$ bundle installOr install it yourself as:
$ gem install nautilferResolving UID Mismatch Between Docker and Host
The dev container runs as a non-root user so that files it writes to the mounted checkout are owned by you rather than by root. The image bakes in whichever UID the build receives, and defaults to 1000.
If your UID is not 1000, the build has to be told. Otherwise the container runs as 1000, your checkout is owned by
someone else, and writes to /app fail instead of merely being misowned. Export UID once, and every docker compose
command picks it up:
# in .bashrc or similar
export UIDexport UID with no assignment is the form that works: UID is read-only in bash, so export UID=... fails with
UID: readonly variable. For a single command without touching your shell config:
env UID=$(id -u) docker compose build appTwo limits. The UID must be 1000 or above — below that it collides with a system account in the base image and
useradd fails the build on purpose (useradd: UID 0 is not unique), so run the build as an ordinary user rather than
as root. And this matters on Linux hosts: on Docker Desktop for Windows the bind mount does not carry host ownership,
so there is nothing to match.
Usage
To use nautilfer, first require it.
require 'nautilfer'Instantiate Nautilfer with the adapter you want to use:
notifier = Nautilfer.new(endpoint: "#{workflow_endpoint}", adapter: Nautilfer::Adapters::Teams.new)
notifier.notify("## TEST\nhello")To notify a Slack channel via Incoming Webhook:
slack_notifier = Nautilfer.new(endpoint: "#{slack_webhook_url}", adapter: Nautilfer::Adapters::Slack.new)
slack_notifier.notify("Deployment completed")Control notifications by environment
Use the environment controls to avoid sending notifications in non-production environments. The notifier checks the environment you pass in (defaulting to ENV['NAUTILFER_ENV'], ENV['RAILS_ENV'], or ENV['RACK_ENV']) and will only send messages when the environment is allowed.
Enable notifications only in specific environments:
notifier = Nautilfer.new(
endpoint: "#{workflow_endpoint}",
adapter: Nautilfer::Adapters::Teams.new,
environment: 'production',
enabled_environments: ['production']
)
notifier.notify("Release deployed")Or disable notifications for certain environments:
slack_notifier = Nautilfer.new(
endpoint: "#{slack_webhook_url}",
adapter: Nautilfer::Adapters::Slack.new,
environment: 'test',
disabled_environments: ['test', 'development']
)
slack_notifier.notify("Smoke tests running")Configure defaults once
Persist your environment preferences by configuring defaults up front. New instances will reuse these values unless you override them per call.
Nautilfer.configure do |config|
config.environment = ENV['NAUTILFER_ENV']
config.enabled_environments = ['production']
config.disabled_environments = ['test']
end
notifier = Nautilfer.new(endpoint: "#{workflow_endpoint}", adapter: :teams)
notifier.notify("Deployment finished")Configure message templates
Define reusable message templates in the global configuration and select them when instantiating a notifier. Templates are callables that receive the original message and return the formatted text.
Nautilfer.configure do |config|
config.message_templates = {
default: ->(message) { "[default] #{message}" },
headline: ->(message) { "## #{message}" }
}
config.default_message_template = :default
end
notifier = Nautilfer.new(endpoint: "#{workflow_endpoint}", adapter: :slack)
notifier.notify("Deployment finished") # => sends "[default] Deployment finished"
headline_notifier = Nautilfer.new(endpoint: "#{workflow_endpoint}", adapter: :slack, message_template: :headline)
headline_notifier.notify("Deployment finished") # => sends "## Deployment finished"Chatwork Notification Integration
To enable Chatwork notifications using the unified adapter interface, initialize Nautilfer with the Chatwork adapter and tar
get a room-specific endpoint:
endpoint = "https://api.chatwork.com/v2/rooms/#{room_id}/messages"
notifier = Nautilfer.new(
endpoint: endpoint,
adapter: Nautilfer::Adapters::Chatwork.new(api_token: ENV['CHATWORK_API_TOKEN'])
)
notifier.notify('This is a test message from Nautilfer!')You can also pass adapter: :chatwork when CHATWORK_API_TOKEN is set in your environment.
Features
- More features coming soon!
Commit Message Guidelines
To ensure consistency and facilitate automatic updates to the CHANGELOG.md, please follow the Conventional Commits specification when creating commit messages. This helps maintain a clear and structured commit history.
When submitting a Pull Request (PR), make sure your commits adhere to these guidelines.
Example of Conventional Commit Messages:
feat: add new feature for parsing web pagesfix: resolve issue with URL redirectiondocs: update README with usage instructionschore: update dependenciesbuild: update build configurationci: update CI pipelinestyle: fix code style issuesrefactor: refactor code for better readabilityperf: improve performance of data processingtest: add new tests for URL parsing module
By following these guidelines, you help ensure that our project's commit history is easy to navigate and that versioning and release notes are generated correctly.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/slidict/nautilfer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
License
The gem is available as open-source under the terms of the MIT License.
Acknowledgments
Special thanks to all the contributors and open-source projects that make this possible.