proxy_pac_rb 0.9.1 → 1.0.0
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 +4 -4
- data/.rubocop.yml +4 -0
- data/.travis.yml +3 -2
- data/Gemfile +4 -3
- data/README.md +12 -13
- data/Rakefile +1 -0
- data/bin/pprb +1 -0
- data/features/step_definitions.rb +1 -0
- data/features/support/aruba.rb +1 -0
- data/features/support/env.rb +1 -0
- data/features/support/reporting.rb +1 -0
- data/lib/proxy_pac_rb.rb +1 -0
- data/lib/proxy_pac_rb/basic_configuration.rb +2 -1
- data/lib/proxy_pac_rb/cli/compress.rb +1 -0
- data/lib/proxy_pac_rb/cli/compress_proxy_pac.rb +1 -0
- data/lib/proxy_pac_rb/cli/find.rb +1 -0
- data/lib/proxy_pac_rb/cli/find_proxy.rb +1 -0
- data/lib/proxy_pac_rb/cli/init.rb +1 -0
- data/lib/proxy_pac_rb/cli/init_proxy_pac.rb +1 -0
- data/lib/proxy_pac_rb/cli/lint.rb +1 -0
- data/lib/proxy_pac_rb/cli/lint_proxy_pac.rb +1 -0
- data/lib/proxy_pac_rb/cli/runner.rb +1 -0
- data/lib/proxy_pac_rb/cli/shared.rb +1 -0
- data/lib/proxy_pac_rb/cli/show.rb +1 -0
- data/lib/proxy_pac_rb/cli_validator.rb +1 -0
- data/lib/proxy_pac_rb/code_configuration.rb +1 -0
- data/lib/proxy_pac_rb/encoding.rb +2 -1
- data/lib/proxy_pac_rb/environment.rb +19 -15
- data/lib/proxy_pac_rb/errors.rb +1 -0
- data/lib/proxy_pac_rb/exceptions.rb +1 -0
- data/lib/proxy_pac_rb/javascript.rb +1 -0
- data/lib/proxy_pac_rb/javascript_compiler.rb +3 -2
- data/lib/proxy_pac_rb/main.rb +1 -0
- data/lib/proxy_pac_rb/parser.rb +1 -0
- data/lib/proxy_pac_rb/proxy_pac_compressor.rb +1 -0
- data/lib/proxy_pac_rb/proxy_pac_dumper.rb +2 -1
- data/lib/proxy_pac_rb/proxy_pac_file.rb +5 -4
- data/lib/proxy_pac_rb/proxy_pac_js.rb +1 -0
- data/lib/proxy_pac_rb/proxy_pac_linter.rb +2 -1
- data/lib/proxy_pac_rb/proxy_pac_loader.rb +2 -1
- data/lib/proxy_pac_rb/proxy_pac_parser.rb +1 -0
- data/lib/proxy_pac_rb/rack/proxy_pac_compressor.rb +3 -1
- data/lib/proxy_pac_rb/rack/proxy_pac_linter.rb +3 -1
- data/lib/proxy_pac_rb/rspec.rb +1 -0
- data/lib/proxy_pac_rb/rspec/helpers.rb +1 -0
- data/lib/proxy_pac_rb/rspec/matchers/base_matcher.rb +5 -4
- data/lib/proxy_pac_rb/rspec/matchers/proxy.rb +1 -0
- data/lib/proxy_pac_rb/rspec/matchers/url.rb +1 -0
- data/lib/proxy_pac_rb/runtime.rb +6 -5
- data/lib/proxy_pac_rb/runtimes.rb +4 -3
- data/lib/proxy_pac_rb/runtimes/rubyracer.rb +2 -1
- data/lib/proxy_pac_rb/runtimes/rubyrhino.rb +1 -0
- data/lib/proxy_pac_rb/version.rb +2 -1
- data/proxy_pac_rb.gemspec +1 -2
- data/script/config.ru +1 -0
- data/script/console +1 -0
- data/spec/api/proxy_pac_compressor_spec.rb +1 -0
- data/spec/api/proxy_pac_dumper_spec.rb +1 -0
- data/spec/api/proxy_pac_file_spec.rb +1 -0
- data/spec/api/proxy_pac_linter_spec.rb +1 -0
- data/spec/api/proxy_pac_loader_spec.rb +1 -0
- data/spec/api/proxy_pac_parser_spec.rb +1 -0
- data/spec/basic_configuration_spec.rb +1 -0
- data/spec/code_configuration_spec.rb +1 -0
- data/spec/environment_spec.rb +2 -3
- data/spec/parser_spec.rb +1 -0
- data/spec/rack/proxy_pac_compressor_spec.rb +1 -0
- data/spec/rack/proxy_pac_linter_spec.rb +1 -0
- data/spec/rspec/compare_proxy_pac_files_spec.rb +1 -0
- data/spec/rspec/parse_proxy_pac_spec.rb +1 -0
- data/spec/rspec/readability_spec.rb +1 -0
- data/spec/rspec/rspec_spec.rb +1 -0
- data/spec/rspec/validitiy_spec.rb +1 -0
- data/spec/rspec_integration_spec_helper.rb +1 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/support/aruba.rb +1 -0
- data/spec/support/matchers/file.rb +3 -2
- data/spec/support/matchers/option.rb +3 -2
- data/spec/support/rack_test.rb +1 -0
- data/spec/support/reporting.rb +1 -0
- data/spec/support/rspec.rb +1 -0
- data/spec/support/shared_examples/configuration.rb +1 -0
- data/spec/support/shared_examples/loader.rb +1 -0
- data/spec/support/strip.rb +1 -0
- data/spec/support/webmock.rb +1 -0
- data/templates/build/middleman/config.rb +1 -0
- data/templates/default/Gemfile +1 -0
- data/templates/default/Rakefile +1 -0
- data/templates/test_framework/rspec/spec_helper.rb +1 -0
- data/templates/test_framework/rspec/support/aruba.rb +1 -0
- data/templates/test_framework/rspec/support/proxy_pac_rb.rb +1 -0
- data/templates/test_framework/rspec/support/rspec.rb +1 -0
- metadata +11 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a0794209d07fae2f81954cf207260f5327eced23
|
|
4
|
+
data.tar.gz: 2dd5a036c784b5da8928feecdb4088b92c09b8b7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bd12c1cdc0db98524e6569c39415e134bbcbe8c705446a8f329f35c9cf195bc458f3795d003caa051df242e853ab54b6fca6f7ea58b52216200f50d7085203a0
|
|
7
|
+
data.tar.gz: 28a2df7b5d63954cea69f9c64e0a3828df71366b1bf87ec1cf55910f785230b761e6789d55c080fe80d5a1184ff1899505b6fec330f9e275626ab2eaa56bb47c
|
data/.rubocop.yml
CHANGED
|
@@ -2,6 +2,7 @@ AllCops:
|
|
|
2
2
|
Exclude:
|
|
3
3
|
- 'tmp/**/*'
|
|
4
4
|
DisplayCopNames: true
|
|
5
|
+
TargetRubyVersion: 2.3
|
|
5
6
|
|
|
6
7
|
Metrics/AbcSize:
|
|
7
8
|
Max: 38
|
|
@@ -38,3 +39,6 @@ Metrics/PerceivedComplexity:
|
|
|
38
39
|
Style/MethodName:
|
|
39
40
|
Exclude:
|
|
40
41
|
- lib/proxy_pac_rb/environment.rb
|
|
42
|
+
|
|
43
|
+
Style/GuardClause:
|
|
44
|
+
Enabled: false
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
source 'https://rubygems.org'
|
|
2
3
|
|
|
3
4
|
# Specify your gem's dependencies in local_pac.gemspec
|
|
4
5
|
gemspec
|
|
5
6
|
|
|
7
|
+
gem 'listen', '~> 3.0.0'
|
|
8
|
+
|
|
6
9
|
group :debug do
|
|
7
10
|
gem 'pry'
|
|
8
11
|
gem 'byebug'
|
|
9
12
|
|
|
10
13
|
gem 'pry-doc', require: false
|
|
11
|
-
gem 'pry-stack_explorer', require: false
|
|
12
|
-
# gem 'pry-exception_explorer', require: false
|
|
13
|
-
# gem 'pry-rescue', require: false
|
|
14
14
|
gem 'pry-byebug', require: false
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
group :development, :test do
|
|
18
|
+
gem 'middleman', '~> 4.0', require: false
|
|
18
19
|
gem 'aruba', '~>0.10.0', require: false
|
|
19
20
|
gem 'awesome_print', require: 'ap'
|
|
20
21
|
gem 'bundler', '~> 1.3', require: false
|
data/README.md
CHANGED
|
@@ -191,28 +191,27 @@ code snippet captured from the `middleman`-configuration file `config.rb`:
|
|
|
191
191
|
* `config.rb`:
|
|
192
192
|
|
|
193
193
|
```ruby
|
|
194
|
-
#
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
194
|
+
# IMPORTANT: Needs to come first before compressor
|
|
195
|
+
require 'proxy_pac_rb/rack/proxy_pac_linter'
|
|
196
|
+
use ProxyPacRb::Rack::ProxyPacLinter
|
|
197
|
+
|
|
198
|
+
require 'proxy_pac_rb/rack/proxy_pac_compressor'
|
|
199
|
+
use ProxyPacRb::Rack::ProxyPacCompressor
|
|
200
|
+
|
|
202
201
|
# The middleware works on content served with
|
|
203
202
|
# "Content-Type" 'application/x-ns-proxy-autoconfig'
|
|
204
|
-
|
|
205
|
-
|
|
203
|
+
page "*.pac", content_type: 'application/x-ns-proxy-autoconfig', layout: false
|
|
204
|
+
|
|
206
205
|
# This provides an uncompressed copy of the proxy.pac to make it
|
|
207
206
|
# possible for your support to review it by hand
|
|
208
|
-
Dir.glob(File.join(source_dir, '**', '*.pac')).each do |f|
|
|
207
|
+
Dir.glob(File.join(source_dir, '**', '*.pac*')).each do |f|
|
|
209
208
|
# Path should be relative to source dir
|
|
210
209
|
relative_path = Pathname.new(f).relative_path_from(Pathname.new(source_dir))
|
|
210
|
+
relative_path = relative_path.to_s.gsub(/(?<path>.*\.pac)\..*/, '\k<path>')
|
|
211
211
|
|
|
212
212
|
# "text/plain" prevents the middlewares to handle it
|
|
213
|
-
proxy(format('%s.raw', relative_path), relative_path
|
|
213
|
+
proxy(format('%s.raw', relative_path), relative_path, content_type: 'text/plain', layout: false)
|
|
214
214
|
end
|
|
215
|
-
|
|
216
215
|
```
|
|
217
216
|
|
|
218
217
|
### Ruby
|
data/Rakefile
CHANGED
data/bin/pprb
CHANGED
data/features/support/aruba.rb
CHANGED
data/features/support/env.rb
CHANGED
data/lib/proxy_pac_rb.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
module ProxyPacRb
|
|
2
3
|
# Basic configuration for ProxyPacRb
|
|
3
4
|
class BasicConfiguration
|
|
@@ -77,7 +78,7 @@ module ProxyPacRb
|
|
|
77
78
|
private
|
|
78
79
|
|
|
79
80
|
def find_option(name)
|
|
80
|
-
|
|
81
|
+
raise NotImplementedError, %(Unknown option "#{name}") unless option? name
|
|
81
82
|
|
|
82
83
|
local_options[name]
|
|
83
84
|
end
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
module ProxyPacRb
|
|
2
3
|
# Encodes strings as UTF-8
|
|
3
4
|
module Encoding
|
|
@@ -11,7 +12,7 @@ module ProxyPacRb
|
|
|
11
12
|
data.force_encoding('UTF-8')
|
|
12
13
|
|
|
13
14
|
unless data.valid_encoding?
|
|
14
|
-
|
|
15
|
+
raise ::Encoding::UndefinedConversionError, "Could not encode ASCII-8BIT data #{string.dump} as UTF-8"
|
|
15
16
|
end
|
|
16
17
|
else
|
|
17
18
|
data = string.encode('UTF-8')
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
module ProxyPacRb
|
|
3
4
|
# Environment in which a proxy.pac will be evaluated
|
|
4
5
|
class Environment
|
|
@@ -55,8 +56,8 @@ module ProxyPacRb
|
|
|
55
56
|
end
|
|
56
57
|
|
|
57
58
|
def isInNet(host, base_ip, mask)
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
raise ArgumentError, '<base ip> needs to be defined' if base_ip.nil? || base_ip.empty?
|
|
60
|
+
raise ArgumentError, '<mask> needs to be defined' if mask.nil? || mask.empty?
|
|
60
61
|
|
|
61
62
|
IPAddr.new(base_ip).mask(mask).include? resolve_host(host)
|
|
62
63
|
end
|
|
@@ -79,7 +80,7 @@ module ProxyPacRb
|
|
|
79
80
|
return nil if host.blank?
|
|
80
81
|
|
|
81
82
|
Timeout.timeout(dns_timeout) do
|
|
82
|
-
Resolv.each_address(host.force_encoding('ASCII-8BIT')) do |address|
|
|
83
|
+
Resolv.each_address(host.dup.force_encoding('ASCII-8BIT')) do |address|
|
|
83
84
|
begin
|
|
84
85
|
return address if IPAddr.new(address).ipv4?
|
|
85
86
|
# rubocop:disable Lint/HandleExceptions
|
|
@@ -100,24 +101,27 @@ module ProxyPacRb
|
|
|
100
101
|
public
|
|
101
102
|
|
|
102
103
|
def prepare(string)
|
|
104
|
+
str = []
|
|
105
|
+
str << string.to_s.chomp
|
|
106
|
+
|
|
103
107
|
if client_ip
|
|
104
|
-
|
|
105
|
-
|
|
108
|
+
str << "\n"
|
|
109
|
+
str << javascript_function_templates.my_ip_address_template(client_ip)
|
|
106
110
|
end
|
|
107
111
|
|
|
108
112
|
if time
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
113
|
+
str << javascript_function_templates.time_variables
|
|
114
|
+
str << "\n"
|
|
115
|
+
str << javascript_function_templates.week_day_range_template(time)
|
|
116
|
+
str << "\n"
|
|
117
|
+
str << javascript_function_templates.week_day_range_template(time)
|
|
118
|
+
str << "\n"
|
|
119
|
+
str << javascript_function_templates.date_range_template(time)
|
|
120
|
+
str << "\n"
|
|
121
|
+
str << javascript_function_templates.time_range_template(time)
|
|
118
122
|
end
|
|
119
123
|
|
|
120
|
-
|
|
124
|
+
str.join("\n")
|
|
121
125
|
end
|
|
122
126
|
end
|
|
123
127
|
end
|
data/lib/proxy_pac_rb/errors.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
module ProxyPacRb
|
|
2
3
|
# Compile javascript
|
|
3
4
|
class JavascriptCompiler
|
|
@@ -14,11 +15,11 @@ module ProxyPacRb
|
|
|
14
15
|
end
|
|
15
16
|
|
|
16
17
|
def compile(content:, environment:)
|
|
17
|
-
|
|
18
|
+
raise Exceptions::RuntimeUnavailable, "#{runtime.name} is unavailable on this system" unless runtime.available?
|
|
18
19
|
|
|
19
20
|
proxy_pac_content = content.to_s.dup
|
|
20
21
|
|
|
21
|
-
environment.prepare(proxy_pac_content)
|
|
22
|
+
proxy_pac_content = environment.prepare(proxy_pac_content)
|
|
22
23
|
|
|
23
24
|
context = runtime.compile(proxy_pac_content)
|
|
24
25
|
context.include environment
|
data/lib/proxy_pac_rb/main.rb
CHANGED
data/lib/proxy_pac_rb/parser.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
module ProxyPacRb
|
|
3
4
|
# Dump Proxy pac to file system
|
|
4
5
|
class ProxyPacDumper
|
|
@@ -58,7 +59,7 @@ module ProxyPacRb
|
|
|
58
59
|
elsif ::File.exist? path
|
|
59
60
|
return path + out_extension
|
|
60
61
|
else
|
|
61
|
-
|
|
62
|
+
raise Errno::ENOENT, "Both paths \"#{path.gsub(/#{in_extension}*$/, '') + in_extension}\" and \"#{path}\" do not exist."
|
|
62
63
|
end
|
|
63
64
|
end
|
|
64
65
|
end
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
module ProxyPacRb
|
|
2
3
|
# Pac file
|
|
3
4
|
class ProxyPacFile
|
|
@@ -53,9 +54,9 @@ module ProxyPacRb
|
|
|
53
54
|
|
|
54
55
|
def find(url, fail_safe: true)
|
|
55
56
|
if fail_safe == true
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
raise ProxyPacInvalidError, "The proxy.pac \"#{source}\" is not readable: #{message}. Stopping here." unless readable?
|
|
58
|
+
raise ProxyPacInvalidError, "The proxy.pac \"#{source}\" is not valid: #{message}. Stopping here." unless valid?
|
|
59
|
+
raise ProxyPacInvalidError, "The proxy.pac \"#{source}\" is could not be parsed. There's no compiled javascript to use to lookup a url: #{message}. Stopping here." unless javascript?
|
|
59
60
|
end
|
|
60
61
|
|
|
61
62
|
uri = Addressable::URI.heuristic_parse(url)
|
|
@@ -66,7 +67,7 @@ module ProxyPacRb
|
|
|
66
67
|
uri.host = url
|
|
67
68
|
end
|
|
68
69
|
|
|
69
|
-
|
|
70
|
+
raise UrlInvalidError, 'url is missing host' unless uri.host
|
|
70
71
|
|
|
71
72
|
javascript.FindProxyForURL(uri.to_s, uri.host)
|
|
72
73
|
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
module ProxyPacRb
|
|
3
4
|
# Dump Proxy pac to file system
|
|
4
5
|
class ProxyPacLinter
|
|
@@ -46,7 +47,7 @@ module ProxyPacRb
|
|
|
46
47
|
%(proxy.pac-file "#{proxy_pac.source}" does not contain "FindProxyForURL".)
|
|
47
48
|
end
|
|
48
49
|
|
|
49
|
-
|
|
50
|
+
raise LinterError, message unless proxy_pac.content.to_s.include?('FindProxyForURL')
|
|
50
51
|
|
|
51
52
|
self
|
|
52
53
|
end
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
module ProxyPacRb
|
|
3
4
|
# Dump Proxy pac to file system
|
|
4
5
|
class ProxyPacLoader
|
|
@@ -55,7 +56,7 @@ module ProxyPacRb
|
|
|
55
56
|
def load(proxy_pac)
|
|
56
57
|
proxy_pac.type = :null
|
|
57
58
|
|
|
58
|
-
|
|
59
|
+
raise StandardError
|
|
59
60
|
end
|
|
60
61
|
|
|
61
62
|
def suitable_for?(proxy_pac)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
require 'proxy_pac_rb'
|
|
2
3
|
require 'rack'
|
|
3
4
|
|
|
@@ -48,8 +49,9 @@ module ProxyPacRb
|
|
|
48
49
|
return [status, headers, body] unless headers.key?('Content-Type') \
|
|
49
50
|
&& %r{application/x-ns-proxy-autoconfig} === headers['Content-Type']
|
|
50
51
|
|
|
51
|
-
content =
|
|
52
|
+
content = []
|
|
52
53
|
body.each { |part| content << part }
|
|
54
|
+
content = content.join
|
|
53
55
|
|
|
54
56
|
begin
|
|
55
57
|
proxy_pac = ProxyPacFile.new(source: content)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
require 'proxy_pac_rb'
|
|
2
3
|
require 'rack'
|
|
3
4
|
|
|
@@ -40,8 +41,9 @@ module ProxyPacRb
|
|
|
40
41
|
return [status, headers, body] unless headers.key?('Content-Type') \
|
|
41
42
|
&& %r{application/x-ns-proxy-autoconfig} === headers['Content-Type']
|
|
42
43
|
|
|
43
|
-
content =
|
|
44
|
+
content = []
|
|
44
45
|
body.each { |part| content << part }
|
|
46
|
+
content = content.join
|
|
45
47
|
|
|
46
48
|
proxy_pac = ProxyPacFile.new(source: content)
|
|
47
49
|
|
data/lib/proxy_pac_rb/rspec.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
module ProxyPacRb
|
|
2
3
|
module RSpecMatchers
|
|
3
4
|
# @api private
|
|
@@ -54,8 +55,8 @@ module ProxyPacRb
|
|
|
54
55
|
# Generates a description using {EnglishPhrasing}.
|
|
55
56
|
# @return [String]
|
|
56
57
|
def description
|
|
57
|
-
desc =
|
|
58
|
-
desc <<
|
|
58
|
+
desc = self.class.matcher_name.to_s.tr('_', ' ')
|
|
59
|
+
desc << Array(@expected).join(', ') if defined?(@expected) && @expected.is_a?(Array)
|
|
59
60
|
desc
|
|
60
61
|
end
|
|
61
62
|
|
|
@@ -111,7 +112,7 @@ module ProxyPacRb
|
|
|
111
112
|
def assert_ivars(*expected_ivars)
|
|
112
113
|
return unless (expected_ivars - present_ivars).any?
|
|
113
114
|
ivar_list = EnglishPhrasing.list(expected_ivars)
|
|
114
|
-
|
|
115
|
+
raise "#{self.class.name} needs to supply#{ivar_list}"
|
|
115
116
|
end
|
|
116
117
|
|
|
117
118
|
if RUBY_VERSION.to_f < 1.9
|
|
@@ -121,7 +122,7 @@ module ProxyPacRb
|
|
|
121
122
|
end
|
|
122
123
|
# :nocov:
|
|
123
124
|
else
|
|
124
|
-
|
|
125
|
+
alias present_ivars instance_variables
|
|
125
126
|
end
|
|
126
127
|
|
|
127
128
|
# @private
|
data/lib/proxy_pac_rb/runtime.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
module ProxyPacRb
|
|
2
3
|
# Abstract base class for runtimes
|
|
3
4
|
class Runtime
|
|
@@ -17,20 +18,20 @@ module ProxyPacRb
|
|
|
17
18
|
end
|
|
18
19
|
|
|
19
20
|
def exec(_source, _options = {})
|
|
20
|
-
|
|
21
|
+
raise NotImplementedError
|
|
21
22
|
end
|
|
22
23
|
|
|
23
24
|
def eval(_source, _options = {})
|
|
24
|
-
|
|
25
|
+
raise NotImplementedError
|
|
25
26
|
end
|
|
26
27
|
|
|
27
28
|
def call(_properties, *_args)
|
|
28
|
-
|
|
29
|
+
raise NotImplementedError
|
|
29
30
|
end
|
|
30
31
|
end
|
|
31
32
|
|
|
32
33
|
def name
|
|
33
|
-
|
|
34
|
+
raise NotImplementedError
|
|
34
35
|
end
|
|
35
36
|
|
|
36
37
|
def context_class
|
|
@@ -56,7 +57,7 @@ module ProxyPacRb
|
|
|
56
57
|
end
|
|
57
58
|
|
|
58
59
|
def available?
|
|
59
|
-
|
|
60
|
+
raise NotImplementedError
|
|
60
61
|
end
|
|
61
62
|
end
|
|
62
63
|
end
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
module ProxyPacRb
|
|
2
3
|
# JavaScript Runtimes
|
|
3
4
|
module Runtimes
|
|
@@ -7,7 +8,7 @@ module ProxyPacRb
|
|
|
7
8
|
class << self
|
|
8
9
|
def autodetect
|
|
9
10
|
from_environment || best_available ||
|
|
10
|
-
|
|
11
|
+
raise(RuntimeUnavailableError, 'Could not find a JavaScript runtime. ' \
|
|
11
12
|
'See https://github.com/sstephenson/execjs for a list of available runtimes.')
|
|
12
13
|
end
|
|
13
14
|
|
|
@@ -20,8 +21,8 @@ module ProxyPacRb
|
|
|
20
21
|
|
|
21
22
|
runtime = const_get(ENV['JS_RUNTIME'])
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
raise RuntimeUnavailableError, "#{ENV['JS_RUNTIME']} runtime is not defined" unless runtime
|
|
25
|
+
raise RuntimeUnavailableError, "#{runtime.name} runtime is not available on this system" unless runtime.available?
|
|
25
26
|
|
|
26
27
|
runtime
|
|
27
28
|
end
|
data/lib/proxy_pac_rb/version.rb
CHANGED
data/proxy_pac_rb.gemspec
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
lib = ::File.expand_path('../lib', __FILE__)
|
|
2
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
4
|
require 'proxy_pac_rb/version'
|
|
@@ -9,11 +10,9 @@ Gem::Specification.new do |spec|
|
|
|
9
10
|
spec.email = ['dg1@vrnetze.de']
|
|
10
11
|
spec.homepage = 'https://github.com/dg-vrnetze/proxy_pac_rb'
|
|
11
12
|
spec.summary = 'Compress, lint and parse proxy auto-config files from commandline, rack-compatible applications and custom ruby code.'
|
|
12
|
-
# rubocop:disable Metrics/LineLength
|
|
13
13
|
spec.description = <<-DESC
|
|
14
14
|
"proxy_pac_rb" is a gem to compress, lint and parse proxy auto-config files. It comes with a cli program, some rack middlewares and can be used from within ruby scripts as well. "proxy_pac_rb" uses a JavaScript runtime to evaulate a proxy auto-config file the same way a browser does to determine what proxy (if any at all) should a program use to connect to a server. You must install on of the supported JavaScript runtimes: therubyracer or therubyrhino
|
|
15
15
|
DESC
|
|
16
|
-
# rubocop:enable Metrics/LineLength
|
|
17
16
|
|
|
18
17
|
spec.license = 'MIT'
|
|
19
18
|
|
data/script/config.ru
CHANGED
data/script/console
CHANGED
data/spec/environment_spec.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
require 'spec_helper'
|
|
3
4
|
|
|
4
5
|
RSpec.describe ProxyPacRb::Environment do
|
|
@@ -209,9 +210,7 @@ RSpec.describe ProxyPacRb::Environment do
|
|
|
209
210
|
|
|
210
211
|
describe '#prepare' do
|
|
211
212
|
context 'when valid' do
|
|
212
|
-
let(:string) { '' }
|
|
213
|
-
|
|
214
|
-
before(:each) { environment.prepare(string) }
|
|
213
|
+
let(:string) { environment.prepare('') }
|
|
215
214
|
|
|
216
215
|
%w(
|
|
217
216
|
myIpAddress
|
data/spec/parser_spec.rb
CHANGED
data/spec/rspec/rspec_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
data/spec/support/aruba.rb
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
RSpec::Matchers.define :be_existing_file do |_|
|
|
2
3
|
match { |actual| File.file?(actual) }
|
|
3
4
|
|
|
4
5
|
failure_message do |actual|
|
|
5
|
-
format(
|
|
6
|
+
format('expected that file "%s" exists', actual)
|
|
6
7
|
end
|
|
7
8
|
|
|
8
9
|
failure_message_when_negated do |actual|
|
|
9
|
-
format(
|
|
10
|
+
format('expected that file "%s" does not exist', actual)
|
|
10
11
|
end
|
|
11
12
|
end
|
|
12
13
|
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
RSpec::Matchers.define :be_valid_option do |_|
|
|
2
3
|
match do |actual|
|
|
3
4
|
subject.option?(actual)
|
|
4
5
|
end
|
|
5
6
|
|
|
6
7
|
failure_message do |actual|
|
|
7
|
-
format(
|
|
8
|
+
format('expected that "%s" is a valid option', actual)
|
|
8
9
|
end
|
|
9
10
|
|
|
10
11
|
failure_message_when_negated do |actual|
|
|
11
|
-
format(
|
|
12
|
+
format('expected that "%s" is not a valid option', actual)
|
|
12
13
|
end
|
|
13
14
|
end
|
|
14
15
|
|
data/spec/support/rack_test.rb
CHANGED
data/spec/support/reporting.rb
CHANGED
data/spec/support/rspec.rb
CHANGED
data/spec/support/strip.rb
CHANGED
data/spec/support/webmock.rb
CHANGED
data/templates/default/Gemfile
CHANGED
data/templates/default/Rakefile
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: proxy_pac_rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dennis Günnewig
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2016-05-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: addressable
|
|
@@ -94,8 +94,14 @@ dependencies:
|
|
|
94
94
|
- - "~>"
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
96
|
version: '0.19'
|
|
97
|
-
description:
|
|
98
|
-
|
|
97
|
+
description: '"proxy_pac_rb" is a gem to compress, lint and parse proxy auto-config
|
|
98
|
+
files. It comes with a cli program, some rack middlewares and can be used from within
|
|
99
|
+
ruby scripts as well. "proxy_pac_rb" uses a JavaScript runtime to evaulate a proxy
|
|
100
|
+
auto-config file the same way a browser does to determine what proxy (if any at
|
|
101
|
+
all) should a program use to connect to a server. You must install on of the supported
|
|
102
|
+
JavaScript runtimes: therubyracer or therubyrhino
|
|
103
|
+
|
|
104
|
+
'
|
|
99
105
|
email:
|
|
100
106
|
- dg1@vrnetze.de
|
|
101
107
|
executables:
|
|
@@ -254,7 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
254
260
|
version: '0'
|
|
255
261
|
requirements: []
|
|
256
262
|
rubyforge_project:
|
|
257
|
-
rubygems_version: 2.
|
|
263
|
+
rubygems_version: 2.6.3
|
|
258
264
|
signing_key:
|
|
259
265
|
specification_version: 4
|
|
260
266
|
summary: Compress, lint and parse proxy auto-config files from commandline, rack-compatible
|