add :eager option to markup
Charlie Somerville charlie@charliesomerville.com
Wed, 04 Dec 2013 10:24:16 +1100
1 files changed,
18 insertions(+),
10 deletions(-)
jump to
M
lib/github/markup.rb
→
lib/github/markup.rb
@@ -27,20 +27,28 @@ content
end end - def markup(file, pattern, &block) + def markup(file, pattern, opts = {}, &block) loader = proc do - require file.to_s - add_markup(pattern, &block) + begin + require file.to_s + add_markup(pattern, &block) + true + rescue LoadError + false + end end - @@deferred_markups << loader - add_markup pattern do |*args| - @@deferred_markups.delete(loader) + + if opts[:eager] loader.call - block.call(*args) + else + @@deferred_markups << loader + add_markup pattern do |*args| + @@deferred_markups.delete(loader) + loader.call + block.call(*args) + end + true end - true - rescue LoadError - false end def command(command, regexp, &block)