Module: DrymlFireMarker

Defined in:
lib/dryml-firemarker.rb

Constant Summary collapse

VERSION =
File.read(File.expand_path('../../VERSION', __FILE__)).strip
WINDOZE =
RbConfig::CONFIG['host_os'] =~ /mswin|msys|mingw32|windows/i

Class Method Summary collapse

Class Method Details

.metadata_to_json(template_path, kind, name, line, *args) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/dryml-firemarker.rb', line 10

def self.(template_path, kind, name, line, *args)
  keys            = [ ] # we need to keep track of the key order for ruby 1.8.x unordered hashes
          = { }
  [kind]  = name
  keys.push(kind)
  path            = Pathname.new(template_path).realpath.to_s
  writeable       = path.match(/^#{Regexp.quote(rails_root)}\//) &&
                    ( auto_path.blank? ||! path.match(/^#{Regexp.quote(auto_path)}\//) )
  path.gsub!(%r{/}, '\\\\\\\\') if WINDOZE # ridiculous escaping needed !!!
  unless args.empty?
    ['args'] = args.join(' | ')
    keys.push('args')
  end
  ['path'] = path + ':' + line.to_s + (writeable ? '+' : '')
  keys.push('path')
  "{#{ keys.map{|k| k.inspect + ':' + [k].inspect}.join(',') }}"
end