papertrail_rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8afe2c4a1320ac140e8b6bbf5b47c6a3df96195a
4
+ data.tar.gz: 0a00c08bc777f828c7191b38bd95f9351730a269
5
+ SHA512:
6
+ metadata.gz: a6516b51dd51fcae7c4dbaab7ea95f62ca7819f7dd3d09f892e34c5732a89c1e61168128b4be0fa9488f99f511933c067dc01f70998213446eae35bf379e756b
7
+ data.tar.gz: 2899e7ba57775ce42cce68642d6ea42863d76dd772147ed7d4b327cb27f4b67757a9f89c6c25e930af1729ae303e2149561c7b973d70ec9d7321f7566f8adfe6
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'httparty', '~> 0.13.1'
data/MIT-LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2011- Intercom, Inc. (https://www.intercom.io)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # papertrail_rails
2
+
3
+ Ruby wrapper for querying the papertrail API
@@ -0,0 +1,22 @@
1
+ # require 'papertrail_rails/request'
2
+ require_relative 'papertrail_rails/request'
3
+ module PapertrailRails
4
+ @api_key = nil
5
+
6
+ def self.api_key=(api_key)
7
+ @api_key = api_key
8
+ PapertrailRails::Request.set_default_headers(api_key)
9
+ end
10
+
11
+ def self.api_key
12
+ @api_key
13
+ end
14
+
15
+ def self.search_status(query)
16
+ PapertrailRails::Request.get("/events/search.json?q=status=", query)
17
+ end
18
+
19
+ def search(query)
20
+ PapertrailRails::Request.get('/events/search.json?q=', query)
21
+ end
22
+ end
@@ -0,0 +1,34 @@
1
+ require 'httparty'
2
+
3
+ module PapertrailRails
4
+ class Request
5
+ @@headers = {}
6
+ @base_uri = "https://papertrailapp.com/api/v1"
7
+
8
+ include HTTParty
9
+
10
+ def self.get(path, query)
11
+ response = HTTParty.get(append_query_string_to_url(path, query), @@headers)
12
+ check_code(response.code)
13
+ response.parsed_response
14
+ end
15
+
16
+ def self.append_query_string_to_url(path, query)
17
+ @base_uri + path + query
18
+ end
19
+
20
+ def self.set_default_headers(api_key)
21
+ @@headers = { headers: { 'X-Papertrail-Token' => api_key } } if @@headers.empty?
22
+ end
23
+
24
+ def self.check_code(code)
25
+ case code
26
+ when 401
27
+ raise AuthenticationError.new('Api key is missing or invalid')
28
+ end
29
+ end
30
+
31
+ class AuthenticationError < StandardError
32
+ end
33
+ end
34
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: papertrail_rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Nick Wargnier
8
+ - Mike Nickelson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-06-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: httparty
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - '='
19
+ - !ruby/object:Gem::Version
20
+ version: 0.13.1
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - '='
26
+ - !ruby/object:Gem::Version
27
+ version: 0.13.1
28
+ description: Ruby wrapper for querying the papertrail API
29
+ email:
30
+ - nick@amitree.com
31
+ - mike@amitree.com
32
+ executables: []
33
+ extensions: []
34
+ extra_rdoc_files: []
35
+ files:
36
+ - Gemfile
37
+ - MIT-LICENSE
38
+ - README.md
39
+ - lib/papertrail_rails.rb
40
+ - lib/papertrail_rails/request.rb
41
+ homepage: http://rubygems.org/gems/papertrail_rails
42
+ licenses:
43
+ - MIT
44
+ metadata: {}
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '2.0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubyforge_project:
61
+ rubygems_version: 2.2.2
62
+ signing_key:
63
+ specification_version: 4
64
+ summary: Papertrail Rails Wrapper
65
+ test_files: []