ngrok-wrapper 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.codeclimate.yml +39 -0
- data/.github/workflows/ci.yml +45 -0
- data/.github/workflows/codeql-analysis.yml +70 -0
- data/.gitignore +14 -0
- data/.rspec +3 -0
- data/.rubocop.yml +72 -0
- data/.ruby-version +1 -0
- data/.simplecov +10 -0
- data/.tool-versions +1 -0
- data/CHANGELOG.md +25 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +23 -0
- data/README.md +258 -0
- data/Rakefile +3 -0
- data/disabled.yml +26 -0
- data/enabled.yml +122 -0
- data/lib/ngrok/wrapper/version.rb +7 -0
- data/lib/ngrok/wrapper.rb +196 -0
- data/ngrok-wrapper.gemspec +37 -0
- data/sig/ngrok/wrapper.rbs +6 -0
- data/spec/fixtures/ngrok.no_auth_token.log +43 -0
- data/spec/fixtures/ngrok.sample.log +34 -0
- data/spec/fixtures/ngrok_invalid_auth_token.log +37 -0
- data/spec/ngrok/wrapper_spec.rb +356 -0
- data/spec/spec_helper.rb +23 -0
- metadata +163 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 270d9efa417c5821721519760816d3febbf085d183680ad0268a244eaec4a753
|
4
|
+
data.tar.gz: dd477aa0effed04807720dd6e22a3f607b79f88b343318c7d1674c18e573b056
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e8d752ee9ee727a5e54705e1c7d361b6babd13415a68173325df4cf4a2c7158fa37cc60920b8023e9b57b45c1ce1450325bcc17949885045ff1f1d3b9bebcb7a
|
7
|
+
data.tar.gz: 7f3e3c5404e138e6f4a01ed06c77d13f746bc977057b91494a26f98f80fa59fa2c55b992cf6bf015142e6bc38ff4fc1fcd73e5537e77018801a8b945e9b33623
|
data/.codeclimate.yml
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
version: "2"
|
2
|
+
exclude_patterns:
|
3
|
+
- "sig/**/*"
|
4
|
+
checks:
|
5
|
+
argument-count:
|
6
|
+
config:
|
7
|
+
threshold: 4
|
8
|
+
complex-logic:
|
9
|
+
config:
|
10
|
+
threshold: 4
|
11
|
+
file-lines:
|
12
|
+
config:
|
13
|
+
threshold: 300
|
14
|
+
method-complexity:
|
15
|
+
config:
|
16
|
+
threshold: 9
|
17
|
+
method-count:
|
18
|
+
config:
|
19
|
+
threshold: 20
|
20
|
+
method-lines:
|
21
|
+
config:
|
22
|
+
threshold: 25
|
23
|
+
nested-control-flow:
|
24
|
+
config:
|
25
|
+
threshold: 4
|
26
|
+
return-statements:
|
27
|
+
config:
|
28
|
+
threshold: 4
|
29
|
+
plugins:
|
30
|
+
rubocop:
|
31
|
+
enabled: true
|
32
|
+
channel: 'beta'
|
33
|
+
fixme:
|
34
|
+
enabled: true
|
35
|
+
config:
|
36
|
+
strings:
|
37
|
+
- FIXME
|
38
|
+
- BUG
|
39
|
+
- CUSTOM
|
@@ -0,0 +1,45 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ main ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ '**' ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
tests:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
strategy:
|
13
|
+
fail-fast: false
|
14
|
+
matrix:
|
15
|
+
include:
|
16
|
+
- ruby: 2.6
|
17
|
+
|
18
|
+
- ruby: 2.7
|
19
|
+
|
20
|
+
- ruby: 3.0
|
21
|
+
|
22
|
+
- ruby: 3.1
|
23
|
+
|
24
|
+
name: ruby ${{ matrix.ruby }}
|
25
|
+
|
26
|
+
steps:
|
27
|
+
- name: Checkout
|
28
|
+
uses: actions/checkout@v2
|
29
|
+
|
30
|
+
- name: Set up Ruby
|
31
|
+
uses: ruby/setup-ruby@v1
|
32
|
+
with:
|
33
|
+
ruby-version: ${{ matrix.ruby }}
|
34
|
+
bundler-cache: false
|
35
|
+
|
36
|
+
- name: Install dependencies
|
37
|
+
run: bundle install
|
38
|
+
|
39
|
+
- name: Run tests
|
40
|
+
run: bundle exec rspec
|
41
|
+
|
42
|
+
- name: Code Climate
|
43
|
+
uses: paambaati/codeclimate-action@v3.0.0
|
44
|
+
env:
|
45
|
+
CC_TEST_REPORTER_ID: d1116c05a48e27785cb11369bde3a5e7f9d9e5a114d294bcbefa19cd193b029c
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# For most projects, this workflow file will not need changing; you simply need
|
2
|
+
# to commit it to your repository.
|
3
|
+
#
|
4
|
+
# You may wish to alter this file to override the set of languages analyzed,
|
5
|
+
# or to provide custom queries or build logic.
|
6
|
+
#
|
7
|
+
# ******** NOTE ********
|
8
|
+
# We have attempted to detect the languages in your repository. Please check
|
9
|
+
# the `language` matrix defined below to confirm you have the correct set of
|
10
|
+
# supported CodeQL languages.
|
11
|
+
#
|
12
|
+
name: "CodeQL"
|
13
|
+
|
14
|
+
on:
|
15
|
+
push:
|
16
|
+
branches: [ main ]
|
17
|
+
pull_request:
|
18
|
+
# The branches below must be a subset of the branches above
|
19
|
+
branches: [ main ]
|
20
|
+
schedule:
|
21
|
+
- cron: '22 0 * * 3'
|
22
|
+
|
23
|
+
jobs:
|
24
|
+
analyze:
|
25
|
+
name: Analyze
|
26
|
+
runs-on: ubuntu-latest
|
27
|
+
permissions:
|
28
|
+
actions: read
|
29
|
+
contents: read
|
30
|
+
security-events: write
|
31
|
+
|
32
|
+
strategy:
|
33
|
+
fail-fast: false
|
34
|
+
matrix:
|
35
|
+
language: [ 'ruby' ]
|
36
|
+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
37
|
+
# Learn more about CodeQL language support at https://git.io/codeql-language-support
|
38
|
+
|
39
|
+
steps:
|
40
|
+
- name: Checkout repository
|
41
|
+
uses: actions/checkout@v2
|
42
|
+
|
43
|
+
# Initializes the CodeQL tools for scanning.
|
44
|
+
- name: Initialize CodeQL
|
45
|
+
uses: github/codeql-action/init@v1
|
46
|
+
with:
|
47
|
+
languages: ${{ matrix.language }}
|
48
|
+
# If you wish to specify custom queries, you can do so here or in a config file.
|
49
|
+
# By default, queries listed here will override any specified in a config file.
|
50
|
+
# Prefix the list here with "+" to use these queries and those in the config file.
|
51
|
+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
52
|
+
|
53
|
+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
54
|
+
# If this step fails, then you should remove it and run the build manually (see below)
|
55
|
+
- name: Autobuild
|
56
|
+
uses: github/codeql-action/autobuild@v1
|
57
|
+
|
58
|
+
# ℹ️ Command-line programs to run using the OS shell.
|
59
|
+
# 📚 https://git.io/JvXDl
|
60
|
+
|
61
|
+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
62
|
+
# and modify them (or add more) to build your code if your project
|
63
|
+
# uses a compiled language
|
64
|
+
|
65
|
+
#- run: |
|
66
|
+
# make bootstrap
|
67
|
+
# make release
|
68
|
+
|
69
|
+
- name: Perform CodeQL Analysis
|
70
|
+
uses: github/codeql-action/analyze@v1
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# This is the default configuration file. Enabling and disabling is configured
|
2
|
+
# in separate files. This file adds all other parameters apart from Enabled.
|
3
|
+
|
4
|
+
require:
|
5
|
+
- rubocop-performance
|
6
|
+
- rubocop-rspec
|
7
|
+
|
8
|
+
inherit_from:
|
9
|
+
- enabled.yml
|
10
|
+
- disabled.yml
|
11
|
+
|
12
|
+
AllCops:
|
13
|
+
# Default formatter will be used if no -f/--format option is given.
|
14
|
+
DisplayCopNames: true
|
15
|
+
# Style guide URLs are not displayed in offense messages by default. Change
|
16
|
+
# behavior by overriding DisplayStyleGuide, or by giving the
|
17
|
+
# -S/--display-style-guide option.
|
18
|
+
DisplayStyleGuide: true
|
19
|
+
# Extra details are not displayed in offense messages by default. Change
|
20
|
+
# behavior by overriding ExtraDetails, or by giving the
|
21
|
+
# -E/--extra-details option.
|
22
|
+
ExtraDetails: true
|
23
|
+
NewCops: enable
|
24
|
+
# Additional cops that do not reference a style guide rule may be enabled by
|
25
|
+
# default. Change behavior by overriding StyleGuideCopsOnly, or by giving
|
26
|
+
# the --only-guide-cops option.
|
27
|
+
TargetRubyVersion: 2.6
|
28
|
+
|
29
|
+
Layout/LineLength:
|
30
|
+
Max: 120
|
31
|
+
|
32
|
+
Metrics/AbcSize:
|
33
|
+
# The ABC size is a calculated magnitude, so this number can be a Fixnum or
|
34
|
+
# a Float.
|
35
|
+
Max: 30
|
36
|
+
|
37
|
+
Metrics/ClassLength:
|
38
|
+
CountComments: false # count full line comments?
|
39
|
+
Max: 200
|
40
|
+
|
41
|
+
Metrics/ModuleLength:
|
42
|
+
CountComments: false # count full line comments?
|
43
|
+
Max: 200
|
44
|
+
|
45
|
+
# Avoid complex methods.
|
46
|
+
Metrics/CyclomaticComplexity:
|
47
|
+
Max: 11
|
48
|
+
|
49
|
+
Metrics/MethodLength:
|
50
|
+
CountComments: false # count full line comments?
|
51
|
+
Max: 25
|
52
|
+
|
53
|
+
Metrics/PerceivedComplexity:
|
54
|
+
Max: 11
|
55
|
+
|
56
|
+
Metrics/BlockLength:
|
57
|
+
CountComments: false
|
58
|
+
Max: 100
|
59
|
+
Exclude:
|
60
|
+
- 'Rakefile'
|
61
|
+
- '**/*.rake'
|
62
|
+
- 'spec/**/*.rb'
|
63
|
+
- 'db/**/*.rb'
|
64
|
+
|
65
|
+
RSpec/MultipleExpectations:
|
66
|
+
Max: 13
|
67
|
+
|
68
|
+
RSpec/NestedGroups:
|
69
|
+
Max: 7
|
70
|
+
|
71
|
+
Style/StringLiterals:
|
72
|
+
ConsistentQuotesInMultiline: true
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.6.9
|
data/.simplecov
ADDED
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 2.6.9
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## [v0.1.0](https://github.com/texpert/ngrok-wrapper/tree/v0.1.0) (2022-01-09)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/texpert/ngrok-wrapper/compare/3e032fa019c91ee7338a7ad3a3335e6c5597b394...v0.1.0)
|
6
|
+
|
7
|
+
**Merged pull requests:**
|
8
|
+
|
9
|
+
- Added `github_changelog_generator` to the gemspec [\#14](https://github.com/texpert/ngrok-wrapper/pull/14) ([texpert](https://github.com/texpert))
|
10
|
+
- Described gem's usage in Rails, move the description from `examples` folder into README.md [\#13](https://github.com/texpert/ngrok-wrapper/pull/13) ([texpert](https://github.com/texpert))
|
11
|
+
- Fix Codeclimate rubocop channel to beta to enable latest 1-24-1 [\#11](https://github.com/texpert/ngrok-wrapper/pull/11) ([texpert](https://github.com/texpert))
|
12
|
+
- Add codeclimate fixme and rubocop plugins [\#10](https://github.com/texpert/ngrok-wrapper/pull/10) ([texpert](https://github.com/texpert))
|
13
|
+
- Decompose `fetch_urls` for maintainability [\#9](https://github.com/texpert/ngrok-wrapper/pull/9) ([texpert](https://github.com/texpert))
|
14
|
+
- Refactor `ngrok_running?` to re-use `ngrok_process_status_lines` instead of a shell process [\#8](https://github.com/texpert/ngrok-wrapper/pull/8) ([texpert](https://github.com/texpert))
|
15
|
+
- Raise if Ngrok with the pid from persistence file is running on other port [\#7](https://github.com/texpert/ngrok-wrapper/pull/7) ([texpert](https://github.com/texpert))
|
16
|
+
- Refactor DRYing `ngrok_exec_params` method [\#6](https://github.com/texpert/ngrok-wrapper/pull/6) ([texpert](https://github.com/texpert))
|
17
|
+
- Remove redundant methods and introduce `:params` read accessor [\#5](https://github.com/texpert/ngrok-wrapper/pull/5) ([texpert](https://github.com/texpert))
|
18
|
+
- Don't forget to close the log file and don't use returns in a block [\#4](https://github.com/texpert/ngrok-wrapper/pull/4) ([texpert](https://github.com/texpert))
|
19
|
+
- Fix CI setup-ruby action to use Ruby version from strategy matrix [\#3](https://github.com/texpert/ngrok-wrapper/pull/3) ([texpert](https://github.com/texpert))
|
20
|
+
- Fix CodeClimate issue Class Wrapper has 22 methods \(exceeds 20 allowed\) [\#2](https://github.com/texpert/ngrok-wrapper/pull/2) ([texpert](https://github.com/texpert))
|
21
|
+
- Fix the specs to avoid trying to run real Ngrok when testing using fixture log files [\#1](https://github.com/texpert/ngrok-wrapper/pull/1) ([texpert](https://github.com/texpert))
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Portions Copyright (c) 2022 Aureliu Brinzeanu
|
2
|
+
Portions Copyright (c) 2014-2019 Anton Bogdanovich
|
3
|
+
|
4
|
+
MIT License
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
a copy of this software and associated documentation files (the
|
8
|
+
"Software"), to deal in the Software without restriction, including
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be
|
15
|
+
included in all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,258 @@
|
|
1
|
+
# Ngrok::Wrapper
|
2
|
+
|
3
|
+
Ngrok-wrapper gem is a ruby wrapper for ngrok v2.
|
4
|
+
|
5
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/d978e217a8219326e325/maintainability)](https://codeclimate.com/github/texpert/ngrok-wrapper/maintainability)
|
6
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/d978e217a8219326e325/test_coverage)](https://codeclimate.com/github/texpert/ngrok-wrapper/test_coverage)
|
7
|
+
|
8
|
+
## History
|
9
|
+
|
10
|
+
Ngrok-wrapper is renamed from my fork of the initial awesome [Ngrok-tunnel](https://github.com/bogdanovich/ngrok-tunnel) gem by [Anton Bogdanovich](https://github.com/bogdanovich)
|
11
|
+
|
12
|
+
I was dealing with debugging work on some webhooks at my current project. Using Ngrok on a free plan, I quickly got tired of Ngrok generating a new endpoint URL every time on restarting the process.
|
13
|
+
|
14
|
+
There was a pull request [Add support for leaving an ngrok process open and reusing an existing ngrok process
|
15
|
+
instead of starting a new one on every process](https://github.com/bogdanovich/ngrok-tunnel/pull/11), but it wasn't
|
16
|
+
quite working.
|
17
|
+
|
18
|
+
So, I have created [a working one](https://github.com/bogdanovich/ngrok-tunnel/pull/20), but neither
|
19
|
+
of these PRs got any reaction from the author.
|
20
|
+
|
21
|
+
So, excuse me, [Anton Bogdanovich](https://github.com/bogdanovich), but I've decided to craft another gem, based on your awesome work, thank you!
|
22
|
+
|
23
|
+
## Installation
|
24
|
+
|
25
|
+
*Note:* You must have ngrok v2+ installed available in your `PATH`.
|
26
|
+
|
27
|
+
Add this line to your application's Gemfile:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
gem 'ngrok-wrapper'
|
31
|
+
```
|
32
|
+
|
33
|
+
And then execute:
|
34
|
+
|
35
|
+
$ bundle
|
36
|
+
|
37
|
+
Or install it yourself as:
|
38
|
+
|
39
|
+
$ gem install ngrok-wrapper
|
40
|
+
|
41
|
+
## Usage
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
require 'ngrok/wrapper'
|
45
|
+
|
46
|
+
# spawn ngrok (default port 3001)
|
47
|
+
Ngrok::Wrapper.start
|
48
|
+
|
49
|
+
# ngrok local_port
|
50
|
+
Ngrok::Wrapper.port
|
51
|
+
=> 3001
|
52
|
+
|
53
|
+
# ngrok external url
|
54
|
+
Ngrok::Wrapper.ngrok_url
|
55
|
+
=> "http://aaa0e65.ngrok.io"
|
56
|
+
|
57
|
+
Ngrok::Wrapper.ngrok_url_https
|
58
|
+
=> "https://aaa0e65.ngrok.io"
|
59
|
+
|
60
|
+
Ngrok::Wrapper.running?
|
61
|
+
=> true
|
62
|
+
|
63
|
+
Ngrok::Wrapper.stopped?
|
64
|
+
=> false
|
65
|
+
|
66
|
+
# ngrok process id
|
67
|
+
Ngrok::Wrapper.pid
|
68
|
+
=> 27384
|
69
|
+
|
70
|
+
# ngrok log file descriptor
|
71
|
+
Ngrok::Wrapper.log
|
72
|
+
=> #<File:/tmp/ngrok20141022-27376-cmmiq4>
|
73
|
+
|
74
|
+
# kill ngrok
|
75
|
+
Ngrok::Wrapper.stop
|
76
|
+
=> :stopped
|
77
|
+
|
78
|
+
```
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
# ngrok custom parameters
|
82
|
+
Ngrok::Wrapper.start(addr: 'foo.dev:80',
|
83
|
+
subdomain: 'MY_SUBDOMAIN',
|
84
|
+
hostname: 'MY_HOSTNAME',
|
85
|
+
authtoken: 'MY_TOKEN',
|
86
|
+
inspect: false,
|
87
|
+
log: 'ngrok.log',
|
88
|
+
config: '~/.ngrok2/ngrok.yml',
|
89
|
+
persistence: true,
|
90
|
+
persistence_file: '/Users/user/.ngrok2/ngrok-process.json') # optional parameter
|
91
|
+
```
|
92
|
+
|
93
|
+
- If `persistence: true` is specified, on the 1st server start, an Ngrok process will get invoked, and the attributes of this Ngrok process, like `pid`, URLs and `port` will be stored in the `persistence_file`.
|
94
|
+
- On server stop, the Ngrok process will not be killed.
|
95
|
+
- On the subsequent server start, Ngrok::Wrapper will read the process attributes from the `persistence_file` and will try to re-use the running Ngrok process, if it hadn't been killed.
|
96
|
+
- The `persistence_file` parameter is optional when invoking `Ngrok::Wrapper.start`, by default the '/Users/user/.ngrok2/ngrok-process.json' will be created and used
|
97
|
+
- The `authtoken` parameter is also optional, as long as the `config` parameter is specified (usually Ngrok config
|
98
|
+
is the `~/.ngrok2/ngrok.yml` file)
|
99
|
+
|
100
|
+
### With Rails
|
101
|
+
|
102
|
+
- Use ~/.ngrok2/ngrok.yml as a config file
|
103
|
+
- Set NGROK_INSPECT=false if you want to disable the inspector web-server
|
104
|
+
- Add this code at the end of `config/application.rb` in a Rails project
|
105
|
+
|
106
|
+
```ruby
|
107
|
+
NGROK_ENABLED = Rails.env.development? &&
|
108
|
+
(Rails.const_defined?(:Server) || ($PROGRAM_NAME.include?('puma') && Puma.const_defined?(:Server))) &&
|
109
|
+
ENV['NGROK_TUNNEL'] == 'true'
|
110
|
+
```
|
111
|
+
|
112
|
+
- Add the following code at the start of `config/environments/development.rb`
|
113
|
+
|
114
|
+
```ruby
|
115
|
+
if NGROK_ENABLED
|
116
|
+
require 'ngrok/wrapper'
|
117
|
+
|
118
|
+
options = { addr: 'https://localhost:3000', persistence: true }
|
119
|
+
options[:config] = ENV.fetch('NGROK_CONFIG', "#{ENV['HOME']}/.ngrok2/ngrok.yml")
|
120
|
+
options[:inspect] = ENV['NGROK_INSPECT'] if ENV['NGROK_INSPECT']
|
121
|
+
|
122
|
+
puts "[NGROK] tunneling at #{Ngrok::Wrapper.start(options)}"
|
123
|
+
puts '[NGROK] inspector web interface listening at http://127.0.0.1:4040' if ENV['NGROK_INSPECT'] == 'true'
|
124
|
+
|
125
|
+
NGROK_URL = Ngrok::Wrapper.ngrok_url_https
|
126
|
+
end
|
127
|
+
```
|
128
|
+
|
129
|
+
- If you need SSL (`https`) webhooks, you can use the `localhost` gem and then, in `config/puma.rb`:
|
130
|
+
|
131
|
+
```ruby
|
132
|
+
if self.class.const_defined?(:NGROK_ENABLED)
|
133
|
+
bind 'ssl://localhost:3000'
|
134
|
+
else
|
135
|
+
port ENV.fetch('PORT', 3000)
|
136
|
+
end
|
137
|
+
```
|
138
|
+
|
139
|
+
- And in `config/environments/development.rb`:
|
140
|
+
|
141
|
+
```ruby
|
142
|
+
config.force_ssl = true if NGROK_ENABLED
|
143
|
+
|
144
|
+
config.action_mailer.default_url_options = {
|
145
|
+
host: NGROK_ENABLED ? NGROK_URL.delete_prefix('https://') : 'myapp.local',
|
146
|
+
port: 3000
|
147
|
+
}
|
148
|
+
```
|
149
|
+
|
150
|
+
- To make the sessions bound to the Ngrok domain, in `config/initializers/session_store.rb`:
|
151
|
+
|
152
|
+
```ruby
|
153
|
+
Rails.application.config.session_store :cookie_store,
|
154
|
+
key: "_#{Rails.env}_my_app_secure_session_3",
|
155
|
+
domain: NGROK_ENABLED ? NGROK_URL.delete_prefix('https://') : :all,
|
156
|
+
tld_length: 2
|
157
|
+
```
|
158
|
+
|
159
|
+
- To use the webhooks when sending to, for example, Slack API, you can define the redirect URL in controller as follows:
|
160
|
+
|
161
|
+
```ruby
|
162
|
+
redirect_uri = NGROK_ENABLED ? "#{NGROK_URL}/slack/oauth/#{organization.id}" : slack_oauth_url(organization.id)
|
163
|
+
```
|
164
|
+
|
165
|
+
### With Rack server
|
166
|
+
|
167
|
+
- Use ~/.ngrok2/ngrok.yml as a config file.
|
168
|
+
- Set NGROK_INSPECT=false if you want to disable the inspector web-server.
|
169
|
+
- Add the following code to the end of a configuration file of your preferred web-server, e.g. config/puma.rb,
|
170
|
+
config/unicorn.rb, or config/thin.rb
|
171
|
+
|
172
|
+
```ruby
|
173
|
+
require 'ngrok/wrapper'
|
174
|
+
|
175
|
+
options = { addr: 'https://localhost:3000', persistence: true }
|
176
|
+
options[:config] = ENV.fetch('NGROK_CONFIG', "#{ENV['HOME']}/.ngrok2/ngrok.yml")
|
177
|
+
options[:inspect] = ENV['NGROK_INSPECT'] if ENV['NGROK_INSPECT']
|
178
|
+
|
179
|
+
puts "[NGROK] tunneling at #{Ngrok::Wrapper.start(options)}"
|
180
|
+
puts '[NGROK] inspector web interface listening at http://127.0.0.1:4040' if ENV['NGROK_INSPECT'] == 'true'
|
181
|
+
|
182
|
+
NGROK_URL = Ngrok::Wrapper.ngrok_url_https
|
183
|
+
```
|
184
|
+
|
185
|
+
## Gem Maintenance
|
186
|
+
|
187
|
+
### Preparing a release
|
188
|
+
|
189
|
+
Merge all the pull requests that should make it into the new release into the `main` branch, then checkout and pull the
|
190
|
+
branch and run the `github_changelog_generator`, specifying the new version as a `--future-release` cli parameter:
|
191
|
+
|
192
|
+
```
|
193
|
+
git checkout main
|
194
|
+
git pull
|
195
|
+
|
196
|
+
github_changelog_generator -u texpert -p ngrok-wrapper --future-release v0.1.0
|
197
|
+
```
|
198
|
+
|
199
|
+
Then add the changes to `git`, commit and push the `Preparing the new release` commit directly into the `main` branch:
|
200
|
+
|
201
|
+
```
|
202
|
+
git add .
|
203
|
+
git commit -m 'Preparing the new v0.1.0 release'
|
204
|
+
git push
|
205
|
+
```
|
206
|
+
|
207
|
+
### RubyGems credentials
|
208
|
+
|
209
|
+
Ensure you have the RubyGems credentials located in the `~/.gem/credentials` file.
|
210
|
+
|
211
|
+
### Adding a gem owner
|
212
|
+
|
213
|
+
```
|
214
|
+
gem owner ngrok-wrapper -a branzeanu.aurel@gmail.com
|
215
|
+
```
|
216
|
+
|
217
|
+
### Building a new gem version
|
218
|
+
|
219
|
+
Adjust the new gem version number in the `lib/ngrok/wrapper/version.rb` file. It is used when building the gem by the following command:
|
220
|
+
|
221
|
+
```
|
222
|
+
gem build ngrok-wrapper.gemspec
|
223
|
+
```
|
224
|
+
|
225
|
+
Assuming the version was set to `0.1.0`,
|
226
|
+
a `ngrok-wrapper-0.1.0.gem` binary file will be generated at the root of the app (repo).
|
227
|
+
|
228
|
+
- The binary file shouldn't be added into the `git` tree, it will be pushed into the RubyGems and to the GitHub releases
|
229
|
+
|
230
|
+
### Pushing a new gem release to RubyGems
|
231
|
+
|
232
|
+
```
|
233
|
+
gem push ngrok-wrapper-0.1.0.gem # don't forget to specify the correct version number
|
234
|
+
```
|
235
|
+
|
236
|
+
### Crafting the new release on GitHub
|
237
|
+
|
238
|
+
On the [Releases page](https://github.com/texpert/ngrok-wrapper/releases) push the `Draft a new release` button.
|
239
|
+
|
240
|
+
The new release editing page opens, on which the following actions could be taken:
|
241
|
+
|
242
|
+
- Choose the repo branch (default is `main`)
|
243
|
+
- Insert a tag version (usually, the tag should correspond to the gem's new version, v0.1.0, for example)
|
244
|
+
- the tag will be created by GitHub on the last commit into the chosen branch
|
245
|
+
- Fill the release Title and Description
|
246
|
+
- Attach the binary file with the generated gem version
|
247
|
+
- If the release is not yet ready for production, mark the `This is a pre-release` checkbox
|
248
|
+
- Press either the `Publish release`, or the `Save draft button` if you want to publish it later
|
249
|
+
- After publishing the release, the the binary gem file will be available on GitHub and could be removed locally
|
250
|
+
|
251
|
+
|
252
|
+
## Contributing
|
253
|
+
|
254
|
+
1. Fork it ( https://github.com/texpert/ngrok-wrapper/fork )
|
255
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
256
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
257
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
258
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/disabled.yml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# These are all the cops that are disabled in the default configuration.
|
2
|
+
|
3
|
+
# By default, the rails cops are not run. Override in project or home
|
4
|
+
# directory .rubocop.yml files, or by giving the -R/--rails option.
|
5
|
+
|
6
|
+
Naming/InclusiveLanguage:
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
RSpec/AnyInstance:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
RSpec/BeEql:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
RSpec/ExampleLength:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
RSpec/ExpectInHook:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
RSpec/MessageSpies:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
Style/Documentation:
|
25
|
+
Description: 'Document classes and non-namespace modules.'
|
26
|
+
Enabled: false
|