Class: Database
- Inherits:
-
Object
- Object
- Database
- Defined in:
- lib/database_dsl.rb,
lib/database.rb
Overview
Database
Creates a DSL for defining Databases which can be downloaded using ‘pipet pull`
Class Method Summary collapse
-
.all ⇒ Object
Returns a list of all objects that inherited from Database.
-
.description(val = nil) ⇒ Object
Provide a description for the database.
-
.md5(val = nil) ⇒ Object
Specify MD5 checksum of database.
-
.name(val = nil) ⇒ Object
Name the database.
-
.pull ⇒ Object
Downloads the database, checks the MD5 sum.
-
.type(val = nil) ⇒ Object
Define type of database.
-
.url(url = nil) ⇒ Object
Specify the URL of a database.
-
.validate ⇒ Object
Make sure all required attributes have been defined.
Class Method Details
.all ⇒ Object
Returns a list of all objects that inherited from Database
7 8 9 |
# File 'lib/database.rb', line 7 def all ObjectSpace.each_object(Class).select { |klass| klass < self } end |
.description(val = nil) ⇒ Object
Provide a description for the database
29 30 31 |
# File 'lib/database_dsl.rb', line 29 def description(val=nil) @description ||= val end |
.md5(val = nil) ⇒ Object
Specify MD5 checksum of database
22 23 24 |
# File 'lib/database_dsl.rb', line 22 def md5(val=nil) @md5 ||= val end |
.name(val = nil) ⇒ Object
Name the database. This is used be ‘pipet pull`
36 37 38 |
# File 'lib/database_dsl.rb', line 36 def name(val=nil) @name ||= val end |
.pull ⇒ Object
Downloads the database, checks the MD5 sum.
74 75 76 |
# File 'lib/database_dsl.rb', line 74 def pull `wget #{@url}` end |
.type(val = nil) ⇒ Object
Define type of database. This is like a tag. For example,
type :nucleotide for a database of nucleotide sequences
type :structure for a database of protein structures
50 51 52 |
# File 'lib/database_dsl.rb', line 50 def type(val=nil) @type ||= val end |
.url(url = nil) ⇒ Object
Specify the URL of a database
15 16 17 |
# File 'lib/database_dsl.rb', line 15 def url(url=nil) @url ||= url end |
.validate ⇒ Object
Make sure all required attributes have been defined.
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/database_dsl.rb', line 57 def validate required_attributes = [ :name, :md5, :description, :type ] required_attributes.map do |ra| self.send(ra) end.include? nil end |