module Xray
Constants
- FILE_PLACEHOLDER
- OPEN_PATH
- UPDATE_CONFIG_PATH
- VERSION
Public Class Methods
augment_template(source, path)
click to toggle source
Returns augmented HTML where the source is simply wrapped in an HTML comment with filepath info. Xray.js uses these comments to associate elements with the templates that rendered them.
This:
<div class=".my-element"> ... </div>
Becomes:
<!-- XRAY START 123 /path/to/file.html --> <div class=".my-element"> ... </div> <!-- XRAY END 123 -->
# File lib/xray-rails.rb, line 36 def self.augment_template(source, path) id = next_id if source.include?('<!DOCTYPE') return source end # skim doesn't allow html comments, so use skim's comment syntax if it's skim if path =~ /\.(skim|hamlc)(\.|$)/ augmented = "/!XRAY START #{id} #{path}\n#{source}\n/!XRAY END #{id}" else augmented = "<!--XRAY START #{id} #{path}-->\n#{source}\n<!--XRAY END #{id}-->" end ActiveSupport::SafeBuffer === source ? ActiveSupport::SafeBuffer.new(augmented) : augmented end
config()
click to toggle source
# File lib/xray/config.rb, line 3 def self.config @@config ||= Config.new end
next_id()
click to toggle source
# File lib/xray-rails.rb, line 50 def self.next_id @id = (@id ||= 0) + 1 end
open_file(file)
click to toggle source
# File lib/xray-rails.rb, line 54 def self.open_file(file) editor = Xray.config.editor cmd = if editor.include?('$file') editor.gsub '$file', file else "#{editor} \"#{file}\"" end Open3.capture3(cmd) end
request_info()
click to toggle source
Used to collect request information during each request cycle for use in the Xray
bar.
# File lib/xray-rails.rb, line 17 def self.request_info Thread.current[:request_info] ||= {} end