dboard 2.0.3 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4961ca57023a24d013d4e60b2d0506663f96abfa413f46b312a8a64dce3c41ff
4
- data.tar.gz: d3d7d4bb2bef67839f7fe36d5885ebef72e82d48def60bea272930548096321f
3
+ metadata.gz: 5b304b24b1a81668338947ec710dac13e40154546ef7223bbdd1c0ccf85707d1
4
+ data.tar.gz: 0b541c61c457f728d1e07e92ddc46579e25f9e228643ab605b7dda5f8410ccbb
5
5
  SHA512:
6
- metadata.gz: d72cad351cfa34e55144425cdad8b2c66df645b6dcb6a0d73c01dfe09de4b16555d083ceff192d00cb0abad49f082791641d4dd8e658480bf75d8845219ad498
7
- data.tar.gz: 2c5ed9dbbdf1f0ac6c0b9b1319aab5ac653e87ccbb447fe115ae5464a7fe4328b2584947ad5dbd05465e744058cbb4b44d31f6832bc9ffccc1314c7e7993efee
6
+ metadata.gz: 777077451031641618207a7e6e90e50a8eda8cd50e87f142d75826fd2ac5bbe970da2b9fbdd915d8739750274a5ab177b03aeaa77e2cbeac5044b4e3b8d88600
7
+ data.tar.gz: 3d3b5d8f1920e6ef2ec58c0374aaaebaeb4e6caf329e8da17e2779a909405f7f60ef26c1cd77df63c50a815f897bd220f7d9b4a941a5c50d78104876cd6be29f
@@ -13,10 +13,13 @@ jobs:
13
13
 
14
14
  strategy:
15
15
  matrix:
16
- ruby-version: ["3.0", "2.7", "2.6"]
16
+ ruby-version:
17
+ - 3.1
18
+ - "3.0"
19
+ - 2.7
17
20
 
18
21
  steps:
19
- - uses: actions/checkout@v2
22
+ - uses: actions/checkout@v3
20
23
  - name: Set up Ruby ${{ matrix.ruby-version }}
21
24
  uses: ruby/setup-ruby@v1
22
25
  with:
data/dboard.gemspec CHANGED
@@ -17,10 +17,10 @@ Gem::Specification.new do |s|
17
17
  s.files = `git ls-files`.split("\n")
18
18
  s.require_paths = [ "lib" ]
19
19
 
20
- s.add_dependency "net_http_timeout_errors"
21
20
  s.add_dependency "dalli"
22
21
  s.add_dependency "httparty"
23
22
  s.add_dependency "json"
23
+ s.add_dependency "net_http_timeout_errors"
24
24
  s.add_dependency "rake"
25
25
  s.add_dependency "sinatra"
26
26
  end
data/lib/api.rb CHANGED
@@ -11,10 +11,26 @@ module Dboard
11
11
  @@version = nil
12
12
 
13
13
  class Client
14
- include HTTParty
14
+ class << self
15
+ attr_accessor :clients
16
+ end
17
+
18
+ def self.endpoints=(endpoints)
19
+ self.clients = endpoints.map { |config|
20
+ Class.new {
21
+ include HTTParty
22
+ base_uri config.fetch(:base_uri)
23
+ basic_auth *config.fetch(:basic_auth)
24
+ }
25
+ }
26
+ end
15
27
 
16
- def self.post(*, **)
17
- with_retries { super }
28
+ def self.post(url, opts)
29
+ with_retries {
30
+ self.clients.each do |client|
31
+ client.post(url, opts)
32
+ end
33
+ }
18
34
  end
19
35
 
20
36
  private
data/lib/collector.rb CHANGED
@@ -7,16 +7,16 @@ module Dboard
7
7
 
8
8
  attr_reader :sources
9
9
 
10
- def self.register_source(key, instance)
11
- Collector.instance.register_source(key, instance)
10
+ def self.register_source(key, source_instance)
11
+ instance.register_source(key, source_instance)
12
12
  end
13
13
 
14
14
  def self.register_after_update_callback(callback)
15
- Collector.instance.register_after_update_callback(callback)
15
+ instance.register_after_update_callback(callback)
16
16
  end
17
17
 
18
18
  def self.register_error_callback(callback)
19
- Collector.instance.register_error_callback(callback)
19
+ instance.register_error_callback(callback)
20
20
  end
21
21
 
22
22
  def self.start
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Dboard
2
- VERSION = "2.0.3"
2
+ VERSION = "3.0.0"
3
3
  end
@@ -5,17 +5,17 @@ describe Dboard::Collector, ".register_source" do
5
5
  Dboard::Collector.instance.sources.clear
6
6
  end
7
7
 
