ngrok-tunnel 2.0.1 → 2.0.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4c864e0a2db71b2c84350df7daba7ef501c75a2d
4
- data.tar.gz: adbc7d33d04e99d3e657f53ff4c203d93a323b0e
3
+ metadata.gz: 9403b3ccb11df523110810244d731267ab8fa167
4
+ data.tar.gz: 00bb979f702a180d544b2330ad54141a992f64e0
5
5
  SHA512:
6
- metadata.gz: f97a3e3eb817a84c124029ab9e40ea3d6bbd81548a576ba6c454f261564d9aa7a1150496d0b47035010d93a699b39543b7706d3e9fec113247e3a9f67dc25709
7
- data.tar.gz: 96dbd1d0a73e59675ffe02e386953383d202c258b386665de17a6f4965ee40461fe274d5eab3f75e36806b1ed81d33ae804d27ed1b4b8f0720f3e8538293ab2f
6
+ metadata.gz: 547594a5dea6990a2382d644fbac257fc0d96d59af9d78eafc5cced6995e0b33c58be9dd73b873059b83eff7e3076a6ef63bc6ec2ddfa1a65897866c1ff2d97c
7
+ data.tar.gz: 48ed16dd13d5c8237dc7bb9a2f213c095e4eb19200121264acea53909608e52ee4500e8b78945111a963dbcca983f9f3c249d17e23958b5e6a2452c86603cd7e
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Ngrok-tunnel gem is a ruby wrapper for ngrok
4
4
 
5
- [![Gem Version](https://badge.fury.io/rb/ngrok-tunnel.svg)](http://badge.fury.io/rb/ngrok-tunnel)
5
+ [![Gem Version](https://badge.fury.io/rb/ngrok-tunnel.svg)](http://badge.fury.io/rb/ngrok-tunnel) [![Code Climate](https://codeclimate.com/github/bogdanovich/ngrok-tunnel/badges/gpa.svg)](https://codeclimate.com/github/bogdanovich/ngrok-tunnel)
6
6
 
7
7
  ## Installation
8
8
 
@@ -1,5 +1,5 @@
1
1
  module Ngrok
2
2
  class Tunnel
3
- VERSION = "2.0.1"
3
+ VERSION = "2.0.16"
4
4
  end
5
5
  end
data/lib/ngrok/tunnel.rb CHANGED
@@ -8,7 +8,7 @@ module Ngrok
8
8
  class Error < StandardError; end
9
9
 
10
10
  class Tunnel
11
-
11
+
12
12
  class << self
13
13
  attr_reader :pid, :ngrok_url, :ngrok_url_https, :status
14
14
 
@@ -23,12 +23,12 @@ module Ngrok
23
23
 
24
24
  if stopped?
25
25
  @params[:log] = (@params[:log]) ? File.open(@params[:log], 'w+') : Tempfile.new('ngrok')
26
- @pid = spawn("exec ngrok " + ngrok_exec_params)
27
- at_exit { Ngrok::Tunnel.stop }
26
+ @pid = spawn("exec ngrok http " + ngrok_exec_params)
27
+ at_exit { Ngrok::Tunnel.stop }
28
28
  @status = :running
29
29
  fetch_urls
30
30
  end
31
-
31
+
32
32
  @ngrok_url
33
33
  end
34
34
 
@@ -72,7 +72,7 @@ module Ngrok
72
72
  private
73
73
 
74
74
  def ngrok_exec_params
75
- exec_params = "-log=stdout "
75
+ exec_params = "-log=stdout -log-level=debug "
76
76
  exec_params << "-authtoken=#{@params[:authtoken]} " if @params[:authtoken]
77
77
  exec_params << "-subdomain=#{@params[:subdomain]} " if @params[:subdomain]
78
78
  exec_params << "-config=#{@params[:config]} #{@params[:port].to_i} > #{@params[:log].path}"
@@ -81,15 +81,20 @@ module Ngrok
81
81
  def fetch_urls
82
82
  @params[:timeout].times do
83
83
  log_content = @params[:log].read
84
- @ngrok_url, @ngrok_url_https = log_content.scan(/"Url":"([^"]+)"/).flatten
85
- return @ngrok_url if @ngrok_url
84
+ result = log_content.scan(/URL:(.+)\sProto:(http|https)\s/)
85
+ if !result.empty?
86
+ result = Hash[*result.flatten].invert
87
+ @ngrok_url = result['http']
88
+ @ngrok_url_https = result['https']
89
+ return @ngrok_url if @ngrok_url
90
+ end
86
91
 
87
- error = log_content.scan(/"Error":"([^"]+)"/).flatten
92
+ error = log_content.scan(/msg="command failed" err="([^"]+)"/).flatten
88
93
  unless error.empty?
89
94
  self.stop
90
95
  raise Ngrok::Error, error.first
91
96
  end
92
-
97
+
93
98
  sleep 1
94
99
  @params[:log].rewind
95
100
  end
@@ -42,21 +42,17 @@ describe Ngrok::Tunnel do
42
42
  end
43
43
 
44
44
  it "should have valid ngrok_url" do
45
- expect(Ngrok::Tunnel.ngrok_url).to be =~ /http:\/\/.*ngrok.com$/
45
+ expect(Ngrok::Tunnel.ngrok_url).to be =~ /http:\/\/.*ngrok\.io$/
46
46
  end
47
47
 
48
48
  it "should have valid ngrok_url_https" do
49
- expect(Ngrok::Tunnel.ngrok_url_https).to be =~ /https:\/\/.*ngrok.com$/
49
+ expect(Ngrok::Tunnel.ngrok_url_https).to be =~ /https:\/\/.*ngrok\.io$/
50
50
  end
51
51
 
52
52
  it "should have pid > 0" do
53
53
  expect(Ngrok::Tunnel.pid).to be > 0
54
54
  end
55
55
 
56
- it "should present in process list" do
57
- expect(Ngrok::Tunnel.pid.to_s).to eq `pidof ngrok`.strip
58
- end
59
-
60
56
  end
61
57
 
62
58
  describe "Custom log file" do
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.0.1
4
+ version: 2.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Bogdanovich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-24 00:00:00.000000000 Z
11
+ date: 2015-04-19 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,8 +87,8 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - ".gitignore"
91
- - ".rspec"
90
+ - .gitignore
91
+ - .rspec
92
92
  - Gemfile
93
93
  - LICENSE.txt
94
94
  - README.md
@@ -108,12 +108,12 @@ require_paths:
108
108
  - lib
109
109
  required_ruby_version: !ruby/object:Gem::Requirement
110
110
  requirements:
111
- - - ">="
111
+ - - '>='
112
112
  - !ruby/object:Gem::Version
113
113
  version: '0'
114
114
  required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - ">="
116
+ - - '>='
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0'
119
119
  requirements: []
@@ -125,3 +125,4 @@ summary: Ngrok-tunnel gem is a ruby wrapper for ngrok
125
125
  test_files:
126
126
  - spec/spec_helper.rb
127
127
  - spec/tunnel/tunnel_spec.rb
128
+ has_rdoc: