Class: Rack::Padlock::Phantomjs
- Inherits:
-
Object
- Object
- Rack::Padlock::Phantomjs
- Defined in:
- lib/rack/padlock/phantomjs.rb
Constant Summary collapse
- KILL_TIMEOUT =
seconds
20
Instance Attribute Summary collapse
-
#binary ⇒ Object
readonly
Returns the value of attribute binary.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
Instance Method Summary collapse
- #command ⇒ Object
-
#initialize(addresses, binary = nil) ⇒ Phantomjs
constructor
A new instance of Phantomjs.
- #start ⇒ Object
Constructor Details
#initialize(addresses, binary = nil) ⇒ Phantomjs
Returns a new instance of Phantomjs.
7 8 9 10 11 |
# File 'lib/rack/padlock/phantomjs.rb', line 7 def initialize(addresses, binary=nil) @binary = binary || 'phantomjs' @addresses = addresses @pid = nil end |
Instance Attribute Details
#binary ⇒ Object (readonly)
Returns the value of attribute binary.
5 6 7 |
# File 'lib/rack/padlock/phantomjs.rb', line 5 def binary @binary end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
5 6 7 |
# File 'lib/rack/padlock/phantomjs.rb', line 5 def pid @pid end |
Instance Method Details
#command ⇒ Object
13 14 15 16 |
# File 'lib/rack/padlock/phantomjs.rb', line 13 def command js_path = ::File.('../padlock.js', __FILE__) "#{@binary} --ignore-ssl-errors=yes #{js_path} #{@addresses.join(' ')}" end |
#start ⇒ Object
18 19 20 21 |
# File 'lib/rack/padlock/phantomjs.rb', line 18 def start puts "Starting up phantomjs\n" Timeout.timeout(KILL_TIMEOUT) { system(command) } end |