snitcher 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e56f9fe98d4ef909a4fab53faa0c58db5298cd6c
4
- data.tar.gz: 6df2091f4831bf880e95f117abd750cee1cd1115
3
+ metadata.gz: a8c248e10b01d23be566aa4d4f0f63c6536b672d
4
+ data.tar.gz: f3f2054fce497f55b4abcb15be75ebba1b8d1532
5
5
  SHA512:
6
- metadata.gz: 09a09239a6d04449e485be7619e793dafc5b262fb9ddef3e4674d2982517a610eb4e49abd5725e5fd47ff9ecc2e59cd0bdf9c237e96f37961932ace32510aecf
7
- data.tar.gz: 0858831e9a8bc9df6b6afce7d3dbb8bd34f3fbdbf135818a10f8a2e9ad43bdbd223d04768be4c5574543fdb223e806536bff8057121f10e665c518af6f4d46d0
6
+ metadata.gz: 86e2b8428cf2f239d1e6dd3eb9bc005e11729f1156c208ec5d3906d379f121748a2fe0179d9ed8da68bbfbc9e7a082d580af0abbdd4ec66ebcf502c9f24c2948
7
+ data.tar.gz: b0701107c63002a730162abb24d197d9aa3740d85e09956eb86111cd5d2fdfa1ca01c3ea4790226f899b570839fcbba74c9711db0688c56102d30a7afc09e6a9
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ branches:
2
+ only:
3
+ - master
4
+ language: ruby
5
+ matrix:
6
+ allow_failures:
7
+ - rvm: ruby-head
8
+ rvm:
9
+ - 1.9.3
10
+ - 2.0.0
11
+ - 2.1.0
12
+ - ruby-head
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
@@ -0,0 +1,9 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ group :test do
6
+ gem "coveralls", "~> 0.7", require: false
7
+ gem "rspec", "~> 2.14"
8
+ gem "webmock", "~> 1.17"
9
+ end
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 Chris Gaffney
1
+ Copyright (c) 2013 Collective Idea
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
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
+ [![Gem Version](https://badge.fury.io/rb/snitcher.png)](http://badge.fury.io/rb/snitcher)
6
+ [![Build Status](https://travis-ci.org/collectiveidea/snitcher.png?branch=master)](https://travis-ci.org/collectiveidea/snitcher)
7
+ [![Code Climate](https://codeclimate.com/github/collectiveidea/snitcher.png)](https://codeclimate.com/github/collectiveidea/snitcher)
8
+ [![Coverage Status](https://coveralls.io/repos/collectiveidea/snitcher/badge.png)](https://coveralls.io/r/collectiveidea/snitcher)
9
+ [![Dependency Status](https://gemnasium.com/collectiveidea/snitcher.png)](https://gemnasium.com/collectiveidea/snitcher)
10
+
5
11
  ![Snitches get Stitches](doc/get_them_stitches.jpg)
6
12
 
7
- ## Basic Usage
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
- ## Note on Patches/Pull Requests
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
- * Fork the project.
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
- Please don't make changes to the Rakefile or version.
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
@@ -0,0 +1,8 @@
1
+ require "bundler"
2
+ require "rspec/core/rake_task"
3
+
4
+ Bundler::GemHelper.install_tasks
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
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/https"
1
+ require "net/http"
2
2
 
3
3
  module Snitcher
4
+ extend self
4
5
 
5
- class Snitch
6
- attr_reader :token
6
+ def snitch(token)
7
+ http = Net::HTTP.new("nosnch.in", 443)
8
+ http.use_ssl = true
7
9
 
8
- def initialize(token)
9
- @token = token
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
@@ -0,0 +1,8 @@
1
+ if ENV["TRAVIS"]
2
+ require "coveralls"
3
+ Coveralls.wear!
4
+ end
5
+
6
+ require "snitcher"
7
+
8
+ Dir[File.expand_path("../support/*.rb", __FILE__)].each { |f| require f }
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+ config.order = "random"
3
+ end
@@ -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.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
- - Chris Gaffney
7
+ - Collective Idea
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-22 00:00:00.000000000 Z
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
- - gaffneyc@gmail.com
16
- executables: []
42
+ email: info@collectiveidea.com
43
+ executables:
44
+ - snitch
17
45
  extensions: []
18
46
  extra_rdoc_files: []
19
47
  files:
20
- - lib/snitcher.rb
21
- - LICENSE
48
+ - ".gitignore"
49
+ - ".travis.yml"
50
+ - CHANGELOG.md
51
+ - Gemfile
52
+ - LICENSE.txt
22
53
  - README.md
23
- homepage: https://github.com/gaffneyc/snitcher
24
- licenses: []
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.3
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