Module: Myth::Source

Defined in:
lib/myth.rb

Class Method Summary collapse

Class Method Details

.contentsObject



19
20
21
# File 'lib/myth.rb', line 19

def self.contents
  @contents ||= File.read(path)
end

.contextObject



27
28
29
30
# File 'lib/myth.rb', line 27

def self.context
  # Window or self has to be added so myth can attach to something
  @context ||= ExecJS.compile("preprocess=function(css,options){try{css=myth(css,options);}catch(e){e.css=css;throw e;}return css;};if(typeof self==\"undefined\")self={};" + contents + "if(self.myth)myth=self.myth;")
end

.pathObject



10
11
12
# File 'lib/myth.rb', line 10

def self.path
  @path ||= ENV['MYTH_SOURCE_PATH'] || bundled_path
end

.path=(path) ⇒ Object



14
15
16
17
# File 'lib/myth.rb', line 14

def self.path=(path)
  @contents = @version = @context = nil
  @path = path
end

.versionObject



23
24
25
# File 'lib/myth.rb', line 23

def self.version
  @version ||= contents[/Myth Preprocessor v([\d.]+)/, 1]
end