ruby-grafana-reporter 0.1.7 → 0.2.0

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +166 -339
  3. data/bin/ruby-grafana-reporter +5 -4
  4. data/lib/VERSION.rb +5 -3
  5. data/lib/grafana/abstract_panel_query.rb +22 -20
  6. data/lib/grafana/abstract_query.rb +132 -127
  7. data/lib/grafana/abstract_sql_query.rb +51 -42
  8. data/lib/grafana/dashboard.rb +77 -66
  9. data/lib/grafana/errors.rb +66 -61
  10. data/lib/grafana/grafana.rb +130 -131
  11. data/lib/grafana/panel.rb +41 -39
  12. data/lib/grafana/panel_image_query.rb +52 -49
  13. data/lib/grafana/variable.rb +217 -259
  14. data/lib/grafana_reporter/abstract_report.rb +112 -109
  15. data/lib/grafana_reporter/application/application.rb +404 -229
  16. data/lib/grafana_reporter/application/errors.rb +33 -30
  17. data/lib/grafana_reporter/application/webservice.rb +231 -0
  18. data/lib/grafana_reporter/asciidoctor/alerts_table_query.rb +104 -99
  19. data/lib/grafana_reporter/asciidoctor/annotations_table_query.rb +99 -96
  20. data/lib/grafana_reporter/asciidoctor/errors.rb +40 -37
  21. data/lib/grafana_reporter/asciidoctor/extensions/alerts_table_include_processor.rb +92 -86
  22. data/lib/grafana_reporter/asciidoctor/extensions/annotations_table_include_processor.rb +91 -86
  23. data/lib/grafana_reporter/asciidoctor/extensions/panel_image_block_macro.rb +69 -67
  24. data/lib/grafana_reporter/asciidoctor/extensions/panel_image_inline_macro.rb +68 -65
  25. data/lib/grafana_reporter/asciidoctor/extensions/panel_property_inline_macro.rb +61 -58
  26. data/lib/grafana_reporter/asciidoctor/extensions/panel_query_table_include_processor.rb +78 -75
  27. data/lib/grafana_reporter/asciidoctor/extensions/panel_query_value_inline_macro.rb +73 -70
  28. data/lib/grafana_reporter/asciidoctor/extensions/processor_mixin.rb +20 -18
  29. data/lib/grafana_reporter/asciidoctor/extensions/show_environment_include_processor.rb +43 -41
  30. data/lib/grafana_reporter/asciidoctor/extensions/sql_table_include_processor.rb +70 -67
  31. data/lib/grafana_reporter/asciidoctor/extensions/sql_value_inline_macro.rb +66 -65
  32. data/lib/grafana_reporter/asciidoctor/extensions/value_as_variable_include_processor.rb +61 -57
  33. data/lib/grafana_reporter/asciidoctor/panel_first_value_query.rb +34 -32
  34. data/lib/grafana_reporter/asciidoctor/panel_image_query.rb +25 -23
  35. data/lib/grafana_reporter/asciidoctor/panel_property_query.rb +44 -43
  36. data/lib/grafana_reporter/asciidoctor/panel_table_query.rb +38 -36
  37. data/lib/grafana_reporter/asciidoctor/query_mixin.rb +310 -309
  38. data/lib/grafana_reporter/asciidoctor/report.rb +177 -159
  39. data/lib/grafana_reporter/asciidoctor/sql_first_value_query.rb +37 -34
  40. data/lib/grafana_reporter/asciidoctor/sql_table_query.rb +39 -32
  41. data/lib/grafana_reporter/configuration.rb +257 -326
  42. data/lib/grafana_reporter/errors.rb +48 -38
  43. data/lib/grafana_reporter/logger/two_way_logger.rb +58 -52
  44. data/lib/ruby-grafana-reporter.rb +29 -27
  45. metadata +10 -23
