access_watch 0.0.2 → 0.0.3
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/README.md +2 -2
- data/lib/access_watch/client.rb +24 -12
- data/lib/access_watch/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cad2bcef8d760ae8b64bdf959c7d481f5ac0be55
|
4
|
+
data.tar.gz: 49b160e978b63a7abd58e87522eabc994d55464c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd37080cf88ccc657c991061105faa6655da6844e9524fc145b5342477803edb49ac78b86e0628ce10bb2c2d9d90d2323bb8565bf53de2359440c402e7e4edfd
|
7
|
+
data.tar.gz: 54167e4c67cefeb07046c20d8bb59da8072a780f4eb069f1c67ef7c4fd38df6832eed1b183ec617eb9f537885f040040b080fbd1a6cd76c5d315b5511186f1ce
|
data/README.md
CHANGED
@@ -6,11 +6,11 @@ A Ruby library to log and analyse HTTP requests using the [Access Watch](http://
|
|
6
6
|
|
7
7
|
Install the latest version with
|
8
8
|
|
9
|
-
```gem install
|
9
|
+
```gem install access_watch```
|
10
10
|
|
11
11
|
or in your Gemfile
|
12
12
|
|
13
|
-
```gem "
|
13
|
+
```gem "access_watch"```
|
14
14
|
|
15
15
|
## Basic Usage
|
16
16
|
|
data/lib/access_watch/client.rb
CHANGED
@@ -13,22 +13,19 @@ module AccessWatch
|
|
13
13
|
@api_endpoint = options[:api_endpoint] || "https://access.watch/api/1.0/"
|
14
14
|
end
|
15
15
|
|
16
|
-
HTTPS = "https".freeze
|
17
|
-
CERTIFICATE_AUTHORITIES_PATH = File.expand_path("../../../cacert.pem", __FILE__)
|
18
|
-
|
19
16
|
def post(path, data)
|
20
17
|
uri = URI(api_endpoint + path)
|
21
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
22
|
-
|
23
|
-
if uri.scheme == HTTPS
|
24
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
25
|
-
http.ca_file = CERTIFICATE_AUTHORITIES_PATH
|
26
|
-
http.use_ssl = true
|
27
|
-
end
|
28
|
-
|
29
18
|
post = Net::HTTP::Post.new(uri.path, default_headers)
|
30
19
|
post.body = data.to_json
|
31
|
-
resp = http.request(post)
|
20
|
+
resp = http(uri).request(post)
|
21
|
+
end
|
22
|
+
|
23
|
+
def get(path, params = nil)
|
24
|
+
uri = URI.parse(api_endpoint + path)
|
25
|
+
uri.query = URI.encode_www_form(params) if params
|
26
|
+
request = Net::HTTP::Get.new(uri.request_uri, default_headers)
|
27
|
+
response = http(uri).request(request)
|
28
|
+
response.body
|
32
29
|
end
|
33
30
|
|
34
31
|
def default_headers
|
@@ -38,5 +35,20 @@ module AccessWatch
|
|
38
35
|
"Content-Type" => "application/json",
|
39
36
|
}
|
40
37
|
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
HTTPS = "https".freeze
|
42
|
+
CERTIFICATE_AUTHORITIES_PATH = File.expand_path("../../../cacert.pem", __FILE__)
|
43
|
+
|
44
|
+
def http(uri)
|
45
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
46
|
+
if uri.scheme == HTTPS
|
47
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
48
|
+
http.ca_file = CERTIFICATE_AUTHORITIES_PATH
|
49
|
+
http.use_ssl = true
|
50
|
+
end
|
51
|
+
http
|
52
|
+
end
|
41
53
|
end
|
42
54
|
end
|
data/lib/access_watch/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: access_watch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexis Bernard
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|