prometheus-splash 0.5.2 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +38 -0
  3. data/README.md +58 -60
  4. data/bin/splash +3 -0
  5. data/config/splash.yml +106 -10
  6. data/lib/splash/backends.rb +7 -0
  7. data/lib/splash/backends/file.rb +36 -0
  8. data/lib/splash/backends/redis.rb +44 -1
  9. data/lib/splash/cli.rb +16 -4
  10. data/lib/splash/cli/commands.rb +12 -5
  11. data/lib/splash/cli/config.rb +9 -1
  12. data/lib/splash/cli/daemon.rb +49 -2
  13. data/lib/splash/cli/documentation.rb +5 -2
  14. data/lib/splash/cli/logs.rb +21 -13
  15. data/lib/splash/cli/process.rb +103 -0
  16. data/lib/splash/cli/sequences.rb +114 -0
  17. data/lib/splash/cli/transfers.rb +206 -0
  18. data/lib/splash/cli/webadmin.rb +46 -0
  19. data/lib/splash/commands.rb +26 -4
  20. data/lib/splash/config.rb +184 -23
  21. data/lib/splash/config/flush.rb +9 -1
  22. data/lib/splash/config/sanitycheck.rb +7 -2
  23. data/lib/splash/config/service.rb +8 -1
  24. data/lib/splash/config/setup.rb +8 -3
  25. data/lib/splash/constants.rb +41 -10
  26. data/lib/splash/daemon.rb +5 -1
  27. data/lib/splash/daemon/controller.rb +31 -11
  28. data/lib/splash/daemon/metrics.rb +47 -22
  29. data/lib/splash/daemon/orchestrator.rb +141 -36
  30. data/lib/splash/daemon/orchestrator/grammar.rb +40 -5
  31. data/lib/splash/daemon/orchestrator/hooks.rb +10 -0
  32. data/lib/splash/dependencies.rb +19 -0
  33. data/lib/splash/exiter.rb +14 -0
  34. data/lib/splash/helpers.rb +93 -46
  35. data/lib/splash/loggers.rb +30 -4
  36. data/lib/splash/loggers/cli.rb +18 -11
  37. data/lib/splash/loggers/daemon.rb +14 -3
  38. data/lib/splash/loggers/dual.rb +14 -1
  39. data/lib/splash/loggers/web.rb +51 -0
  40. data/lib/splash/logs.rb +16 -5
  41. data/lib/splash/processes.rb +83 -0
  42. data/lib/splash/sequences.rb +105 -0
  43. data/lib/splash/templates.rb +10 -0
  44. data/lib/splash/transfers.rb +224 -0
  45. data/lib/splash/transports.rb +9 -0
  46. data/lib/splash/transports/rabbitmq.rb +33 -4
  47. data/lib/splash/webadmin.rb +122 -0
  48. data/lib/splash/webadmin/api/routes/commands.rb +28 -0
  49. data/lib/splash/webadmin/api/routes/config.rb +10 -0
  50. data/lib/splash/webadmin/api/routes/init.rb +2 -0
  51. data/lib/splash/webadmin/api/routes/logs.rb +59 -0
  52. data/lib/splash/webadmin/api/routes/process.rb +60 -0
  53. data/lib/splash/webadmin/api/routes/sequences.rb +28 -0
  54. data/lib/splash/webadmin/main.rb +27 -0
  55. data/lib/splash/webadmin/portal/controllers/commands.rb +7 -0
  56. data/lib/splash/webadmin/portal/controllers/documentation.rb +6 -0
  57. data/lib/splash/webadmin/portal/controllers/home.rb +31 -0
  58. data/lib/splash/webadmin/portal/controllers/logs.rb +14 -0
  59. data/lib/splash/webadmin/portal/controllers/notfound.rb +5 -0
  60. data/lib/splash/webadmin/portal/controllers/processes.rb +14 -0
  61. data/lib/splash/webadmin/portal/controllers/proxy.rb +36 -0
  62. data/lib/splash/webadmin/portal/controllers/restclient.rb +19 -0
  63. data/lib/splash/webadmin/portal/controllers/sequences.rb +7 -0
  64. data/lib/splash/webadmin/portal/init.rb +11 -0
  65. data/lib/splash/webadmin/portal/public/css/ultragreen.css +8544 -0
  66. data/lib/splash/webadmin/portal/public/fonts/FontAwesome.otf +0 -0
  67. data/lib/splash/webadmin/portal/public/fonts/fontawesome-webfont.ttf +0 -0
  68. data/lib/splash/webadmin/portal/public/fonts/fontawesome-webfont.woff +0 -0
  69. data/lib/splash/webadmin/portal/public/fonts/fontawesome-webfont.woff2 +0 -0
  70. data/lib/splash/webadmin/portal/public/images/logo_splash.png +0 -0
  71. data/lib/splash/webadmin/portal/public/images/logo_splash_reduce.png +0 -0
  72. data/lib/splash/webadmin/portal/public/images/logo_splash_tiny.png +0 -0
  73. data/lib/splash/webadmin/portal/views/commands.slim +49 -0
  74. data/lib/splash/webadmin/portal/views/documentation.slim +3 -0
  75. data/lib/splash/webadmin/portal/views/home.slim +123 -0
  76. data/lib/splash/webadmin/portal/views/layout.slim +43 -0
  77. data/lib/splash/webadmin/portal/views/logs.slim +32 -0
  78. data/lib/splash/webadmin/portal/views/nav.slim +17 -0
  79. data/lib/splash/webadmin/portal/views/not_found.slim +3 -0
  80. data/lib/splash/webadmin/portal/views/processes.slim +29 -0
  81. data/lib/splash/webadmin/portal/views/proxy.slim +16 -0
  82. data/lib/splash/webadmin/portal/views/restclient.slim +41 -0
  83. data/lib/splash/webadmin/portal/views/restclient_result.slim +29 -0
  84. data/lib/splash/webadmin/portal/views/sequences.slim +50 -0
  85. data/prometheus-splash.gemspec +12 -3
  86. data/spec/helpers_spec.rb +119 -0
  87. metadata +196 -8
