scoutie 0.0.2

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 275e0394544020b2c28bb53aa8d7512be9e3478b
4
+ data.tar.gz: 0a7a580d38bc36fa6e3a0cdb5184c8adab38cca7
5
+ SHA512:
6
+ metadata.gz: 15dc7cab6b0c1e42951794f2e0e5d7db0dc18902af653ee80c59c2075bbea40c0143782cf66ef1ed71c09e463b660a50e9f35cf6ab04cd136cd82000aba2b5ce
7
+ data.tar.gz: 7b60b6e4839e4203c927d7e4a17d462176cb5d72761283047316788a6684d77e1e69e16be5c92285601ba8c8c1f433114fc7e181c06344a672d1bd03d6f0e3ea
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in scoutie.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Brittany Martin
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.
@@ -0,0 +1,49 @@
1
+ # Scoutie
2
+
3
+ A rake task to check the status code of a JSON request
4
+
5
+ ![alt tag](https://github.com/Brit200313/scoutie/blob/master/img/scoutie.png)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'scoutie'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install scoutie
22
+
23
+ ## Usage
24
+
25
+ Have a JSON API you want to test as you're coding along?
26
+
27
+ Simply run:
28
+
29
+ $ rake scoutie[url]
30
+
31
+ and Scoutie will return a response code and recommendation on proceeding.
32
+
33
+ ## Examples
34
+
35
+ $ rake scoutie["http://jsonip.com"] ⏎ ✱ ◼
36
+ Response: 200
37
+ Sweet! You're golden to use that API.
38
+
39
+ $ rake scoutie["https://www.yammer.com/api/v1/subscriptions/to_user/:id.json"] ✱ ◼
40
+ Response: 401
41
+ Nice try! Someone is missing an authorization token.
42
+
43
+ ## Contributing
44
+
45
+ 1. Fork it ( https://github.com/[my-github-username]/scoutie/fork )
46
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
47
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
48
+ 4. Push to the branch (`git push origin my-new-feature`)
49
+ 5. Create a new Pull Request
@@ -0,0 +1,13 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ import "lib/tasks/scout.rake"
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
8
+
9
+ task :console do
10
+ exec "irb -r mega_lotto -I ./lib"
11
+ end
12
+
13
+
Binary file
Binary file
@@ -0,0 +1,10 @@
1
+ require "scoutie/version"
2
+ require "scoutie/status"
3
+
4
+ begin
5
+ require "pry"
6
+ rescue LoadError
7
+ end
8
+
9
+ module Scoutie
10
+ end
Binary file
@@ -0,0 +1,40 @@
1
+ require 'httparty'
2
+
3
+ module Scoutie
4
+ class Status
5
+ def get_status(url)
6
+ api_response = HTTParty.get(url, :query => {:output => 'json'})
7
+ status = api_response.response.code.to_i
8
+ puts "Response: #{status}"
9
+
10
+ case status
11
+ when 200
12
+ puts "Sweet! You're golden to use that API."
13
+ when 207
14
+ puts "Yikes! You sent a destructive operation (POST, PUT, DELETE) against more than one resource and the operations against each indiviudal resource did not share a common outcome."
15
+ when 300 || 301
16
+ puts "Stop trying to make fetch happen. Not ideal, would be better if the response was a 200."
17
+ when 400
18
+ puts "Hold up. You're sending a malformed request to the API or the request cannot be validated."
19
+ when 401
20
+ puts "Nice try! Someone is missing an authorization token."
21
+ when 403
22
+ puts "Hate to be vague but this means you're doing something the API is not happy with. Better investigate."
23
+ when 404
24
+ puts "Manipulative much? This means that the resource you wanted to manipulate could not be found."
25
+ when 409
26
+ puts "Your request is syntactically correct but violates a business rule. Better take a closer look."
27
+ when 410
28
+ puts "N'Sync says your request is G-O-N-E. The requested resource is no longer available at the server and no forwarding address is known."
29
+ when 500
30
+ puts "This is embarrassing. This indicates a technical failure inside the API."
31
+ when 503
32
+ puts "Busy busy busy! The API is too busy to accept your request, or if your access to the API has been temporarily suspended due to overuse."
33
+ else
34
+ puts "Your request returned #{api_response} -- Scoutie has no idea what to do with that."
35
+ end
36
+
37
+ status
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,3 @@
1
+ module Scoutie
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,11 @@
1
+ require 'scoutie'
2
+
3
+ desc 'checks the HTTP status code of a JSON request'
4
+ task :scoutie, :url do |t, args|
5
+ url = args[:url] || 'http://www.telize.com/geoip?callback=?'
6
+ s = Scoutie::Status.new.get_status(url)
7
+ end
8
+
9
+
10
+
11
+
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'scoutie/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "scoutie"
8
+ spec.version = Scoutie::VERSION
9
+ spec.authors = ["Brittany Martin"]
10
+ spec.email = ["brittany.jill.martin@gmail.com"]
11
+ spec.summary = %q{Easy to use rake task to check JSON API calls}
12
+ spec.description = %q{Easy to use rake task to check JSON API calls}
13
+ spec.homepage = "https://github.com/Brit200313/scoutie"
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 "httparty"
22
+ spec.add_development_dependency "bundler", "~> 1.7"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec"
25
+ spec.add_development_dependency "pry"
26
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ module Scoutie
4
+ describe Status do
5
+ describe "#get_status" do
6
+ let(:status) { Status.new }
7
+
8
+ it "returns a 200 status code when available" do
9
+ s = status.get_status 'http://www.telize.com/geoip?callback=?'
10
+ expect(s).to be(200)
11
+ end
12
+
13
+ it "returns a 401 status code when denied" do
14
+ s = status.get_status 'https://www.yammer.com/api/v1/subscriptions/to_user/:id.json'
15
+ expect(s).to be(401)
16
+ end
17
+
18
+ it "returns a 403 status code when denied" do
19
+ s = status.get_status 'http://content.guardianapis.com/.json'
20
+ expect(s).to be(403)
21
+ end
22
+
23
+ it "throws exception if no protocol provided" do
24
+ expect{ status.get_status 'bananas!' }.to raise_error(URI::InvalidURIError)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,2 @@
1
+ require 'scoutie'
2
+ require 'pry'
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: scoutie
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Brittany Martin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
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.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Easy to use rake task to check JSON API calls
84
+ email:
85
+ - brittany.jill.martin@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - img/scoutie.png
97
+ - lib/.DS_Store
98
+ - lib/scoutie.rb
99
+ - lib/scoutie/.DS_Store
100
+ - lib/scoutie/status.rb
101
+ - lib/scoutie/version.rb
102
+ - lib/tasks/scout.rake
103
+ - scoutie.gemspec
104
+ - spec/lib/scoutie_spec.rb
105
+ - spec/spec_helper.rb
106
+ homepage: https://github.com/Brit200313/scoutie
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.2.2
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Easy to use rake task to check JSON API calls
130
+ test_files:
131
+ - spec/lib/scoutie_spec.rb
132
+ - spec/spec_helper.rb