black_vulture_client 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: 2a69fa524b2fc3d6ef2f0070a708079bafe97966
4
- data.tar.gz: d40f0f61e9b8066fe28071cd33e0e3d579f0629c
3
+ metadata.gz: 4f2d61af4da8ff817ff8fc100fb76a97db6050e4
4
+ data.tar.gz: e993ef796ba674027e41813c6a145bbf68ada310
5
5
  SHA512:
6
- metadata.gz: ad9bc5dbd757595b838ec4388c3fe36ab809c67f966582c0111162594776f95cfcf4c472b09fb68a1acf75120bdde948e89600dea73284c68d3ded8dd8d38cd0
7
- data.tar.gz: c0ad9589176f00dfdd0cd2107e38d856ec7211953bd2017e4d00bf785f484ea18193a2f8d21f6018a5f1750a874527d49843ce80beddbd8ebd3994676ff1d88c
6
+ metadata.gz: 3437c955fc8b7a1fb8e3bf1ee8e7dad7e0c3f83c638506031009e7fc762b21c831ab998ad3aef76d9a32e8e8c3f68202bb6cbde42819a8abe5d84e84583baf42
7
+ data.tar.gz: 340c44a38ac45e01dcea758b2ae6f05d1a085756862b56d858f9e7ecd9d9d7314495d7b22952bd9d7edc56374dba058e786237b56d8f183ba6a06027f52e9f0b
@@ -1,3 +1,3 @@
1
1
  module BlackVultureClient
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -4,33 +4,33 @@ module BlackVulture
4
4
 
5
5
  class Client
6
6
  attr_accessor :email, :token
7
-
7
+
8
8
  def initialize(email, token)
9
9
  @email = email
10
10
  @token = token
11
11
  end
12
-
12
+
13
13
  def list_facts(line)
14
14
  url_path = "/facts/#{line}.json"
15
15
  uri = uri(url_path)
16
16
  response = get(uri)
17
17
  JSON.parse(response.body)
18
18
  end
19
-
19
+
20
20
  def create_report(line, query)
21
21
  uri = uri_for_report(line, query)
22
22
  response = get(uri)
23
23
  JSON.parse(response.body)
24
24
  end
25
-
25
+
26
26
  def create_fact(payload)
27
27
  uri = uri('/facts.json')
28
28
  response = post(uri, payload)
29
29
  JSON.parse(response.body)
30
30
  end
31
-
31
+
32
32
  private
33
-
33
+
34
34
  def headers
35
35
  {
36
36
  'X-User-Token' => @token,
@@ -39,27 +39,27 @@ module BlackVulture
39
39
  'Content-Type' => 'application/json'
40
40
  }
41
41
  end
42
-
42
+
43
43
  def host
44
- 'http://localhost:3000'
44
+ ENV["BLACK_VULTURE_URL"] || "http://52.32.38.238"
45
45
  end
46
-
46
+
47
47
  def uri(name)
48
48
  URI.parse("#{host}#{name}")
49
49
  end
50
-
50
+
51
51
  def build_http(uri)
52
52
  Net::HTTP.new(uri.host, uri.port)
53
53
  end
54
-
54
+
55
55
  def get(uri)
56
56
  build_http(uri).get(uri.request_uri, headers)
57
57
  end
58
-
58
+
59
59
  def post(uri, payload)
60
60
  build_http(uri).post(uri.path, payload.to_json, headers)
61
61
  end
62
-
62
+
63
63
  def uri_for_report(line, query)
64
64
  URI.parse("#{host}/reports/#{line}#{query}")
65
65
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: black_vulture_client
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
  - josediaz16
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-13 00:00:00.000000000 Z
11
+ date: 2016-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler