6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/js_flasher/get_templates.rb', line 6
def get_templates_ob(subset = nil)
subset ||= self.template_sources.keys
templates_ob = {}
self.template_sources.each do |tpl_name, tpl_dir|
if subset && subset.include?(tpl_name)
templates_ob[tpl_name] = {}
Dir.chdir(tpl_dir) do
outs = Dir.glob("**/*")
outs.each do |filename|
out_arr = filename.split('/').last.split('.')
out_arr.shift
extension = ".#{out_arr.join('.')}"
filename_key = (self.extensions_in_keys) ? filename : filename.gsub(extension, '')
if self.supported_extensions.include? extension
filecontents = File.open(filename, "rb") { |f| f.read }
templates_ob[tpl_name][filename_key] = filecontents.gsub(/([\n\t\r])/, '')
end
end
end
end
end
if subset.length === 1
templates_ob = templates_ob[subset[0].to_sym]
end
return templates_ob
end
|