dashboarder 0.0.2 → 0.0.3

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.
data/README.md CHANGED
@@ -23,24 +23,11 @@ $ LIBRATO_EMAIL=me@example.co LIBRATO_KEY=123456 irb -r dashboarder
23
23
  ```
24
24
 
25
25
  ```ruby
26
- # a simple dashboard definition
27
- definition = [
28
- 'my dashboard name',
29
- [:an_instrument_name, :a_metric_name, :another_metric_name],
30
- [:another_instrument_name, :a_metric_name]
31
- ]
32
-
33
- # this will ensure the dashboard exists
34
- # will not overwrite if already does
35
- Dashboarder::Dashboard.compose(definition)
36
-
37
- # compose an individual instrument
38
- # will not overwrite if already exists
39
- Dashboarder::Instrument.compose(['my instrument', :first_metric, :second_metric])
40
-
41
- # If an instrument has already been defined, you can compose
42
- # like so:
43
- Dashboarder::Dashboard.compose([:my_dashboard, :some_instrument, :some_other_instrument])
26
+ # compose an instrument
27
+ Dashboarder::Instrument.compose(:my_instrument, [:my_metric, :my_other_metric])
28
+
29
+ # compose a dashboard
30
+ Dashboarder::Dashboard.compose(:my_dashboard, [:my_instrument, :my_other_instrument])
44
31
  ```
45
32
 
46
33
  ## Contributing
@@ -1,18 +1,15 @@
1
1
  module Dashboarder
2
2
  module Dashboard
3
- def self.compose!(definition)
4
- name = definition.first
5
- instrument_definitions = definition[1..-1]
6
- instrument_ids = instrument_definitions.map { |d| Instrument.compose(d)['id'] }
3
+ def self.compose!(name, instrument_names)
4
+ instrument_ids = instrument_names.map do |d|
5
+ i = Instrument.get(d) || raise("Instrument #{name} not defined yet")
6
+ i['id']
7
+ end
7
8
  Dashboarder.api.post('/v1/dashboards', { :name => name, :instruments => instrument_ids })
8
9
  end
9
10
 
10
- def self.compose(definition)
11
- dashboard = get(definition.first)
12
- unless dashboard
13
- dashboard = compose!(definition)
14
- end
15
- dashboard
11
+ def self.compose(name, instrument_names)
12
+ get(name) || compose!(name, instrument_names)
16
13
  end
17
14
 
18
15
  def self.get(name)
@@ -4,29 +4,13 @@ module Dashboarder
4
4
  Dashboarder.api.get('/v1/instruments', :query => {:name => name})['instruments'].first
5
5
  end
6
6
 
7
- def self.compose!(definition)
8
- name = definition.first
9
- metric_names = definition[1..-1]
10
-
7
+ def self.compose!(name, metric_names)
11
8
  streams = metric_names.map { |n| { :metric => n, :source => '*' } }
12
9
  Dashboarder.api.post('/v1/instruments', { :name => name, :streams => streams })
13
10
  end
14
11
 
15
- def self.compose(definition)
16
- # if we passed an atom, attempt to fetch rather than build
17
- if definition.kind_of?(String) || definition.kind_of?(Symbol)
18
- instrument = get(definition)
19
- raise "instrument #{definition} has not been created yet" unless instrument
20
- instrument
21
- else
22
- name = definition.first
23
- instrument = get(name)
24
-
25
- unless instrument
26
- instrument = compose!(definition)
27
- end
28
- instrument
29
- end
12
+ def self.compose(name, metric_names)
13
+ get(name) || compose!(name, metric_names)
30
14
  end
31
15
  end
32
16
  end
@@ -1,3 +1,3 @@
1
1
  module Dashboarder
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dashboarder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-11-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
16
- requirement: &70262015999380 !ruby/object:Gem::Requirement
16
+ requirement: &70137711475360 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70262015999380
24
+ version_requirements: *70137711475360
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: excon
27
- requirement: &70262015998380 !ruby/object:Gem::Requirement
27
+ requirement: &70137711474340 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70262015998380
35
+ version_requirements: *70137711474340
36
36
  description: a lightweight composer for librato instruments and dashboards
37
37
  email:
38
38
  - michael.gorsuch@gmail.com