snitcher 0.4.0 → 0.4.1
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 +5 -5
- data/.travis.yml +3 -1
- data/CHANGELOG.md +4 -1
- data/README.md +8 -0
- data/lib/snitcher.rb +19 -3
- data/lib/snitcher/version.rb +1 -1
- data/spec/snitcher_spec.rb +13 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 28c075e51d743b5bd9cfea27193db58b8eadd72774ac4d1478800ffe6b73fb12
|
4
|
+
data.tar.gz: e08200f4bc411eed2c909c91cac08bb993497063a8955f0155f499c27f35fc43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f53823e4e0ba5ea1d435104de453427dcafa2f32a51bc092ad7f679c1b79a24a8ba0e9a06dcc7850b30e29c776d78e2b8652ec1099012de89b1093bfa8aa9232
|
7
|
+
data.tar.gz: a793e491ed792109ec1702287a575d893f215385863add7844242e6524cde7078b4479c1f1fef5fc762f906b0ba4bb3cd7df8dd6f40cfeeaaca3a16208b88d5a
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,12 @@
|
|
1
|
+
## 0.4.1 / 2018-07-09
|
2
|
+
* [FEATURE] Added :status option to Snitcher.snitch! ([@gaffneyc](https://github.com/gaffneyc))
|
3
|
+
*
|
1
4
|
## 0.4.0 / 2016-06-20
|
2
5
|
* [FEATURE] Added Snitcher::API for integrating with the DMS API ([@danabrit](https://github.com/danabrit))
|
3
6
|
* [FEATURE] Added Snitcher.snitch! which raises exceptions on errors ([@gaffneyc](https://github.com/gaffneyc))
|
4
7
|
|
5
8
|
## 0.3.2 / 2015-08-13
|
6
|
-
* [BUG] Fixed passing
|
9
|
+
* [BUG] Fixed passing messages during a check-in ([@ryoung](https://github.com/ryoung))
|
7
10
|
|
8
11
|
## 0.3.1 / 2015-06-23
|
9
12
|
* [ENHANCEMENT] Add a custom User-Agent
|
data/README.md
CHANGED
@@ -23,6 +23,14 @@ You also may provide a message with the check in:
|
|
23
23
|
Snitcher.snitch("c2354d53d2", message: "Finished in 23.8 seconds.")
|
24
24
|
```
|
25
25
|
|
26
|
+
Errors can be reported by providing the `status` option. A status of `nil`,
|
27
|
+
`0`, or `""` are all considered a success. Any other status is treated as a
|
28
|
+
failure.
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
Snitcher.snitch("c2354d53d2", status: 1)
|
32
|
+
```
|
33
|
+
|
26
34
|
The default timeout of 5 seconds can be overridden:
|
27
35
|
|
28
36
|
```ruby
|
data/lib/snitcher.rb
CHANGED
@@ -17,6 +17,9 @@ module Snitcher
|
|
17
17
|
# @option opts [String] :message Text message to include with the check-in.
|
18
18
|
# The message is limited to 256 characters.
|
19
19
|
#
|
20
|
+
# @option opts [String, Fixnum, nil] :status Exit code for the check-in. A
|
21
|
+
# status of "", nil, or 0 are all treated as the job finishing successfully.
|
22
|
+
#
|
20
23
|
# @option opts [Float, Fixnum] :timeout Number of seconds to wait for a
|
21
24
|
# response from the server. Default is 5 seconds.
|
22
25
|
#
|
@@ -26,8 +29,18 @@ module Snitcher
|
|
26
29
|
#
|
27
30
|
# @return [Boolean] if the check-in succeeded.
|
28
31
|
def snitch!(token, opts = {})
|
29
|
-
|
30
|
-
|
32
|
+
params = {}
|
33
|
+
params[:m] = opts[:message] if opts[:message]
|
34
|
+
|
35
|
+
# It's unnecessary to send an empty status
|
36
|
+
if opts[:status] && opts[:status] != ""
|
37
|
+
params[:s] = opts[:status]
|
38
|
+
end
|
39
|
+
|
40
|
+
uri = URI.parse(checkin_url(opts, token))
|
41
|
+
if params.any?
|
42
|
+
uri.query = URI.encode_www_form(params)
|
43
|
+
end
|
31
44
|
|
32
45
|
opts = initialize_opts(opts, uri)
|
33
46
|
|
@@ -51,6 +64,9 @@ module Snitcher
|
|
51
64
|
# @option opts [String] :message Text message to include with the check-in.
|
52
65
|
# The message is limited to 256 characters.
|
53
66
|
#
|
67
|
+
# @option opts [String, Fixnum, nil] :status Exit code for the check-in. A
|
68
|
+
# status of "", nil, or 0 are all treated as the job finishing successfully.
|
69
|
+
#
|
54
70
|
# @option opts [Float, Fixnum] :timeout Number of seconds to wait for a
|
55
71
|
# response from the server. Default is 5 seconds.
|
56
72
|
#
|
@@ -74,7 +90,7 @@ module Snitcher
|
|
74
90
|
open_timeout: timeout,
|
75
91
|
read_timeout: timeout,
|
76
92
|
ssl_timeout: timeout,
|
77
|
-
use_ssl: use_ssl?(uri)
|
93
|
+
use_ssl: use_ssl?(uri),
|
78
94
|
}
|
79
95
|
end
|
80
96
|
|
data/lib/snitcher/version.rb
CHANGED
data/spec/snitcher_spec.rb
CHANGED
@@ -48,6 +48,19 @@ describe Snitcher do
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
+
specify "with status" do
|
52
|
+
Snitcher.snitch!(token, status: "0")
|
53
|
+
expect(a_request(:get, "https://nosnch.in/#{token}?s=0")).to have_been_made
|
54
|
+
|
55
|
+
Snitcher.snitch!(token, status: 1237)
|
56
|
+
expect(a_request(:get, "https://nosnch.in/#{token}?s=1237")).to have_been_made
|
57
|
+
|
58
|
+
# Both nil and "" avoid adding the `s` query param.
|
59
|
+
Snitcher.snitch!(token, status: nil)
|
60
|
+
Snitcher.snitch!(token, status: "")
|
61
|
+
expect(a_request(:get, "https://nosnch.in/#{token}")).to have_been_made.twice
|
62
|
+
end
|
63
|
+
|
51
64
|
it "raises a Timeout::Error if the request timesout" do
|
52
65
|
stub_request(:get, "https://nosnch.in/#{token}").to_timeout
|
53
66
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snitcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Collective Idea
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
90
|
version: '0'
|
91
91
|
requirements: []
|
92
92
|
rubyforge_project:
|
93
|
-
rubygems_version: 2.6
|
93
|
+
rubygems_version: 2.7.6
|
94
94
|
signing_key:
|
95
95
|
specification_version: 4
|
96
96
|
summary: Simple API client for deadmanssnitch.com
|