Class: Markdownplus::IncludeHandler
- Defined in:
- lib/markdownplus/handler.rb
Constant Summary collapse
- @@cache =
{}
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.cached(url) ⇒ Object
26 27 28 29 30 |
# File 'lib/markdownplus/handler.rb', line 26 def self.cached(url) return @@cache[url] if @@cache[url] @@cache[url] = open(url).read @@cache[url] end |
Instance Method Details
#execute(input, parameters, variables, warnings, errors) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/markdownplus/handler.rb', line 8 def execute(input, parameters, variables, warnings, errors) output = nil warnings << "Include handler ignores input" if(input!=nil && !input.strip.empty?) if parameters==nil errors << "No url given" elsif parameters.count == 0 errors << "No url given" else begin output = IncludeHandler.cached(parameters.first.to_s) rescue => e errors << "Error opening [#{parameters.first}] [#{e.message}]" end end output end |