Class: BuildMaster::ContentEngineRepository

Inherits:
Object
  • Object
show all
Defined in:
lib/buildmaster/site/content_engine_repository.rb

Instance Method Summary collapse

Constructor Details

#initializeContentEngineRepository

Returns a new instance of ContentEngineRepository.



6
7
8
9
10
11
12
# File 'lib/buildmaster/site/content_engine_repository.rb', line 6

def initialize
  @map = Hash.new
  @map['.textile'] = TextileEngine.new
  @map['.markdown'] = MarkdownEngine.new
  @map['.html'] = HtmlEngine.new
  @map['.txt'] = TextileEngine.new
end

Instance Method Details

#for_candidate(directory, basename) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/buildmaster/site/content_engine_repository.rb', line 22

def for_candidate(directory, basename)
  @map.each_pair do |extname, engine|
    candidate = directory.file("#{basename}#{extname}")
    if candidate.exists?
      return candidate, engine
    end
  end
  return nil, nil
end

#for_source(source_file) ⇒ Object



18
19
20
# File 'lib/buildmaster/site/content_engine_repository.rb', line 18

def for_source(source_file)
  @map[source_file.extname]
end

#supports?(extname) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/buildmaster/site/content_engine_repository.rb', line 14

def supports?(extname)
  @map.has_key?(extname)
end