ngrok-tunnel 2.0.21 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 48b412799e8a113e374412c2a68da389ee04c49c
4
- data.tar.gz: aeabe2d6f25eb6224646762dc478b29c0bfcbd34
3
+ metadata.gz: 4744a8f70e339c7390520de791b624d36c167b4f
4
+ data.tar.gz: 51739d7cdb5f89fd86d7cfb6376571d563b12cc9
5
5
  SHA512:
6
- metadata.gz: cbb75e5b3c6eaa23504eebdba9d7498831bfac45ce3a1abc01c58c1ce7ac12ec5ce1fcc6a67cd94f22544df686f4d3b7a2701c1353e15a2d57f57dbe9371546f
7
- data.tar.gz: 05901e60c7d2ab019c127b958f903385c6f9fed6a3ffe0c837def7f284b27b7b5d22a80702c600d6ae38e9a22d0295cc90df32e2815f2f9101aec69c4d154727
6
+ metadata.gz: 966afd8e4d1b6f87438ba320d5c06f4229b65981470f345245c0694b0028041e00da2a6de0a1f98079478b4f30f9dc2a5c6e729401c3b21bf5d790dcecfe5e24
7
+ data.tar.gz: 2ebf404553a5d007937b7bbf35e10f45e4d3932b8d8e09ffb18f4897ace33d7d485d8ec3f425ed9cffec0cde8919c40da62778c5a895f4e9ca966498ee9fcb0b
data/.gitignore CHANGED
@@ -12,3 +12,4 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
+ test.log
@@ -1,3 +1,7 @@
1
+ ## 2.1.0
2
+
3
+ - Added support for non-local server using `addr` parameter
4
+
1
5
  ## 2.0.21
2
6
 
3
7
  - Added support for -inspect option
data/README.md CHANGED
@@ -36,10 +36,10 @@ Ngrok::Tunnel.port
36
36
 
37
37
  # ngrok external url
38
38
  Ngrok::Tunnel.ngrok_url
39
- => "http://aaa0e65.ngrok.com"
39
+ => "http://aaa0e65.ngrok.io"
40
40
 
41
41
  Ngrok::Tunnel.ngrok_url_https
42
- => "https://aaa0e65.ngrok.com"
42
+ => "https://aaa0e65.ngrok.io"
43
43
 
44
44
  Ngrok::Tunnel.running?
45
45
  => true
@@ -63,7 +63,7 @@ Ngrok::Tunnel.stop
63
63
 
