alertifii 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +35 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +17 -0
- data/.gitignore +20 -0
- data/.rubocop.yml +80 -0
- data/.travis.yml +8 -0
- data/CODE_OF_CONDUCT.md +46 -0
- data/Gemfile +30 -0
- data/Guardfile +48 -0
- data/LICENSE +21 -0
- data/README.md +74 -0
- data/Rakefile +63 -0
- data/alertifii.gemspec +26 -0
- data/bin/add +25 -0
- data/exe/alertifii +37 -0
- data/lib/alertifii/message.rb +38 -0
- data/lib/alertifii/receipt.rb +16 -0
- data/lib/alertifii/response.rb +46 -0
- data/lib/alertifii/version.rb +3 -0
- data/lib/alertifii.rb +15 -0
- data/spec/alertifii/message_spec.rb +36 -0
- data/spec/alertifii/receipt_spec.rb +24 -0
- data/spec/alertifii/response_spec.rb +26 -0
- data/spec/lib/alertifii_spec.rb +7 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/vscode_formatter.rb +31 -0
- metadata +117 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2562866c0f2788880c04347173b5a9266777871533f8e783d897a1173fa54b33
|
4
|
+
data.tar.gz: ccc3d223f255cc6f9329ec040c6951ac08a3242ebde4f2fabfdee5483bf6f0c0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 49b19b5c090abbfd290d1689bae70a1618793b20d38b7d21aa7ba95aee247160c98bd5f7810fb2679c65836dcec597b14f12565055de807403769841cab064d7
|
7
|
+
data.tar.gz: 88129721be81327e8f88aaa6cba21110cc3410b03fbbf0fe0b1e578bccb2349ce468803cd28a62018619210c6a7c166b420abb2f708b7c8e612e08f35c7c03c8
|
@@ -0,0 +1,35 @@
|
|
1
|
+
---
|
2
|
+
name: Bug report
|
3
|
+
about: Create a report to help us improve
|
4
|
+
|
5
|
+
---
|
6
|
+
|
7
|
+
**Describe the bug**
|
8
|
+
A clear and concise description of what the bug is.
|
9
|
+
|
10
|
+
**To Reproduce**
|
11
|
+
Steps to reproduce the behavior:
|
12
|
+
1. Go to '...'
|
13
|
+
2. Click on '....'
|
14
|
+
3. Scroll down to '....'
|
15
|
+
4. See error
|
16
|
+
|
17
|
+
**Expected behavior**
|
18
|
+
A clear and concise description of what you expected to happen.
|
19
|
+
|
20
|
+
**Screenshots**
|
21
|
+
If applicable, add screenshots to help explain your problem.
|
22
|
+
|
23
|
+
**Desktop (please complete the following information):**
|
24
|
+
- OS: [e.g. iOS]
|
25
|
+
- Browser [e.g. chrome, safari]
|
26
|
+
- Version [e.g. 22]
|
27
|
+
|
28
|
+
**Smartphone (please complete the following information):**
|
29
|
+
- Device: [e.g. iPhone6]
|
30
|
+
- OS: [e.g. iOS8.1]
|
31
|
+
- Browser [e.g. stock browser, safari]
|
32
|
+
- Version [e.g. 22]
|
33
|
+
|
34
|
+
**Additional context**
|
35
|
+
Add any other context about the problem here.
|
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
name: Feature request
|
3
|
+
about: Suggest an idea for this project
|
4
|
+
|
5
|
+
---
|
6
|
+
|
7
|
+
**Is your feature request related to a problem? Please describe.**
|
8
|
+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
9
|
+
|
10
|
+
**Describe the solution you'd like**
|
11
|
+
A clear and concise description of what you want to happen.
|
12
|
+
|
13
|
+
**Describe alternatives you've considered**
|
14
|
+
A clear and concise description of any alternative solutions or features you've considered.
|
15
|
+
|
16
|
+
**Additional context**
|
17
|
+
Add any other context or screenshots about the feature request here.
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
require: rubocop-rspec
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
TargetRubyVersion: 2.4.0
|
5
|
+
Exclude:
|
6
|
+
- 'vendor/**/*'
|
7
|
+
- 'tmp/**/*'
|
8
|
+
- 'spec/spec_helper.rb'
|
9
|
+
|
10
|
+
# The defaults for these seem to be based on a rails env, this is not rails.
|
11
|
+
Metrics/ModuleLength:
|
12
|
+
CountComments: false
|
13
|
+
Max: 250
|
14
|
+
|
15
|
+
Metrics/ClassLength:
|
16
|
+
Max: 250
|
17
|
+
|
18
|
+
Metrics/MethodLength:
|
19
|
+
Max: 20
|
20
|
+
|
21
|
+
Metrics/AbcSize:
|
22
|
+
Max: 25
|
23
|
+
|
24
|
+
Metrics/CyclomaticComplexity:
|
25
|
+
Max: 8
|
26
|
+
|
27
|
+
Metrics/PerceivedComplexity:
|
28
|
+
Max: 10
|
29
|
+
|
30
|
+
# it's 2016, people have wide monitors.
|
31
|
+
Metrics/LineLength:
|
32
|
+
Enabled: false
|
33
|
+
|
34
|
+
Metrics/BlockLength:
|
35
|
+
Exclude:
|
36
|
+
- '*.gemspec'
|
37
|
+
- 'Guardfile'
|
38
|
+
- 'Rakefile'
|
39
|
+
- 'spec/**/*'
|
40
|
+
|
41
|
+
# we exclude these two files since they are generated, the rest of our projects
|
42
|
+
# should use // style regexps.
|
43
|
+
Style/RegexpLiteral:
|
44
|
+
EnforcedStyle: slashes
|
45
|
+
AllowInnerSlashes: true
|
46
|
+
Exclude:
|
47
|
+
- 'Guardfile'
|
48
|
+
- '*.gemspec'
|
49
|
+
|
50
|
+
# Prefer single-quoted strings when you don't need string interpolation or special symbols
|
51
|
+
Style/StringLiterals:
|
52
|
+
Enabled: false
|
53
|
+
|
54
|
+
Style/WordArray:
|
55
|
+
EnforcedStyle: brackets
|
56
|
+
|
57
|
+
Style/FrozenStringLiteralComment:
|
58
|
+
Enabled: false
|
59
|
+
|
60
|
+
Style/MixinUsage:
|
61
|
+
Exclude:
|
62
|
+
- 'bin/*'
|
63
|
+
- 'exe/*'
|
64
|
+
|
65
|
+
# Specs don't need inline documentation.
|
66
|
+
Style/Documentation:
|
67
|
+
Enabled: true
|
68
|
+
Exclude:
|
69
|
+
- 'spec/**/*'
|
70
|
+
|
71
|
+
RSpec/NamedSubject:
|
72
|
+
Enabled: false
|
73
|
+
|
74
|
+
Lint/Debugger:
|
75
|
+
Enabled: false
|
76
|
+
|
77
|
+
# Purty hashes.
|
78
|
+
Layout/AlignHash:
|
79
|
+
EnforcedHashRocketStyle: table
|
80
|
+
EnforcedColonStyle: table
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
## Our Standards
|
8
|
+
|
9
|
+
Examples of behavior that contributes to creating a positive environment include:
|
10
|
+
|
11
|
+
* Using welcoming and inclusive language
|
12
|
+
* Being respectful of differing viewpoints and experiences
|
13
|
+
* Gracefully accepting constructive criticism
|
14
|
+
* Focusing on what is best for the community
|
15
|
+
* Showing empathy towards other community members
|
16
|
+
|
17
|
+
Examples of unacceptable behavior by participants include:
|
18
|
+
|
19
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
20
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
21
|
+
* Public or private harassment
|
22
|
+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
23
|
+
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
24
|
+
|
25
|
+
## Our Responsibilities
|
26
|
+
|
27
|
+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
28
|
+
|
29
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
30
|
+
|
31
|
+
## Scope
|
32
|
+
|
33
|
+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
34
|
+
|
35
|
+
## Enforcement
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at ebrodeur@ujami.net. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
38
|
+
|
39
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
40
|
+
|
41
|
+
## Attribution
|
42
|
+
|
43
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
44
|
+
|
45
|
+
[homepage]: http://contributor-covenant.org
|
46
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
gemspec
|
3
|
+
|
4
|
+
gem 'excon'
|
5
|
+
gem 'gli'
|
6
|
+
gem 'oj'
|
7
|
+
gem 'codecov', :require => false, :group => :test
|
8
|
+
|
9
|
+
group :test do
|
10
|
+
gem 'bump'
|
11
|
+
gem 'bundler'
|
12
|
+
gem 'rake'
|
13
|
+
gem 'rspec'
|
14
|
+
gem 'rubocop'
|
15
|
+
gem 'rubocop-rspec'
|
16
|
+
gem 'simplecov'
|
17
|
+
gem 'yard'
|
18
|
+
end
|
19
|
+
|
20
|
+
group :development, optional: true do
|
21
|
+
gem 'guard'
|
22
|
+
gem 'guard-bundler'
|
23
|
+
gem 'guard-rspec'
|
24
|
+
gem 'guard-rubocop'
|
25
|
+
gem 'guard-shell'
|
26
|
+
gem 'guard-yard'
|
27
|
+
gem 'pry'
|
28
|
+
gem "pry-inline"
|
29
|
+
gem "solargraph"
|
30
|
+
end
|
data/Guardfile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
clearing :on
|
2
|
+
|
3
|
+
guard :shell do
|
4
|
+
# watch('exe/alertifii') { `exe/alertifii -h`}
|
5
|
+
watch('exe/alertifii') { `exe/alertifii message -h` }
|
6
|
+
end
|
7
|
+
|
8
|
+
guard :bundler do
|
9
|
+
require 'guard/bundler'
|
10
|
+
require 'guard/bundler/verify'
|
11
|
+
helper = Guard::Bundler::Verify.new
|
12
|
+
|
13
|
+
files = ['Gemfile']
|
14
|
+
files += Dir['*.gemspec'] if files.any? { |f| helper.uses_gemspec?(f) }
|
15
|
+
|
16
|
+
# Assume files are symlinked from somewhere
|
17
|
+
files.each { |file| watch(helper.real_path(file)) }
|
18
|
+
end
|
19
|
+
|
20
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
21
|
+
require 'guard/rspec/dsl'
|
22
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
23
|
+
|
24
|
+
# RSpec files
|
25
|
+
rspec = dsl.rspec
|
26
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
27
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
28
|
+
watch(rspec.spec_files)
|
29
|
+
|
30
|
+
# Ruby files
|
31
|
+
ruby = dsl.ruby
|
32
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
33
|
+
end
|
34
|
+
|
35
|
+
unless ENV["DISABLE_RUBOCOP"] == 'true'
|
36
|
+
guard :rubocop do
|
37
|
+
watch(/.+\.rb$/)
|
38
|
+
watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
unless ENV["DISABLE_YARD"] == 'true'
|
43
|
+
guard 'yard' do
|
44
|
+
watch(%r{app\/.+\.rb})
|
45
|
+
watch(%r{lib\/.+\.rb})
|
46
|
+
watch(%r{ext\/.+\.c})
|
47
|
+
end
|
48
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 Ernie Brodeur
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Alertifii
|
2
|
+
This gem provides a CLI and an API interface to https://alertifii.com.
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
To install:
|
7
|
+
|
8
|
+
gem install alertifii
|
9
|
+
|
10
|
+
To use inside of an application, add this to the your gemfile:
|
11
|
+
|
12
|
+
gem 'alertifii'
|
13
|
+
|
14
|
+
and run bundle to make it available:
|
15
|
+
|
16
|
+
bundle
|
17
|
+
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
For now, not much is supported on the CLI.
|
22
|
+
|
23
|
+
Sending a message:
|
24
|
+
|
25
|
+
alertifii --token=your_app_token --user=user_key message here we go again, on my own.
|
26
|
+
alertifii -tyour_app_token -uuser_key message here we go again, on my own.
|
27
|
+
|
28
|
+
Getting receipt details:
|
29
|
+
|
30
|
+
|
31
|
+
alertifii -tyour_app_token receipt receipt-hash
|
32
|
+
|
33
|
+
Currently unsupported message features:
|
34
|
+
- attachments
|
35
|
+
- callbacks
|
36
|
+
- setting timestamp
|
37
|
+
|
38
|
+
|
39
|
+
### Api
|
40
|
+
|
41
|
+
``` ruby
|
42
|
+
require 'alertifii'
|
43
|
+
|
44
|
+
### message
|
45
|
+
message = Alertifii::Message.new(token: 'token', user: 'user_key', message: '...')
|
46
|
+
message.push
|
47
|
+
|
48
|
+
|
49
|
+
### Receipt
|
50
|
+
Alertifii::Message.new(token: 'token', user: 'user_key', message: '...', 'priority': 2, expire: 1, retry: 60).push
|
51
|
+
|
52
|
+
receipt = Alertifii::Receipt.new(receipt: "receipt", token: 'token')
|
53
|
+
receipt.get
|
54
|
+
|
55
|
+
### Responses
|
56
|
+
response = Alertifii::Message.new(token: 'token', user: 'user_key', message: '...').push
|
57
|
+
|
58
|
+
# the below data is populated from the response
|
59
|
+
puts response.status # return the status of the request, 0 or 1
|
60
|
+
puts response.request # uuid of the request
|
61
|
+
puts response.errors # array of errors (if any)
|
62
|
+
puts response.receipt # receipt (if requested)
|
63
|
+
puts response.headers # response headers (includes limits)
|
64
|
+
puts response.attributes # any other k/v pair returned from alertifii
|
65
|
+
```
|
66
|
+
|
67
|
+
## Contributing
|
68
|
+
|
69
|
+
1. Fork it
|
70
|
+
2. Switch to development (`git checkout development`)
|
71
|
+
3. Create your feature branch (`git checkout -b my-new-feature`)
|
72
|
+
4. Commit your changes (`git commit -am 'Added some feature'`)
|
73
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
74
|
+
6. Create new Pull Request against `development`
|
data/Rakefile
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
require "open-uri"
|
4
|
+
### Configurables
|
5
|
+
|
6
|
+
files = {
|
7
|
+
Gemfile: 'https://gist.githubusercontent.com/erniebrodeur/5a5518f5051210f1828a0712bf623dc8/raw',
|
8
|
+
Rakefile: 'https://gist.githubusercontent.com/erniebrodeur/afc92b72158413aa1f85d8d1facd267a/raw',
|
9
|
+
Rubocop: 'https://gist.githubusercontent.com/erniebrodeur/f7f63996ef1e017aee9bf9d8e680a1df/raw',
|
10
|
+
Tasks: 'https://gist.githubusercontent.com/erniebrodeur/03573fecf4f274101c14f6802abdbe83/raw',
|
11
|
+
BinAdd: 'https://gist.githubusercontent.com/erniebrodeur/a815ee4d8bd9ccc54d91025a5543ebb8/raw',
|
12
|
+
VsCodeFormatter: 'https://gist.githubusercontent.com/erniebrodeur/b24d757c0c625d108019eaceff2234cc/raw'
|
13
|
+
}
|
14
|
+
|
15
|
+
# spec
|
16
|
+
RSpec::Core::RakeTask.new(:spec)
|
17
|
+
task default: :spec
|
18
|
+
|
19
|
+
# automagical updating
|
20
|
+
desc "updates for various bits of the development environment."
|
21
|
+
|
22
|
+
namespace :update do
|
23
|
+
desc "update everything (multitasked)"
|
24
|
+
multitask(all: %i[gemfile rakefile rubocop tasks vscode_formatter])
|
25
|
+
|
26
|
+
desc 'Update Gemfile from gist'
|
27
|
+
task :gemfile do
|
28
|
+
grab_file 'Gemfile', files[:Gemfile]
|
29
|
+
end
|
30
|
+
|
31
|
+
desc 'Update Rakefile from gist'
|
32
|
+
task :rakefile do
|
33
|
+
grab_file 'Rakefile', files[:Rakefile]
|
34
|
+
end
|
35
|
+
|
36
|
+
desc 'Update .rubocop.yml from gist'
|
37
|
+
task :rubocop do
|
38
|
+
grab_file '.rubocop.yml', files[:Rubocop]
|
39
|
+
end
|
40
|
+
|
41
|
+
desc 'Update .vscode/tasks.json from gist'
|
42
|
+
task :tasks do
|
43
|
+
mkdir_p '.vscode'
|
44
|
+
grab_file '.vscode/tasks.json', files[:Tasks]
|
45
|
+
end
|
46
|
+
|
47
|
+
desc 'Update vscode_formatter.rb in spec_helper'
|
48
|
+
task :vscode_formatter do
|
49
|
+
mkdir_p 'spec'
|
50
|
+
grab_file 'spec/vscode_formatter.rb', files[:VsCodeFormatter]
|
51
|
+
end
|
52
|
+
|
53
|
+
desc 'Add a new lib and spec file (binary)'
|
54
|
+
task :binadd do
|
55
|
+
mkdir_p 'bin'
|
56
|
+
grab_file 'bin/add', files[:BinAdd]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def grab_file(filename, uri)
|
61
|
+
File.write filename, OpenURI.open_uri(uri).read
|
62
|
+
puts "Updated #{filename} from: #{uri}"
|
63
|
+
end
|
data/alertifii.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.expand_path('lib/alertifii/version', __dir__)
|
2
|
+
Gem::Specification.new do |spec|
|
3
|
+
spec.name = 'alertifii'
|
4
|
+
spec.authors = ['Austin Miller']
|
5
|
+
spec.email = ['austinrmiller1991@gmail.com']
|
6
|
+
spec.date = Time.now.strftime('%Y-%m-%d')
|
7
|
+
spec.version = Alertifii::VERSION
|
8
|
+
spec.platform = Gem::Platform::RUBY
|
9
|
+
spec.license = 'MIT'
|
10
|
+
|
11
|
+
# descriptions
|
12
|
+
spec.description = 'Api (and CLI) to interface with alertifii.com'
|
13
|
+
spec.summary = 'This spec provides both an API and CLI interface to alertifii.com.'
|
14
|
+
spec.homepage = 'https://github.com/armiiller/alertifii-ruby'
|
15
|
+
|
16
|
+
# files
|
17
|
+
spec.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
# dependencies.
|
23
|
+
spec.add_runtime_dependency 'excon'
|
24
|
+
spec.add_runtime_dependency 'gli'
|
25
|
+
spec.add_runtime_dependency 'oj'
|
26
|
+
end
|
data/bin/add
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'bundler'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
# add files to lib and spec
|
6
|
+
# takes one arg, the path from lib/spec + base filename
|
7
|
+
# example: add models/something
|
8
|
+
|
9
|
+
unless ARGV[0]
|
10
|
+
puts "example: add models/something"
|
11
|
+
exit
|
12
|
+
end
|
13
|
+
|
14
|
+
file = ARGV[0].dup
|
15
|
+
root = Bundler.root.split.last.to_s
|
16
|
+
|
17
|
+
file.chomp!(".rb")
|
18
|
+
|
19
|
+
lib = "lib/#{root}/#{file}.rb"
|
20
|
+
spec = "spec/#{root}/#{file}_spec.rb"
|
21
|
+
|
22
|
+
[lib, spec].each do |s|
|
23
|
+
FileUtils.mkdir_p(File.dirname(s))
|
24
|
+
puts "created: #{FileUtils.touch(s).first}"
|
25
|
+
end
|
data/exe/alertifii
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'gli'
|
3
|
+
require 'alertifii'
|
4
|
+
|
5
|
+
include GLI::App
|
6
|
+
|
7
|
+
program_desc 'A simple todo list'
|
8
|
+
subcommand_option_handling :normal
|
9
|
+
|
10
|
+
flag %i[t token], type: String, desc: 'Application token'
|
11
|
+
flag %i[u user], type: String, desc: 'User token', required: false
|
12
|
+
|
13
|
+
desc 'send a message'
|
14
|
+
command :message do |c|
|
15
|
+
c.flag :device, type: String, desc: 'device to send too'
|
16
|
+
c.flag :title, type: String, desc: 'title of message'
|
17
|
+
c.flag :url, type: String, desc: 'url to include'
|
18
|
+
c.flag :url_title, type: String, desc: 'title of included url'
|
19
|
+
c.flag :priority, type: String, desc: 'numeric priority (-2,-1,0,1,2) from low to high'
|
20
|
+
c.flag :sound, type: String, desc: 'sound, see alertifii api for list.'
|
21
|
+
c.flag :expire, type: String, desc: 'how long should a priority message live'
|
22
|
+
c.flag :retry, type: String, desc: 'how often should a resend be attempted (until acknowledged)'
|
23
|
+
c.action do |global_options, options, args|
|
24
|
+
puts Alertifii::Message.new({
|
25
|
+
message: args.join(" "), user: global_options[:user], token: global_options[:token]
|
26
|
+
}.merge(GLI::Options.new(options).to_h.reject { |_k, v| v.nil? })).push
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'get a receipt'
|
31
|
+
command :receipt do |c|
|
32
|
+
c.action do |global_options, _options, args|
|
33
|
+
puts Alertifii::Receipt.new(token: global_options[:token], receipt: args[0]).get
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
run(ARGV)
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Alertifii
|
2
|
+
# Message is a struct to send a message to alertifii.
|
3
|
+
# @!attribute [rw] token
|
4
|
+
# @return [String] application token
|
5
|
+
# @!attribute [rw] user
|
6
|
+
# @return [String] user key
|
7
|
+
# @!attribute [rw] message
|
8
|
+
# @return [String] message to transmit
|
9
|
+
# @!attribute [rw] device
|
10
|
+
# @return [String] device to transmit too
|
11
|
+
# @!attribute [rw] title
|
12
|
+
# @return [String] title of the message
|
13
|
+
# @!attribute [rw] url
|
14
|
+
# @return [String] supplementary url
|
15
|
+
# @!attribute [rw] url_title
|
16
|
+
# @return [String] title of the supplementary url
|
17
|
+
# @!attribute [rw] priority
|
18
|
+
# @return [Numeric] numeric value for priority.
|
19
|
+
# @!attribute [rw] sound
|
20
|
+
# @return [String] sound to play
|
21
|
+
# @!attribute [rw] timestamp
|
22
|
+
# @return [Numeric] timestamp to expire, in epoch
|
23
|
+
# @!attribute [rw] expire
|
24
|
+
# @return [Numeric] expire time until message expires
|
25
|
+
# @!attribute [rw] retry
|
26
|
+
# @return [Numeric] how long to retry for, in seconds
|
27
|
+
# @!attribute [rw] callback
|
28
|
+
# @return [String] callback url
|
29
|
+
Message = Struct.new(:token, :user, :message, :attachment, :device, :title, :url, :url_title, :priority, :sound, :timestamp, :expire, :retry, :callback, keyword_init: true) do
|
30
|
+
# push the configured message to alertifii.
|
31
|
+
# @return [Response] response for the receipt request
|
32
|
+
def push
|
33
|
+
%i[token message].each { |param| raise "#{param} must be supplied" unless send param }
|
34
|
+
|
35
|
+
Response.create_from_excon_response Excon.post(path: '1/messages.json', query: to_h)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Alertifii
|
2
|
+
# Receipt is a struct to interface with the receipt endpoint.
|
3
|
+
# @!attribute [rw] receipt
|
4
|
+
# @return [String] id of the receipt to request
|
5
|
+
# @!attribute [rw] token
|
6
|
+
# @return [String] application token to check for a receipt
|
7
|
+
Receipt = Struct.new(:receipt, :token, keyword_init: true) do
|
8
|
+
# Call alertifii and return a response.
|
9
|
+
# @return [Response] response for the receipt request
|
10
|
+
def get
|
11
|
+
%i[receipt token].each { |param| raise "#{param} must be supplied" unless send param }
|
12
|
+
|
13
|
+
Response.create_from_excon_response Excon.get(path: "1/receipts/#{receipt}.json", query: { token: token })
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Alertifii
|
2
|
+
# Response encapsulates the response back from alertifii.
|
3
|
+
# Class to wrap the user and basic functions related to it.
|
4
|
+
# @attribute status
|
5
|
+
# @return [Numeric] status of the response
|
6
|
+
# @attribute request
|
7
|
+
# @return [String] request is a UUID representing the specific call
|
8
|
+
# @attribute errors
|
9
|
+
# @return [Array] errors includes any errors made
|
10
|
+
# @attribute receipt
|
11
|
+
# @return [String] receipt returns a receipt if requested
|
12
|
+
# @attribute headers
|
13
|
+
# @return [Hash] headers is the headers returned from the call.
|
14
|
+
# @attribute attributes
|
15
|
+
# @return [String] any extra k/v pairs from the server.
|
16
|
+
Response = Struct.new(:status, :request, :errors, :receipt, :headers, :attributes, keyword_init: true) do
|
17
|
+
# New response object, from an excon_response
|
18
|
+
# @return [Response] populated response object
|
19
|
+
def self.create_from_excon_response(excon_response)
|
20
|
+
json = Oj.load excon_response[:body]
|
21
|
+
values = {}
|
22
|
+
attributes = {}
|
23
|
+
json.each { |k, v| members.include?(k.to_sym) ? values.store(k, v) : attributes.store(k, v) }
|
24
|
+
|
25
|
+
Response.new values.merge(headers: excon_response.headers, attributes: attributes)
|
26
|
+
end
|
27
|
+
|
28
|
+
# purty.
|
29
|
+
def to_s
|
30
|
+
"#{errors ? 'errors: ' + errors.join("\n") : 'status: ok'}, #{limits}"
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
# :nocov:
|
36
|
+
# Application limits
|
37
|
+
# @return [Array] 0: Remaining Calls, 1: Total Limit, 2: Limit Reset
|
38
|
+
def limits
|
39
|
+
return '' unless headers.include? 'X-Limit-App-Limit'
|
40
|
+
|
41
|
+
output = [headers['X-Limit-App-Remaining'], headers['X-Limit-App-Limit'], headers['X-Limit-App-Reset']]
|
42
|
+
output.define_singleton_method(:to_s) { "requests #{self[0]} of #{self[1]}, reset on #{Time.at(self[2].to_f)}" }
|
43
|
+
output
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/alertifii.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'oj'
|
2
|
+
require 'excon'
|
3
|
+
|
4
|
+
require 'alertifii/message'
|
5
|
+
require 'alertifii/response'
|
6
|
+
require 'alertifii/receipt'
|
7
|
+
require 'alertifii/version'
|
8
|
+
|
9
|
+
# alertifii interface for ruby
|
10
|
+
module Alertifii
|
11
|
+
# headers to include in every request.
|
12
|
+
HEADERS = { 'Content-Type' => 'application/json', 'User-Agent' => "alertifii (ruby gem) v#{VERSION}" }
|
13
|
+
# excon connection to use for every request.
|
14
|
+
Excon = Excon.new('https://api.alertifii.com', headers: HEADERS)
|
15
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Alertifii::Message do
|
4
|
+
it { is_expected.to have_attributes(token: a_kind_of(String).or(be_nil)) }
|
5
|
+
it { is_expected.to have_attributes(user: a_kind_of(String).or(be_nil)) }
|
6
|
+
it { is_expected.to have_attributes(message: a_kind_of(String).or(be_nil)) }
|
7
|
+
it { is_expected.to have_attributes(attachment: a_kind_of(String).or(be_nil)) }
|
8
|
+
it { is_expected.to have_attributes(device: a_kind_of(String).or(be_nil)) }
|
9
|
+
it { is_expected.to have_attributes(title: a_kind_of(String).or(be_nil)) }
|
10
|
+
it { is_expected.to have_attributes(url: a_kind_of(String).or(be_nil)) }
|
11
|
+
it { is_expected.to have_attributes(url_title: a_kind_of(String).or(be_nil)) }
|
12
|
+
it { is_expected.to have_attributes(priority: a_kind_of(Numeric).or(be_nil)) }
|
13
|
+
it { is_expected.to have_attributes(sound: a_kind_of(String).or(be_nil)) }
|
14
|
+
it { is_expected.to have_attributes(timestamp: a_kind_of(DateTime).or(be_nil)) }
|
15
|
+
it { is_expected.to have_attributes(expire: a_kind_of(Numeric).or(be_nil)) }
|
16
|
+
it { is_expected.to have_attributes(retry: a_kind_of(Numeric).or(be_nil)) }
|
17
|
+
it { is_expected.to have_attributes(callback: a_kind_of(String).or(be_nil)) }
|
18
|
+
|
19
|
+
it { is_expected.to respond_to(:push).with(0).argument }
|
20
|
+
|
21
|
+
describe "#push" do
|
22
|
+
let(:params) { { 'token' => 't', 'user' => 'u', 'message' => 'message' } }
|
23
|
+
|
24
|
+
it "is expected to send" do
|
25
|
+
expect { described_class.new(params).push }.to raise_error Excon::Error::StubNotFound
|
26
|
+
end
|
27
|
+
|
28
|
+
['token', 'user', 'message'].each do |param|
|
29
|
+
context "when #{param} is not supplied" do
|
30
|
+
before { params.delete param }
|
31
|
+
|
32
|
+
it { expect { described_class.new(params).push }.to raise_error RuntimeError, /#{param} must be supplied/ }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Alertifii::Receipt do
|
4
|
+
it { is_expected.to have_attributes(receipt: a_kind_of(String).or(be_nil)) }
|
5
|
+
it { is_expected.to have_attributes(token: a_kind_of(String).or(be_nil)) }
|
6
|
+
|
7
|
+
it { is_expected.to respond_to(:get).with(0).argument }
|
8
|
+
|
9
|
+
describe "#push" do
|
10
|
+
let(:params) { { 'token' => 't', 'receipt' => 'receipt' } }
|
11
|
+
|
12
|
+
it "is expected to send" do
|
13
|
+
expect { described_class.new(params).get }.to raise_error Excon::Error::StubNotFound
|
14
|
+
end
|
15
|
+
|
16
|
+
['token', 'receipt'].each do |param|
|
17
|
+
context "when #{param} is not supplied" do
|
18
|
+
before { params.delete param }
|
19
|
+
|
20
|
+
it { expect { described_class.new(params).get }.to raise_error RuntimeError, /#{param} must be supplied/ }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Alertifii do
|
4
|
+
describe Alertifii::Response do
|
5
|
+
let(:excon_response) { Excon::Response.new body: '{}', headers: {} }
|
6
|
+
|
7
|
+
it { is_expected.to have_attributes(status: a_kind_of(String).or(be_nil)) }
|
8
|
+
it { is_expected.to have_attributes(request: a_kind_of(String).or(be_nil)) }
|
9
|
+
it { is_expected.to have_attributes(errors: a_kind_of(Array).or(be_nil)) }
|
10
|
+
it { is_expected.to have_attributes(receipt: a_kind_of(String).or(be_nil)) }
|
11
|
+
it { is_expected.to have_attributes(headers: a_kind_of(Hash).or(be_nil)) }
|
12
|
+
it { is_expected.to have_attributes(attributes: a_kind_of(Hash).or(be_nil)) }
|
13
|
+
|
14
|
+
it { expect(described_class).to respond_to(:create_from_excon_response).with(1).argument }
|
15
|
+
|
16
|
+
describe "#to_s" do
|
17
|
+
it "is expected to be purty." do
|
18
|
+
expect(Alertifii::Response.create_from_excon_response(excon_response).to_s).to include('status')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "::create_from_excon_response" do
|
23
|
+
it { expect(Alertifii::Response.create_from_excon_response(excon_response)).to be_a_kind_of described_class }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'excon'
|
2
|
+
require 'simplecov'
|
3
|
+
require 'codecov'
|
4
|
+
Excon.defaults[:mock] = true
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
config.filter_run :focus
|
8
|
+
config.run_all_when_everything_filtered = true
|
9
|
+
config.example_status_persistence_file_path = "tmp/examples.txt"
|
10
|
+
end
|
11
|
+
|
12
|
+
RSpec::Matchers.alias_matcher :return_a_kind_of, :be_a_kind_of
|
13
|
+
|
14
|
+
SimpleCov.formatters = [ SimpleCov::Formatter::HTMLFormatter, SimpleCov::Formatter::Codecov]
|
15
|
+
SimpleCov.start { add_filter "/spec/" }
|
16
|
+
|
17
|
+
require 'alertifii'
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class VsCodeFormatter
|
2
|
+
RSpec::Core::Formatters.register self, :message, :dump_summary, :dump_failures, :dump_pending, :seed
|
3
|
+
|
4
|
+
def initialize(output)
|
5
|
+
@output = output
|
6
|
+
end
|
7
|
+
|
8
|
+
def message(notification)
|
9
|
+
@output << notification.message
|
10
|
+
end
|
11
|
+
|
12
|
+
def dump_failures(notification)
|
13
|
+
return if notification.failure_notifications.empty?
|
14
|
+
|
15
|
+
notification.failed_examples.each { |e| @output << "error: #{e.full_description} @ #{e.location}" << "\n" }
|
16
|
+
end
|
17
|
+
|
18
|
+
def dump_summary(summary); end
|
19
|
+
|
20
|
+
def dump_pending(notification)
|
21
|
+
return if notification.pending_examples.empty?
|
22
|
+
|
23
|
+
notification.pending_examples.each { |e| @output << "warning: #{e.full_description} @ #{e.location}" << "\n" }
|
24
|
+
end
|
25
|
+
|
26
|
+
def seed(notification)
|
27
|
+
return unless notification.seed_used?
|
28
|
+
|
29
|
+
@output << notification.fully_formatted
|
30
|
+
end
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: alertifii
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Austin Miller
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-05-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: excon
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: gli
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: oj
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Api (and CLI) to interface with alertifii.com
|
56
|
+
email:
|
57
|
+
- austinrmiller1991@gmail.com
|
58
|
+
executables:
|
59
|
+
- add
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
64
|
+
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
65
|
+
- ".gitignore"
|
66
|
+
- ".rubocop.yml"
|
67
|
+
- ".travis.yml"
|
68
|
+
- CODE_OF_CONDUCT.md
|
69
|
+
- Gemfile
|
70
|
+
- Guardfile
|
71
|
+
- LICENSE
|
72
|
+
- README.md
|
73
|
+
- Rakefile
|
74
|
+
- alertifii.gemspec
|
75
|
+
- bin/add
|
76
|
+
- exe/alertifii
|
77
|
+
- lib/alertifii.rb
|
78
|
+
- lib/alertifii/message.rb
|
79
|
+
- lib/alertifii/receipt.rb
|
80
|
+
- lib/alertifii/response.rb
|
81
|
+
- lib/alertifii/version.rb
|
82
|
+
- spec/alertifii/message_spec.rb
|
83
|
+
- spec/alertifii/receipt_spec.rb
|
84
|
+
- spec/alertifii/response_spec.rb
|
85
|
+
- spec/lib/alertifii_spec.rb
|
86
|
+
- spec/spec_helper.rb
|
87
|
+
- spec/vscode_formatter.rb
|
88
|
+
homepage: https://github.com/armiiller/alertifii-ruby
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubygems_version: 3.4.4
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: This spec provides both an API and CLI interface to alertifii.com.
|
111
|
+
test_files:
|
112
|
+
- spec/alertifii/message_spec.rb
|
113
|
+
- spec/alertifii/receipt_spec.rb
|
114
|
+
- spec/alertifii/response_spec.rb
|
115
|
+
- spec/lib/alertifii_spec.rb
|
116
|
+
- spec/spec_helper.rb
|
117
|
+
- spec/vscode_formatter.rb
|