eltesla 0.0.1 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d5a5688dc14f783b38a944c3e29088ee53343beab09b3a7dd0a4d59a54eadcc
4
- data.tar.gz: 39b89807a086e30b1b0d680975a29a3f657591e82e192b9709fc4c91388d3487
3
+ metadata.gz: fe285ae92d66faa2dd75811848c19a3f2822154ac843289022623159ebaa9fd6
4
+ data.tar.gz: a1a75c68b07739500005ba57fe69d617b8d6d3d05caaca2496d7ec48a2edd777
5
5
  SHA512:
6
- metadata.gz: b263b136234020ac7b6e88b7493131b2f815120409b36b1c6bd51d1d873adae29a4456e05a6e1613150fe4fbbb72d6c9f65e49be6a49e54963673749fe6a3036
7
- data.tar.gz: 1b935e5420b4720c16be076184c13a32ba98f597043bc32b9dd4fbecaf74dcd99a9670ba7765354908e86864db976380c038beec17bb346e3ff4bed2f455b91a
6
+ metadata.gz: 8ce15a43687eb8602a50071b27f73dde7ab39eb59afb4433f120d7637007f73d2164d53c63066e13968ddb93d0a6e9252032add720fa7e0a877b50f54446287c
7
+ data.tar.gz: 79604e4f914721f4333437c172b6eb3c67961468715037a8e50b55f8d1320793e5d0963ce48ebbd5281e27b46ade426cf291a44a5328e34edc810559e15055a2
@@ -1,9 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'net/http'
3
+ require 'httparty'
4
4
  require 'uri'
5
5
  require 'json'
6
6
 
7
+ # rb(main):004> HTTParty.post('https://eltesla.dev/metrics', body: { results: []}.to_json, headers: { 'Content-Type' => 'application/json' })
7
8
  module Eltesla
8
9
  # Client for the Eltesla backend
9
10
  class Client
@@ -50,14 +51,14 @@ module Eltesla
50
51
  private
51
52
 
52
53
  def http_post!
53
- http = Net::HTTP.new(ENDPOINT.host, ENDPOINT.port)
54
- request = Net::HTTP::Post.new(
55
- ENDPOINT.request_uri,
56
- { 'Content-Type': 'application/json' }
54
+ result = HTTParty.post(
55
+ 'https://eltesla.dev/metrics',
56
+ headers: { 'Content-Type' => 'application/json' },
57
+ body: { results: queue.map(&:to_h) }.to_json
57
58
  )
58
- request.body = { results: queue }.to_json
59
+ return if result.success?
59
60
 
60
- http.request(request).value
61
+ raise "HTTP error: code #{result.response.code}"
61
62
  end
62
63
  end
63
64
  end
@@ -1,3 +1,3 @@
1
1
  module Eltesla
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eltesla
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandre Ignjatovic
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: httparty
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.21'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.21'
27
41
  description: Client for the Eltesla service, for easier refactoring
28
42
  email: alexandre.ignjatovic@gmail.com
29
43
  executables: []