logentries_pull_api 0.1.0 → 0.1.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: 6f261df1ae942edc0644465762bd06c1b7a0bee9
4
- data.tar.gz: 3f85b56a820ee525a0dcf11299888e0b3da3ddc5
3
+ metadata.gz: 4d271d72c8d7bd6cf91e6f6332511fb3c7c2c6a9
4
+ data.tar.gz: 35228d8e1830a4720c05393e6216effad52cbc61
5
5
  SHA512:
6
- metadata.gz: 53cf63ec7049be09064cfc57ef372820dba9ef9c04275bf8872d4d47fcf32efaabca32eee87a0e6099e78e3fe827259d62f6855cd4ae1992f251d58f4cda7db1
7
- data.tar.gz: 88b7b0121fd53f3ac626eba47a785d23d70569707f53a4a1f0007b1f455b7ccea3bfde8d98dc2bc9d2d370b969592113b29ead036b3c837b65a4925436481c9f
6
+ metadata.gz: bbc07d79e92718b901268f5daa106b03c59866e78153492224818b368fa0cbc4c9dc7aa6a36a8422f1a60bb9846d7601e00aba9cb6539d3ba555b0d26cf255bf
7
+ data.tar.gz: 425c1a3d889a36549aa929748b66ed84d033e7fac052e8e9e37cf8a9d871e262a08e667fb76fbb0c3b66fa866cc4240c4792745790c17e388f8e8ca8eb566775
@@ -3,6 +3,7 @@ require 'net/http'
3
3
  require 'uri'
4
4
 
5
5
  module LogentriesPullApi
6
+
6
7
  class Client
7
8
 
8
9
  attr_reader :account_key, :log_set_key, :log_key
@@ -14,21 +15,37 @@ module LogentriesPullApi
14
15
  end
15
16
 
16
17
 
17
- def get
18
+ def get(options = {})
19
+ response = fetch_response_from assemble_uri(options)
20
+
21
+ raise LogentriesPullApi::Error, response['reason'] if response.is_a? Hash
22
+
23
+ response
24
+ end
25
+
26
+ private
27
+
28
+ LOGENTRIES_API_URL = 'https://pull.logentries.com'
29
+
30
+
31
+ def assemble_uri(options)
18
32
  encoded_log_set_key = URI.encode log_set_key
19
33
  encoded_log_key = URI.encode log_key
20
34
 
21
35
  uri = URI.parse "#{LOGENTRIES_API_URL}/#{account_key}/hosts/#{encoded_log_set_key}/#{encoded_log_key}/"
22
- uri.query = URI.encode_www_form format: 'json'
36
+ uri.query = URI.encode_www_form options.merge format: 'json'
37
+
38
+ uri
39
+ end
23
40
 
41
+
42
+ def fetch_response_from(uri)
24
43
  response = Net::HTTP.get_response uri
25
44
  JSON.parse response.body
26
45
  end
27
46
 
47
+ end
28
48
 
29
- private
30
-
31
- LOGENTRIES_API_URL = 'https://pull.logentries.com'
49
+ class Error < StandardError; end
32
50
 
33
- end
34
51
  end
@@ -1,3 +1,3 @@
1
1
  module LogentriesPullApi
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logentries_pull_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Balazs Szerencsi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-28 00:00:00.000000000 Z
11
+ date: 2016-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler