Class: Vessel::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/vessel/loader.rb

Direct Known Subclasses

ApplicationLoader

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLoader

Returns a new instance of Loader.



7
8
9
# File 'lib/vessel/loader.rb', line 7

def initialize
  @crawlers = {}
end

Instance Attribute Details

#crawlersObject (readonly)

Returns the value of attribute crawlers.



5
6
7
# File 'lib/vessel/loader.rb', line 5

def crawlers
  @crawlers
end

Instance Method Details

#find_crawler(name) ⇒ Object



28
29
30
# File 'lib/vessel/loader.rb', line 28

def find_crawler(name)
  @crawlers[name]
end

#list_crawlersObject



32
33
34
# File 'lib/vessel/loader.rb', line 32

def list_crawlers
  @crawlers.keys.sort
end

#load_crawler(name) ⇒ Object



19
20
21
22
# File 'lib/vessel/loader.rb', line 19

def load_crawler(name)
  path = File.expand_path("crawlers/#{name}.rb")
  require(path) if File.exist?(path)
end

#load_crawlersObject



15
16
17
# File 'lib/vessel/loader.rb', line 15

def load_crawlers
  Dir["crawlers/**/*.rb"].each { |file| require(file) }
end

#register(name, klass) ⇒ Object



24
25
26
# File 'lib/vessel/loader.rb', line 24

def register(name, klass)
  @crawlers.merge!(name => klass)
end

#templatorObject



11
12
13
# File 'lib/vessel/loader.rb', line 11

def templator
  Templator
end