ensure_ngrok_tunnel 0.1.0 → 0.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
  SHA256:
3
- metadata.gz: b2931e7c38d85022b0b5815e48da8d78c97fc224f5ebe849d5fbe13d6948c104
4
- data.tar.gz: 4ce0716280a2584eb065aa79b11def5612107d948b7a684a887ac657bc4e0b31
3
+ metadata.gz: 3893dd2afbe621460feb6d745c2988f557ca53eff7a406cb16b7b4fc08b79ae6
4
+ data.tar.gz: 4c93098adf79cf001339f82c497d0d75658fb83fb07923a8d3626e56566238a3
5
5
  SHA512:
6
- metadata.gz: 79b4fe7d512dd8361afbcf93e43aff0f64ed0d73315d402c52dd94154a499dd6e7d04094278cf651f6adc63bda88305fc04b37af61d2cca3f33e8eb2e256dca2
7
- data.tar.gz: 370c80d3e42c43913acd13abf1022c04638a583e8728bad90525ab779c85299e60e04d6b81cac272e3327e7a35c58e5b475c6b43e64a4f0e7ee1a194ce962c97
6
+ metadata.gz: cf912fec2740449d78c69f94ea1f078215e0330d77749e59e73d490b688d692f5a14092113f5f4ad989a90c31d6123dddf92bbc2597cf36716a2e96772d50919
7
+ data.tar.gz: 72f4bd7ba897074779707ed3398fee445cd09acec9407128aa65f15c3b7314491d83e3f8b9b0d5cc5abaedd2328d90d8a00b212ccceb3d4ab3e100a14b9b0956
@@ -1,21 +1,21 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ensure_ngrok_tunnel (0.1.0)
4
+ ensure_ngrok_tunnel (0.1.1)
5
5
  json
6
6
  rest-client
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- domain_name (0.5.20170404)
11
+ domain_name (0.5.20180417)
12
12
  unf (>= 0.0.5, < 1.0.0)
13
13
  http-cookie (1.0.3)
14
14
  domain_name (~> 0.5)
15
15
  json (2.1.0)
16
- mime-types (3.1)
16
+ mime-types (3.2.2)
17
17
  mime-types-data (~> 3.2015)
18
- mime-types-data (3.2016.0521)
18
+ mime-types-data (3.2018.0812)
19
19
  netrc (0.11.0)
20
20
  rake (10.4.2)
21
21
  rest-client (2.0.2)
@@ -35,4 +35,4 @@ DEPENDENCIES
35
35
  rake (~> 10.0)
36
36
 
37
37
  BUNDLED WITH
38
- 1.16.1
38
+ 1.16.2
data/README.md CHANGED
@@ -1,9 +1,4 @@
1
1
  # EnsureNgrokTunnel
2
-
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ensure_ngrok_tunnel`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
2
  ## Installation
8
3
 
9
4
  Add this line to your application's Gemfile:
@@ -26,11 +21,13 @@ In your development.rb, call `EnsureNgrokTunnel.start` with a [valid ngrok confi
26
21
 
27
22
  To determine whether the tunnel already exists, `EnsureNgrokTunnel` just looks for any tunnel bound to the port specified by `addr` in the config, or if not set, in `ENV['PORT']`. If you are using a config that just specifies a tunnel by name, you can optionally pass the port as `port: XXXX`.
28
23
 
24
+ If an instance of ngrok is already running on the standard port (4040), `EnsureNgrokTunnel` will talk to it, otherwise it spawns one with `ngrok start --none` (this instance should die when the parent process does, though with rails development the usual spring/fs-watch shenanigans will probably occasionally result in zombied ngroks).
25
+
29
26
  `EnsureNgrokTunnel` returns the tunnel url.
30
27
 
31
28
  Example:
32
29
  ```ruby
33
- server_port = ENV.fetch('PORT')
30
+ server_port = ENV.fetch('TUNNEL_PORT')
34
31
  ngrok_url = EnsureNgrokTunnel.start(
35
32
  config: {
36
33
  name: Rails.application.class.parent.name.underscore,
@@ -46,6 +43,8 @@ Example:
46
43
  puts "[NGROK] tunneling at " + ngrok_url
47
44
  ```
48
45
 
46
+ **NOTE:** be careful about using the standard PORT env var in Rails with sidekiq. When using heroku local & a Procfile with web & worker processes, the PORT variable seems to get incremented by 100 in the worker process, which will cause `EnsureNgrokTunnel` not to find the tunnel in whichever is the second process to launch.
47
+
49
48
  ## Development
50
49
 
51
50
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["lastobelus@mac.com"]
11
11
 
12
12
  spec.summary = %q{Ensure an ngrok tunnel is started}
13
- spec.description = %q{This tiny gem has a singular tunnel: ensure there is an ngrok tunnel running for the specified port.}
13
+ spec.description = %q{This tiny gem has a singular purpose: ensure there is an ngrok tunnel running for the specified port.}
14
14
  spec.homepage = "https://github.com/lastobelus/ensure_ngrok_tunnel"
15
15
  spec.license = "MIT"
16
16
 
@@ -5,9 +5,8 @@ module EnsureNgrokTunnel
5
5
  require 'json'
6
6
  require 'open-uri'
7
7
 
8
- port ||= config['addr'] || config[:addr] || ENV.fetch("PORT")
8
+ port ||= config[:addr] || ENV.fetch("PORT")
9
9
 
10
- puts "setting up ngrok"
11
10
  ngrok_url = false
12
11
  ngrok_process = nil
13
12
  ngrok = nil
@@ -29,6 +28,7 @@ module EnsureNgrokTunnel
29
28
  end
30
29
 
31
30
  retries = 0
31
+
32
32
  begin
33
33
  ngrok = JSON.parse(ngrok)
34
34
  tunnel = ngrok['tunnels'].detect{|t| t['config']['addr'].split(':').last.to_s == port.to_s}
@@ -40,8 +40,7 @@ module EnsureNgrokTunnel
40
40
  end
41
41
  rescue
42
42
  retries += 1
43
- name = config['name'] || config['hostname'] || config['subdomain'] || ENV.fetch('DOMAIN', '????')
44
- puts "starting ngrok tunnel for #{name}"
43
+ name = config[:name] || config[:hostname] || config[:subdomain] || ENV.fetch('DOMAIN', '????')
45
44
  begin
46
45
  response = RestClient.post ngrok_url, config.to_json, {content_type: :json, accept: :json}
47
46
  rescue => e
@@ -1,3 +1,3 @@
1
1
  module EnsureNgrokTunnel
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ensure_ngrok_tunnel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Johnston
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-22 00:00:00.000000000 Z
11
+ date: 2018-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,7 +66,7 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- description: 'This tiny gem has a singular tunnel: ensure there is an ngrok tunnel
69
+ description: 'This tiny gem has a singular purpose: ensure there is an ngrok tunnel
70
70
  running for the specified port.'
71
71
  email:
72
72
  - lastobelus@mac.com
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  version: '0'
106
106
  requirements: []
107
107
  rubyforge_project:
108
- rubygems_version: 2.7.6
108
+ rubygems_version: 2.7.7
109
109
  signing_key:
110
110
  specification_version: 4
111
111
  summary: Ensure an ngrok tunnel is started