snitcher 0.3.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dfa2c9e77f2a460c686bc38cb48b271c32276baf
4
- data.tar.gz: cb0fe423892d35aec921787bb619e899231148d5
3
+ metadata.gz: f95719e2e2be1ad6b5432efc058e665e0f10c0f5
4
+ data.tar.gz: 728ab009d5477a6e8ecfd07660d2e40c013e52d5
5
5
  SHA512:
6
- metadata.gz: da4d0919667bc3e3ee37316368c5980fb06e34d9c388f9145fdf58a0cfc4e1229e425842150f32b09bfe7b54e7e00b4f7a6f8989483fbae7338bd8a247dddb58
7
- data.tar.gz: 0ee626c061780cfb8d65ff0b68ab7fd9e0226878b11c0ca777393255a4672485c3b3d35581e7214a36e2606cfdda3132de228eeb3536f81740e67020aa558610
6
+ metadata.gz: 8c66ef13e29d9b58b74c16bed76b3f272161a861bdc5f36ba824c90ada6abf09bc7f1a8d11dc01de150d297cd43133371d83ad35632d6945b874d8ecf5fcf18e
7
+ data.tar.gz: ddcee25b534ce9f06ac50e6ab515e68aa079d2dcf3b17ebb4c846a003c712295379fe38231dc8d7af29b50ff023cafaab97bb743a3c28c1a71bc9f275232f717
@@ -8,5 +8,6 @@ matrix:
8
8
  rvm:
9
9
  - 1.9.3
10
10
  - 2.0.0
11
- - 2.1.0
11
+ - 2.1
12
+ - 2.2
12
13
  - ruby-head
@@ -1,3 +1,6 @@
1
+ ## 0.3.1 / TBD
2
+ * [ENHANCEMENT] Add a custom User-Agent
3
+
1
4
  ## 0.3.0 / 2014-10-14
2
5
 
3
6
  * [FEATURE] Add support for the message parameter during check-in
data/README.md CHANGED
@@ -18,12 +18,33 @@ To check in for one of your snitches:
18
18
  Snitcher.snitch("c2354d53d2")
19
19
  ```
20
20
 
21
+ You also may provide a message with the check in:
22
+
23
+ ```ruby
24
+ Snitcher.snitch("c2354d53d2", message: "Finished in 23.8 seconds.")
25
+ ```
26
+
27
+ The default timeout of 2 seconds can be overridden:
28
+
29
+ ```ruby
30
+ Snitcher.snitch("c2354d53d2", timeout: 10)
31
+ ```
32
+
33
+ ## Command Line Tool
34
+
21
35
  You can also check in from the command line:
22
36
 
23
37
  ```bash
24
38
  $ snitch c2354d53d2
25
39
  ```
26
40
 
41
+ If you want to include a message, use the `-m` or `--message` flag.
42
+
43
+ ```bash
44
+ $ snitch c2354d53d2 -m "Finished in 23.8 seconds."
45
+ $ snitch c2354d53d2 --message "Finished in 23.8 seconds."
46
+ ```
47
+
27
48
  ## Contributing
28
49
 
29
50
  Snitcher is open source and contributions from the community are encouraged! No
@@ -34,10 +34,24 @@ module Snitcher
34
34
  uri.query = URI.encode_www_form(:m => message)
35
35
  end
36
36
 
37
- response = http.request(Net::HTTP::Get.new(uri.request_uri))
37
+ request = Net::HTTP::Get.new(uri.request_uri)
38
+ request["User-Agent"] = user_agent
39
+
40
+ response = http.request(request)
38
41
  response.is_a?(Net::HTTPSuccess)
39
42
  end
40
43
  rescue ::Timeout::Error
41
44
  false
42
45
  end
46
+
47
+ private
48
+
49
+ def user_agent
50
+ # RUBY_ENGINE was not added until 1.9.3
51
+ engine = defined?(::RUBY_ENGINE) ? ::RUBY_ENGINE : "Ruby"
52
+
53
+ "Snitcher; #{engine}/#{RUBY_VERSION}; #{RUBY_PLATFORM}; v#{VERSION}"
54
+ end
43
55
  end
56
+
57
+ require "snitcher/version"
@@ -0,0 +1,3 @@
1
+ module Snitcher
2
+ VERSION = "0.3.1"
3
+ end
@@ -1,12 +1,15 @@
1
1
  # encoding: UTF-8
2
2
 
3
+ $:.unshift File.expand_path("../lib", __FILE__)
4
+ require "snitcher/version"
5
+
3
6
  Gem::Specification.new do |spec|
4
7
  spec.name = "snitcher"
5
- spec.version = "0.3.0"
8
+ spec.version = Snitcher::VERSION
6
9
 
7
10
  spec.author = "Collective Idea"
8
- spec.email = "info@collectiveidea.com"
9
- spec.homepage = "https://github.com/collectiveidea/snitcher"
11
+ spec.email = "hi@deadmanssnitch.com"
12
+ spec.homepage = "https://github.com/deadmanssnitch/snitcher"
10
13
  spec.summary = "Simple API client for deadmanssnitch.com"
11
14
  spec.license = "MIT"
12
15
 
@@ -16,6 +16,16 @@ describe Snitcher do
16
16
  expect(a_request(:get, "https://nosnch.in/#{token}")).to have_been_made.once
17
17
  end
18
18
 
19
+ it "includes a custom user-agent" do
20
+ Snitcher.snitch(token)
21
+
22
+ expect(
23
+ a_request(:get, "https://nosnch.in/#{token}").with(
24
+ headers: { "User-Agent" => /\ASnitcher;.*; v#{Snitcher::VERSION}\z/ },
25
+ )
26
+ ).to have_been_made
27
+ end
28
+
19
29
  context "when successful" do
20
30
  before do
21
31
  stub_request(:get, "https://nosnch.in/#{token}").to_return(status: 200)
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.3.0
4
+ version: 0.3.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: 2014-10-14 00:00:00.000000000 Z
11
+ date: 2015-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.1'
41
41
  description:
42
- email: info@collectiveidea.com
42
+ email: hi@deadmanssnitch.com
43
43
  executables:
44
44
  - snitch
45
45
  extensions: []
@@ -55,12 +55,13 @@ files:
55
55
  - bin/snitch
56
56
  - doc/get_them_stitches.jpg
57
57
  - lib/snitcher.rb
58
+ - lib/snitcher/version.rb
58
59
  - snitcher.gemspec
59
60
  - spec/snitcher_spec.rb
60
61
  - spec/spec_helper.rb
61
62
  - spec/support/random.rb
62
63
  - spec/support/webmock.rb
63
- homepage: https://github.com/collectiveidea/snitcher
64
+ homepage: https://github.com/deadmanssnitch/snitcher
64
65
  licenses:
65
66
  - MIT
66
67
  metadata: {}
@@ -80,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
81
  version: '0'
81
82
  requirements: []
82
83
  rubyforge_project:
83
- rubygems_version: 2.2.2
84
+ rubygems_version: 2.4.6
84
85
  signing_key:
85
86
  specification_version: 4
86
87
  summary: Simple API client for deadmanssnitch.com