ngrok-v1 0.0.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 +7 -0
- data/.gitignore +9 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +21 -0
- data/README.md +21 -0
- data/Rakefile +1 -0
- data/lib/ngrok-v1.rb +2 -0
- data/lib/ngrok-v1/client.rb +74 -0
- data/lib/ngrok-v1/version.rb +3 -0
- data/localtunnel.gemspec +20 -0
- metadata +81 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9e124310d039cbe23943427cc55b9df9cc4cc1ee
|
4
|
+
data.tar.gz: dbaa073fb1ba22d226df0972d7e1a57057e8839e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7774135990e8924811b543a6ed86951adf9a86b1f7c7aadefad01fe3c7f5202b6361491034ab49c9af79e7b9fc2ece3beac782ffefdc9e0256578758ec6015f2
|
7
|
+
data.tar.gz: bb54000002cdd9169c3f9c7213398aab0ba45cc7903214c6c83c8bf933ff9f23ac43d83821425638d3b33ef460131237c9d615bc246d408986ba9ff7c02bb4a4
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Swinburne Software Innovation Lab
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# ngrok-v1
|
2
|
+
|
3
|
+
Ruby gem wrapping [ngrok](https://ngrok.com) v1.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'ngrok-v1'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
```bash
|
16
|
+
$ bundle install
|
17
|
+
```
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/ngrok-v1.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
require "tempfile"
|
2
|
+
|
3
|
+
module NgrokV1
|
4
|
+
class Client
|
5
|
+
def initialize(options = {})
|
6
|
+
raise "Failed to find ngrok v1 binary." unless binary_installed?
|
7
|
+
raise "Port number not specified." unless options.key?(:port)
|
8
|
+
raise "Protocol not specified." unless options.key?(:protocol)
|
9
|
+
|
10
|
+
@port = options[:port]
|
11
|
+
@protocol = options[:protocol]
|
12
|
+
@log = nil
|
13
|
+
@pid = nil
|
14
|
+
@uri = nil
|
15
|
+
end
|
16
|
+
|
17
|
+
def start
|
18
|
+
return if running?
|
19
|
+
|
20
|
+
@log = Tempfile.new("ngrok-v1")
|
21
|
+
@pid = Process.spawn(execution_string)
|
22
|
+
|
23
|
+
at_exit { stop } # Ensure process is killed if Ruby exits.
|
24
|
+
|
25
|
+
@uri = parse_uri!
|
26
|
+
end
|
27
|
+
|
28
|
+
def stop
|
29
|
+
return unless running?
|
30
|
+
|
31
|
+
Process.kill("KILL", @pid)
|
32
|
+
|
33
|
+
@pid = nil
|
34
|
+
end
|
35
|
+
|
36
|
+
def running?
|
37
|
+
!@pid.nil?
|
38
|
+
end
|
39
|
+
|
40
|
+
def uri
|
41
|
+
@uri if running?
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def binary_installed?
|
47
|
+
!`ngrok version`.empty?
|
48
|
+
rescue Errno::ENOENT
|
49
|
+
false
|
50
|
+
end
|
51
|
+
|
52
|
+
def execution_string
|
53
|
+
s = "exec ngrok"
|
54
|
+
s << " -log stdout"
|
55
|
+
s << " -proto #{@protocol}" if @protocol
|
56
|
+
s << " #{@port}" if @port
|
57
|
+
s << " > #{@log.path} 2>&1"
|
58
|
+
end
|
59
|
+
|
60
|
+
def parse_uri!(max_seconds = 10)
|
61
|
+
max_seconds.times do
|
62
|
+
sleep 1
|
63
|
+
@log.rewind
|
64
|
+
|
65
|
+
if match_data = @log.read.match(/Tunnel established at (.*)$/)
|
66
|
+
return match_data.captures.first
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
stop
|
71
|
+
raise "Failed to establish tunnel." # Timeout.
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/localtunnel.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ngrok-v1/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ngrok-v1"
|
8
|
+
spec.version = NgrokV1::VERSION
|
9
|
+
spec.authors = ["Swinburne Software Innovation Lab"]
|
10
|
+
spec.email = ["god@ssil.com.au"]
|
11
|
+
spec.summary = %q{Ruby gem wrapping ngrok v1.}
|
12
|
+
spec.description = %q{Ruby gem wrapping ngrok v1.}
|
13
|
+
spec.homepage = "https://github.com/ssilab/ngrok-v1"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.require_paths = ["lib"]
|
17
|
+
spec.post_install_message = "Please ensure that ngrok v1 is installed."
|
18
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
19
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ngrok-v1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Swinburne Software Innovation Lab
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Ruby gem wrapping ngrok v1.
|
42
|
+
email:
|
43
|
+
- god@ssil.com.au
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- lib/ngrok-v1.rb
|
54
|
+
- lib/ngrok-v1/client.rb
|
55
|
+
- lib/ngrok-v1/version.rb
|
56
|
+
- localtunnel.gemspec
|
57
|
+
homepage: https://github.com/ssilab/ngrok-v1
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata: {}
|
61
|
+
post_install_message: Please ensure that ngrok v1 is installed.
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 2.4.5.1
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: Ruby gem wrapping ngrok v1.
|
81
|
+
test_files: []
|