Class: Ngrok::Tunnel
- Inherits:
-
Object
- Object
- Ngrok::Tunnel
- Defined in:
- lib/ngrok/tunnel.rb,
lib/ngrok/tunnel/version.rb
Constant Summary collapse
- VERSION =
"2.0.20"
Class Attribute Summary collapse
-
.ngrok_url ⇒ Object
readonly
Returns the value of attribute ngrok_url.
-
.ngrok_url_https ⇒ Object
readonly
Returns the value of attribute ngrok_url_https.
-
.pid ⇒ Object
readonly
Returns the value of attribute pid.
-
.status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
- .authtoken ⇒ Object
- .inherited(subclass) ⇒ Object
- .init(params = {}) ⇒ Object
- .log ⇒ Object
- .port ⇒ Object
- .running? ⇒ Boolean
- .start(params = {}) ⇒ Object
- .stop ⇒ Object
- .stopped? ⇒ Boolean
- .subdomain ⇒ Object
Class Attribute Details
.ngrok_url ⇒ Object (readonly)
Returns the value of attribute ngrok_url.
13 14 15 |
# File 'lib/ngrok/tunnel.rb', line 13 def ngrok_url @ngrok_url end |
.ngrok_url_https ⇒ Object (readonly)
Returns the value of attribute ngrok_url_https.
13 14 15 |
# File 'lib/ngrok/tunnel.rb', line 13 def ngrok_url_https @ngrok_url_https end |
.pid ⇒ Object (readonly)
Returns the value of attribute pid.
13 14 15 |
# File 'lib/ngrok/tunnel.rb', line 13 def pid @pid end |
.status ⇒ Object (readonly)
Returns the value of attribute status.
13 14 15 |
# File 'lib/ngrok/tunnel.rb', line 13 def status @status end |
Class Method Details
.authtoken ⇒ Object
64 65 66 |
# File 'lib/ngrok/tunnel.rb', line 64 def authtoken @params[:authtoken] end |
.inherited(subclass) ⇒ Object
68 69 70 |
# File 'lib/ngrok/tunnel.rb', line 68 def inherited(subclass) init end |
.init(params = {}) ⇒ Object
15 16 17 18 |
# File 'lib/ngrok/tunnel.rb', line 15 def init(params = {}) @params = {port: 3001, timeout: 10, config: '/dev/null'}.merge(params) @status = :stopped unless @status end |
.log ⇒ Object
56 57 58 |
# File 'lib/ngrok/tunnel.rb', line 56 def log @params[:log] end |
.port ⇒ Object
52 53 54 |
# File 'lib/ngrok/tunnel.rb', line 52 def port @params[:port] end |
.running? ⇒ Boolean
44 45 46 |
# File 'lib/ngrok/tunnel.rb', line 44 def running? @status == :running end |
.start(params = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ngrok/tunnel.rb', line 20 def start(params = {}) ensure_binary init(params) if stopped? @params[:log] = (@params[:log]) ? File.open(@params[:log], 'w+') : Tempfile.new('ngrok') @pid = spawn("exec ngrok http " + ngrok_exec_params) at_exit { Ngrok::Tunnel.stop } fetch_urls end @status = :running @ngrok_url end |
.stop ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/ngrok/tunnel.rb', line 35 def stop if running? Process.kill(9, @pid) @ngrok_url = @ngrok_url_https = @pid = nil @status = :stopped end @status end |
.stopped? ⇒ Boolean
48 49 50 |
# File 'lib/ngrok/tunnel.rb', line 48 def stopped? @status == :stopped end |
.subdomain ⇒ Object
60 61 62 |
# File 'lib/ngrok/tunnel.rb', line 60 def subdomain @params[:subdomain] end |