@@ -1,34 +1,69 @@
1
1
  # coding: utf-8
2
+
3
+ # base Splash module
2
4
  module Splash
5
+
6
+ # global daemon module
3
7
  module Daemon
8
+
9
+ # orchestrator specific module
4
10
  module Orchestrator
11
+
12
+ # Orchestrator grammar method defiition module
5
13
  module Grammar
6
14
 
7
15
  include Splash::Config
8
16
  include Splash::Loggers
9
17
 
18
+ # list of known verbs for Splash orchestrator
19
+ VERBS=[:ping,:list_commands,:execute_command,:ack_command, :shutdown, :get_jobs, :reset]
10
20
 
11
- VERBS=[:ping,:list_commands,:execute_command,:ack_command, :shutdown]
12
-
13
-
14
- def shutdown
21
+ # shutdown verb : stop the Splash daemon gracefully
22
+ # @param [Hash] content message content Hash Structure, ignored
23
+ # @return [Hash] Exiter Case :quiet_exit
24
+ def shutdown(content)
15
25
  terminate
16
26
  end
17
27
 
28
+ # ping verb : return pong to hostname precise in payload
29
+ # @param [Hash] content message content Hash Structure, include mandatory payload[:hostname]
30
+ # @return [String] the pong
18
31
  def ping(content)
19
32
  return "Pong : #{content[:payload][:hostname]} !"
20
33
  end
21
34
 
22
-
35
+ # list_commands verb : return the list of specified commands in local Splash
36
+ # @param [Hash] content message content Hash Structure, ignored
37
+ # @return [Hash] structure of commands
23
38
  def list_commands(content)
24
39
  return get_config.commands
25
40
  end
26
41
 
42
+ # ack_command verb : send ack to Prometheus, for command specified in payload
43
+ # @param [Hash] content message content Hash Structure, include mandatory payload[:name]
44
+ # @return [Hash] Exiter case
27
45
  def ack_command(content)
28
46
  return execute command: content[:payload][:name], ack: true
29
47
  end
30
48
 
31
49
 
50
+ # get_jobs verb : return list of scheduled jobs for internal scheduler
51
+ # @param [Hash] content message content Hash Structure, ignored
52
+ # @return [String] YAML dataset
53
+ def get_jobs(content)
54
+ return @server.jobs.to_yaml
55
+ end
56
+
57
+ # reset verb : reset the internal scheduler
58
+ # @param [Hash] content message content Hash Structure, ignored
59
+ # @return [String] "Scheduler reset" static
60
+ def reset(content)
61
+ return "Scheduler reset" if reset_orchestrator
62
+ end
63
+
64
+ # execute_command verb : execute command specified in payload
65
+ # @param [Hash] content message content Hash Structure, include mandatory payload[:name]
66
+ # @return [Hash] Exiter case
32
67
  def execute_command(content)