64
64
  ```ruby
65
65
  # ngrok custom parameters
66
- Ngrok::Tunnel.start(port: 3333,
66
+ Ngrok::Tunnel.start(addr: 'foo.dev:80',
67
67
  subdomain: 'MY_SUBDOMAIN',
68
68
  hostname: 'MY_HOSTNAME',
69
69
  authtoken: 'MY_TOKEN',
@@ -13,7 +13,10 @@ module Ngrok
13
13
  attr_reader :pid, :ngrok_url, :ngrok_url_https, :status
14
14
 
15
15
  def init(params = {})
16
- @params = {port: 3001, timeout: 10, config: '/dev/null'}.merge(params)
16
+ # map old key 'port' to 'addr' to maintain backwards compatibility with versions 2.0.21 and earlier
17
+ params[:addr] = params.delete(:port) if params.key?(:port)
18
+
19
+ @params = {addr: 3001, timeout: 10, config: '/dev/null'}.merge(params)
17
20
  @status = :stopped unless @status
18
21
  end
19
22
 
@@ -49,8 +52,13 @@ module Ngrok
49
52
  @status == :stopped
50
53
  end
51
54
 
55
+ def addr
56
+ @params[:addr]
57
+ end
58
+
52
59
  def port
53
- @params[:port]
60
+ return addr if addr.is_a?(Numeric)
61
+ addr.split(":").last.to_i
54
62
  end
55
63
 
56
64
  def log
@@ -77,7 +85,7 @@ module Ngrok
77
85
  exec_params << "-subdomain=#{@params[:subdomain]} " if @params[:subdomain]
78
86
  exec_params << "-hostname=#{@params[:hostname]} " if @params[:hostname]
79
87
  exec_params << "-inspect=#{@params[:inspect]} " if @params.has_key? :inspect
80
- exec_params << "-config=#{@params[:config]} #{@params[:port].to_i} > #{@params[:log].path}"
88
+ exec_params << "-config=#{@params[:config]} #{@params[:addr]} > #{@params[:log].path}"
81
89
  end
82
90
 
83
91
  def fetch_urls
@@ -1,5 +1,5 @@
1
1
  module Ngrok
2
2
  class Tunnel
3
- VERSION = "2.0.21"
3
+ VERSION = "2.1.0"
4
4
  end
5
5
  end
@@ -1,4 +1,3 @@
1
-
2
1
  describe Ngrok::Tunnel do
3
2
 
4
3
  describe "Before start" do
@@ -37,10 +36,14 @@ describe Ngrok::Tunnel do
37
36
  expect(Ngrok::Tunnel.status).to eq :running
38
37
  end
39
38
 
40
- it "should match local_port" do
39
+ it "should still support port" do
41
40
  expect(Ngrok::Tunnel.port).to eq(3001)
42
41
  end
43
42
 
43
+ it "should match local_addr" do
44
+ expect(Ngrok::Tunnel.addr).to eq(3001)
45
+ end
46
+
44
47
  it "should have valid ngrok_url" do
45
48
  expect(Ngrok::Tunnel.ngrok_url).to be =~ /http:\/\/.*ngrok\.io$/
46
49
  end
@@ -67,21 +70,44 @@ describe Ngrok::Tunnel do
67
70
 
68
71
  describe "Custom subdomain" do
69
72
  it "should fail without authtoken" do
70
- expect {Ngrok::Tunnel.start(subdomain: 'test-subdomain')}.to raise_error
73
+ expect {Ngrok::Tunnel.start(subdomain: 'test-subdomain')}.to raise_error Ngrok::Error
71
74
  end
72
75
 
73
76
  it "should fail with incorrect authtoken" do
74
- expect {Ngrok::Tunnel.start(subdomain: 'test-subdomain', authtoken: 'incorrect_token')}.to raise_error
77
+ expect {Ngrok::Tunnel.start(subdomain: 'test-subdomain', authtoken: 'incorrect_token')}.to raise_error Ngrok::Error
75
78
  end
76
79
  end
77
80
 
78
81
  describe "Custom hostname" do
79
82
  it "should fail without authtoken" do
80
- expect {Ngrok::Tunnel.start(hostname: 'example.com')}.to raise_error
83
+ expect {Ngrok::Tunnel.start(hostname: 'example.com')}.to raise_error Ngrok::Error
81
84
  end
82
85
 
83
86
  it "should fail with incorrect authtoken" do
84
- expect {Ngrok::Tunnel.start(hostname: 'example.com', authtoken: 'incorrect_token')}.to raise_error
87
+ expect {Ngrok::Tunnel.start(hostname: 'example.com', authtoken: 'incorrect_token')}.to raise_error Ngrok::Error
88
+ end
89
+ end
90
+
91
+ describe "Custom addr" do
92
+ it "should map port param to addr" do
93
+ port = 10010
94
+ Ngrok::Tunnel.start(port: port)
95
+ expect(Ngrok::Tunnel.addr).to eq port
96
+ Ngrok::Tunnel.stop
97
+ end
98
+
99
+ it "should return just the port when the address contains a host" do
100
+ addr = '192.168.0.5:10010'
101
+ Ngrok::Tunnel.start(addr: addr)
102
+ expect(Ngrok::Tunnel.port).to eq 10010
103
+ Ngrok::Tunnel.stop
104
+ end
105
+
106
+ it "should support remote addresses" do
107
+ addr = '192.168.0.5:10010'
108
+ Ngrok::Tunnel.start(addr: addr)
109
+ expect(Ngrok::Tunnel.addr).to eq addr
110
+ Ngrok::Tunnel.stop
85
111
  end
86
112
  end
87
113
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ngrok-tunnel
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.21
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Bogdanovich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-16 00:00:00.000000000 Z
11
+ date: 2016-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry