Project

nautilfer

0.0
No release in over a year
Nautilfer provides a robust and flexible way to send notifications to Microsoft Teams using workflow integrations.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

nautilfer

Gem Version Build Status License: MIT

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 install

Or install it yourself as:

$ gem install nautilfer

Resolving 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 UID

export 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 app

Two 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 pages
  • fix: resolve issue with URL redirection
  • docs: update README with usage instructions
  • chore: update dependencies
  • build: update build configuration
  • ci: update CI pipeline
  • style: fix code style issues
  • refactor: refactor code for better readability
  • perf: improve performance of data processing
  • test: 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.