Module: Kulriir

Defined in:
lib/kulriir.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

KULRII_HOST =
'kulrii.heroku.com'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



7
8
9
# File 'lib/kulriir.rb', line 7

def self.included(base)
  base.extend ClassMethods
end

.syntaxesObject



35
36
37
# File 'lib/kulriir.rb', line 35

def syntaxes
  REXML::Document.new(RestClient.get("http://#{KULRII_HOST}/syntaxes")).elements.collect('syntaxes/syntax') { |e| e.text }
end

.themesObject



39
40
41
# File 'lib/kulriir.rb', line 39

def themes
  REXML::Document.new(RestClient.get("http://#{KULRII_HOST}/themes")).elements.collect('themes/theme') { |e| e.text }
end

Instance Method Details

#highlight(options = {}) ⇒ Object

return a syntax-highlighted version of the string

options:

numbers: boolean indicating whether or not to include line numbers line_numbers: legacy equivalent for 'numbers' option syntax: language to use for highlighting language: legacy equivalent for 'syntax' option theme: theme for highlighting



25
26
27
28
29
30
31
32
# File 'lib/kulriir.rb', line 25

def highlight(options = {})
  options[:numbers] = options.delete(:line_numbers) if options.include?(:line_numbers)
  options[:syntax] = options.delete(:language) if options.include?(:language)
  
  options[:syntax] ||= 'ruby'

  RestClient.post "http://#{KULRII_HOST}/parse", options.merge(:text => self)
end