Class: Eggshell::Bundles::Loader::LoaderMacro

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

Instance Method Summary collapse

Instance Method Details

#process(buffer, macname, args, lines, depth) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/eggshell/bundles/loader.rb', line 21

def process(buffer, macname, args, lines, depth)
	if macname == 'gems'
		args.each do |gemname|
			begin
				require gemname
				@proc._debug("_loaded gem: #{gemname}")
			rescue LoadError
				@proc._warn("could not load gem: #{gemname}")
			end
		end
	elsif macname == 'files'
		args.each do |file|
			begin
				if file[0] == '/'
					require file
				else
					@proc.vars[:target].vars[:include_paths].each do |root|
						if File.exists?("#{root}/#{file}")
							require "#{root}/#{file}"
							@proc._debug("loaded file: #{root}/#{file}")
						end
					end
				end
			rescue LoadError
				@proc._warn("could not load file: #{file}")
			end
		end
	elsif macname == 'bundles'
		args.each do |bundle|
			Eggshell::Bundles::Registry.attach_bundle(bundle, @proc.vars[:target])
		end
	end
end

#set_processor(proc) ⇒ Object



16
17
18
19
# File 'lib/eggshell/bundles/loader.rb', line 16

def set_processor(proc)
	@proc = proc
	proc.register_macro(self, *%w(gems files bundles vars))
end