Module: Hylite::ChooseHyliter
Instance Method Summary collapse
- #call(code, lang) ⇒ Object
- #coderay_available? ⇒ Boolean
- #pygments_available? ⇒ Boolean
- #rouge_available? ⇒ Boolean
Instance Method Details
#call(code, lang) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/hylite/choose_hyliter.rb', line 8 def call(code, lang) case when rouge_available? then Rouge.new(code, lang) when pygments_available? then Pygments.new(code, lang) when coderay_available? then CodeRay.new(code, lang) end end |
#coderay_available? ⇒ Boolean
29 30 31 32 33 34 |
# File 'lib/hylite/choose_hyliter.rb', line 29 def coderay_available? require 'rouge' true rescue LoadError false end |
#pygments_available? ⇒ Boolean
23 24 25 26 27 |
# File 'lib/hylite/choose_hyliter.rb', line 23 def pygments_available? ENV['PATH'].split(File::PATH_SEPARATOR).any? do |dir| File.exist? File.join(dir, 'pygmentize') end end |
#rouge_available? ⇒ Boolean
16 17 18 19 20 21 |
# File 'lib/hylite/choose_hyliter.rb', line 16 def rouge_available? require 'rouge' true rescue LoadError false end |