Class: MiGA::MiGA
- Inherits:
-
Object
- Object
- MiGA::MiGA
- Includes:
- MiGA
- Defined in:
- lib/miga/common.rb,
lib/miga/version.rb
Overview
Generic class used to handle system-wide information and methods, and parent of all other MiGA::* classes.
Direct Known Subclasses
Daemon, Dataset, Metadata, Project, RemoteDataset, Result, TaxIndex, TaxIndexTaxon, Taxonomy
Constant Summary collapse
- @@DEBUG =
Should debugging information be reported?
false
- @@DEBUG_TRACE =
Should the trace of debugging information be reported?
false
Constants included from MiGA
CITATION, VERSION, VERSION_DATE, VERSION_NAME
Class Method Summary collapse
-
.CITATION ⇒ Object
Reference of MiGA.
-
.DEBUG(*args) ⇒ Object
Send debug message.
-
.DEBUG_OFF ⇒ Object
Turn off debugging.
-
.DEBUG_ON ⇒ Object
Turn on debugging.
-
.DEBUG_TRACE_OFF ⇒ Object
Turn off debug tracing (but not debugging).
-
.DEBUG_TRACE_ON ⇒ Object
Turn on debug tracing (and debugging).
-
.FULL_VERSION ⇒ Object
Complete version as string.
-
.initialized? ⇒ Boolean
Has MiGA been initialized?.
-
.LONG_VERSION ⇒ Object
Complete version with nickname and date as string.
-
.root_path ⇒ Object
Root path to MiGA (as estimated from the location of the current file).
-
.tabulate(header, values) ⇒ Object
Tabulates an
values
, and Array of Arrays, all with the same number of entries asheader
. -
.VERSION ⇒ Object
Major.minor version as Float.
-
.VERSION_DATE ⇒ Object
Date of the current gem release.
Instance Method Summary collapse
-
#result_files_exist?(base, ext) ⇒ Boolean
Check if the result files exist with
base
name (String) followed by theext
values (Array of String).
Class Method Details
.CITATION ⇒ Object
Reference of MiGA.
55 |
# File 'lib/miga/version.rb', line 55 def self.CITATION ; CITATION ; end |
.DEBUG(*args) ⇒ Object
Send debug message.
49 50 51 52 53 |
# File 'lib/miga/common.rb', line 49 def self.DEBUG *args $stderr.puts(*args) if @@DEBUG $stderr.puts caller.map{|v| v.gsub(/^/," ")}.join("\n") if @@DEBUG_TRACE end |
.DEBUG_OFF ⇒ Object
Turn off debugging.
32 |
# File 'lib/miga/common.rb', line 32 def self.DEBUG_OFF() @@DEBUG=false end |
.DEBUG_ON ⇒ Object
Turn on debugging.
28 |
# File 'lib/miga/common.rb', line 28 def self.DEBUG_ON() @@DEBUG=true end |
.DEBUG_TRACE_OFF ⇒ Object
Turn off debug tracing (but not debugging).
43 44 45 |
# File 'lib/miga/common.rb', line 43 def self.DEBUG_TRACE_OFF @@DEBUG_TRACE=false end |
.DEBUG_TRACE_ON ⇒ Object
Turn on debug tracing (and debugging).
36 37 38 39 |
# File 'lib/miga/common.rb', line 36 def self.DEBUG_TRACE_ON @@DEBUG_TRACE=true self.DEBUG_ON end |
.FULL_VERSION ⇒ Object
Complete version as string.
40 |
# File 'lib/miga/version.rb', line 40 def self.FULL_VERSION ; VERSION.join(".") ; end |
.initialized? ⇒ Boolean
Has MiGA been initialized?
57 58 59 60 |
# File 'lib/miga/common.rb', line 57 def self.initialized? File.exist?(File.(".miga_rc", ENV["MIGA_HOME"])) and File.exist?(File.(".miga_daemon.json", ENV["MIGA_HOME"])) end |
.LONG_VERSION ⇒ Object
Complete version with nickname and date as string.
44 45 46 47 |
# File 'lib/miga/version.rb', line 44 def self.LONG_VERSION "MiGA " + VERSION.join(".") + " - " + VERSION_NAME + " - " + VERSION_DATE.to_s end |
.root_path ⇒ Object
Root path to MiGA (as estimated from the location of the current file).
16 |
# File 'lib/miga/common.rb', line 16 def self.root_path ; File.("../../..", __FILE__) ; end |
.tabulate(header, values) ⇒ Object
Tabulates an values
, and Array of Arrays, all with the same number of entries as header
. Returns an Array of String, one per line.
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/miga/common.rb', line 65 def self.tabulate(header, values) fields = [header.map{ |h| h.to_s }] fields << fields.first.map{ |h| h.gsub(/\S/, "-") } fields += values.map{ |row| row.map{ |cell| cell.nil? ? "?" : cell.to_s } } clen = fields.map{ |row| row.map{ |cell| cell.length } }.transpose.map{ |col| col.max } fields.map do |row| (0 .. clen.size-1).map do |col_n| col_n==0 ? row[col_n].rjust(clen[col_n]) : row[col_n].ljust(clen[col_n]) end.join(" ") end end |
.VERSION ⇒ Object
Major.minor version as Float.
36 |
# File 'lib/miga/version.rb', line 36 def self.VERSION ; VERSION[0] ; end |
.VERSION_DATE ⇒ Object
Date of the current gem release.
51 |
# File 'lib/miga/version.rb', line 51 def self.VERSION_DATE ; VERSION_DATE ; end |
Instance Method Details
#result_files_exist?(base, ext) ⇒ Boolean
Check if the result files exist with base
name (String) followed by the ext
values (Array of String).
81 82 83 84 85 86 |
# File 'lib/miga/common.rb', line 81 def result_files_exist?(base, ext) ext = [ext] unless ext.kind_of? Array ext.all? do |f| File.exist?(base + f) or File.exist?(base + f + ".gz") end end |