@@ -1,38 +1,48 @@
1
- module GrafanaReporter
2
- # General error of the reporter. All other errors will inherit from this class.
3
- class GrafanaReporterError < StandardError
4
- def initialize(message)
5
- super('GrafanaReporterError: ' + message.to_s)
6
- end
7
- end
8
-
9
- # Thrown, if the requested grafana instance does not have the mandatory 'host'
10
- # setting configured.
11
- class GrafanaInstanceWithoutHostError < GrafanaReporterError
12
- def initialize(instance)
13
- super("Grafana instance '#{instance}' has been configured without mandatory 'host' setting.")
14
- end
15
- end
16
-
17
- # General configuration error. All configuration errors inherit from this class.
18
- class ConfigurationError < GrafanaReporterError
19
- def initialize(message)
20
- super("Configuration error: #{message}")
21
- end
22
- end
23
-
24
- # Thrown, if a configured path does not exist.
25
- class FolderDoesNotExistError < ConfigurationError
26
- def initialize(folder, config_item)
27
- super("#{config_item} '#{folder}' does not exist.")
28
- end
29
- end
30
-
31
- # Thrown if the configuration does not match the expected schema.
32
- # Details about how to fix that are provided in the message.
33
- class ConfigurationDoesNotMatchSchemaError < ConfigurationError
34
- def initialize(item, verb, expected, currently)
35
- super("Configuration file does not match schema definition. Expected '#{item}' to #{verb} '#{expected}', but was '#{currently}'.")
36
- end
37
- end
38
- end
1
+ # frozen_string_literal: true
2
+
3
+ module GrafanaReporter
4
+ # General error of the reporter. All other errors will inherit from this class.
5
+ class GrafanaReporterError < StandardError
6
+ def initialize(message)
7
+ super("GrafanaReporterError: #{message}")
8
+ end
9
+ end
10
+
11
+ # Thrown, if the requested grafana instance does not have the mandatory 'host'
12
+ # setting configured.
13
+ class GrafanaInstanceWithoutHostError < GrafanaReporterError
14
+ def initialize(instance)
15
+ super("Grafana instance '#{instance}' has been configured without mandatory 'host' setting.")
16
+ end
17
+ end
18
+
19
+ # General configuration error. All configuration errors inherit from this class.
20
+ class ConfigurationError < GrafanaReporterError
21
+ def initialize(message)
22
+ super("Configuration error: #{message}")
23
+ end
24
+ end
25
+
26
+ # Thrown if a non existing template has been specified.
27
+ class MissingTemplateError < ConfigurationError
28
+ def initialize(template)
29
+ super("Given report template '#{template}' is not a valid template.")
30
+ end
31
+ end
32
+
33
+ # Thrown, if a configured path does not exist.
34
+ class FolderDoesNotExistError < ConfigurationError
35
+ def initialize(folder, config_item)
36
+ super("#{config_item} '#{folder}' does not exist.")
37
+ end
38
+ end
39
+
40
+ # Thrown if the configuration does not match the expected schema.
41
+ # Details about how to fix that are provided in the message.
42
+ class ConfigurationDoesNotMatchSchemaError < ConfigurationError
43
+ def initialize(item, verb, expected, currently)
44
+ super("Configuration file does not match schema definition. Expected '#{item}' to #{verb} '#{expected}',"\
45
+ "but was '#{currently}'.")
46
+ end
47
+ end
48
+ end
@@ -1,52 +1,58 @@
1
- module GrafanaReporter
2
-
3
- # This module contains special extensions for use in the reporter.
4
- module Logger
5
-
6
- # This logger enables a special use case, so that one and the same log
7
- # will automatically be send to two different logger destinations.
8
- #
9
- # One destination is the set {#additional_logger=} which respects the
10
- # configured severity. The other destination is an internal logger, which
11
- # will always log all messages in mode Logger::Severity::Debug. All messages
12
- # of the internal logger can easily be retrieved, by using the
13
- # {#internal_messages} method.
14
- #
15
- # Except the {#level=} setting, all calls to the logger will immediately
16
- # be delegated to the internal logger and the configured {#additional_logger=}.
17
- # By having this behavior, the class can be used wherever the standard Logger
18
- # can also be used.
19
- class TwoWayDelegateLogger
20
- def initialize
21
- @internal_messages = StringIO.new
22
- @internal_logger = ::Logger.new(@internal_messages)
23
- @internal_logger.level = ::Logger::Severity::DEBUG
24
- @additional_logger = ::Logger.new(nil)
25
- end
26
-
27
- # Sets the severity level of the additional logger to the given severity.
28
- # @param severity one of {Logger::Severity}
29
- def level=(severity)
30
- @additional_logger.level = severity
31
- end
32
-
33
- # @return [String] all messages of the internal logger.
34
- def internal_messages
35
- @internal_messages.string
36
- end
37
-
38
- # Used to set the additional logger in this class to an already existing
39
- # logger.
40
- # @param logger [Logger] sets the additional logger to the given value.
41
- def additional_logger=(logger)
42
- @additional_logger = logger || ::Logger.new(nil)
43
- end
44
-
45
- # Delegates all not configured calls to the internal and the additional logger.
46
- def method_missing(method, *args)
47
- @internal_logger.send(method, *args)
48
- @additional_logger.send(method, *args)
49
- end
50
- end
51
- end
52
- end
1
+ # frozen_string_literal: true
2
+
3
+ module GrafanaReporter
4
+ # This module contains special extensions for use in the reporter.
5
+ module Logger
6
+ # This logger enables a special use case, so that one and the same log
7
+ # will automatically be send to two different logger destinations.
8
+ #
9
+ # One destination is the set {#additional_logger=} which respects the
10
+ # configured severity. The other destination is an internal logger, which
11
+ # will always log all messages in mode Logger::Severity::Debug. All messages
12
+ # of the internal logger can easily be retrieved, by using the
13
+ # {#internal_messages} method.
14
+ #
15
+ # Except the {#level=} setting, all calls to the logger will immediately
16
+ # be delegated to the internal logger and the configured {#additional_logger=}.
17
+ # By having this behavior, the class can be used wherever the standard Logger
18
+ # can also be used.
19
+ class TwoWayDelegateLogger
20
+ def initialize
21
+ @internal_messages = StringIO.new
22
+ @internal_logger = ::Logger.new(@internal_messages)
23
+ @internal_logger.level = ::Logger::Severity::DEBUG
24
+ @additional_logger = ::Logger.new(nil)
25
+ end
26
+
27
+ # Sets the severity level of the additional logger to the given severity.
28
+ # @param severity one of {Logger::Severity}
29
+ def level=(severity)
30
+ @additional_logger.level = severity
31
+ end
32
+
33
+ # @return [String] all messages of the internal logger.
34
+ def internal_messages
35
+ @internal_messages.string
36
+ end
37
+
38
+ # Used to set the additional logger in this class to an already existing
39
+ # logger.
40
+ # @param logger [Logger] sets the additional logger to the given value.
41
+ def additional_logger=(logger)
42
+ @additional_logger = logger || ::Logger.new(nil)
43
+ end
44
+
45
+ # Delegates all not configured calls to the internal and the additional logger.
46
+ def method_missing(method, *args)
47
+ @internal_logger.send(method, *args)
48
+ @additional_logger.send(method, *args)
49
+ end
50
+
51
+ # Registers all methods to which the internal logger responds.
52
+ def respond_to_missing?(method, *_args)
53
+ super
54
+ @internal_logger.respond_to?(method)
55
+ end
56
+ end
57
+ end
58
+ end
@@ -1,27 +1,29 @@
1
- require 'net/http'
2
- require 'fileutils'
3
- require 'yaml'
4
- require 'socket'
5
- require 'uri'
6
- require 'json'
7
- require 'tempfile'
8
- require 'cgi'
9
- require 'optparse'
10
- require 'date'
11
- require 'time'
12
- require 'logger'
13
- require 'asciidoctor'
14
- require 'asciidoctor/extensions'
15
- require 'asciidoctor-pdf'
16
- require 'zip'
17
- require_relative 'VERSION.rb'
18
-
19
- folders = [
20
- %w[grafana],
21
- %w[grafana_reporter logger],
22
- %w[grafana_reporter],
23
- %w[grafana_reporter asciidoctor extensions],
24
- %w[grafana_reporter asciidoctor],
25
- %w[grafana_reporter application]
26
- ]
27
- folders.each { |folder| Dir[File.join(__dir__, *folder, '*.rb')].sort.each { |file| require_relative file } }
1
+ # frozen_string_literal: true
2
+
3
+ require 'net/http'
4
+ require 'fileutils'
5
+ require 'yaml'
6
+ require 'socket'
7
+ require 'uri'
8
+ require 'json'
9
+ require 'tempfile'
10
+ require 'cgi'
11
+ require 'optparse'
12
+ require 'date'
13
+ require 'time'
14
+ require 'logger'
15
+ require 'asciidoctor'
16
+ require 'asciidoctor/extensions'
17
+ require 'asciidoctor-pdf'
18
+ require 'zip'
19
+ require_relative 'VERSION'
20
+
21
+ folders = [
22
+ %w[grafana],
23
+ %w[grafana_reporter logger],
24
+ %w[grafana_reporter],
25
+ %w[grafana_reporter asciidoctor extensions],
26
+ %w[grafana_reporter asciidoctor],
27
+ %w[grafana_reporter application]
28
+ ]
29
+ folders.each { |folder| Dir[File.join(__dir__, *folder, '*.rb')].sort.each { |file| require_relative file } }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-grafana-reporter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Kohlmeyer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-24 00:00:00.000000000 Z
11
+ date: 2020-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -59,47 +59,33 @@ dependencies:
59
59
  - !ruby/object:Gem::Version
