Class: Database

Inherits:
Object
  • Object
show all
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

Class Method Details

.allObject

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

.pullObject

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

.validateObject

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