Skip to content

Commit

Permalink
Update code and configuration files
Browse files Browse the repository at this point in the history
  • Loading branch information
FelipeGuzmanSierra committed Mar 25, 2024
1 parent dd09306 commit 6a4f956
Show file tree
Hide file tree
Showing 78 changed files with 59 additions and 87 deletions.
28 changes: 0 additions & 28 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,29 +1 @@
# Changelog

## 0.3.0 (19.03.2024)
- [Add Component - Email fetcher](https://github.com/kommitters/bns/issues/40)
- [Use case - Email based notifications](https://github.com/kommitters/bns/issues/45)
- [Dynamic WIP limit value](https://github.com/kommitters/bns/issues/48)

## 0.2.0 (29.02.2024)
- [Add a Postgres fetcher component](https://github.com/kommitters/bns/issues/28)
- [Use case - PTO's Postgres-Slack implementation](https://github.com/kommitters/bns/issues/30)
- [Slack dispatcher](https://github.com/kommitters/bns/issues/32)
- [Refactor fetcher components](https://github.com/kommitters/bns/issues/34)
- [Add Use Case - Boards WI alerts](https://github.com/kommitters/bns/issues/36)
- [Add Use Case - Next Week Birthday](https://github.com/kommitters/bns/issues/38)
- [Add Use Case - Next Week PTO's](https://github.com/kommitters/bns/issues/39)

## 0.1.1 (07.02.2024)
- [Add custom templates option](https://github.com/kommitters/bns/issues/25)
- [PTO's formatting use cases](https://github.com/kommitters/bns/issues/24)

## 0.1.0 (06.02.2024)

- [Build initial codebase](https://github.com/kommitters/bns/issues/6)
- [Birthdays use case implementation](https://github.com/kommitters/bns/issues/7)
- [PTO’s use case implementation](https://github.com/kommitters/bns/issues/8)
- [Error handler implementation](https://github.com/kommitters/bns/issues/9)
- [Types implementation](https://github.com/kommitters/bns/issues/11)
- [Documentation completion](https://github.com/kommitters/bns/issues/12)
- [Opensource configurations](https://github.com/kommitters/bns/issues/10)
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source "https://rubygems.org"

# Specify your gem's dependencies in bns.gemspec
# Specify your gem's dependencies in bas.gemspec
gemspec

gem "rake", "~> 13.0"
Expand Down
63 changes: 34 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,72 +1,77 @@
# BNS - Business Notification System
# BAS - Business Automation System

Many organizations and individuals rely on automatic notifications across various contexts in their daily operations. With BNS, we aim to provide an open-source platform that empowers users to create customized notification systems tailored to their unique requirements. BNS consists of a series of abstract components designed to facilitate the creation of diverse use cases, regardless of context.
Many organizations and individuals rely on automation across various contexts in their daily operations. With BAS, we aim to provide an open-source platform that empowers users to create customized automation systems tailored to their unique requirements. BAS consists of a series of abstract components designed to facilitate the creation of diverse use cases, regardless of context.

The underlying idea is to develop generic components that can serve a wide range of needs, this approach ensures that all members of the community can leverage the platform's evolving suite of components and use cases to their advantage.

![Gem Version](https://img.shields.io/gem/v/bns?style=for-the-badge)
![Gem Total Downloads](https://img.shields.io/gem/dt/bns?style=for-the-badge)
![Build Badge](https://img.shields.io/github/actions/workflow/status/kommitters/bns/ci.yml?branch=project-opensource-config&style=for-the-badge)
[![Coverage Status](https://img.shields.io/coveralls/github/kommitters/bns?style=for-the-badge)](https://coveralls.io/github/kommitters/bns?branch=main)
![GitHub License](https://img.shields.io/github/license/kommitters/bns?style=for-the-badge)
[![OpenSSF Scorecard](https://img.shields.io/ossf-scorecard/github.com/kommitters/bns?label=openssf%20scorecard&style=for-the-badge)](https://api.securityscorecards.dev/projects/github.com/kommitters/bns)
![Gem Version](https://img.shields.io/gem/v/bas?style=for-the-badge)
![Gem Total Downloads](https://img.shields.io/gem/dt/bas?style=for-the-badge)
![Build Badge](https://img.shields.io/github/actions/workflow/status/kommitters/bas/ci.yml?branch=project-opensource-config&style=for-the-badge)
[![Coverage Status](https://img.shields.io/coveralls/github/kommitters/bas?style=for-the-badge)](https://coveralls.io/github/kommitters/bas?branch=main)
![GitHub License](https://img.shields.io/github/license/kommitters/bas?style=for-the-badge)
[![OpenSSF Scorecard](https://img.shields.io/ossf-scorecard/github.com/kommitters/bas?label=openssf%20scorecard&style=for-the-badge)](https://api.securityscorecards.dev/projects/github.com/kommitters/bas)
[![OpenSSF Best Practices](https://img.shields.io/cii/summary/8383?label=openssf%20best%20practices&style=for-the-badge)](https://bestpractices.coreinfrastructure.org/projects/8383)

## Installation

Install the gem and add to the application's Gemfile by executing:

$ bundle add bns
$ bundle add bas

If bundler is not being used to manage dependencies, install the gem by executing:

$ gem install bns
$ gem install bas

## Requirements

* Ruby 3.2.2 or higher
* Ruby 2.6.0 or higher

## Building my own use case

The gem provides with basic interfaces, types, and methods to shape your own use cases in an easy way.

There are 2 currently implemented use cases:
There are 7 currently implemented use cases:
* Birthday notifications - from Notion to Discord
* Next Week Birthday notifications - from Notion to Discord
* PTO notifications - from Notion to Discord
* Next Week PTO notifications - from Notion to Discord
* PTO notifications - from Postgres to Slack
* WIP limit exceeded - from Notion to Discord
* Support email notification - from IMAP to Discord

For this example we'll analize the birthday notification use case, bringing data from a notion database, and dispatching the
For this example we'll analyze the birthday notification use case, bringing data from a notion database, and dispatching the
notifications to a Discord channel.

A *Use Case* object, consists on 4 main componenets, having it's own responsability:
A *Use Case* object, consists on 4 main components, having it's own responsibility:

### 1. Fetcher - Obtaining the data

Specifically, a fetcher is an object in charged of bringing data from a data source. The gem already provides the base interface
for building your own fetcher for your specific data source, or rely on already built classes if they match your purpose.

The base interface for a fetcher can be found under the `bns/fetcher/base.rb` class. Since this is a implementation of the `Fetcher::Base`
The base interface for a fetcher can be found under the `bas/fetcher/base.rb` class. Since this is a implementation of the `Fetcher::Base`
for bringing data from a Notion database, it was created on a new namespace for that data source, it can be found under
`/bns/fetcher/notion/birthday.rb`. It implements specific logic for fetching the data and validating the response.
`/bas/fetcher/notion/use_case/birthday_today.rb`. It implements specific logic for fetching the data and validating the response.

### 2. Mapper - Shaping it

The **Mapper** responsability, is to shape the data using custom types from the app domain, bringing it into a
The **Mapper** responsibility, is to shape the data using custom types from the app domain, bringing it into a
common structure understandable for other components, specifically the **Formatter**.

Because of the use case, the Mapper implementation for it, relyes on specific types for representing a Birthday it self. It can be found
under `/bns/mapper/notion/birthday.rb`
Because of the use case, the Mapper implementation for it, relies on specific types for representing a Birthday it self. It can be found
under `/bas/mapper/notion/birthday_today.rb`

### 3. Formatter - Preparing the message

The **Formatter**, is in charge of preparing the message to be sent in our notification, and give it the right format with the right data.
The template or 'format' to be used should be included in the use case configurations, which we'll review in a further step. It's
implementation can be found under `/bns/formatter/discord/birthday.rb`.
The template or 'format' to be used should be included in the use case configurations, which we'll review in a further step. It's
implementation can be found under `/bas/formatter/birthday.rb`.

### 4. Dispatcher - Sending your notification

Finally, the **Dispatcher** basically, sends or dispatches the formatted message into a destination, since the use case was implemented for
Discord, it implements specific logic to communicate with a Discord channel using a webhook. The webhook configuration and name for the 'Sender'
in the channel should be provided with the initial use case configurations. It can be found under `/bns/dispatcher/discord/implementation.rb`
Discord, it implements specific logic to communicate with a Discord channel using a webhook. The webhook configuration and name for the 'Sender'
in the channel should be provided with the initial use case configurations. It can be found under `/bas/dispatcher/discord/implementation.rb`

## Examples

Expand All @@ -84,7 +89,7 @@ We'll need some configurations for this specific use case:

With the following formula for the **BD_this_year** column: `dateAdd(prop("BD"), year(now()) - year(prop("BD")), "years")`

* A Notion secret, which can be obtained, by creating an integration here: `https://developers.notion.com/`, browsing on the **View my integations** option, and selecting the **New Integration** or **Create new integration** buttons.
* A Notion secret, which can be obtained, by creating an integration here: `https://developers.notion.com/`, browsing on the **View my integrations** option, and selecting the **New Integration** or **Create new integration** buttons.

* A webhook key, which can be generated directly on discord on the desired channel, following this instructions: `https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks`

Expand Down Expand Up @@ -217,7 +222,7 @@ On your serverless configuration, create your lambda function, on your serverles
```ruby
# frozen_string_literal: true

require 'bns'
require 'bas'

# Initialize the environment variables
NOTION_BASE_URL = 'https://api.notion.com'
Expand Down Expand Up @@ -347,10 +352,10 @@ The gem is licensed under an MIT license. See [LICENSE][license] for details.

</sub>

[license]: https://github.com/kommitters/bns/blob/main/LICENSE
[coc]: https://github.com/kommitters/bns/blob/main/CODE_OF_CONDUCT.md
[changelog]: https://github.com/kommitters/bns/blob/main/CHANGELOG.md
[contributing]: https://github.com/kommitters/bns/blob/main/CONTRIBUTING.md
[license]: https://github.com/kommitters/bas/blob/main/LICENSE
[coc]: https://github.com/kommitters/bas/blob/main/CODE_OF_CONDUCT.md
[changelog]: https://github.com/kommitters/bas/blob/main/CHANGELOG.md
[contributing]: https://github.com/kommitters/bas/blob/main/CONTRIBUTING.md
[kommit-website]: https://kommit.co
[kommit-github]: https://github.com/kommitters
[kommit-x]: https://twitter.com/kommitco
Expand Down
23 changes: 9 additions & 14 deletions bns.gemspec → bas.gemspec
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
# frozen_string_literal: true

require_relative "lib/bns/version"
require_relative "lib/bas/version"

Gem::Specification.new do |spec|
spec.name = "bns"
spec.version = Bns::VERSION
spec.name = "bas"
spec.version = Bas::VERSION
spec.authors = ["kommitters Open Source"]
spec.summary = "BNS - Business notification system"
spec.summary = "BAS - Business automation system"

spec.email = ["[email protected]"]
spec.description = "A versatile business notification system offering key components for building various use cases. \
It provides an easy-to-use tool for implementing notifications without excessive complexity."
spec.homepage = "https://github.com/kommitters/bns"
spec.description = "A versatile business automation system offering key components for building various use cases. \
It provides an easy-to-use tool for implementing automation workflows without excessive complexity. \
Formerly known as 'bns'."
spec.homepage = "https://github.com/kommitters/bas"
spec.license = "MIT"
spec.required_ruby_version = ">= 2.6.0"

spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = "https://github.com/kommitters/bns"
spec.metadata["source_code_uri"] = "https://github.com/kommitters/bas"

# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
Expand All @@ -34,10 +35,4 @@ Gem::Specification.new do |spec|

# For more information and examples about making a new gem, check out our
# guide at: https://bundler.io/guides/creating_gem.html

spec.post_install_message = <<-MESSAGE
! The 'BNS' gem has been deprecated and has been replaced by 'BAS'.
! See: https://rubygems.org/gems/bas
! And: https://github.com/kommitters/bas
MESSAGE
end
2 changes: 1 addition & 1 deletion bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# frozen_string_literal: true

require "bundler/setup"
require "bns"
require "bas"

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
Expand Down
9 changes: 9 additions & 0 deletions lib/bas.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

require_relative "bas/version"
require_relative "bas/use_cases/use_cases"

module Bas # rubocop:disable Style/Documentation
include UseCases
class Error < StandardError; end
end
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions lib/bns/version.rb → lib/bas/version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module Bns
module Bas
# Gem version
VERSION = "0.3.0"
VERSION = "0.1.0"
end
9 changes: 0 additions & 9 deletions lib/bns.rb

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions spec/bns_spec.rb → spec/bas_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

RSpec.describe Bns do
RSpec.describe Bas do
it "has a version number" do
expect(Bns::VERSION).not_to be nil
expect(Bas::VERSION).not_to be nil
end
end
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require "bns"
require "bas"
require "vcr"
require "simplecov"
require "simplecov-lcov"
Expand Down

0 comments on commit 6a4f956

Please sign in to comment.