8
+ let(:new_relic) { double(:new_relic) }
9
+ let(:callback) { double(:callback) }
10
+
8
11
  it "can register a source" do
9
- new_relic = double
10
12
  allow(new_relic).to receive(:update_interval).and_return(5)
11
13
  Dboard::Collector.register_source :new_relic, new_relic
12
14
  expect(Dboard::Collector.instance.sources).to eq({ new_relic: new_relic })
13
15
  end
14
16
 
15
17
  it "can register an after update callback" do
16
- new_relic = double
17
18
  allow(new_relic).to receive(:fetch).and_return({ db: "100%" })
18
- callback = double
19
19
  Dboard::Collector.register_after_update_callback callback
20
20
 
21
21
  expect(callback).to receive(:call)
@@ -27,10 +27,9 @@ describe Dboard::Collector, ".register_source" do
27
27
  end
28
28
 
29
29
  it "can register an error callback" do
30
- new_relic = double
31
30
  error = RuntimeError.new("error")
32
31
  allow(new_relic).to receive(:fetch).and_raise(error)
33
- callback = double
32
+
34
33
  Dboard::Collector.register_error_callback callback
35
34
 
36
35
  expect(callback).to receive(:call).with(error)
@@ -48,15 +47,15 @@ describe Dboard::Collector, "update_source" do
48
47
  Dboard::Collector.instance.sources.clear
49
48
  end
50
49
 
50
+ let(:new_relic) { double(:new_relic) }
51
+
51
52
  it "collects and publishes data from sources" do
52
- new_relic = double
53
53
  allow(new_relic).to receive(:fetch).and_return({ db: "100%" })
54
54
  expect(Dboard::Publisher).to receive(:publish).with(:new_relic, { db: "100%" })
55
55
  Dboard::Collector.instance.update_source(:new_relic, new_relic)
56
56
  end
57
57
 
58
58
  it "prints out debugging info" do
59
- new_relic = double
60
59
  allow(new_relic).to receive(:fetch).and_raise(Exception.new("some error"))
61
60
  expect(Dboard::Collector.instance).to receive(:puts).twice
62
61
  Dboard::Collector.instance.update_source(:new_relic, new_relic)
@@ -7,17 +7,17 @@ describe "Publisher", ".publish" do
7
7
  end
8
8
 
9
9
  it "retries network errors" do
10
- stub_request(:post, "http://api.example/sources/new_relic").
11
- to_timeout.times(2).
12
- to_return({ body: "OK!" })
10
+ stub_request(:post, "http://api.example/sources/new_relic")
11
+ .to_timeout.times(2)
12
+ .to_return({ body: "OK!" })
13
13
 
14
14
  Dboard::Publisher.publish(:new_relic, {})
15
15
  end
16
16
 
17
17
  it "raises network errors if we run out of retries" do
18
- stub_request(:post, "http://api.example/sources/new_relic").
19
- to_timeout.times(3).
20
- to_return({ body: "OK!" })
18
+ stub_request(:post, "http://api.example/sources/new_relic")
19
+ .to_timeout.times(3)
20
+ .to_return({ body: "OK!" })
21
21
 
22
22
  expect {
23
23
  Dboard::Publisher.publish(:new_relic, {})
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require "rspec"
2
- require 'webmock/rspec'
2
+ require "webmock/rspec"
3
3
 
4
4
  ENV["RACK_ENV"] ||= "test"
5
5
  ENV["API_URL"] = "http://api.example"
@@ -8,5 +8,6 @@ ENV["API_PASSWORD"] = "test"
8
8
 
9
9
  require File.expand_path(File.join(File.dirname(__FILE__), "../lib/dboard"))
10
10
 
11
- Dboard::Api::Client.basic_auth(ENV["API_USER"], ENV["API_PASSWORD"])
12
- Dboard::Api::Client.base_uri(ENV["API_URL"])
11
+ Dboard::Api::Client.endpoints = [
12
+ { base_uri: ENV["API_URL"], basic_auth: [ ENV["API_USER"], ENV["API_PASSWORD"] ] },
13
+ ]
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dboard
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joakim Kolsjö
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-13 00:00:00.000000000 Z
11
+ date: 2024-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: net_http_timeout_errors
14
+ name: dalli
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: dalli
28
+ name: httparty
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: httparty
42
+ name: json
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: json
56
+ name: net_http_timeout_errors
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -139,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
139
  - !ruby/object:Gem::Version
140
140
  version: '0'
141
141
  requirements: []
142
- rubygems_version: 3.2.32
142
+ rubygems_version: 3.5.9
143
143
  signing_key:
144
144
  specification_version: 4
145
145
  summary: Dashboard framework