ping_me_maybe 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +48 -0
- data/Rakefile +1 -0
- data/lib/ping_me_maybe.rb +23 -0
- data/lib/ping_me_maybe/connection.rb +15 -0
- data/lib/ping_me_maybe/constants.rb +8 -0
- data/lib/ping_me_maybe/version.rb +3 -0
- data/ping_me_maybe.gemspec +24 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8496e3ca61565c5c43992029bff00b46ba1cc9e1
|
4
|
+
data.tar.gz: f601ef0cec97bb10a0c6ec8f79b2502f00f5ba18
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dc1350bcb907d061409a8bacd256c575228c7df93fa4f39b40a3efec86d0568bb544d16eb76da6016d7d138dcce7b6662a008aab0cb18ded68effff5892924a8
|
7
|
+
data.tar.gz: 35f7e8b597a8f516f76582783a7bf7a547efad6aa847d1d30cbcb784073fb1a823e5d48f6766462f30410aa9c62fcb5a41a0a23e84c8f5240cd0e2c6fd97af9a
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Chris Clouten
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# PingMeMaybe
|
2
|
+
|
3
|
+
PingMeMaybe is a small library to be used in conjunction with [Cronut](https://github.com/harrystech/cronut), a dead man's switch server implementation in Rails.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'ping_me_maybe'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install ping_me_maybe
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
PingMeMaybe allows you to ping your Cronut server in jobs that Cronut monitors. To use PingMeMaybe start by adding the Ping ID you wish to ping from your Cronut server as a variable to your Resque job. Then simply invoke the class method `.ping_cronut` on PingMeMaybe, passing it the Cronut Ping ID. Example:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
|
25
|
+
class SomeResqueJob
|
26
|
+
@queue = :some_queue
|
27
|
+
CRONUT_PING_ID = 'ABCD1234'
|
28
|
+
|
29
|
+
def self.perform(some_object_id)
|
30
|
+
begin
|
31
|
+
...
|
32
|
+
PingMeMaybe.ping_cronut(CRONUT_PING_ID)
|
33
|
+
...
|
34
|
+
rescue StandardError => e
|
35
|
+
Rails.logger.error(e.inspect)
|
36
|
+
raise
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
```
|
41
|
+
|
42
|
+
## Contributing
|
43
|
+
|
44
|
+
1. Fork it ( http://github.com/<my-github-username>/ping_me_maybe/fork )
|
45
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
46
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
47
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
48
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "ping_me_maybe/version"
|
2
|
+
require "ping_me_maybe/constants"
|
3
|
+
require "ping_me_maybe/connection"
|
4
|
+
|
5
|
+
module PingMeMaybe
|
6
|
+
|
7
|
+
def self.ping_cronut(public_id)
|
8
|
+
|
9
|
+
if PingMeMaybe::Constants::CRONUT_HOST && public_id
|
10
|
+
begin
|
11
|
+
conn = PingMeMaybe::Connection.cronut_connection
|
12
|
+
str = "#{Time.now.to_i.to_s}-#{public_id}"
|
13
|
+
ping = conn.post "/ping/", {:public_id => (OpenSSL::PKey::RSA.new(PingMeMaybe::Constants::CRONUT_PUBLIC_KEY).public_encrypt(str))}
|
14
|
+
|
15
|
+
return ping.status == 200
|
16
|
+
|
17
|
+
rescue Exception => e
|
18
|
+
error_message = "#{e.message}\nTRACE:\n\t#{e.backtrace.join("\n\t")}"
|
19
|
+
Rails.logger.error(error_message)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "ping_me_maybe/constants"
|
2
|
+
|
3
|
+
module PingMeMaybe
|
4
|
+
module Connection
|
5
|
+
def self.cronut_connection
|
6
|
+
Faraday.new(PingMeMaybe::Constants::CRONUT_HOST) do |c|
|
7
|
+
c.request :url_encoded
|
8
|
+
c.use Faraday::Adapter::NetHttp
|
9
|
+
c.headers = {
|
10
|
+
PingMeMaybe::Constants::CRONUT_API_TOKEN_HEADER => PingMeMaybe::Constants::CRONUT_API_TOKEN
|
11
|
+
}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ping_me_maybe/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ping_me_maybe"
|
8
|
+
spec.version = PingMeMaybe::VERSION
|
9
|
+
spec.authors = ["Chris Clouten"]
|
10
|
+
spec.email = ["chris@harrys.com"]
|
11
|
+
spec.summary = %q{Ping a Cronut server}
|
12
|
+
spec.description = %q{Ping a Cronut server}
|
13
|
+
spec.homepage = "https://github.com/harrystech/ping-me-maybe"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "faraday"
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ping_me_maybe
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris Clouten
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
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: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Ping a Cronut server
|
56
|
+
email:
|
57
|
+
- chris@harrys.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- lib/ping_me_maybe.rb
|
68
|
+
- lib/ping_me_maybe/connection.rb
|
69
|
+
- lib/ping_me_maybe/constants.rb
|
70
|
+
- lib/ping_me_maybe/version.rb
|
71
|
+
- ping_me_maybe.gemspec
|
72
|
+
homepage: https://github.com/harrystech/ping-me-maybe
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.4.2
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Ping a Cronut server
|
96
|
+
test_files: []
|
97
|
+
has_rdoc:
|