33
68
  payload = content[:payload]
34
69
  unless get_config.commands.include? payload[:name].to_sym
@@ -1,13 +1,23 @@
1
1
  # coding: utf-8
2
+
3
+ # base Splash module
2
4
  module Splash
5
+
6
+ # global daemon module
3
7
  module Daemon
8
+
9
+ # orchestrator specific module
4
10
  module Orchestrator
5
11
 
12
+ # Rufus Scheduler Hooks
6
13
  module SchedulerHooks
14
+
15
+ # not yet implemented
7
16
  def on_pre_trigger(job, trigger_time)
8
17
 
9
18
  end
10
19
 
20
+ # not yet implemented
11
21
  def on_post_trigger(job, trigger_time)
12
22
 
13
23
  end
@@ -12,11 +12,17 @@ module Splash
12
12
  require 'fileutils'
13
13
  require 'etc'
14
14
  require 'forwardable'
15
+ require 'json'
16
+ require 'uri'
17
+
18
+
15
19
 
16
20
 
17
21
 
18
22
  # Rubygems
19
23
  begin
24
+ require 'net/ssh'
25
+ require 'net/scp'
20
26
  require 'prometheus/client'
21
27
  require 'prometheus/client/push'
22
28
  require 'thor'
@@ -27,6 +33,14 @@ module Splash
27
33
  require 'colorize'
28
34
  require "redis"
29
35
  require 'ps-ruby'
36
+ require 'sinatra/base'
37
+ require 'thin'
38
+ require 'slim'
39
+ require 'rest-client'
40
+ require 'kramdown'
41
+ require 'rack/reverse_proxy'
42
+ require 'tty-table'
43
+
30
44
 
31
45
  rescue Gem::GemNotFoundException
32
46
  $stderr.puts "Loadind error, it's like you try to run Splash, with a lake of dependencies."
@@ -47,8 +61,13 @@ module Splash
47
61
 
48
62
 
49
63
  require 'splash/commands'
64
+ require 'splash/sequences'
50
65
  require 'splash/logs'
66
+ require 'splash/processes'
67
+ require 'splash/transfers'
68
+
51
69
  require 'splash/daemon'
70
+ require 'splash/webadmin'
52
71
 
53
72
 
54
73
  end
@@ -1,5 +1,9 @@
1
1
  # coding: utf-8
2
+
3
+ # base Splash namespace
2
4
  module Splash
5
+
6
+ # Exiter namespace
3
7
  module Exiter
4
8
  include Splash::Loggers
5
9
  EXIT_MAP= {
@@ -35,6 +39,10 @@ module Splash
35
39
 
36
40
  }
37
41
 
42
+ # exiter wrapper
43
+ # @param [Hash] options
44
+ # @option options [Symbol] :case an exit case
45
+ # @option options [String] :more a complementary string to display
38
46
  def splash_exit(options = {})
39
47
  log = get_logger
40
48
  mess = ""
@@ -50,7 +58,13 @@ module Splash
50
58
  end
51
59
  end
52
60
 
61
+ def splash_return(options = {})
53
62
 
63
+ data = EXIT_MAP[options[:case]]
64
+ data[:status] = (data[:code]>0)? :failure : :success
65
+ data[:more] = options[:more] if options[:more]
66
+ return data
67
+ end
54
68
 
55
69
  end
56
70
  end
@@ -1,23 +1,30 @@
1
- # @option options [String] :stdout_trace the path of the file where to redirect STDOUT
2
1
  # coding: utf-8
2
+
3
+ # base Splash Module
3
4
  module Splash
4
- module Helpers
5
5
 
6
+ # Helpers namespace
7
+ module Helpers
6
8
 
7
9
 
10
+ # return the 'root' name
11
+ # @return [String] name
8
12
  def user_root
9
13
  return Etc.getpwuid(0).name
10
14
  end
11
15
 
16
+ # return the 'root' group name : root or wheel
17
+ # @return [String] name
12
18
  def group_root
13
19
  return Etc.getgrgid(0).name
14
20
  end
15
21
 
16
- # facilité pour récupérer les PID depuis une regexp
22
+ # facility for retreiving PID from process query
17
23
  # @param [Hash] options
