Module: GeneValidatorApp
- Defined in:
- lib/genevalidatorapp/config.rb,
lib/genevalidatorapp.rb,
lib/genevalidatorapp/logger.rb,
lib/genevalidatorapp/routes.rb,
lib/genevalidatorapp/server.rb,
lib/genevalidatorapp/version.rb,
lib/genevalidatorapp/database.rb,
lib/genevalidatorapp/exceptions.rb,
lib/genevalidatorapp/genevalidator.rb
Overview
This file defines all possible exceptions that can be thrown by GeneValidatorApp on startup.
Exceptions only ever inform another entity (downstream code or users) of an issue. Exceptions may or may not be recoverable.
Error classes should be seen as: the error code (class name), human readable message (to_s method), and necessary attributes to act on the error.
We define as many error classes as needed to be precise about the issue, thus making it easy for downstream code (bin/genevalidatorapp or config.ru) to act on them.
Defined Under Namespace
Modules: RunGeneValidator Classes: BIN_DIR_NOT_FOUND, BLAST_DATABASE_ERROR, BLAST_NOT_COMPATIBLE, BLAST_NOT_EXECUTABLE, BLAST_NOT_INSTALLED, CONFIG_FILE_ERROR, Config, DATABASE_DIR_NOT_FOUND, DATABASE_DIR_NOT_SET, Database, ENOENT, EXTENSION_FILE_NOT_FOUND, Logger, NO_BLAST_DATABASE_FOUND, NUM_THREADS_INCORRECT, Routes, Server
Constant Summary collapse
- MINIMUM_BLAST_VERSION =
Use a fixed minimum version of BLAST+
'2.2.30+'- VERSION =
'1.5.2'
Class Attribute Summary collapse
-
.config ⇒ Object
readonly
Returns the value of attribute config.
-
.public_dir ⇒ Object
readonly
Returns the value of attribute public_dir.
-
.temp_dir ⇒ Object
readonly
Returns the value of attribute temp_dir.
Class Method Summary collapse
-
.call(env) ⇒ Object
Rack-interface.
- .environment ⇒ Object
-
.init(config = {}) ⇒ Object
Setting up the environment before running the app…
- .logger ⇒ Object
- .on_start ⇒ Object
- .on_stop ⇒ Object
- .root ⇒ Object
-
.run ⇒ Object
Starting the app manually.
- .verbose? ⇒ Boolean
Class Attribute Details
.config ⇒ Object (readonly)
Returns the value of attribute config.
51 52 53 |
# File 'lib/genevalidatorapp.rb', line 51 def config @config end |
.public_dir ⇒ Object (readonly)
Returns the value of attribute public_dir.
51 52 53 |
# File 'lib/genevalidatorapp.rb', line 51 def public_dir @public_dir end |
.temp_dir ⇒ Object (readonly)
Returns the value of attribute temp_dir.
51 52 53 |
# File 'lib/genevalidatorapp.rb', line 51 def temp_dir @temp_dir end |
Class Method Details
.call(env) ⇒ Object
Rack-interface.
Inject our logger in the env and dispatch request to our controller.
87 88 89 90 |
# File 'lib/genevalidatorapp.rb', line 87 def call(env) env['rack.logger'] = logger Routes.call(env) end |
.environment ⇒ Object
18 19 20 |
# File 'lib/genevalidatorapp.rb', line 18 def environment ENV['RACK_ENV'] end |
.init(config = {}) ⇒ Object
Setting up the environment before running the app…
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/genevalidatorapp.rb', line 35 def init(config = {}) @config = Config.new(config) init_binaries init_database check_dirs init_gv_tempdir init_public_dir load_extension check_num_threads check_max_characters self end |
.logger ⇒ Object
30 31 32 |
# File 'lib/genevalidatorapp.rb', line 30 def logger @logger ||= Logger.new(STDERR, verbose?) end |
.on_start ⇒ Object
69 70 71 72 73 74 |
# File 'lib/genevalidatorapp.rb', line 69 def on_start puts '** GeneValidator is ready.' puts " Go to #{server_url} in your browser and start analysing genes!" puts ' Press CTRL+C to quit.' open_in_browser(server_url) end |
.on_stop ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/genevalidatorapp.rb', line 76 def on_stop puts puts '** Thank you for using GeneValidatorApp :).' puts ' Please cite: ' puts ' Dragan M., Moghul M.I., Priyam A., Wurm Y (in prep).' puts ' GeneValidator: identify problematic gene predictions.' end |
.root ⇒ Object
26 27 28 |
# File 'lib/genevalidatorapp.rb', line 26 def root File.dirname(File.dirname(__FILE__)) end |
.run ⇒ Object
Starting the app manually
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/genevalidatorapp.rb', line 54 def run check_host Server.run(self) rescue Errno::EADDRINUSE puts "** Could not bind to port #{config[:port]}." puts " Is GeneValidator already accessible at #{server_url}?" puts ' No? Try running GeneValidator on another port, like so:' puts puts ' genevalidatorapp -p 4570.' rescue Errno::EACCES puts "** Need root privilege to bind to port #{config[:port]}." puts ' It is not advisable to run GeneValidator as root.' puts ' Please use Apache/Nginx to bind to a privileged port.' end |
.verbose? ⇒ Boolean
22 23 24 |
# File 'lib/genevalidatorapp.rb', line 22 def verbose? @verbose ||= (environment == 'development') end |