Skip to content

Commit

Permalink
CI test in preparation for a Raku Community release
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Dec 15, 2024
1 parent 4668e2e commit 5c42e94
Show file tree
Hide file tree
Showing 13 changed files with 409 additions and 99 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Linux

on:
push:
branches:
- '*'
tags-ignore:
- '*'
pull_request:

jobs:
raku:
strategy:
matrix:
os:
- ubuntu-latest
raku-version:
- 'latest'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: Raku/setup-raku@v1
with:
raku-version: ${{ matrix.raku-version }}
- name: Install Dependencies
run: zef install --/test --test-depends --deps-only .
- name: Run Special Tests
run: raku run-tests -i
32 changes: 32 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: MacOS

on:
push:
branches:
- '*'
tags-ignore:
- '*'
pull_request:

jobs:
raku:
strategy:
matrix:
os:
- macos-latest
raku-version:
- 'latest'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: Raku/setup-raku@v1
with:
raku-version: ${{ matrix.raku-version }}
- name: Install NotmuchMail
run: brew install notmuch
- name: Make NotMuchMailD reachable
run: raku -e 'symlink "/opt/homebrew/lib/libnotmuch.5.dylib".IO, $*EXECUTABLE.parent.sibling("lib/libnotmuch.5.dylib")'
- name: Install Dependencies
run: zef install --/test --test-depends --deps-only .
- name: Run Special Tests
run: raku run-tests -i
28 changes: 28 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Windows

on:
push:
branches:
- '*'
tags-ignore:
- '*'
pull_request:

jobs:
raku:
strategy:
matrix:
os:
- windows-latest
raku-version:
- 'latest'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: Raku/setup-raku@v1
with:
raku-version: ${{ matrix.raku-version }}
- name: Install Dependencies
run: zef install --/test --test-depends --deps-only .
- name: Run Special Tests
run: raku run-tests -i
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Revision history for WebService::Slack::Webhook

{{$NEXT}}
- Initial version as a Raku Community module
66 changes: 35 additions & 31 deletions META6.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
{
"name": "WebService::Slack::Webhook",
"source-url": "https://github.com/nicqrocks/perl6-slack-webhook.git",
"support": {
"source": null
},
"emulates": {},
"perl": "6.c",
"resources": [],
"build-depends": [],
"auth": "github:nicqrocks",
"excludes": {},
"superseded-by": {},
"depends": [
"Net::HTTP::POST",
"JSON::Fast"
],
"tags": [
"web",
"slack"
],
"license": "Artistic-2.0",
"test-depends": [],
"provides": {
"WebService::Slack::Webhook": "lib/WebService/Slack/Webhook.pm6"
},
"version": "0.1.2",
"supersedes": {},
"authors": [
"Nic Quoziente"
],
"description": "Easy way to send a message to Slack"
"auth": "zef:raku-community-modules",
"authors": [
"Nic Quoziente"
],
"build-depends": [
],
"depends": [
"Net::HTTP::POST",
"JSON::Fast"
],
"description": "Support for Slack's WebService API",
"emulates": {
},
"excludes": {
},
"license": "Artistic-2.0",
"name": "WebService::Slack::Webhook",
"perl": "6.c",
"provides": {
"WebService::Slack::Webhook": "lib/WebService/Slack/Webhook.rakumod"
},
"resources": [
],
"source-url": "https://github.com/raku-community-modules/WebService-Slack-Webhook.git",
"superseded-by": {
},
"supersedes": {
},
"tags": [
"web",
"slack"
],
"test-depends": [
],
"version": "0.1.2"
}
73 changes: 56 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,64 @@
# WebService::Slack::Webhook
Small module to use a Slack 'Incoming Webhook' easily.
[![Actions Status](https://github.com/raku-community-modules/WebService-Slack-Webhook/actions/workflows/linux.yml/badge.svg)](https://github.com/raku-community-modules/WebService-Slack-Webhook/actions) [![Actions Status](https://github.com/raku-community-modules/WebService-Slack-Webhook/actions/workflows/macos.yml/badge.svg)](https://github.com/raku-community-modules/WebService-Slack-Webhook/actions) [![Actions Status](https://github.com/raku-community-modules/WebService-Slack-Webhook/actions/workflows/windows.yml/badge.svg)](https://github.com/raku-community-modules/WebService-Slack-Webhook/actions)

## Design
The idea is to make this module as simple to use as possible. In an effort to do this, info will be passed as a hash instead of named arguments. This is because Slack's API for webhooks is not documented terribly well, and they are always new additions to it. So, instead of preventing you from sending a particular bit of data, just pass a hash and it will be sent.
NAME
====

WebService::Slack::Webhook - Support for Slack's WebService API

SYNOPSIS
========

```raku
use WebService::Slack::Webhook;

### `.new`
The `.new` method will require an 'incoming webhook' integration link from Slack, this way it knows where to connect and has the correct authentication to do so. One of these links will be given after setting up an integration using [this link](https://my.slack.com/services/new/incoming-webhook/ "New Slack incoming webhook"). If the url is not given an exception will be thrown. The syntax for this method will look like this:
my $slack = WebService::Slack::Webhook.new(url => $url);

$slack.send("Beep, boop. *excited robot sounds*");
```

DESCRIPTION
===========

The idea is to make this module as simple to use as possible. In an effort to do this, info will be passed as a hash instead of named arguments. This is because Slack's API for webhooks is not documented terribly well, and they are always new additions to it. So, instead of preventing you from sending a particular bit of data, just pass a hash and it will be sent.

USAGE
=====

.new
----

The `.new` method will require an 'incoming webhook' integration link from Slack, this way it knows where to connect and has the correct authentication to do so.

One of these links will be given after setting up an integration using [this link](https://my.slack.com/services/new/incoming-webhook/) "New Slack incoming webhook". If the url is not given an exception will be thrown. The syntax for this method will look like this:

```raku
#String containing the URL.
my $slack = WebService::Slack::Webhook.new(url => "$url");
my $slack = WebService::Slack::Webhook.new(url => $url);
```

Defaults are now available as well. This should make it easier to use this module, because instead of having to pass a huge hash every time, it can just be set as a default. Note that the defaults can still be overridden just by setting the option to something else when passing a hash. Setting defaults:
```

```raku
#Setting a default hash for the object.
my $slack = WebService::Slack::Webhook.new(
url => "$url",
url => $url,
defaults => %( username => "System Messenger" )
);
```

### `.send`
.send
-----

This will be the method to send a message from. It will be overloaded so that it can be used easier. The correct syntax for it will be:
```

```raku
#Using the '$slack' variable from the previous example...

#Using a hash.
my %info = (
username => "Jimmy the Robot",
username => "Jimmy the Robot",
icon_emoji => ":robot_face:",
text => "Beep, boop. *excited robot sounds*"
text => "Beep, boop. *excited robot sounds*"
);
$slack.send(%info);

Expand All @@ -39,7 +68,17 @@ $slack.send(%info);
$slack.send("Beep, boop. *excited robot sounds*");
```

## Requirements
Everything relies on something else (really I'm just lazy). The following is a list of the modules that are required for this one to function correctly:
- JSON::Fast
- Net::HTTP
AUTHOR
======

Nic Quoziente

COPYRIGHT AND LICENSE
=====================

Copyright 2016 - 2017 Nic Quoziente

Copyright 2024 Raku Community

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.

11 changes: 11 additions & 0 deletions dist.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name = WebService::Slack::Webhook

[ReadmeFromPod]
filename = lib/WebService/Slack/Webhook.rakumod

[UploadToZef]

[Badges]
provider = github-actions/linux.yml
provider = github-actions/macos.yml
provider = github-actions/windows.yml
38 changes: 0 additions & 38 deletions lib/WebService/Slack/Webhook.pm6

This file was deleted.

Loading

0 comments on commit 5c42e94

Please sign in to comment.