riemann-dash 0.2.9 → 0.2.10

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.
@@ -26,6 +26,8 @@
26
26
  <script src="vendor/flot/jquery.flot.time.min.js"></script>
27
27
  <script src="vendor/flot/jquery.flot.stack.min.js"></script>
28
28
  <script src="vendor/PriorityQueue.js"></script>
29
+ <script src="vendor/gauge.min.js"></script>
30
+ <script src="vendor/jquery.gauge.js"></script>
29
31
  <script> // turn underscore templates into mustache style templates
30
32
  _.templateSettings = {
31
33
  evaluate : /\{\%([\s\S]+?)\%\}/g, // {% eval(js); %}
@@ -53,6 +55,7 @@
53
55
  <script src="views/list.js"></script>
54
56
  <script src="views/help.js"></script>
55
57
  <script src="views/gauge.js"></script>
58
+ <script src="views/dial.js"></script>
56
59
  <script src="views/grid.js"></script>
57
60
  <script src="dash.js"></script>
58
61
 
@@ -0,0 +1,120 @@
1
+ require './test/test_helper'
2
+ require 'pp'
3
+
4
+ describe "Riemann::Dash::BrowserConfig" do
5
+
6
+ before do
7
+ @mock_backend = Minitest::Mock.new
8
+ Riemann::Dash::BrowserConfig.backend = @mock_backend
9
+ end
10
+
11
+ describe :read do
12
+ it "delegates to its backend" do
13
+ @mock_backend.expect :read, :return_value
14
+
15
+ Riemann::Dash::BrowserConfig.read
16
+
17
+ @mock_backend.verify
18
+ end
19
+ end
20
+
21
+ describe :update do
22
+ it "delegates to its backend" do
23
+ @mock_backend.expect :update, :return_value, [String]
24
+
25
+ Riemann::Dash::BrowserConfig.update("stuff to update")
26
+
27
+ @mock_backend.verify
28
+ end
29
+ end
30
+
31
+ describe :merge_configs do
32
+ before do
33
+ @first_config = {'server' => 'first_server', 'server_type' => 'first_type'}
34
+ @second_config = {'server' => 'second_server', 'server_type' => 'second_type'}
35
+ end
36
+
37
+ describe "when merging the server value" do
38
+ it "prioritises the value from the first config" do
39
+ merged_configs = Riemann::Dash::BrowserConfig.merge_configs(@first_config, @second_config)
40
+
41
+ assert_equal @first_config['server'], merged_configs['server']
42
+ end
43
+
44
+ it "uses the value from the second config if no other exists" do
45
+ merged_configs = Riemann::Dash::BrowserConfig.merge_configs({}, @second_config)
46
+
47
+ assert_equal @second_config['server'], merged_configs['server']
48
+ end
49
+ end
50
+
51
+ describe "when merging the server_type value" do
52
+ it "prioritises the value from the first config" do
53
+ merged_configs = Riemann::Dash::BrowserConfig.merge_configs(@first_config, @second_config)
54
+
55
+ assert_equal @first_config['server_type'], merged_configs['server_type']
56
+ end
57
+
58
+ it "uses the value from the second config if no other exists" do
59
+ merged_configs = Riemann::Dash::BrowserConfig.merge_configs({}, @second_config)
60
+
61
+ assert_equal @second_config['server_type'], merged_configs['server_type']
62
+ end
63
+ end
64
+ end
65
+
66
+ describe :index_by do
67
+ before do
68
+ @list = [{'name' => 'a'}, {'name' => 'b'}, {'name' => 'c'}]
69
+ end
70
+
71
+ it "returns the list of key/value pairs as a map indexed by the specified key/value" do
72
+ indexed_config = Riemann::Dash::BrowserConfig.index_by(lambda { |x| x['name'] }, @list)
73
+
74
+ assert_equal({'name' => 'a'}, indexed_config['a'])
75
+ assert_equal({'name' => 'b'}, indexed_config['b'])
76
+ assert_equal({'name' => 'c'}, indexed_config['c'])
77
+ end
78
+
79
+ end
80
+
81
+ describe :merge_workspace do
82
+ before do
83
+ @first_ws = {"view" => {"version" => 2}, "name" => "first"}
84
+ @second_ws = {"view" => {"version" => 3}, "name" => "second"}
85
+ end
86
+
87
+ it "prioritises the workspace with the higher version" do
88
+ merged_workspace = Riemann::Dash::BrowserConfig.merge_workspace(@first_ws, @second_ws)
89
+ assert_equal @second_ws, merged_workspace
90
+
91
+ merged_workspace = Riemann::Dash::BrowserConfig.merge_workspace(@second_ws, @first_ws)
92
+ assert_equal @second_ws, merged_workspace
93
+ end
94
+
95
+ it "prioritises any workspace over a nil workspace" do
96
+ merged_workspace = Riemann::Dash::BrowserConfig.merge_workspace(@first_ws, nil)
97
+ assert_equal @first_ws, merged_workspace
98
+
99
+ merged_workspace = Riemann::Dash::BrowserConfig.merge_workspace(nil, @first_ws)
100
+ assert_equal @first_ws, merged_workspace
101
+ end
102
+
103
+ it "prioritises any workspace with a version over a workspace without a version" do
104
+ merged_workspace = Riemann::Dash::BrowserConfig.merge_workspace(@first_ws, {"view" => {}})
105
+ assert_equal @first_ws, merged_workspace
106
+
107
+ merged_workspace = Riemann::Dash::BrowserConfig.merge_workspace({"view" => {}}, @first_ws)
108
+ assert_equal @first_ws, merged_workspace
109
+ end
110
+
111
+ it "prioritises the first workspace if both versions are equal" do
112
+ @second_ws['view']['version'] = @first_ws['view']['version']
113
+ merged_workspace = Riemann::Dash::BrowserConfig.merge_workspace(@first_ws, @second_ws)
114
+ assert_equal @first_ws, merged_workspace
115
+
116
+ end
117
+ end
118
+
119
+
120
+ end
@@ -62,53 +62,4 @@ describe "Riemann::Dash::Config" do
62
62
  end
63
63
  end
64
64
 
65
- describe "workspace config" do
66
- before do
67
- FileUtils.rm_rf "test/tmp/"
68
- end
69
-
70
-
71
- describe :read_ws_config do
72
- =begin
73
- # this test fails if the config living at config/config.json has
74
- # been overwritten with user content -- this happens for people
75
- # who had previously run their riemann-dash instance via simply
76
- # cd riemann-dash && bin/riemann-dash -- it would also fail once
77
- # you save your config in the default location
78
- it "retuns hash for empty configs" do
79
- @config.read_ws_config.must_equal "{}"
80
- end
81
- =end
82
-
83
- it "reads the file, if present" do
84
- @config.load_config("test/fixtures/config/ws_config.rb").must_equal true
85
- @config.store[:ws_config].must_equal "test/fixtures/ws_config/dummy_config.json"
86
- @config.read_ws_config.must_equal %Q{{hey: \"ho\"}}
87
- end
88
- end
89
-
90
- describe :update_ws_config do
91
- it "works" do
92
- @config.store[:ws_config] = "test/tmp/config.json"
93
- @config.update_ws_config("{\"server\":\"10.10.10.10\",\"workspaces\":[]}")
94
- end
95
-
96
- it "pretty-prints the config" do
97
- @config.store[:ws_config] = "test/tmp/config.json"
98
- @config.update_ws_config("{\"server\":\"10.10.10.10\",\"workspaces\":[]}")
99
- File.read("test/tmp/config.json").must_equal File.read("test/fixtures/ws_config/pretty_printed_config.json")
100
- end
101
- end
102
- end
103
-
104
- describe "backwards compatible :[] and :[]= forwarders to `store` variable" do
105
- it "reading works" do
106
- @config[:ws_config].must_match %r{config/config.json}
107
- end
108
-
109
- it "writing works" do
110
- @config[:ws_config] = "something"
111
- @config[:ws_config].must_match %r{something}
112
- end
113
- end
114
65
  end
@@ -4,6 +4,7 @@ Bundler.setup(:default, :test)
4
4
 
5
5
  require 'minitest/autorun'
6
6
  require 'minitest/spec'
7
+ require 'minitest/mock'
7
8
  #require "mocha/setup"
8
9
 
9
10
  $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riemann-dash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Kingsbury
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-02 00:00:00.000000000 Z
11
+ date: 2015-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erubis
@@ -96,6 +96,7 @@ files:
96
96
  - Rakefile.rb
97
97
  - bin/riemann-dash
98
98
  - example/config.rb
99
+ - example/config.ru
99
100
  - lib/riemann/dash.rb
100
101
  - lib/riemann/dash/app.rb
101
102
  - lib/riemann/dash/browser_config.rb
@@ -149,7 +150,10 @@ files:
149
150
  - lib/riemann/dash/public/vendor/flot/jquery.flot.threshold.min.js
150
151
  - lib/riemann/dash/public/vendor/flot/jquery.flot.time.js
151
152
  - lib/riemann/dash/public/vendor/flot/jquery.flot.time.min.js
153
+ - lib/riemann/dash/public/vendor/gauge.min.js
154
+ - lib/riemann/dash/public/vendor/jquery.gauge.js
152
155
  - lib/riemann/dash/public/vendor/jquery/jquery-1.9.1.min.js
156
+ - lib/riemann/dash/public/vendor/jquery/jquery-1.9.1.min.map
153
157
  - lib/riemann/dash/public/vendor/jquery/jquery-ui-1.10.2.custom.min.js
154
158
  - lib/riemann/dash/public/vendor/jquery/jquery.quickfit.js
155
159
  - lib/riemann/dash/public/vendor/jquery/jquery.simplemodal.1.4.4.min.js
@@ -158,6 +162,7 @@ files:
158
162
  - lib/riemann/dash/public/vendor/toastr/toastr.css
159
163
  - lib/riemann/dash/public/vendor/toastr/toastr.js
160
164
  - lib/riemann/dash/public/view.js
165
+ - lib/riemann/dash/public/views/dial.js
161
166
  - lib/riemann/dash/public/views/flot.js
162
167
  - lib/riemann/dash/public/views/gauge.js
163
168
  - lib/riemann/dash/public/views/grid.js
@@ -176,6 +181,7 @@ files:
176
181
  - sh/c
177
182
  - sh/env.rb
178
183
  - sh/test
184
+ - test/browser_config_test.rb
179
185
  - test/config_test.rb
180
186
  - test/fixtures/config/basic_config.rb
181
187
  - test/fixtures/config/ws_config.rb
@@ -206,6 +212,7 @@ signing_key:
206
212
  specification_version: 4
207
213
  summary: HTTP dashboard for the distributed event system Riemann.
208
214
  test_files:
215
+ - test/browser_config_test.rb
209
216
  - test/config_test.rb
210
217
  - test/fixtures/config/basic_config.rb
211
218
  - test/fixtures/config/ws_config.rb