ngrok-tunnel 2.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4744a8f70e339c7390520de791b624d36c167b4f
4
- data.tar.gz: 51739d7cdb5f89fd86d7cfb6376571d563b12cc9
3
+ metadata.gz: 4d13e641f1a360b61919ea2b25fbe2756fc17a79
4
+ data.tar.gz: ccf64005f90a0bc710ba7163ed54d93f6b5b39df
5
5
  SHA512:
6
- metadata.gz: 966afd8e4d1b6f87438ba320d5c06f4229b65981470f345245c0694b0028041e00da2a6de0a1f98079478b4f30f9dc2a5c6e729401c3b21bf5d790dcecfe5e24
7
- data.tar.gz: 2ebf404553a5d007937b7bbf35e10f45e4d3932b8d8e09ffb18f4897ace33d7d485d8ec3f425ed9cffec0cde8919c40da62778c5a895f4e9ca966498ee9fcb0b
6
+ metadata.gz: 81b37596784331467111f41936c68840db91501c75e9f81b16563e444e97ab4e57ea220e608f79f9d6f46bd36a2e38c55836f962f0c5276672d0d0c41b2d57ea
7
+ data.tar.gz: b733920ba70cdd3f2654deb568509e2e37002c2abcd1a50213d1e8ae48b3236c7888a9d5bcdde468821bfd1ad57bd97908253585da9ace4f9e4d94a9a5c4bcd7
@@ -1,3 +1,8 @@
1
+ ## 2.1.1
2
+
3
+ - Added support for `region` parameter
4
+ - Added support for `host-header` parameter
5
+
1
6
  ## 2.1.0
2
7
 
3
8
  - Added support for non-local server using `addr` parameter