60
60
  version: '2.3'
61
61
  - !ruby/object:Gem::Dependency
62
- name: simplecov
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - "~>"
66
- - !ruby/object:Gem::Version
67
- version: '0.16'
68
- type: :development
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - "~>"
73
- - !ruby/object:Gem::Version
74
- version: '0.16'
75
- - !ruby/object:Gem::Dependency
76
- name: coveralls
62
+ name: rspec
77
63
  requirement: !ruby/object:Gem::Requirement
78
64
  requirements:
79
65
  - - "~>"
80
66
  - !ruby/object:Gem::Version
81
- version: '0.8'
67
+ version: '3.9'
82
68
  type: :development
83
69
  prerelease: false
84
70
  version_requirements: !ruby/object:Gem::Requirement
85
71
  requirements:
86
72
  - - "~>"
87
73
  - !ruby/object:Gem::Version
88
- version: '0.8'
74
+ version: '3.9'
89
75
  - !ruby/object:Gem::Dependency
90
- name: rspec
76
+ name: simplecov
91
77
  requirement: !ruby/object:Gem::Requirement
92
78
  requirements:
93
79
  - - "~>"
94
80
  - !ruby/object:Gem::Version
95
- version: '3.9'
81
+ version: '0.16'
96
82
  type: :development
97
83
  prerelease: false
