Module: Card::Loader

Defined in:
lib/card/loader.rb

Class Method Summary collapse

Class Method Details

.load_chunksObject



27
28
29
30
31
# File 'lib/card/loader.rb', line 27

def load_chunks
  mod_dirs.each do |mod|
    load_dir "#{mod}/chunk/*.rb"
  end
end

.load_layoutsObject



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/card/loader.rb', line 33

def load_layouts
  mod_dirs.inject({}) do |hash, mod|
    dirname = "#{mod}/layout"
    if File.exist? dirname
      Dir.foreach(dirname) do |filename|
        next if filename =~ /^\./
        hash[filename.gsub /\.html$/, ''] =
          File.read([dirname, filename].join('/'))
      end
    end
    hash
  end
end

.load_modsObject



19
20
21
22
23
24
25
# File 'lib/card/loader.rb', line 19

def load_mods
  load_set_patterns
  load_formats
  load_sets

  refresh_script_and_style if ENV['RAILS_ENV'] == 'development'
end

.mod_dirsObject



47
48
49
50
51
52
53
54
55
# File 'lib/card/loader.rb', line 47

def mod_dirs
  @@mod_dirs ||= begin
    Card.paths['mod'].existent.map do |dirname|
      Dir.entries(dirname).sort.map do |filename|
        "#{dirname}/#{filename}" if filename !~ /^\./
      end.compact
    end.flatten.compact
  end
end