data/README.md CHANGED
@@ -73,6 +73,13 @@ Ngrok::Tunnel.start(addr: 'foo.dev:80',
73
73
 
74
74
  ```
75
75
 
76
+ ### With Rails (Rack server)
77
+
78
+ See [examples/rack-server.rb](examples/rack-server.rb) to get an idea how to use it along with a Rack server so that it automatically starts and stops when a Rack server does.
79
+
80
+ ### With RSpec and Capybara
81
+
82
+ Use this gem: [ngrok-rspec](https://github.com/bogdanovich/ngrok-rspec)
76
83
 
77
84
  ## Contributing
78
85
 
@@ -0,0 +1,20 @@
1
+ # Add these to the end of a configuration file of your prefered web-server,
2
+ # e.g. config/puma.rb, config/unicorn.rb, or config/thin.rb
3
+ # Use ./.ngrok or ~/.ngrok as a config file. Don't forget to add it to `.gitignore' in the former case.
4
+ # Set NGROK_INSPECT=false to disable the inspector web-server.
5
+ unless ENV['RAILS_ENV'] == 'production'
6
+ require 'ngrok/tunnel'
7
+ options = {addr: ENV['PORT']}
8
+ if File.file? '.ngrok'
9
+ options[:config] = '.ngrok'
10
+ elsif File.file? ENV['HOME'] + '/.ngrok'
11
+ options[:config] = ENV['HOME'] + '/.ngrok'
12
+ end
13
+ if ENV['NGROK_INSPECT']
14
+ options[:inspect] = ENV['NGROK_INSPECT']
15
+ end
16
+ puts "[NGROK] tunneling at " + Ngrok::Tunnel.start(options)
17
+ unless ENV['NGROK_INSPECT'] == 'false'
18
+ puts "[NGROK] inspector web interface listening at http://127.0.0.1:4040"
19
+ end
20
+ end
@@ -81,6 +81,8 @@ module Ngrok
81
81
 
82
82
  def ngrok_exec_params
83
83
  exec_params = "-log=stdout -log-level=debug "
84
+ exec_params << "-region=#{@params[:region]} " if @params[:region]
85
+ exec_params << "-host-header=#{@params[:host_header]} " if @params[:host_header]
84
86
  exec_params << "-authtoken=#{@params[:authtoken]} " if @params[:authtoken]
85
87
  exec_params << "-subdomain=#{@params[:subdomain]} " if @params[:subdomain]
86
88
  exec_params << "-hostname=#{@params[:hostname]} " if @params[:hostname]
@@ -1,5 +1,5 @@
1
1
  module Ngrok
2
2
  class Tunnel
3
- VERSION = "2.1.0"
3
+ VERSION = "2.1.1"
4
4
  end
5
5
  end
@@ -2,64 +2,61 @@ describe Ngrok::Tunnel do
2
2
 
3
3
  describe "Before start" do
4
4
 
5
- it "should not be running" do
5
+ it "is not running" do
6
6
  expect(Ngrok::Tunnel.running?).to be false
7
7
  end
8
8
 
9
- it "should be stopped" do
9
+ it "is stopped" do
10
10
  expect(Ngrok::Tunnel.stopped?).to be true
11
11
  end
12
12
 
13
- it "should have status = :stopped" do
13
+ it "has :stopped status" do
14
14
  expect(Ngrok::Tunnel.status).to eq :stopped
15
15
  end
16
16
 
17
17
  end
18
18
 
19
- describe "Run process" do
19
+ describe "After start" do
20
20
 
21
- before(:all) do
22
- Ngrok::Tunnel.start
23
- end
24
-
25
- after(:all) { Ngrok::Tunnel.stop }
21
+ before(:all) { Ngrok::Tunnel.start }
22
+ after(:all) { Ngrok::Tunnel.stop }
26
23
 
27
- it "should be running" do
24
+ it "is running" do
28
25
  expect(Ngrok::Tunnel.running?).to be true
29
26
  end
30
27
 
31
- it "should not be stopped" do
28
+ it "is not stopped" do
32
29
  expect(Ngrok::Tunnel.stopped?).to be false
33
30
  end
34
31
 
35
- it "should have status = :running" do
32
+ it "has :running status" do
36
33
  expect(Ngrok::Tunnel.status).to eq :running
37
34
  end
38
35
 
39
- it "should still support port" do
36
+ it "has correct port property" do
40
37
  expect(Ngrok::Tunnel.port).to eq(3001)
41
38
  end
42
39
 
43
- it "should match local_addr" do
40
+ it "has correct addr property" do
44
41
  expect(Ngrok::Tunnel.addr).to eq(3001)
45
42
  end
46
43
 
47
- it "should have valid ngrok_url" do
44
+ it "has valid ngrok_url" do
48
45
  expect(Ngrok::Tunnel.ngrok_url).to be =~ /http:\/\/.*ngrok\.io$/
49
46
  end
50
47
 
51
- it "should have valid ngrok_url_https" do
48
+ it "has valid ngrok_url_https" do
52
49
  expect(Ngrok::Tunnel.ngrok_url_https).to be =~ /https:\/\/.*ngrok\.io$/
53
50
  end
54
51
 
55
- it "should have pid > 0" do
52
+ it "has correct pid property" do
56
53
  expect(Ngrok::Tunnel.pid).to be > 0
57
54
  end
58
55
 
59
56
  end
60
57
 
61
58
  describe "Custom log file" do
62
- it "should be able to use custom log file" do
59
+ it "uses custom log file" do
63
60
  Ngrok::Tunnel.start(log: 'test.log')
64
61
  expect(Ngrok::Tunnel.running?).to eq true
65
62
  expect(Ngrok::Tunnel.log.path).to eq 'test.log'
@@ -69,41 +66,41 @@ describe Ngrok::Tunnel do
69
66
  end
70
67
 
71
68
  describe "Custom subdomain" do
72
- it "should fail without authtoken" do
69
+ it "fails without authtoken" do
73
70
  expect {Ngrok::Tunnel.start(subdomain: 'test-subdomain')}.to raise_error Ngrok::Error
74
71
  end
75
72
 
76
- it "should fail with incorrect authtoken" do
73
+ it "fails with incorrect authtoken" do
77
74
  expect {Ngrok::Tunnel.start(subdomain: 'test-subdomain', authtoken: 'incorrect_token')}.to raise_error Ngrok::Error
78
75
  end
79
76
  end
80
77
 
81
78
  describe "Custom hostname" do
82
- it "should fail without authtoken" do
79
+ it "fails without authtoken" do
83
80
  expect {Ngrok::Tunnel.start(hostname: 'example.com')}.to raise_error Ngrok::Error
84
81
  end
85
82
 
86
- it "should fail with incorrect authtoken" do
83
+ it "fails with incorrect authtoken" do
87
84
  expect {Ngrok::Tunnel.start(hostname: 'example.com', authtoken: 'incorrect_token')}.to raise_error Ngrok::Error
88
85
  end
89
86
  end
90
87
 
91
88
  describe "Custom addr" do
92
- it "should map port param to addr" do
89
+ it "maps port param to addr" do
93
90
  port = 10010
94
91
  Ngrok::Tunnel.start(port: port)
95
92
  expect(Ngrok::Tunnel.addr).to eq port
96
93
  Ngrok::Tunnel.stop
97
94
  end
98
95
 
99
- it "should return just the port when the address contains a host" do
96
+ it "returns just the port when the address contains a host" do
100
97
  addr = '192.168.0.5:10010'
101
98
  Ngrok::Tunnel.start(addr: addr)
102
99
  expect(Ngrok::Tunnel.port).to eq 10010
103
100
  Ngrok::Tunnel.stop
104
101
  end
105
102
 
106
- it "should support remote addresses" do
103
+ it "supports remote addresses" do
107
104
  addr = '192.168.0.5:10010'
108
105
  Ngrok::Tunnel.start(addr: addr)
109
106
  expect(Ngrok::Tunnel.addr).to eq addr
@@ -111,22 +108,51 @@ describe Ngrok::Tunnel do
111
108
  end
112
109
  end
113
110
 
111
+ describe "Custom region" do
112
+ it "doesn't include the -region parameter when it is not provided" do
113
+ Ngrok::Tunnel.start()
114
+ expect(Ngrok::Tunnel.send(:ngrok_exec_params)).not_to include("-region=")
115
+ Ngrok::Tunnel.stop
116
+ end
117
+
118
+ it "includes the -region parameter with the correct value when it is provided" do
119
+ region = 'eu'
120
+ Ngrok::Tunnel.start(region: region)
121
+ expect(Ngrok::Tunnel.send(:ngrok_exec_params)).to include("-region=#{region}")
122
+ Ngrok::Tunnel.stop
123
+ end
124
+ end
125
+
126
+ describe "Custom host header" do
127
+ it "doesn't include the -host-header parameter when it is not provided" do
128
+ Ngrok::Tunnel.start()
129
+ expect(Ngrok::Tunnel.send(:ngrok_exec_params)).not_to include("-host-header=")
130
+ Ngrok::Tunnel.stop
131
+ end
132
+
133
+ it "includes the -host-header parameter with the correct value when it is provided" do
134
+ host_header = 'foo.bar'
135
+ Ngrok::Tunnel.start(host_header: host_header)
136
+ expect(Ngrok::Tunnel.send(:ngrok_exec_params)).to include("-host-header=#{host_header}")
137
+ Ngrok::Tunnel.stop
138
+ end
139
+ end
140
+
114
141
  describe "Custom parameters provided" do
115
- it "should not include the -inspect parameter when it is not provided" do
142
+ it "doesn't include the -inspect parameter when it is not provided" do
116
143
  Ngrok::Tunnel.start()
117
- expect(Ngrok::Tunnel.send(:ngrok_exec_params).include? "-inspect=").to be false
144
+ expect(Ngrok::Tunnel.send(:ngrok_exec_params)).not_to include("-inspect=")
118
145
  Ngrok::Tunnel.stop
119
146
  end
120
147
 
121
- it "should include the -inspect parameter with the correct value when it is provided" do
148
+ it "includes the -inspect parameter with the correct value when it is provided" do
122
149
  Ngrok::Tunnel.start(inspect: true)
123
- expect(Ngrok::Tunnel.send(:ngrok_exec_params).include? "-inspect=true").to be true
150
+ expect(Ngrok::Tunnel.send(:ngrok_exec_params)).to include("-inspect=true")
124
151
  Ngrok::Tunnel.stop
125
152
 
126
153
  Ngrok::Tunnel.start(inspect: false)
127
- expect(Ngrok::Tunnel.send(:ngrok_exec_params).include? "-inspect=false").to be true
154
+ expect(Ngrok::Tunnel.send(:ngrok_exec_params)).to include("-inspect=false")
128
155
  Ngrok::Tunnel.stop
129
156
  end
130
157
  end
131
-
132
158
  end
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ngrok-tunnel
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Bogdanovich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-12 00:00:00.000000000 Z
11
+ date: 2018-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.10'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.10'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: pry-byebug
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '2.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '3.1'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.1'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.7'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.7'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '10.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '10.0'
83
83
  description: Ngrok-tunnel gem is a ruby wrapper for ngrok
@@ -87,13 +87,14 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - .gitignore
91
- - .rspec
90
+ - ".gitignore"
91
+ - ".rspec"
92
92
  - CHANGELOG.md
93
93
  - Gemfile
94
94
  - LICENSE.txt
95
95
  - README.md
96
96
  - Rakefile
97
+ - examples/rack-server.rb
97
98
  - lib/ngrok/tunnel.rb
98
99
  - lib/ngrok/tunnel/version.rb
99
100
  - ngrok-tunnel.gemspec
@@ -109,21 +110,20 @@ require_paths:
109
110
  - lib
110
111
  required_ruby_version: !ruby/object:Gem::Requirement
111
112
  requirements:
112
- - - '>='
113
+ - - ">="
113
114
  - !ruby/object:Gem::Version
114
115
  version: '0'
115
116
  required_rubygems_version: !ruby/object:Gem::Requirement
116
117
  requirements:
117
- - - '>='
118
+ - - ">="
118
119
  - !ruby/object:Gem::Version
119
120
  version: '0'
120
121
  requirements: []
121
122
  rubyforge_project:
122
- rubygems_version: 2.2.2
123
+ rubygems_version: 2.5.1
123
124
  signing_key:
124
125
  specification_version: 4
125
126
  summary: Ngrok-tunnel gem is a ruby wrapper for ngrok
126
127
  test_files:
127
128
  - spec/spec_helper.rb
128
129
  - spec/tunnel/tunnel_spec.rb
129
- has_rdoc: