slack_messaging 1.0.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.codeclimate.yml +37 -0
- data/.github/code_of_conduct.md +85 -0
- data/.github/contributing.md +11 -0
- data/.github/issue_template.md +99 -0
- data/.github/pull_request_template.md +19 -0
- data/.github/security.md +11 -0
- data/.github/workflows/develop.yml +30 -0
- data/.ruby-version +1 -1
- data/Guardfile +5 -0
- data/{LICENSE.txt → LICENSE} +0 -0
- data/README.md +48 -20
- data/lib/slack_messaging/config.rb +7 -50
- data/lib/slack_messaging/random_message.rb +19 -19
- data/lib/slack_messaging/version.rb +1 -1
- data/slack_messaging.gemspec +23 -22
- data/spec/slack_messaging/config_spec.rb +4 -23
- data/spec/spec_helper.rb +3 -0
- metadata +46 -30
- data/.octopolo.yml +0 -4
- data/.rspec +0 -2
- data/.soyuz.yml +0 -13
- data/.travis.yml +0 -10
- data/CHANGELOG.markdown +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 93cd98600f0898757299926ffefac71db5786acbf90e505530682fca8509a8c9
|
4
|
+
data.tar.gz: 95f6c1ecb7e4bd06aacd0d2158bf0709bb9c9d942e54ddb6d4494add2f4125d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a4eba4e6b9dd8d28c4695f54ec50b0c65d1120ba38fc2cf9b5a2de3cb62bd06d6a93ff12e2e210ba392efb1bf54859369eb9d86d6f026aa52a49d45dbeaf1b9
|
7
|
+
data.tar.gz: ff7496274332c5dc60c7b06d110a7f4af88bcd613798a940905de656722439011be782009d7c6b4e7089e290fbdbc35e483156789ae16722e4a049eaf884a7b7
|
data/.codeclimate.yml
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
version: "2"
|
2
|
+
checks:
|
3
|
+
argument-count:
|
4
|
+
config:
|
5
|
+
threshold: 4
|
6
|
+
complex-logic:
|
7
|
+
config:
|
8
|
+
threshold: 4
|
9
|
+
file-lines:
|
10
|
+
config:
|
11
|
+
threshold: 250
|
12
|
+
method-complexity:
|
13
|
+
config:
|
14
|
+
threshold: 8
|
15
|
+
method-count:
|
16
|
+
config:
|
17
|
+
threshold: 20
|
18
|
+
method-lines:
|
19
|
+
config:
|
20
|
+
threshold: 25
|
21
|
+
nested-control-flow:
|
22
|
+
config:
|
23
|
+
threshold: 4
|
24
|
+
return-statements:
|
25
|
+
config:
|
26
|
+
threshold: 4
|
27
|
+
similar-code:
|
28
|
+
config:
|
29
|
+
threshold: # language-specific defaults. an override will affect all languages.
|
30
|
+
identical-code:
|
31
|
+
config:
|
32
|
+
threshold: # language-specific defaults. an override will affect all languages.
|
33
|
+
exclude_patterns:
|
34
|
+
- "**/spec/"
|
35
|
+
- "**/test/"
|
36
|
+
- "**/vendor/"
|
37
|
+
- "**/*.js"
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
### Table of Contents
|
4
|
+
|
5
|
+
* [Our Pledge](#our-pledge)
|
6
|
+
* [Our Standards](#our-standards)
|
7
|
+
* [Our Responsibilities](#our-responsibilities)
|
8
|
+
* [Scope](#scope)
|
9
|
+
* [Enforcement](#enforcement)
|
10
|
+
* [Attribution](#attribution)
|
11
|
+
|
12
|
+
## Our Pledge
|
13
|
+
|
14
|
+
In the interest of fostering an open and welcoming environment, we as
|
15
|
+
contributors and maintainers pledge to making participation in our project and
|
16
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
17
|
+
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
18
|
+
level of experience, education, socio-economic status, nationality, personal
|
19
|
+
appearance, race, religion, or sexual identity and orientation.
|
20
|
+
|
21
|
+
## Our Standards
|
22
|
+
|
23
|
+
Examples of behavior that contributes to creating a positive environment
|
24
|
+
include:
|
25
|
+
|
26
|
+
* Using welcoming and inclusive language
|
27
|
+
* Being respectful of differing viewpoints and experiences
|
28
|
+
* Gracefully accepting constructive criticism
|
29
|
+
* Focusing on what is best for the community
|
30
|
+
* Showing empathy towards other community members
|
31
|
+
|
32
|
+
Examples of unacceptable behavior by participants include:
|
33
|
+
|
34
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
35
|
+
advances
|
36
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
37
|
+
* Public or private harassment
|
38
|
+
* Publishing others' private information, such as a physical or electronic
|
39
|
+
address, without explicit permission
|
40
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
41
|
+
professional setting
|
42
|
+
|
43
|
+
## Our Responsibilities
|
44
|
+
|
45
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
46
|
+
behavior and are expected to take appropriate and fair corrective action in
|
47
|
+
response to any instances of unacceptable behavior.
|
48
|
+
|
49
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
50
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
51
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
52
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
53
|
+
threatening, offensive, or harmful.
|
54
|
+
|
55
|
+
## Scope
|
56
|
+
|
57
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
58
|
+
when an individual is representing the project or its community. Examples of
|
59
|
+
representing a project or community include using an official project e-mail
|
60
|
+
address, posting via an official social media account, or acting as an appointed
|
61
|
+
representative at an online or offline event. Representation of a project may be
|
62
|
+
further defined and clarified by project maintainers.
|
63
|
+
|
64
|
+
## Enforcement
|
65
|
+
|
66
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
67
|
+
reported by contacting the project team at emma.sax4@gmail.com. All
|
68
|
+
complaints will be reviewed and investigated and will result in a response that
|
69
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
70
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
71
|
+
Further details of specific enforcement policies may be posted separately.
|
72
|
+
|
73
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
74
|
+
faith may face temporary or permanent repercussions as determined by other
|
75
|
+
members of the project's leadership.
|
76
|
+
|
77
|
+
## Attribution
|
78
|
+
|
79
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
80
|
+
available at [https://www.contributor-covenant.org/version/1/4/code-of-conduct.html](https://www.contributor-covenant.org/version/1/4/code-of-conduct.html).
|
81
|
+
|
82
|
+
[homepage]: [https://www.contributor-covenant.org](https://www.contributor-covenant.org)
|
83
|
+
|
84
|
+
For answers to common questions about this code of conduct, see
|
85
|
+
[https://www.contributor-covenant.org/faq](https://www.contributor-covenant.org/faq).
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
1. Fork it (https://github.com/emmasax4/slack_messaging/fork)
|
4
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
5
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
6
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
7
|
+
5. Continue making awesome changes!
|
8
|
+
6. To see how it works, follow the [Usage section in the README.md](https://github.com/emmasax4/slack_messaging#usage)
|
9
|
+
7. When you're satisfied, make a pull request to this repository
|
10
|
+
8. If I don't comment or start looking at the pull request in a couple of days, feel free to send me [an email](mailto:emma.sax4@gmail.com)
|
11
|
+
9. I approve your pull request and merge!
|
@@ -0,0 +1,99 @@
|
|
1
|
+
Please fill in the section that best describes your issue and delete all other sections.
|
2
|
+
|
3
|
+
<details><summary>Bug Report</summary>
|
4
|
+
|
5
|
+
## Bug Description
|
6
|
+
|
7
|
+
> A clear and concise description of what the bug is.
|
8
|
+
|
9
|
+
## To Reproduce
|
10
|
+
|
11
|
+
> Steps to reproduce the behavior:
|
12
|
+
>
|
13
|
+
> 1. Go to "..."
|
14
|
+
> 2. Click on "..."
|
15
|
+
> 3. Scroll down to "..."
|
16
|
+
> 4. See error
|
17
|
+
|
18
|
+
## Expected Behavior
|
19
|
+
|
20
|
+
> A clear and concise description of what you expected to happen.
|
21
|
+
|
22
|
+
## Screenshots
|
23
|
+
|
24
|
+
> If applicable, add screenshots to help explain your problem.
|
25
|
+
|
26
|
+
## Desktop
|
27
|
+
|
28
|
+
> Please complete the following information:
|
29
|
+
>
|
30
|
+
> - OS: [e.g. iOS]
|
31
|
+
> - Browser: [e.g. chrome, safari]
|
32
|
+
> - Version: [e.g. 22]
|
33
|
+
|
34
|
+
## Smartphone
|
35
|
+
|
36
|
+
> Please complete the following information:
|
37
|
+
>
|
38
|
+
> - Device: [e.g. iPhone6]
|
39
|
+
> - OS: [e.g. iOS8.1]
|
40
|
+
> - Browser: [e.g. stock browser, safari]
|
41
|
+
> - Version: [e.g. 22]
|
42
|
+
|
43
|
+
## Additional Context
|
44
|
+
|
45
|
+
> Add any other context about the problem here.
|
46
|
+
|
47
|
+
</details>
|
48
|
+
|
49
|
+
<details><summary>Feature Request</summary>
|
50
|
+
|
51
|
+
## Is this feature request related to a problem?
|
52
|
+
|
53
|
+
> A clear and concise description of what the problem is. Ex: I'm always frustrated when [...]
|
54
|
+
|
55
|
+
## The Solution I'd Prefer
|
56
|
+
|
57
|
+
> A clear and concise description of what you want to happen.
|
58
|
+
|
59
|
+
## Alternative Solutions I've Considered
|
60
|
+
|
61
|
+
> A clear and concise description of any alternative solutions or features you've considered.
|
62
|
+
|
63
|
+
## Additional Context
|
64
|
+
|
65
|
+
> Add any other context or screenshots about the feature request here.
|
66
|
+
|
67
|
+
</details>
|
68
|
+
|
69
|
+
<details><summary>Security Report</summary>
|
70
|
+
|
71
|
+
## What is the alert or vulnerability?
|
72
|
+
|
73
|
+
> A clear and concise description of what the vulnerability is. Ex: The Ruby gem [...] has reported vulnerability CVE-[...].
|
74
|
+
|
75
|
+
## Where did you find out about this vulnerability?
|
76
|
+
|
77
|
+
> A clear and concise description of where this vulnerability was first reported or where you heard about it.
|
78
|
+
|
79
|
+
## What are the risks of doing nothing?
|
80
|
+
|
81
|
+
> A clear and concise description of what will happen if we leave the vulnerability as is.
|
82
|
+
|
83
|
+
## Suggestions for improvement?
|
84
|
+
|
85
|
+
> A clear and concise description of what can be done to mitigate this vulnerability.
|
86
|
+
|
87
|
+
## Additional Context
|
88
|
+
|
89
|
+
> Add any other context, URLs, or screenshots about the alert or vulnerability.
|
90
|
+
|
91
|
+
</details>
|
92
|
+
|
93
|
+
<details><summary>General Question or Concern</summary>
|
94
|
+
|
95
|
+
## What's your question or comment?
|
96
|
+
|
97
|
+
> A clear and concise question or comment. Please add as much context as possible.
|
98
|
+
|
99
|
+
</details>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
## Changes
|
2
|
+
|
3
|
+
> A list of the changes that your pull request will make:
|
4
|
+
>
|
5
|
+
> * Adding a page "..."
|
6
|
+
> * Refactoring "..."
|
7
|
+
|
8
|
+
## Related Pull Requests and Issues
|
9
|
+
|
10
|
+
> If applicable, a list of related pull requests and issues:
|
11
|
+
>
|
12
|
+
> * Issue #1
|
13
|
+
> * Issue #2
|
14
|
+
> * Pull Request #1
|
15
|
+
> * Pull Request #2
|
16
|
+
|
17
|
+
## Additional Context
|
18
|
+
|
19
|
+
> Add any other context about the problem here.
|
data/.github/security.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Security Policy
|
2
|
+
|
3
|
+
## Reporting a Vulnerability
|
4
|
+
|
5
|
+
If you happen to find any security vulnerabilities in this project, please let me know! I've turned on GitHub's security advisory and alert suggestions, but it's always possible that I'll miss something.
|
6
|
+
|
7
|
+
To let me know there's a security vulnerability, please make a [new GitHub Issue](https://github.com/emmasax4/slack_messaging/issues/new) and fill in the Security Report section to the best of your capabilities.
|
8
|
+
|
9
|
+
I'll respond on the Issue or take appropriate action as soon as I'm able.
|
10
|
+
|
11
|
+
Thank you for helping my project to be as secure as possible.
|
@@ -0,0 +1,30 @@
|
|
1
|
+
name: Develop
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
branches: [ main ]
|
5
|
+
pull_request:
|
6
|
+
branches: [ main ]
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
test:
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
steps:
|
12
|
+
- name: Check Out Code
|
13
|
+
uses: actions/checkout@v2
|
14
|
+
with:
|
15
|
+
fetch-depth: 0
|
16
|
+
|
17
|
+
- name: Define Run Variables
|
18
|
+
run: echo "::set-env name=BRANCH::$(echo ${{ github.head_ref }} | sed -E 's|refs/[a-zA-Z]+/||')"
|
19
|
+
|
20
|
+
- name: Switch to Current Branch
|
21
|
+
run: git checkout ${{ env.BRANCH }}
|
22
|
+
|
23
|
+
- name: Configure System
|
24
|
+
run: sudo gem update --system 3.0.8 && sudo gem install bundler
|
25
|
+
|
26
|
+
- name: Install Gems
|
27
|
+
run: bundle config set path "vendor/bundle" && bundle install
|
28
|
+
|
29
|
+
- name: Run Rspec Tests
|
30
|
+
run: bundle exec rspec
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.
|
1
|
+
ruby-2.7.1
|
data/Guardfile
ADDED
data/{LICENSE.txt → LICENSE}
RENAMED
File without changes
|
data/README.md
CHANGED
@@ -1,29 +1,44 @@
|
|
1
|
-
# Slack Messaging [![
|
1
|
+
# Slack Messaging [![Maintainability](https://api.codeclimate.com/v1/badges/c74baada70ad96048dc7/maintainability)](https://codeclimate.com/github/emmasax4/slack_messaging/maintainability) ![Develop](https://github.com/emmasax4/slack_messaging/workflows/Develop/badge.svg)
|
2
2
|
|
3
3
|
This is a simple project designed to post messages to a given Slack channel as a bot.
|
4
4
|
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'slack_messaging'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install slack_messaging
|
20
|
+
|
5
21
|
### Usage
|
6
22
|
|
7
|
-
|
23
|
+
This project requires a config file that should look like this:
|
8
24
|
|
9
25
|
```
|
10
|
-
|
11
|
-
|
26
|
+
slack:
|
27
|
+
channel: "#<AWESOME CHANNEL NAME>"
|
28
|
+
username: <AWESOME USER NAME>
|
29
|
+
webhook_url: <WEBHOOK URL>
|
30
|
+
icon_emoji: ":<SOME EMOJI>:"
|
12
31
|
```
|
13
32
|
|
14
|
-
|
33
|
+
The default is for the file to be named `~/.slack_messaging.yml`, but a different path can be passed in like this:
|
15
34
|
|
16
35
|
```
|
17
|
-
slack
|
18
|
-
channel: "#[AWESOME CHANNEL NAME]"
|
19
|
-
username: [AWESOME USER NAME]
|
20
|
-
webhook_url: [WEBHOOK URL]
|
21
|
-
icon_emoji: ":[SOME EMOJI]:"
|
36
|
+
$ slack-messaging --config="/PATH/TO/FILE/config.yml" slack
|
22
37
|
```
|
23
38
|
|
24
39
|
To obtain the webhook url, go to [this link](https://api.slack.com/incoming-webhooks).
|
25
40
|
|
26
|
-
Okay, now the project will
|
41
|
+
Okay, now the project will be ready to rock and roll.
|
27
42
|
|
28
43
|
To print a friendly message to Slack, run:
|
29
44
|
|
@@ -31,7 +46,7 @@ To print a friendly message to Slack, run:
|
|
31
46
|
slack-messaging slack
|
32
47
|
```
|
33
48
|
|
34
|
-
from the main directory. Here, no specific message is being given to print to Slack, so slack_messaging will choose a random quote, which are all defined in [`lib/slack_messaging/random_message.rb`](https://github.com/
|
49
|
+
from the main directory. Here, no specific message is being given to print to Slack, so slack_messaging will choose a random quote, which are all defined in [`lib/slack_messaging/random_message.rb`](https://github.com/emmasax4/slack_messaging/blob/main/lib/slack_messaging/random_message.rb). Feel free to change the messages or add more to cater what you'd like slack_messaging to say.
|
35
50
|
|
36
51
|
However, what if you wanted to print something specific? Well, you can! Just run:
|
37
52
|
|
@@ -47,18 +62,31 @@ slack-messaging slack "MESSAGE 1" "MESSAGE 2" "MESSAGE 3" ... "MESSAGE N"
|
|
47
62
|
|
48
63
|
The output of slack_messaging will look something like this:
|
49
64
|
|
50
|
-
<img src="https://github.com/
|
65
|
+
<img src="https://github.com/emmasax4/slack_messaging/blob/main/OutputFile.png" width="1000">
|
51
66
|
|
52
67
|
I hope you enjoy printing fun and specialized messages to Slack!
|
53
68
|
|
54
69
|
### Tests
|
55
70
|
|
56
|
-
To run the tests, run `rspec` from the command line.
|
71
|
+
To run the tests, run `bundle exec rspec` from the command line. GitHub Actions will also run the tests upon every commit to make sure they're up to date and that everything is working correctly. Locally, you can also run `bundle exec guard` to automatically run tests as you develop! There are currently only tests for the `notify_slack` and `random_message` classes. Feel free to help us add more!
|
72
|
+
|
73
|
+
## Contributing
|
74
|
+
|
75
|
+
To submit a feature request, bug ticket, etc, please submit an official [GitHub Issue](https://github.com/emmasax4/slack_messaging/issues/new).
|
76
|
+
|
77
|
+
To report any security vulnerabilities, please view this project's [Security Policy](https://github.com/emmasax4/slack_messaging/security/policy).
|
78
|
+
|
79
|
+
This repository does have a standard [Code of Conduct](https://github.com/emmasax4/slack_messaging/blob/main/.github/code_of_conduct.md).
|
80
|
+
|
81
|
+
## Releasing
|
82
|
+
|
83
|
+
To make a new release of this gem:
|
57
84
|
|
58
|
-
|
85
|
+
1. Merge the pull request via the big green button
|
86
|
+
2. Run `git tag vX.X.X` and `git push --tag`
|
87
|
+
3. Make a new release [here](https://github.com/emmasax4/slack_messaging/releases/new)
|
88
|
+
4. Run `gem build *.gemspec`
|
89
|
+
5. Run `gem push *.gem` to push the new gem to RubyGems
|
90
|
+
6. Run `rm *.gem` to clean up your local repository
|
59
91
|
|
60
|
-
|
61
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
62
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
63
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
64
|
-
5. Create a new Pull Request
|
92
|
+
To set up your local machine to push to RubyGems via the API, see the [RubyGems documentation](https://guides.rubygems.org/publishing/#publishing-to-rubygemsorg).
|
@@ -1,14 +1,8 @@
|
|
1
1
|
require 'yaml'
|
2
|
+
require 'hashie'
|
2
3
|
|
3
4
|
module SlackMessaging
|
4
5
|
|
5
|
-
module PrivateAttrAccessor
|
6
|
-
def private_attr_accessor(*names)
|
7
|
-
private
|
8
|
-
attr_accessor *names
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
6
|
class DefaultPaths
|
13
7
|
class << self
|
14
8
|
def config
|
@@ -22,15 +16,10 @@ module SlackMessaging
|
|
22
16
|
end
|
23
17
|
|
24
18
|
class Config
|
25
|
-
|
26
|
-
CONFIG_DEFAULTS = {}
|
27
|
-
|
28
19
|
class << self
|
29
|
-
extend PrivateAttrAccessor
|
30
|
-
private_attr_accessor :config_data
|
31
20
|
|
32
21
|
def config
|
33
|
-
|
22
|
+
config_data.to_hash
|
34
23
|
end
|
35
24
|
|
36
25
|
def load(path)
|
@@ -38,54 +27,22 @@ module SlackMessaging
|
|
38
27
|
config
|
39
28
|
end
|
40
29
|
|
41
|
-
def
|
42
|
-
|
43
|
-
config
|
30
|
+
def config_data
|
31
|
+
@config_data ||= Hashie::Mash.new
|
44
32
|
end
|
45
|
-
|
46
|
-
def data
|
47
|
-
self.config_data ||= {}
|
48
|
-
end
|
49
|
-
private :data
|
50
|
-
|
51
|
-
def default_value(key)
|
52
|
-
CONFIG_DEFAULTS[key.to_sym]
|
53
|
-
end
|
54
|
-
private :default_value
|
33
|
+
private :config_data
|
55
34
|
|
56
35
|
def method_missing(method, args=false)
|
57
|
-
|
58
|
-
return default_value(method) if default_value(method)
|
59
|
-
nil
|
36
|
+
config_data.send(method, args)
|
60
37
|
end
|
61
38
|
private :method_missing
|
62
39
|
|
63
40
|
def load_config(file)
|
64
41
|
raise MissingConfig, "Missing configuration file: #{file}" unless File.exist?(file)
|
65
|
-
|
42
|
+
YAML.load_file(file).each{ |key,value| config_data.assign_property(key, value) }
|
66
43
|
end
|
67
44
|
private :load_config
|
68
45
|
|
69
|
-
# We want all ouf our YAML loaded keys to be symbols
|
70
|
-
# taken from http://devblog.avdi.org/2009/07/14/recursively-symbolize-keys/
|
71
|
-
def symbolize_keys(hash)
|
72
|
-
hash.inject({}){|result, (key, value)|
|
73
|
-
new_key = case key
|
74
|
-
when String then key.to_sym
|
75
|
-
else key
|
76
|
-
end
|
77
|
-
new_value = case value
|
78
|
-
when Hash then symbolize_keys(value)
|
79
|
-
else value
|
80
|
-
end
|
81
|
-
result[new_key] = new_value
|
82
|
-
result
|
83
|
-
}
|
84
|
-
end
|
85
|
-
private :symbolize_keys
|
86
|
-
|
87
46
|
end
|
88
|
-
|
89
|
-
MissingConfig = Class.new(StandardError)
|
90
47
|
end
|
91
48
|
end
|
@@ -3,25 +3,25 @@ module SlackMessaging
|
|
3
3
|
attr_accessor :text
|
4
4
|
|
5
5
|
MESSAGE_ARRAY = [
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
6
|
+
"A true friend is someone who thinks that you are a good egg even though he knows that you are slightly cracked.\n--Bernard Meltzer",
|
7
|
+
"If you can't make it good, at least make it look good.\n--Bill Gates",
|
8
|
+
"I'm convinced of this: Good done anywhere is good done everywhere.\n--Maya Angelou",
|
9
|
+
"The real trouble with reality is that there's no background music.\n--Anonymous",
|
10
|
+
"Whatever you are, be a good one.\n--Abraham Lincoln",
|
11
|
+
"Good, better, best. Never let it rest. 'Til your good is better and your better is best.\n--St. Jerome",
|
12
|
+
"Despite everything, I believe that people are really good at heart.\n--Anne Frank",
|
13
|
+
"Life is 10% what happens to you and 90% how you react to it.\n--Charles R. Swindoll",
|
14
|
+
"The way to get started is to quit talking and begin doing.\n--Walt Disney",
|
15
|
+
"A creative man is motivated by the desire to achieve, not by the desire to beat others.\n--Ayn Rand",
|
16
|
+
"Problems are not stop signs, they are guidelines.\n--Robert H. Schuller",
|
17
|
+
"Correction does much, but encouragement does more.\n--Johann Wolfgang von Goethe",
|
18
|
+
"Positive anything is better than negative nothing.\n--Elbert Hubbard",
|
19
|
+
"To succeed, you need to find something to hold on to, something to motivate you, something to inspire you.\n--Joyce Meyer",
|
20
|
+
"If you're not making mistakes, then you're not doing anything. I'm positive that a doer makes mistakes.\n--John Wooden",
|
21
|
+
"The best way to deal with other people is to just let them be other people.\n--Anonymous",
|
22
|
+
"Talk to yourself like you would to someone you love.\n--Brenee Brown",
|
23
|
+
"Don't let small minds convince you that your dreams are too big.\n--Anonymous",
|
24
|
+
]
|
25
25
|
|
26
26
|
def initialize
|
27
27
|
self.text = MESSAGE_ARRAY[rand(MESSAGE_ARRAY.length)]
|
data/slack_messaging.gemspec
CHANGED
@@ -3,29 +3,30 @@ lib = File.expand_path('../lib', __FILE__)
|
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
4
|
require 'slack_messaging/version'
|
5
5
|
|
6
|
-
Gem::Specification.new do |
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "slack_messaging"
|
8
|
+
gem.version = SlackMessaging::VERSION
|
9
|
+
gem.authors = ["Emma Sax"]
|
10
|
+
gem.email = ["emma.sax4@gmail.com"]
|
11
|
+
gem.summary = %q{Personalized Slack Messages}
|
12
|
+
gem.description = %q{Sending Personalized Slack Messages to a Slack channel of your choice.}
|
13
|
+
gem.homepage = "https://github.com/emmasax4/slack_messaging"
|
14
|
+
gem.license = "MIT"
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
gem.files = `git ls-files -z`.split("\x0")
|
17
|
+
gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
|
+
gem.require_paths = ["lib"]
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
gem.add_dependency 'hashie', '~> 4.1'
|
22
|
+
gem.add_dependency 'gli', '~> 2.10'
|
23
|
+
gem.add_dependency 'highline', '~> 2.0'
|
24
|
+
gem.add_dependency 'slack-notifier', '~> 1.5.1'
|
25
|
+
gem.add_dependency 'rack', '~> 2.2'
|
26
|
+
gem.add_dependency 'activesupport', '~> 6.0'
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
gem.add_development_dependency 'bundler', '~> 2.1'
|
29
|
+
gem.add_development_dependency 'guard-rspec', '~> 4.3'
|
30
|
+
gem.add_development_dependency 'rake', '~> 13.0'
|
31
|
+
gem.add_development_dependency 'rspec', '~> 3.9'
|
31
32
|
end
|
@@ -4,32 +4,13 @@ require 'slack_messaging'
|
|
4
4
|
module SlackMessaging
|
5
5
|
describe Config do
|
6
6
|
|
7
|
-
context "#set_config_options" do
|
8
|
-
it "should create a corresponding method that returns the value" do
|
9
|
-
SlackMessaging::Config.set_config_options(test: "something")
|
10
|
-
expect(SlackMessaging::Config.test).to eql("something")
|
11
|
-
end
|
12
|
-
|
13
|
-
it "setting a new key should return the entire config hash" do
|
14
|
-
items = SlackMessaging::Config.config.count
|
15
|
-
expect(SlackMessaging::Config.set_config_options(test1: "something_else").count).to eql(items + 1)
|
16
|
-
expect(SlackMessaging::Config.set_config_options(test2: "something else").count).to eql(items + 2)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
context "#config_data" do
|
21
|
-
it "should be a private method" do
|
22
|
-
expect(SlackMessaging::Config).not_to respond_to(:config_data)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
7
|
context "config key methods" do
|
27
8
|
it "should return nil when not set" do
|
28
9
|
expect(SlackMessaging::Config.doesnt_exist).to eql(nil)
|
10
|
+
expect(SlackMessaging::Config.doesnt_exist?).to eql(false)
|
29
11
|
end
|
30
|
-
|
31
12
|
it "should return the config value when set" do
|
32
|
-
SlackMessaging::Config.
|
13
|
+
SlackMessaging::Config.new_value = "testing"
|
33
14
|
expect(SlackMessaging::Config.new_value).to eql("testing")
|
34
15
|
end
|
35
16
|
end
|
@@ -37,7 +18,7 @@ module SlackMessaging
|
|
37
18
|
context "after loading a config file" do
|
38
19
|
before do
|
39
20
|
config_file = {"domain" => "example_domain",
|
40
|
-
"slack" => {"slack_option"=>true,
|
21
|
+
"slack" => {"slack_option" => true,
|
41
22
|
"username" => "Rspec Tester",
|
42
23
|
"icon_url" => "http://fake.url",
|
43
24
|
"channel" => "#test-channel",
|
@@ -55,7 +36,7 @@ module SlackMessaging
|
|
55
36
|
|
56
37
|
it "overwriting values should work" do
|
57
38
|
expect(SlackMessaging::Config.slack).to be_kind_of(Hash)
|
58
|
-
SlackMessaging::Config.
|
39
|
+
SlackMessaging::Config.slack = "this is a string now"
|
59
40
|
expect(SlackMessaging::Config.slack).to eql("this is a string now")
|
60
41
|
end
|
61
42
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -31,6 +31,9 @@ RSpec.configure do |config|
|
|
31
31
|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
32
32
|
end
|
33
33
|
|
34
|
+
config.filter_run :focus => true
|
35
|
+
config.run_all_when_everything_filtered = true
|
36
|
+
|
34
37
|
# rspec-mocks config goes here. You can use an alternate test double
|
35
38
|
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
36
39
|
config.mock_with :rspec do |mocks|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack_messaging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emma Sax
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '4.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '4.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: gli
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '2.0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '2.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: slack-notifier
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,71 +72,85 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: '2.2'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: '2.2'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: activesupport
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '6.0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '6.0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: bundler
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '1
|
103
|
+
version: '2.1'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '1
|
110
|
+
version: '2.1'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: guard-rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '4.3'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '4.3'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: rake
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
129
|
- - "~>"
|
116
130
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
131
|
+
version: '13.0'
|
118
132
|
type: :development
|
119
133
|
prerelease: false
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
136
|
- - "~>"
|
123
137
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
138
|
+
version: '13.0'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: rspec
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
128
142
|
requirements:
|
129
143
|
- - "~>"
|
130
144
|
- !ruby/object:Gem::Version
|
131
|
-
version: 3.
|
145
|
+
version: '3.9'
|
132
146
|
type: :development
|
133
147
|
prerelease: false
|
134
148
|
version_requirements: !ruby/object:Gem::Requirement
|
135
149
|
requirements:
|
136
150
|
- - "~>"
|
137
151
|
- !ruby/object:Gem::Version
|
138
|
-
version: 3.
|
139
|
-
description: Sending Personalized Slack Messages
|
152
|
+
version: '3.9'
|
153
|
+
description: Sending Personalized Slack Messages to a Slack channel of your choice.
|
140
154
|
email:
|
141
155
|
- emma.sax4@gmail.com
|
142
156
|
executables:
|
@@ -144,16 +158,19 @@ executables:
|
|
144
158
|
extensions: []
|
145
159
|
extra_rdoc_files: []
|
146
160
|
files:
|
161
|
+
- ".codeclimate.yml"
|
162
|
+
- ".github/code_of_conduct.md"
|
163
|
+
- ".github/contributing.md"
|
164
|
+
- ".github/issue_template.md"
|
165
|
+
- ".github/pull_request_template.md"
|
166
|
+
- ".github/security.md"
|
167
|
+
- ".github/workflows/develop.yml"
|
147
168
|
- ".gitignore"
|
148
|
-
- ".octopolo.yml"
|
149
|
-
- ".rspec"
|
150
169
|
- ".ruby-gemset"
|
151
170
|
- ".ruby-version"
|
152
|
-
- ".soyuz.yml"
|
153
|
-
- ".travis.yml"
|
154
|
-
- CHANGELOG.markdown
|
155
171
|
- Gemfile
|
156
|
-
-
|
172
|
+
- Guardfile
|
173
|
+
- LICENSE
|
157
174
|
- OutputFile.png
|
158
175
|
- README.md
|
159
176
|
- Rakefile
|
@@ -171,11 +188,11 @@ files:
|
|
171
188
|
- spec/slack_messaging/notify_slack_spec.rb
|
172
189
|
- spec/slack_messaging/random_message_spec.rb
|
173
190
|
- spec/spec_helper.rb
|
174
|
-
homepage: https://github.com/
|
191
|
+
homepage: https://github.com/emmasax4/slack_messaging
|
175
192
|
licenses:
|
176
193
|
- MIT
|
177
194
|
metadata: {}
|
178
|
-
post_install_message:
|
195
|
+
post_install_message:
|
179
196
|
rdoc_options: []
|
180
197
|
require_paths:
|
181
198
|
- lib
|
@@ -190,11 +207,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
207
|
- !ruby/object:Gem::Version
|
191
208
|
version: '0'
|
192
209
|
requirements: []
|
193
|
-
|
194
|
-
|
195
|
-
signing_key:
|
210
|
+
rubygems_version: 3.1.2
|
211
|
+
signing_key:
|
196
212
|
specification_version: 4
|
197
|
-
summary:
|
213
|
+
summary: Personalized Slack Messages
|
198
214
|
test_files:
|
199
215
|
- spec/slack_messaging/config_spec.rb
|
200
216
|
- spec/slack_messaging/notify_slack_spec.rb
|
data/.octopolo.yml
DELETED
data/.rspec
DELETED
data/.soyuz.yml
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
defaults:
|
2
|
-
deploy_cmd: gem push *.gem
|
3
|
-
before_deploy_cmds:
|
4
|
-
- /usr/local/bin/op tag-release
|
5
|
-
- sed -i "" -e "s/\".*/\"$(git tag| sed s/v// | sort -n -t. -k1,1 -k2,2 -k3,3 | tail -1)\"/" lib/sport_ngin_aws_auditor/version.rb
|
6
|
-
- git add lib/slack_messaging/version.rb
|
7
|
-
- git commit -m "Version Bump" && git push
|
8
|
-
- gem build slack_messaging.gemspec
|
9
|
-
after_deploy_cmds:
|
10
|
-
- rm *.gem
|
11
|
-
environments:
|
12
|
-
-
|
13
|
-
rubygems: {}
|
data/.travis.yml
DELETED
data/CHANGELOG.markdown
DELETED
File without changes
|