98
84
  version_requirements: !ruby/object:Gem::Requirement
99
85
  requirements:
100
86
  - - "~>"
101
87
  - !ruby/object:Gem::Version
102
- version: '3.9'
88
+ version: '0.16'
103
89
  - !ruby/object:Gem::Dependency
104
90
  name: webmock
105
91
  requirement: !ruby/object:Gem::Requirement
@@ -142,6 +128,7 @@ files:
142
128
  - "./lib/grafana_reporter/abstract_report.rb"
143
129
  - "./lib/grafana_reporter/application/application.rb"
144
130
  - "./lib/grafana_reporter/application/errors.rb"
131
+ - "./lib/grafana_reporter/application/webservice.rb"
145
132
  - "./lib/grafana_reporter/asciidoctor/alerts_table_query.rb"
146
133
  - "./lib/grafana_reporter/asciidoctor/annotations_table_query.rb"
147
134
  - "./lib/grafana_reporter/asciidoctor/errors.rb"
@@ -187,7 +174,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
187
174
  requirements:
188
175
  - - ">="
189
176
  - !ruby/object:Gem::Version
190
- version: '0'
177
+ version: 1.9.3
191
178
  required_rubygems_version: !ruby/object:Gem::Requirement
192
179
  requirements:
193
180
  - - ">="