snitcher 0.1.0 → 0.2.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 +4 -4
- data/.gitignore +17 -0
- data/.travis.yml +12 -0
- data/CHANGELOG.md +9 -0
- data/Gemfile +9 -0
- data/{LICENSE → LICENSE.txt} +1 -1
- data/README.md +36 -9
- data/Rakefile +8 -0
- data/bin/snitch +29 -0
- data/lib/snitcher.rb +7 -25
- data/snitcher.gemspec +19 -0
- data/spec/snitcher_spec.rb +59 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/support/random.rb +3 -0
- data/spec/support/webmock.rb +1 -0
- metadata +60 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8c248e10b01d23be566aa4d4f0f63c6536b672d
|
4
|
+
data.tar.gz: f3f2054fce497f55b4abcb15be75ebba1b8d1532
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86e2b8428cf2f239d1e6dd3eb9bc005e11729f1156c208ec5d3906d379f121748a2fe0179d9ed8da68bbfbc9e7a082d580af0abbdd4ec66ebcf502c9f24c2948
|
7
|
+
data.tar.gz: b0701107c63002a730162abb24d197d9aa3740d85e09956eb86111cd5d2fdfa1ca01c3ea4790226f899b570839fcbba74c9711db0688c56102d30a7afc09e6a9
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
## 0.2.0 / 2014-01-20
|
2
|
+
|
3
|
+
* [FEATURE] Add "snitch" executable ([@laserlemon](https://github.com/laserlemon))
|
4
|
+
* [FEATURE] Allow Snitcher module mixin ([@zspencer](https://github.com/zspencer))
|
5
|
+
* [ENHANCEMENT] Add tests ([@laserlemon](https://github.com/laserlemon), [@ersatzryan](https://github.com/ersatzryan))
|
6
|
+
|
7
|
+
## 0.1.0 / 2013-06-22
|
8
|
+
|
9
|
+
* [FEATURE] Add `Snitcher.snitch` method ([@gaffneyc](https://github.com/gaffneyc))
|
data/Gemfile
ADDED
data/{LICENSE → LICENSE.txt}
RENAMED
data/README.md
CHANGED
@@ -2,24 +2,51 @@
|
|
2
2
|
|
3
3
|
Simple API client for [Dead Man's Snitch](https://deadmanssnitch.com)
|
4
4
|
|
5
|
+
[](http://badge.fury.io/rb/snitcher)
|
6
|
+
[](https://travis-ci.org/collectiveidea/snitcher)
|
7
|
+
[](https://codeclimate.com/github/collectiveidea/snitcher)
|
8
|
+
[](https://coveralls.io/r/collectiveidea/snitcher)
|
9
|
+
[](https://gemnasium.com/collectiveidea/snitcher)
|
10
|
+
|
5
11
|

|
6
12
|
|
7
|
-
##
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
To check in for one of your snitches:
|
8
16
|
|
9
|
-
Notify Dead Man's Snitch that a thing happened:
|
10
17
|
```ruby
|
11
18
|
Snitcher.snitch("c2354d53d2")
|
12
19
|
```
|
13
20
|
|
14
|
-
|
21
|
+
You can also check in from the command line:
|
22
|
+
|
23
|
+
```bash
|
24
|
+
$ snitch c2354d53d2
|
25
|
+
```
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
Snitcher is open source and contributions from the community are encouraged! No
|
30
|
+
contribution is too small. Please consider:
|
31
|
+
|
32
|
+
* adding features
|
33
|
+
* squashing bugs
|
34
|
+
* updating documentation
|
35
|
+
* fixing typos
|
36
|
+
|
37
|
+
For the best chance of having your changes merged, please:
|
38
|
+
|
39
|
+
1. fork the project
|
40
|
+
2. push your changes, with tests
|
41
|
+
3. submit a pull request with at least one animated GIF
|
15
42
|
|
16
|
-
|
17
|
-
* Add tests to show the problem or test your feature
|
18
|
-
* Make your feature addition or bug fix.
|
19
|
-
* Send me a pull request. Bonus points for topic branches.
|
43
|
+
## Thanks
|
20
44
|
|
21
|
-
|
45
|
+
A big thank you to [Randy Schmidt](https://github.com/r38y) for dreaming up
|
46
|
+
Dead Man's Snitch in the first place and for
|
47
|
+
[entrusting](http://r38y.com/dead-mans-snitch-sold) its future to Collective
|
48
|
+
Idea.
|
22
49
|
|
23
50
|
## Copyright
|
24
51
|
|
25
|
-
See LICENSE for details.
|
52
|
+
See [LICENSE.txt](LICENSE.txt) for details.
|
data/Rakefile
ADDED
data/bin/snitch
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "optparse"
|
4
|
+
require "snitcher"
|
5
|
+
|
6
|
+
option_parser = OptionParser.new do |parser|
|
7
|
+
parser.banner = "Usage: snitch TOKEN"
|
8
|
+
|
9
|
+
parser.on("-h", "--help", "Show this message") do
|
10
|
+
puts parser.help
|
11
|
+
exit 0
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
token = ARGV[0]
|
16
|
+
|
17
|
+
if token
|
18
|
+
print "Snitching #{token} ... "
|
19
|
+
|
20
|
+
if Snitcher.snitch(token)
|
21
|
+
puts "succeeded."
|
22
|
+
exit 0
|
23
|
+
else
|
24
|
+
warn "failed."
|
25
|
+
exit 1
|
26
|
+
end
|
27
|
+
else
|
28
|
+
puts option_parser.help
|
29
|
+
end
|
data/lib/snitcher.rb
CHANGED
@@ -1,31 +1,13 @@
|
|
1
|
-
require "net/
|
1
|
+
require "net/http"
|
2
2
|
|
3
3
|
module Snitcher
|
4
|
+
extend self
|
4
5
|
|
5
|
-
|
6
|
-
|
6
|
+
def snitch(token)
|
7
|
+
http = Net::HTTP.new("nosnch.in", 443)
|
8
|
+
http.use_ssl = true
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
end
|
11
|
-
|
12
|
-
def checkin
|
13
|
-
http = Net::HTTP.new("nosnch.in", 443)
|
14
|
-
http.use_ssl = true
|
15
|
-
|
16
|
-
response = http.request(Net::HTTP::Get.new("/#{@token}"))
|
17
|
-
response.code_type == Net::HTTPOK
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
class << self
|
22
|
-
def by_token(token)
|
23
|
-
Snitch.new(token)
|
24
|
-
end
|
25
|
-
|
26
|
-
def checkin(token)
|
27
|
-
by_token(token).checkin
|
28
|
-
end
|
29
|
-
alias_method :snitch, :checkin
|
10
|
+
response = http.request(Net::HTTP::Get.new("/#{token}"))
|
11
|
+
response.is_a?(Net::HTTPSuccess)
|
30
12
|
end
|
31
13
|
end
|
data/snitcher.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "snitcher"
|
5
|
+
spec.version = "0.2.0"
|
6
|
+
|
7
|
+
spec.author = "Collective Idea"
|
8
|
+
spec.email = "info@collectiveidea.com"
|
9
|
+
spec.homepage = "https://github.com/collectiveidea/snitcher"
|
10
|
+
spec.summary = "Simple API client for deadmanssnitch.com"
|
11
|
+
spec.license = "MIT"
|
12
|
+
|
13
|
+
spec.files = `git ls-files`.split($/)
|
14
|
+
spec.executables = spec.files.grep(/^bin/) { |f| File.basename(f) }
|
15
|
+
spec.test_files = spec.files.grep(/^spec/)
|
16
|
+
|
17
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
18
|
+
spec.add_development_dependency "rake", "~> 10.1"
|
19
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
require "securerandom"
|
4
|
+
|
5
|
+
describe Snitcher do
|
6
|
+
let(:token) { SecureRandom.hex(5) }
|
7
|
+
|
8
|
+
before do
|
9
|
+
stub_request(:get, /nosnch\.in/)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe ".snitch" do
|
13
|
+
it "pings DMS with the given token" do
|
14
|
+
Snitcher.snitch(token)
|
15
|
+
|
16
|
+
expect(a_request(:get, "https://nosnch.in/#{token}")).to have_been_made.once
|
17
|
+
end
|
18
|
+
|
19
|
+
context "when successful" do
|
20
|
+
before do
|
21
|
+
stub_request(:get, "https://nosnch.in/#{token}").to_return(status: 200)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "returns true" do
|
25
|
+
expect(Snitcher.snitch(token)).to eq(true)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "when unsuccessful" do
|
30
|
+
before do
|
31
|
+
stub_request(:get, "https://nosnch.in/#{token}").to_return(status: 404)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "returns false" do
|
35
|
+
expect(Snitcher.snitch(token)).to eq(false)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "inclusion" do
|
41
|
+
let(:snitching_class) { Class.new { include Snitcher } }
|
42
|
+
|
43
|
+
it "snitches" do
|
44
|
+
snitching_class.new.snitch(token)
|
45
|
+
|
46
|
+
expect(a_request(:get, "https://nosnch.in/#{token}")).to have_been_made.once
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "extension" do
|
51
|
+
let(:snitching_class) { Class.new { extend Snitcher } }
|
52
|
+
|
53
|
+
it "snitches" do
|
54
|
+
snitching_class.snitch(token)
|
55
|
+
|
56
|
+
expect(a_request(:get, "https://nosnch.in/#{token}")).to have_been_made.once
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "webmock/rspec"
|
metadata
CHANGED
@@ -1,27 +1,68 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snitcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Collective Idea
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
11
|
+
date: 2014-01-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.1'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.1'
|
13
41
|
description:
|
14
|
-
email:
|
15
|
-
|
16
|
-
|
42
|
+
email: info@collectiveidea.com
|
43
|
+
executables:
|
44
|
+
- snitch
|
17
45
|
extensions: []
|
18
46
|
extra_rdoc_files: []
|
19
47
|
files:
|
20
|
-
-
|
21
|
-
-
|
48
|
+
- ".gitignore"
|
49
|
+
- ".travis.yml"
|
50
|
+
- CHANGELOG.md
|
51
|
+
- Gemfile
|
52
|
+
- LICENSE.txt
|
22
53
|
- README.md
|
23
|
-
|
24
|
-
|
54
|
+
- Rakefile
|
55
|
+
- bin/snitch
|
56
|
+
- doc/get_them_stitches.jpg
|
57
|
+
- lib/snitcher.rb
|
58
|
+
- snitcher.gemspec
|
59
|
+
- spec/snitcher_spec.rb
|
60
|
+
- spec/spec_helper.rb
|
61
|
+
- spec/support/random.rb
|
62
|
+
- spec/support/webmock.rb
|
63
|
+
homepage: https://github.com/collectiveidea/snitcher
|
64
|
+
licenses:
|
65
|
+
- MIT
|
25
66
|
metadata: {}
|
26
67
|
post_install_message:
|
27
68
|
rdoc_options: []
|
@@ -29,18 +70,22 @@ require_paths:
|
|
29
70
|
- lib
|
30
71
|
required_ruby_version: !ruby/object:Gem::Requirement
|
31
72
|
requirements:
|
32
|
-
- -
|
73
|
+
- - ">="
|
33
74
|
- !ruby/object:Gem::Version
|
34
75
|
version: '0'
|
35
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
77
|
requirements:
|
37
|
-
- -
|
78
|
+
- - ">="
|
38
79
|
- !ruby/object:Gem::Version
|
39
80
|
version: '0'
|
40
81
|
requirements: []
|
41
82
|
rubyforge_project:
|
42
|
-
rubygems_version: 2.0
|
83
|
+
rubygems_version: 2.2.0
|
43
84
|
signing_key:
|
44
85
|
specification_version: 4
|
45
86
|
summary: Simple API client for deadmanssnitch.com
|
46
|
-
test_files:
|
87
|
+
test_files:
|
88
|
+
- spec/snitcher_spec.rb
|
89
|
+
- spec/spec_helper.rb
|
90
|
+
- spec/support/random.rb
|
91
|
+
- spec/support/webmock.rb
|