18
- # @option options [String] :pattern un motif de regexp
19
- # @option options [Array] :patterns Un tableau de motif de regexp
20
- # @return [String] le PID
24
+ # @option options [String] :pattern a regexp to search
25
+ # @option options [Array] :patterns an array of regexp to search
26
+ # @option options [Bool] :full flag to retrieve all process data not only PID
27
+ # @return [String|Array] PID or data structure
21
28
  def get_processes(options = {})
22
29
  patterns = []
23
30
  patterns = options[:patterns] if options[:patterns]
@@ -26,11 +33,15 @@ module Splash
26
33
  patterns.each do |item|
27
34
  res = res.find_processes item
28
35
  end
29
- return res.pick_attr('PID')
36
+ if options[:full] then
37
+ return res
38
+ else
39
+ return res.pick_attr('PID')
40
+ end
30
41
  end
31
42
 
32
43
 
33
- # facilities to find a file in gem path
44
+ # facility to find a file in gem path
34
45
  # @param [String] _gem a Gem name
35
46
  # @param [String] _file a file relative path in the gem
36
47
  # @return [String] the path of the file, if found.
@@ -62,8 +73,8 @@ module Splash
62
73
 
63
74
 
64
75
 
65
- # facilité pour vérifier si le process actif est root
66
- # @return [Bool] vrai ou faux
76
+ # facility to verifyingif the active process run as root
77
+ # @return [Bool] status
67
78
  def is_root?
68
79
  case (Process.uid)
69
80
  when 0
@@ -73,9 +84,9 @@ module Splash
73
84
  end
74
85
  end
75
86
 
76
- # facilité pour s'assurer qu'on execute une méthode avec les droits root
87
+ # wrapping execution if process run as root
77
88
  # @param [Symbol] method a method name th wrap
78
- # @return [void] le retour de la méthode wrappée
89
+ # @return [void] return of wrapped method
79
90
  def run_as_root(method, options = {})
80
91
  unless is_root?
81
92
  return {:case => :not_root, :more => "subcommands : #{method.to_s}"}
@@ -183,15 +194,15 @@ module Splash
183
194
  return 0
184
195
  end
185
196
 
186
- # @!group facilités sur le système de fichier
197
+ # @!group facilities for file system commands
187
198
 
188
- # facilité d'installation de fichier
199
+ # facility for file installation
189
200
  # @param [Hash] options
190
- # @option options [String] :source le chemin source du fichier
191
- # @option options [String] :target le chemin cible du fichier
192
- # @option options [String] :mode les droits du fichier du type Octal "XXX"
193
- # @option options [String] :owner le owner du fichier
194
- # @option options [String] :group le groupe du fichier
201
+ # @option options [String] :source file source path
202
+ # @option options [String] :target file target path
203
+ # @option options [String] :mode String for OCTAL rights like "644"
204
+ # @option options [String] :owner file owner for target
205
+ # @option options [String] :group file group for target
195
206
  def install_file(options = {})
196
207
  #begin
197
208
  FileUtils::copy options[:source], options[:target] #unless File::exist? options[:target]
@@ -203,12 +214,12 @@ module Splash
203
214
  #end
204
215
  end
205
216
 
206
- # facilité de création de répertoire
217
+ # facility for folder creation
207
218
  # @param [Hash] options
208
- # @option options [String] :path le répertoire à créer (relatif ou absolut)
209
- # @option options [String] :mode les droits du fichier du type Octal "XXX"
210
- # @option options [String] :owner le owner du fichier
211
- # @option options [String] :group le groupe du fichier
219
+ # @option options [String] :path folder path (relative or absolute)
220
+ # @option options [String] :mode String for OCTAL rights like "644"
221
+ # @option options [String] :owner file owner for folder
222
+ # @option options [String] :group file group for folder
212
223
  def make_folder(options = {})
213
224
  begin
214
225
  FileUtils::mkdir_p options[:path] unless File::exist? options[:path]
@@ -220,10 +231,10 @@ module Splash
220
231
  end
221
232
  end
222
233
 
223
- # facilité de liaison symbolique de fichier
234
+ # facility for Symbolic link
224
235
  # @param [Hash] options
225
- # @option options [String] :source le chemin source du fichier
226
- # @option options [String] :link le chemin du lien symbolique
236
+ # @option options [String] :source path of the file
237
+ # @option options [String] :link path of the symlink
227
238
  def make_link(options = {})
228
239
  begin
