Class: RedGlass

Inherits:
Object
  • Object
show all
Defined in:
lib/red-glass/red_glass.rb

Constant Summary collapse

PROJ_ROOT =
File.dirname(__FILE__).to_s

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(driver, opts = {}) ⇒ RedGlass

Returns a new instance of RedGlass.



12
13
14
15
16
17
18
19
20
21
# File 'lib/red-glass/red_glass.rb', line 12

def initialize(driver, opts={})
  @driver = driver
  @opts = opts
  opts[:listener].red_glass = self if opts[:listener]
  @test_id = opts[:test_id] || UUID.new.generate
  @server_log = opts[:server_log] || false
  @event_sequence = []
  @page_metadata = {}
  @recording = false
end

Instance Attribute Details

#archive_dirObject

Returns the value of attribute archive_dir.



8
9
10
# File 'lib/red-glass/red_glass.rb', line 8

def archive_dir
  @archive_dir
end

#driverObject

Returns the value of attribute driver.



8
9
10
# File 'lib/red-glass/red_glass.rb', line 8

def driver
  @driver
end

#event_sequenceObject

Returns the value of attribute event_sequence.



8
9
10
# File 'lib/red-glass/red_glass.rb', line 8

def event_sequence
  @event_sequence
end

#optsObject

Returns the value of attribute opts.



8
9
10
# File 'lib/red-glass/red_glass.rb', line 8

def opts
  @opts
end

#page_metadataObject

Returns the value of attribute page_metadata.



8
9
10
# File 'lib/red-glass/red_glass.rb', line 8

def 
  @page_metadata
end

#pidObject

Returns the value of attribute pid.



8
9
10
# File 'lib/red-glass/red_glass.rb', line 8

def pid
  @pid
end

#portObject

Returns the value of attribute port.



8
9
10
# File 'lib/red-glass/red_glass.rb', line 8

def port
  @port
end

#recordingObject

Returns the value of attribute recording.



8
9
10
# File 'lib/red-glass/red_glass.rb', line 8

def recording
  @recording
end

#test_idObject

Returns the value of attribute test_id.



8
9
10
# File 'lib/red-glass/red_glass.rb', line 8

def test_id
  @test_id
end

Instance Method Details

#pauseObject



36
37
38
# File 'lib/red-glass/red_glass.rb', line 36

def pause
  @recording = false
end

#reloadObject



30
31
32
33
34
# File 'lib/red-glass/red_glass.rb', line 30

def reload
  set_config
  start_server
  load_js
end

#startObject



23
24
25
26
27
28
# File 'lib/red-glass/red_glass.rb', line 23

def start
  set_config
  start_server
  load_js
  @recording = true
end

#stopObject



40
41
42
43
# File 'lib/red-glass/red_glass.rb', line 40

def stop
  Process.kill('INT', @pid) if @pid
  @recording = false
end

#take_snapshotObject



45
46
47
48
49
50
51
52
53
# File 'lib/red-glass/red_glass.rb', line 45

def take_snapshot
  
  create_page_archive_directory
  take_screenshot
  capture_page_source
  load_js
  serialize_dom
  
end