robodash 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE.md +9 -0
- data/README.md +17 -0
- data/lib/robodash/version.rb +5 -0
- data/lib/robodash.rb +48 -0
- metadata +51 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3481accdbedd74773f15df8a57825ca3561f817753e7949b2a37dc7e1762fa71
|
4
|
+
data.tar.gz: d4afb9395e7ecb87f2ebe1f8fedd77804dde6596e330dd5b85f2ec7932a3604e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e015e544be54b83e31136cc0f1553d2c9160ddbebe998a315e075c7c28d69907906f3f8adc8b64298d6677fd42152ef04783866cd2fbf0389a65c50656952a1a
|
7
|
+
data.tar.gz: 3efba1800bc1763eab900428fdda9d6279789e2cb98aee7dea515aa3de58ac786f52c9fb97b59b4039dcc541a32ebe35ab801b74075235c9d510c88e4029e9eb
|
data/LICENSE.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# MIT License
|
2
|
+
|
3
|
+
Copyright 2024 Bram Jetten
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
+
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
|
9
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Robodash
|
2
|
+
|
3
|
+
This is a Ruby gem to easily send pings to Robodash.
|
4
|
+
```ruby
|
5
|
+
gem 'robodash'
|
6
|
+
```
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
Robodash.api_token = # your dashboard API token
|
10
|
+
|
11
|
+
# Pinging
|
12
|
+
Robodash.ping("Some bg job")
|
13
|
+
|
14
|
+
# Counting things
|
15
|
+
Robodash.count("Something to track", 10)
|
16
|
+
```
|
17
|
+
|
data/lib/robodash.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "robodash/version"
|
4
|
+
|
5
|
+
module Robodash
|
6
|
+
class Error < StandardError; end
|
7
|
+
|
8
|
+
class << self
|
9
|
+
attr_accessor :api_token
|
10
|
+
|
11
|
+
def ping(name)
|
12
|
+
send_request("ping", {name: name})
|
13
|
+
end
|
14
|
+
|
15
|
+
# Count should always be an integer
|
16
|
+
def count(name, count)
|
17
|
+
send_request("count", {name: name, count: count.to_i})
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def send_request(endpoint, body)
|
23
|
+
raise "API token is not set!" unless api_token
|
24
|
+
|
25
|
+
begin
|
26
|
+
Thread.new do
|
27
|
+
uri = URI("https://beta.robodash.app/api/#{endpoint}.json")
|
28
|
+
request = Net::HTTP::Post.new(uri)
|
29
|
+
request["Authorization"] = "dashboard-token #{api_token}"
|
30
|
+
request["Content-Type"] = "application/json"
|
31
|
+
request.body = body.to_json
|
32
|
+
|
33
|
+
Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
|
34
|
+
http.open_timeout = 5
|
35
|
+
http.read_timeout = 10
|
36
|
+
http.request(request)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
true
|
40
|
+
rescue StandardError => e
|
41
|
+
warn "Failed to ping Robodash: #{e.message}"
|
42
|
+
false
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
metadata
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: robodash
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bram Jetten
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-12-21 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Robodash is a lightweight Ruby gem for sending POST requests to Robodash's
|
14
|
+
API. It is designed to be simple to use, with support for API tokens and background
|
15
|
+
threading for non-blocking requests. Ideal for 'fire-and-forget' HTTP pings.
|
16
|
+
email:
|
17
|
+
- mail@bramjetten.nl
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- LICENSE.md
|
23
|
+
- README.md
|
24
|
+
- lib/robodash.rb
|
25
|
+
- lib/robodash/version.rb
|
26
|
+
homepage: https://beta.robodash.app
|
27
|
+
licenses:
|
28
|
+
- MIT
|
29
|
+
metadata:
|
30
|
+
homepage_uri: https://beta.robodash.app
|
31
|
+
source_code_uri: https://github.com/Bramjetten/robodash-gem
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
require_paths:
|
35
|
+
- lib
|
36
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.7.0
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
requirements: []
|
47
|
+
rubygems_version: 3.5.3
|
48
|
+
signing_key:
|
49
|
+
specification_version: 4
|
50
|
+
summary: A simple gem to send asynchronous POST requests to Robodash.
|
51
|
+
test_files: []
|