Module: DrymlFireMarker

Extended by:
DrymlFireMarker
Included in:
DrymlFireMarker
Defined in:
lib/dryml-firemarker.rb,
lib/dryml-firemarker-shared-overrides.rb

Defined Under Namespace

Modules: SharedOverrides

Constant Summary collapse

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

Instance Method Summary collapse

Instance Method Details

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



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

def (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