kolekti 0.0.2 → 1.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
  SHA1:
3
- metadata.gz: 35c6a62d501817f67b76a8869a260862dd527c42
4
- data.tar.gz: 61baf792d42778967902f279360b9034914f3a9a
3
+ metadata.gz: 35c62c82a9b9cfb081e6be5f6a1b28b24c5a67a5
4
+ data.tar.gz: 1c6045bc9c8084c38ee7a6ccacd9096a50ce939f
5
5
  SHA512:
6
- metadata.gz: b6d522a2191c7a3dd284294bb97070697b571bd5c09a0e46c5f8da9fb095eb7dacc92c8237cf1424facd492a812ca63ba430fe3e165fef1fbe2579c521796fa6
7
- data.tar.gz: 9f33e5f105279b70a7690f712b703314de41ca17b7e92917ef4c1d309855881224ba8684f5260568d547053707d9ac328162fd010a7fb460f2e19f9916733048
6
+ metadata.gz: 99ecb31c96ddf973c80a95900a8ea032a0adfeb4105880cc5cfe6c479339678bf2cce0c912a6d37962bbe0b5b069503e518ba6a2f112fe6177332f64e5eaf6f7
7
+ data.tar.gz: 67d6b94012a490922a7c375fd6d89f3e3916418bbc28dd69e0e422264862fe0ee552de14fb4ed4a92750576572eca7b5885aa10b2791217b4f8526dcede12fdd
data/CHANGELOG.rdoc CHANGED
@@ -4,6 +4,10 @@ The Kolekti gem provides a basic API for KalibroProcessor's collectors
4
4
 
5
5
  == Unreleased
6
6
 
7
+ == v1.0.0 - 01/03/2016
8
+
9
+ Only register collectors if they are available and not already registered
10
+
7
11
  == v0.0.2 - 24/02/2016
8
12
 
9
13
  Add backport for Array#to_h on ruby-2.0.0-p598
data/README.md CHANGED
@@ -36,3 +36,7 @@ You have one key class you need to extend `Kolekti::Collector` implementing the
36
36
  Actual examples are:
37
37
 
38
38
  * [KolektiAnalizo](https://github.com/mezuro/kolekti_analizo)
39
+
40
+ ## Versioning
41
+
42
+ Kolekti follows the [semantic versioning](http://semver.org/) policy.
@@ -13,7 +13,7 @@ module Kolekti
13
13
  end
14
14
  end
15
15
 
16
- def available?; raise NotImplementedError; end
16
+ def self.available?; raise NotImplementedError; end
17
17
 
18
18
  def initialize(name, description, supported_metrics)
19
19
  @name = name
@@ -1,3 +1,3 @@
1
1
  module Kolekti
2
- VERSION = "0.0.2"
2
+ VERSION = "1.0.0"
3
3
  end
data/lib/kolekti.rb CHANGED
@@ -9,20 +9,17 @@ module Kolekti
9
9
  COLLECTORS = []
10
10
 
11
11
  def self.register_collector(collector)
12
- COLLECTORS << collector
12
+ COLLECTORS << collector.new if collector.available? && !already_included?(collector)
13
13
  end
14
14
 
15
15
  def self.collectors
16
16
  COLLECTORS
17
17
  end
18
18
 
19
- def self.unregister_collector(collector)
20
- raise ArgumentError.new("Collector #{collector} was not registered!") unless COLLECTORS.include? collector
21
- COLLECTORS.delete collector
22
- end
23
-
24
- def self.available_collectors
25
- collectors.select(&:available?)
19
+ def self.deregister_collector(collector)
20
+ to_be_deregistered_index = COLLECTORS.find_index { |kollector| kollector.is_a?(collector) }
21
+ raise ArgumentError.new("Collector #{collector} was not registered!") if to_be_deregistered_index.nil?
22
+ COLLECTORS.delete_at(to_be_deregistered_index)
26
23
  end
27
24
 
28
25
  def self.default_metric_value(metric_configuration)
@@ -33,4 +30,10 @@ module Kolekti
33
30
 
34
31
  collector.default_value_from(metric_configuration)
35
32
  end
33
+
34
+ private
35
+
36
+ def self.already_included?(collector)
37
+ COLLECTORS.any? { |kollector| kollector.is_a?(collector) }
38
+ end
36
39
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kolekti
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Miranda
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2016-02-24 00:00:00.000000000 Z
14
+ date: 2016-03-01 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: kalibro_client