puma-ngrok-tunnel 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +10 -0
- data/.travis.yml +4 -1
- data/CHANGELOG.md +9 -3
- data/Gemfile +2 -0
- data/README.md +23 -21
- data/Rakefile +8 -6
- data/lib/puma-ngrok-tunnel/version.rb +3 -1
- data/lib/puma/plugin/ngrok_tunnel.rb +16 -8
- data/puma-ngrok-tunnel.gemspec +13 -9
- metadata +37 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65b1ce3120be08b61f95a94b6ffc3487022f20cdb2627f3a926d088c1623e99b
|
4
|
+
data.tar.gz: e23605a56aff5a764b6121b4c65f679ed874e3de223dc02488b8e44dcab525bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5440af3101fd81aec45f3690ebf57e3a49f7d0bffa09877cdcc3c8cb37fc1fddf288ea19ad3b08a14690306f68c5bc4331b7c7d20bbcd982b02251700e0812c
|
7
|
+
data.tar.gz: 480f373d71ff8e79687fbdecac7f7ea95b6149d13822a922f89baae0ed072c34ced8738c98e4e7f8daa9ef13c665fef8952ac2c0e997a415db95752f4bffc83d
|
data/.rubocop.yml
ADDED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,16 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.1.2
|
4
|
+
|
5
|
+
* Setting minimum ruby version to be 2.3
|
6
|
+
* Tided up the code with Robocop
|
7
|
+
* Added various to the repo.
|
8
|
+
|
3
9
|
## 0.1.1
|
4
10
|
|
5
|
-
*
|
6
|
-
* Adding more examples to docs.
|
11
|
+
* Improving mechanism for the tunnel being closed when rails is restarted, namely when `touch tmp/restart.txt` is used. This is based on [puma-metrics](https://github.com/harmjanblok/puma-metrics/blob/master/lib/puma/plugin/metrics.rb)
|
12
|
+
* Adding more examples to docs.
|
7
13
|
|
8
14
|
## 0.1.0
|
9
15
|
|
10
|
-
* Initial Release
|
16
|
+
* Initial Release
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,15 +1,18 @@
|
|
1
|
-
# puma-ngrok-tunnel
|
2
|
-
|
3
1
|
[![Gem Version](https://badge.fury.io/rb/puma-ngrok-tunnel.svg)](https://badge.fury.io/rb/puma-ngrok-tunnel)
|
2
|
+
[![Build Status](https://travis-ci.org/MikeRogers0/puma-ngrok-tunnel.svg?branch=master)](https://travis-ci.org/MikeRogers0/puma-ngrok-tunnel)
|
3
|
+
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/90680257c9dd4613a36ec3ac890e3559)](https://www.codacy.com/app/MikeRogers0/puma-ngrok-tunnel?utm_source=github.com&utm_medium=referral&utm_content=MikeRogers0/puma-ngrok-tunnel&utm_campaign=Badge_Grade)
|
4
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/c5710efd4dc1f90c7487/maintainability)](https://codeclimate.com/github/MikeRogers0/puma-ngrok-tunnel/maintainability)
|
5
|
+
|
6
|
+
# puma-ngrok-tunnel
|
4
7
|
|
5
8
|
![image](https://user-images.githubusercontent.com/325384/57193363-1d2c4800-6f32-11e9-82a4-1efc54fac0ad.png)
|
6
9
|
|
7
10
|
A plugin for puma that'll start a [ngrok tunnel](https://ngrok.com/) to your rails server when puma starts. Primary I built this to make the following a little easier:
|
8
11
|
|
9
|
-
* Working with apps that require Webhooks to be received by the app to work correctly
|
10
|
-
* Demoing your local rails app to someone else without have to share IPs
|
11
|
-
* Working with [Puma-dev](https://github.com/puma/puma-dev/) so your apps feels as production-like as possible.
|
12
|
-
* Testing on mobile.
|
12
|
+
* Working with apps that require Webhooks to be received by the app to work correctly
|
13
|
+
* Demoing your local rails app to someone else without have to share IPs
|
14
|
+
* Working with [Puma-dev](https://github.com/puma/puma-dev/) so your apps feels as production-like as possible.
|
15
|
+
* Testing on mobile.
|
13
16
|
|
14
17
|
I've setup a [sample Rails 6 app](https://github.com/MikeRogers0/puma-ngrok-tunnel-SampleRails6App) that demos an implementation of this gem.
|
15
18
|
|
@@ -17,7 +20,8 @@ I've setup a [sample Rails 6 app](https://github.com/MikeRogers0/puma-ngrok-tunn
|
|
17
20
|
|
18
21
|
Make sure you have installed ngrok on your machine:
|
19
22
|
|
20
|
-
$ brew
|
23
|
+
$ brew tap caskroom/cask
|
24
|
+
$ brew cask install ngrok
|
21
25
|
|
22
26
|
Add this line to your application's Gemfile:
|
23
27
|
|
@@ -33,29 +37,28 @@ And then execute:
|
|
33
37
|
|
34
38
|
Lastly in your `config/puma.rb` file, append the line:
|
35
39
|
|
36
|
-
|
37
40
|
```ruby
|
38
41
|
plugin :ngrok_tunnel if ENV.fetch('RAILS_ENV') { 'development' } == 'development'
|
39
42
|
```
|
40
43
|
|
41
44
|
## Usage
|
42
45
|
|
43
|
-
Read about how to configure puma to use this
|
46
|
+
Read about how to configure puma to use this in [the Puma documentation](https://github.com/puma/puma#plugins).
|
44
47
|
|
45
48
|
There are a few variables this plugin reads from the environment which control its behavior. These are based on the arguments you'd pass to the [ngrok terminal command](https://ngrok.com/docs#http-subdomain).
|
46
49
|
|
47
|
-
* `PORT` - Optional, your rails port, defaults to `3000`. If `NGROK_ADDR` is set, this is ignored.
|
48
|
-
* `NGROK_ADDR` - Optional, if you're using Puma-dev set this to be your hostname & port, e.g. `my-app-name.test:443`.
|
49
|
-
* `NGROK_AUTHTOKEN` - Optional, your ngrok authtoken. If you have ngrok configured on your local machine you don't need this.
|
50
|
-
* `NGROK_HOST_HEADER` - Optional, if you're using Puma-dev you should set this to your virtual host e.g. `my-app-name.test`.
|
51
|
-
* `NGROK_CONFIG` - Optional, your ngrok configuration file location, defaults to `~/.ngrok2/ngrok.yml`.
|
52
|
-
* `NGROK_SUBDOMAIN` - Optional, ngrok will assign you a random subdomain unless this is set.
|
53
|
-
* `NGROK_REGION` - Optional, the region of your ngrok tunnel. defaults to `us`.
|
54
|
-
* `NGROK_HOSTNAME` - Optional, full ngrok hostname, shouldn't be set if `NGROK_SUBDOMAIN` is set.
|
50
|
+
* `PORT` - Optional, your rails port, defaults to `3000`. If `NGROK_ADDR` is set, this is ignored.
|
51
|
+
* `NGROK_ADDR` - Optional, if you're using Puma-dev set this to be your hostname & port, e.g. `my-app-name.test:443`.
|
52
|
+
* `NGROK_AUTHTOKEN` - Optional, your ngrok authtoken. If you have ngrok configured on your local machine you don't need this.
|
53
|
+
* `NGROK_HOST_HEADER` - Optional, if you're using Puma-dev you should set this to your virtual host e.g. `my-app-name.test`.
|
54
|
+
* `NGROK_CONFIG` - Optional, your ngrok configuration file location, defaults to `~/.ngrok2/ngrok.yml`.
|
55
|
+
* `NGROK_SUBDOMAIN` - Optional, ngrok will assign you a random subdomain unless this is set.
|
56
|
+
* `NGROK_REGION` - Optional, the region of your ngrok tunnel. defaults to `us`.
|
57
|
+
* `NGROK_HOSTNAME` - Optional, full ngrok hostname, shouldn't be set if `NGROK_SUBDOMAIN` is set.
|
55
58
|
|
56
59
|
### Sample .env for use with `rails s`
|
57
60
|
|
58
|
-
```
|
61
|
+
```bash
|
59
62
|
# puma-ngrok-tunnel setup
|
60
63
|
# You need https://github.com/bkeepers/dotenv setup to make sure Puma can use these.
|
61
64
|
export NGROK_TUNNEL_ENABLED=true
|
@@ -65,7 +68,7 @@ export NGROK_REGION=eu
|
|
65
68
|
|
66
69
|
### Sample .env for use with Puma-dev
|
67
70
|
|
68
|
-
```
|
71
|
+
```bash
|
69
72
|
# Puma-dev: You need to define this otherwise it uses it's own puma.rb file.
|
70
73
|
CONFIG=config/puma.rb
|
71
74
|
|
@@ -92,7 +95,7 @@ in your terminal.
|
|
92
95
|
|
93
96
|
If you seeing an error like:
|
94
97
|
|
95
|
-
```
|
98
|
+
```ruby
|
96
99
|
Blocked host: a620ba29.ngrok.io
|
97
100
|
To allow requests to a620ba29.ngrok.io, add the following to your environment configuration:
|
98
101
|
config.hosts << "a620ba29.ngrok.io"
|
@@ -113,4 +116,3 @@ This will whitelist the ngrok subdomain to access your rails host.
|
|
113
116
|
## License
|
114
117
|
|
115
118
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
116
|
-
|
data/Rakefile
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rake/testtask'
|
3
5
|
|
4
6
|
Rake::TestTask.new(:test) do |t|
|
5
|
-
t.libs <<
|
6
|
-
t.libs <<
|
7
|
-
t.test_files = FileList[
|
7
|
+
t.libs << 'test'
|
8
|
+
t.libs << 'lib'
|
9
|
+
t.test_files = FileList['test/**/*_test.rb']
|
8
10
|
end
|
9
11
|
|
10
|
-
task :
|
12
|
+
task default: :test
|
@@ -1,22 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'ngrok/tunnel'
|
1
3
|
|
2
4
|
Puma::Plugin.create do
|
3
5
|
def start(launcher)
|
4
6
|
puts '[puma-ngrok-tunnel] Starting'
|
5
7
|
|
6
|
-
require 'ngrok/tunnel'
|
7
|
-
|
8
8
|
launcher.events.register(:state) do |state|
|
9
|
-
if %i[halt restart stop].include?(state)
|
10
|
-
if Ngrok::Tunnel.running?
|
11
|
-
puts '[puma-ngrok-tunnel] Stopping'
|
12
|
-
Ngrok::Tunnel.stop
|
13
|
-
end
|
14
|
-
end
|
9
|
+
ngrok_stop! if %i[halt restart stop].include?(state)
|
15
10
|
end
|
16
11
|
|
12
|
+
ngrok_start!
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def ngrok_start!
|
17
18
|
puts '[puma-ngrok-tunnel] Tunneling at: ' + Ngrok::Tunnel.start(options)
|
18
19
|
end
|
19
20
|
|
21
|
+
def ngrok_stop!
|
22
|
+
return unless Ngrok::Tunnel.running?
|
23
|
+
|
24
|
+
puts '[puma-ngrok-tunnel] Stopping'
|
25
|
+
Ngrok::Tunnel.stop
|
26
|
+
end
|
27
|
+
|
20
28
|
def options
|
21
29
|
@options ||= {
|
22
30
|
addr: ENV.fetch('NGROK_ADDR') { nil } || ENV.fetch('PORT') { 3000 },
|
data/puma-ngrok-tunnel.gemspec
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require "puma-ngrok-tunnel/version"
|
1
|
+
# frozen_string_literal: true
|
4
2
|
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'puma-ngrok-tunnel/version'
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
8
|
spec.name = 'puma-ngrok-tunnel'
|
@@ -17,22 +18,25 @@ Gem::Specification.new do |spec|
|
|
17
18
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
19
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
20
|
if spec.respond_to?(:metadata)
|
20
|
-
spec.metadata[
|
21
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
21
22
|
else
|
22
|
-
raise
|
23
|
-
|
23
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
24
|
+
'public gem pushes.'
|
24
25
|
end
|
25
26
|
|
26
27
|
# Specify which files should be added to the gem when it is released.
|
27
28
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
28
|
-
spec.files
|
29
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
29
30
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
30
31
|
end
|
31
32
|
spec.require_paths = ['lib']
|
33
|
+
spec.required_ruby_version = '>= 2.3'
|
32
34
|
|
33
35
|
spec.add_runtime_dependency 'ngrok-tunnel', '~> 2.1', '>= 2.1.1'
|
34
36
|
spec.add_runtime_dependency 'puma', '~> 3.0'
|
35
37
|
|
36
|
-
spec.add_development_dependency 'bundler', '~>
|
37
|
-
spec.add_development_dependency '
|
38
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
39
|
+
spec.add_development_dependency 'minitest', '~> 5.0'
|
40
|
+
spec.add_development_dependency 'rake', '~> 12.3'
|
41
|
+
spec.add_development_dependency 'simplecov', '~> 0.16.1'
|
38
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puma-ngrok-tunnel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Rogers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ngrok-tunnel
|
@@ -50,28 +50,56 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
53
|
+
version: '2.0'
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
60
|
+
version: '2.0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: minitest
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '5.0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '5.0'
|
61
75
|
- !ruby/object:Gem::Dependency
|
62
76
|
name: rake
|
63
77
|
requirement: !ruby/object:Gem::Requirement
|
64
78
|
requirements:
|
65
79
|
- - "~>"
|
66
80
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
81
|
+
version: '12.3'
|
68
82
|
type: :development
|
69
83
|
prerelease: false
|
70
84
|
version_requirements: !ruby/object:Gem::Requirement
|
71
85
|
requirements:
|
72
86
|
- - "~>"
|
73
87
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
88
|
+
version: '12.3'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: simplecov
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 0.16.1
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 0.16.1
|
75
103
|
description: A Puma plugin that opens a ngrok tunnel after the rails server starts
|
76
104
|
email:
|
77
105
|
- me@mikerogers.io
|
@@ -80,6 +108,7 @@ extensions: []
|
|
80
108
|
extra_rdoc_files: []
|
81
109
|
files:
|
82
110
|
- ".gitignore"
|
111
|
+
- ".rubocop.yml"
|
83
112
|
- ".travis.yml"
|
84
113
|
- CHANGELOG.md
|
85
114
|
- Gemfile
|
@@ -102,15 +131,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
131
|
requirements:
|
103
132
|
- - ">="
|
104
133
|
- !ruby/object:Gem::Version
|
105
|
-
version: '
|
134
|
+
version: '2.3'
|
106
135
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
136
|
requirements:
|
108
137
|
- - ">="
|
109
138
|
- !ruby/object:Gem::Version
|
110
139
|
version: '0'
|
111
140
|
requirements: []
|
112
|
-
|
113
|
-
rubygems_version: 2.7.6
|
141
|
+
rubygems_version: 3.0.3
|
114
142
|
signing_key:
|
115
143
|
specification_version: 4
|
116
144
|
summary: Puma integration for starting a Ngrok Tunnel
|