229
240
  FileUtils::rm options[:link] if (File::symlink? options[:link] and not File::exist? options[:link])
@@ -236,15 +247,15 @@ module Splash
236
247
  # @!endgroup
237
248
 
238
249
 
239
- #@!group Vérifiers de l'application
250
+ #@!group Verifiers for application : FS and TCP/IP services
240
251
 
241
- # verifier d'existence d'un repertoire
252
+ # check folder
242
253
  # @return [Array] of Symbol with error type : [:inexistant,:mode,:owner,:group]
243
254
  # @param [Hash] options
244
- # @option options [String] :path le répertoire (relatif ou absolut) obligatoire
245
- # @option options [String] :mode droit du répertoire optionnel
246
- # @option options [String] :owner owner du répertoire optionnel
247
- # @option options [String] :group groupe du répertoire optionnel
255
+ # @option options [String] :name folder path (relative or absolute)
256
+ # @option options [String] :mode String for OCTAL rights like "644", optionnal
257
+ # @option options [String] :owner file owner for folder, optionnal
258
+ # @option options [String] :group file group for folder, optionnal
248
259
  def verify_folder(options ={})
249
260
  res = Array::new
250
261
  return [:inexistant] unless File.directory?(options[:name])
@@ -262,21 +273,21 @@ module Splash
262
273
  return res
263
274
  end
264
275
 
265
- # verifier d'existence d'un lien
266
- # @return [Bool] vrai ou faux
276
+ # check symlink
277
+ # @return [Boolean]
267
278
  # @param [Hash] options
268
- # @option options [String] :name path du lien
279
+ # @option options [String] :name path of the link
269
280
  def verify_link(options ={})
270
281
  return File.file?(options[:name])
271
282
  end
272
283
 
273
- # verifier d'existence d'un fichier
284
+ # check file
274
285
  # @return [Array] of Symbol with error type : [:inexistant,:mode,:owner,:group]
275
286
  # @param [Hash] options
276
- # @option options [String] :name path du fichier obligatoire
277
- # @option options [String] :mode droit du fichier optionnel
278
- # @option options [String] :owner owner du fichier optionnel
279
- # @option options [String] :group groupe du fichier optionnel
287
+ # @option options [String] :name path of file
288
+ # @option options [String] :mode String for OCTAL rights like "644", optionnal
289
+ # @option options [String] :owner file owner for file, optionnal
290
+ # @option options [String] :group file group for file, optionnal
280
291
  def verify_file(options ={})
281
292
  res = Array::new
282
293
  return [:inexistant] unless File.file?(options[:name])
@@ -294,16 +305,25 @@ module Splash
294
305
  return res
295
306
  end
296
307
 
297
- # verifier de l'ecoute d'un service sur un host et port donné en TCP
298
- # @return [Bool] vrai ou faux
308
+ # TCP/IP service checker
309
+ # @return [Bool] status
299
310
  # @param [Hash] options
300
- # @option options [String] :host le nom d'hote
301
- # @option options [String] :port le port TCP
311
+ # @option options [String] :host hostname
312
+ # @option options [String] :port TCP port
313
+ # @option options [String] :url full URL, priority on :host and :port
302
314
  def verify_service(options ={})
303
315
  begin
316
+ if options[:url] then
317
+ uri = URI.parse(options[:url])
318
+ host = uri.host
319
+ port = uri.port
320
+ else
321
+ host = options[:host]
322
+ port = options[:port]
323
+ end
304
324
  Timeout::timeout(1) do
305
325
  begin
306
- s = TCPSocket.new(options[:host], options[:port])
326
+ s = TCPSocket.new(host, port)
307
327
  s.close
308
328
  return true
309
329
  rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
@@ -316,7 +336,34 @@ module Splash
316
336
  end
317
337
  #!@endgroup
318
338
 
339
+ def format_response(data, format)
340
+ response = case format
341
+ when 'application/json' then JSON.pretty_generate(data)
342
+ when 'text/x-yaml' then data.to_yaml
343
+ else JSON.pretty_generate(data)
344
+ end
345
+ return response
346
+ end
347
+
348
+ def format_by_extensions(extension)
349
+ result = {
350
+ 'json' => 'application/json',
351
+ 'yaml' => 'text/x-yaml',
352
+ 'yml' => 'text/x-yaml'
353
+ }
354
+ return result[extension]
355
+ end
319
356
 
357
+ # check if unicode must be used with term ENV
358
+ # @return [Boolean]
359
+ def check_unicode_term
360
+ return false unless ENV.include? "TERM"
361
+ if ENV.values_at("LC_ALL","LC_CTYPE","LANG").compact.first.include?("UTF-8") and ENV.values_at('TERM').first.include? "xterm" then
362
+ return true
363
+ else
364
+ return false
365
+ end
366
+ end
320
367
 
321
368
  end
322
369
  end
@@ -1,12 +1,20 @@
1
1
  # coding: utf-8
2
2
 
3
-
3
+ # base Splash module
4
4
  module Splash
5
+
6
+ # Loggers namespace
5
7
  module Loggers
6
8
  include Splash::Config
7
9
 
8
10
  @@logger=nil
9
11
 
12
+
13
+ # factory for Loggers
14
+ # @param [Hash] options
15
+ # @option options [Symbol] :logger the name of the logger actually in [:cli, :daemon, :dual]
16
+ # @option options [Boolean] :force to force new instance creation (Logger is class variable)
17
+ # @return [SPlash::Loggers::<type>] type is Cli, Dual, Daemon, Web
10
18
  def get_logger(options = {})
11
19
  logger = (get_config.loggers[:list].include? options[:logger])? options[:logger].to_s : get_config.loggers[:default].to_s
12
20
  aclass = "Splash::Loggers::#{logger.capitalize}"
@@ -18,11 +26,15 @@ module Splash
18
26
  end
19
27
  end
20
28
 
29
+ # build a session number
30
+ # @return [String] Session number
21
31
  def get_session
22
32
  return "#{Time.now.to_i.to_s}#{rand(999)}"
23
33
  end
24
34
 
25
35
 
36
+ # wrapper to change logger, call get_logger with force: true
37
+ # @option options [Symbol] :logger the name of the logger actually in [:cli, :daemon, :dual]
26
38
  def change_logger(options = {})
27
39
  level = get_logger.level
28
40
  options[:force] = true
@@ -31,9 +43,10 @@ module Splash
31
43
 
32
44
  LEVELS = [:debug, :warn, :info, :result, :fatal, :unknown]
33
45
  ALIAS = {:flat => :info, :item => :info, :ok => :info, :ko => :info, :trigger => :info,
34
- :schedule => :info, :arrow => :info, :send => :info,
46
+ :schedule => :info, :arrow => :info, :send => :info, :call => :info,
35
47
  :receive => :info, :error => :result, :success => :result }
36
48
 
49
+ # class template for loggers
37
50
  class LoggerTemplate
38
51
  include Splash::Config
39
52
 
@@ -48,13 +61,18 @@ module Splash
48
61
  self.log({ :level => method, :message => message, :session => session})
49
62
  end
50
63
  end
64
+
65
+ # constructor
51
66
  def initialize
52
67
  self.level = get_config.loggers[:level]
53
68
 
54
69
 
55
70
  end
56
71
 
57
-
72
+ # abstract method for log wrapper
73
+ # @param [Hash] options
74
+ # @option options [Symbol] :level, a valid level in LEVELS or ALIAS
75
+ # @option options [String] :message text
58
76
  def log(options)
59
77
  level = (ALIAS.keys.include? options[:level])? ALIAS[options[:level]] : options[:level]
60
78
  if @active_levels.include? level then
@@ -62,11 +80,15 @@ module Splash
62
80
  end
63
81
  end
64
82
 
65
-
83
+ # getter for the current level
84
+ # @return [Symbol] level
66
85
  def level
67
86
  return @active_levels.first
68
87
  end
69
88
 
89
+ # virtual setter for level, set the current level
90
+ # @raise a badLevel in case of bad level
91
+ # @param [Symbol] level
70
92
  def level=(level)
71
93
  if LEVELS.include? level then
72
94
  @active_levels = LEVELS.dup
@@ -78,6 +100,9 @@ module Splash
78
100
 
79
101
 
80
102
  private
103
+ # mapper for symbol Symbol to String
104
+ # @param [Symbol] symbol
105
+ # @return [String] in upcase, exception :arrow give '=>', :flat give ''
81
106
  def alt(symbol)
82
107
  return "=>" if symbol == :arrow
83
108
  return '' if symbol == :flat
@@ -86,6 +111,7 @@ module Splash
86
111
 
87
112
  end
88
113
 
114
+ # badLevel Exception
89
115
  class BadLevel < Exception; end
90
116
 
91
117
  end