proxy_pac_rb 0.4.0 → 0.4.2
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/Gemfile.lock +1 -1
- data/README.md +33 -4
- data/lib/proxy_pac_rb/proxy_pac_js.rb +14 -12
- data/lib/proxy_pac_rb/rack/proxy_pac_compressor.rb +2 -1
- data/lib/proxy_pac_rb/rack/proxy_pac_linter.rb +3 -4
- data/lib/proxy_pac_rb/version.rb +1 -1
- data/spec/rack/proxy_pac_compressor_spec.rb +5 -0
- data/spec/rack/proxy_pac_linter_spec.rb +5 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/support/rack_test.rb +4 -0
- data/spec/support/rspec.rb +0 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1965713a0aecec2df86db7b6b214469d6b8b19a3
|
4
|
+
data.tar.gz: d74100e8339ad216ee5ab2d2d06036478e56a59d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e88fc56a91184d502bbfdaa926ec0baba657051d77b788cabbc3d8ca91c893bdec5edeffb8a5ee07f5d6b2062e1e9e639492a1a866b3ec1a5522ad101d101c01
|
7
|
+
data.tar.gz: 64ce7df70bf552e6f5c8702960a35fb7f2f6ef8aaff9911c4f7d4bd97cb6dc8b446ac3277ff4a193ba3db831eef9f463a90867574425114e73e74a1b8e35923c
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -91,12 +91,35 @@ pprb lint proxy_pac -p sample.pac
|
|
91
91
|
```
|
92
92
|
|
93
93
|
### Rack-based servers
|
94
|
+
```
|
94
95
|
|
95
|
-
*
|
96
|
+
*Warning*
|
96
97
|
|
97
|
-
|
98
|
-
|
99
|
-
|
98
|
+
The linter-`rack`-middleware needs to be activated before ANY other
|
99
|
+
middleman-extension, `rack`-middleware or whatever framework you are using
|
100
|
+
can instantiate the `V8`-runtime! Only the first time the
|
101
|
+
`V8`-javascript-engine - aka `therubyracer` - is instantiated, it is possible to
|
102
|
+
create a binding to ruby code. Every other `V8`-object created later re-uses
|
103
|
+
this binding.
|
104
|
+
|
105
|
+
You might an error like this if you ignore this warning!
|
106
|
+
|
107
|
+
```bash
|
108
|
+
error build/proxy.pac
|
109
|
+
Unexpected token: name (is) (line: 1, col: 10, pos: 10)
|
110
|
+
|
111
|
+
Error
|
112
|
+
at new JS_Parse_Error (<eval>:2359:10623)
|
113
|
+
at js_error (<eval>:2359:10842)
|
114
|
+
at croak (<eval>:2359:19086)
|
115
|
+
at token_error (<eval>:2359:19223)
|
116
|
+
at unexpected (<eval>:2359:19311)
|
117
|
+
at semicolon (<eval>:2359:19784)
|
118
|
+
at simple_statement (<eval>:2359:22580)
|
119
|
+
at <eval>:2359:20553
|
120
|
+
at <eval>:2359:19957
|
121
|
+
at <eval>:2359:31968
|
122
|
+
There were errors during this build
|
100
123
|
```
|
101
124
|
|
102
125
|
*Linter Middleware*
|
@@ -106,6 +129,12 @@ require 'proxy_pac_rb/rack/proxy_pac_linter'
|
|
106
129
|
use ProxyPacRb::Rack::ProxyPacLinter
|
107
130
|
```
|
108
131
|
|
132
|
+
*Compressor Middleware*
|
133
|
+
|
134
|
+
```ruby
|
135
|
+
require 'proxy_pac_rb/rack/proxy_pac_compressor'
|
136
|
+
use ProxyPacRb::Rack::ProxyPacCompressor
|
137
|
+
|
109
138
|
### Ruby
|
110
139
|
|
111
140
|
*Load from website*
|
@@ -24,13 +24,14 @@ module ProxyPacRb
|
|
24
24
|
value = %("#{value}") if value
|
25
25
|
|
26
26
|
<<-EOS.strip_heredoc
|
27
|
-
function
|
28
|
-
|
29
|
-
|
30
|
-
return wdays[weekday];
|
31
|
-
}
|
32
|
-
return -1;
|
27
|
+
function getDay(weekday) {
|
28
|
+
if (weekday in wdays) {
|
29
|
+
return wdays[weekday];
|
33
30
|
}
|
31
|
+
return -1;
|
32
|
+
}
|
33
|
+
|
34
|
+
function weekdayRange() {
|
34
35
|
var date = new Date(#{value});
|
35
36
|
var argc = arguments.length;
|
36
37
|
var wday;
|
@@ -54,13 +55,14 @@ module ProxyPacRb
|
|
54
55
|
value = %("#{value}") if value
|
55
56
|
|
56
57
|
<<-EOS.strip_heredoc
|
57
|
-
function
|
58
|
-
|
59
|
-
|
60
|
-
return months[name];
|
61
|
-
}
|
62
|
-
return -1;
|
58
|
+
function getMonth(name) {
|
59
|
+
if (name in months) {
|
60
|
+
return months[name];
|
63
61
|
}
|
62
|
+
return -1;
|
63
|
+
}
|
64
|
+
|
65
|
+
function dateRange() {
|
64
66
|
var date = new Date(#{value});
|
65
67
|
var argc = arguments.length;
|
66
68
|
if (argc < 1) {
|
@@ -43,7 +43,8 @@ module ProxyPacRb
|
|
43
43
|
&& %r{application/x-ns-proxy-autoconfig} === headers['Content-Type']
|
44
44
|
# rubocop:enable Style/CaseEquality
|
45
45
|
|
46
|
-
content =
|
46
|
+
content = ''
|
47
|
+
body.each { |part| content << part }
|
47
48
|
|
48
49
|
begin
|
49
50
|
proxy_pac = ProxyPacFile.new(source: content)
|
@@ -42,16 +42,15 @@ module ProxyPacRb
|
|
42
42
|
&& %r{application/x-ns-proxy-autoconfig} === headers['Content-Type']
|
43
43
|
# rubocop:enable Style/CaseEquality
|
44
44
|
|
45
|
-
content =
|
45
|
+
content = ''
|
46
|
+
body.each { |part| content << part }
|
46
47
|
|
47
48
|
proxy_pac = ProxyPacFile.new(source: content)
|
48
49
|
|
49
50
|
loader.load(proxy_pac)
|
50
51
|
linter.lint(proxy_pac)
|
51
52
|
|
52
|
-
|
53
|
-
content = proxy_pac.content
|
54
|
-
else
|
53
|
+
unless proxy_pac.valid?
|
55
54
|
status = 500
|
56
55
|
content = proxy_pac.message
|
57
56
|
headers['Content-Length'] = content.bytesize.to_s if headers['Content-Length']
|
data/lib/proxy_pac_rb/version.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'proxy_pac_rb/rack/proxy_pac_compressor'
|
3
|
+
require 'rack/lint'
|
3
4
|
|
4
5
|
RSpec.describe ProxyPacRb::Rack::ProxyPacCompressor, type: :rack_test do
|
5
6
|
let(:compressed_content) { %(function FindProxyForURL(){return\"DIRECT\"}) }
|
@@ -23,7 +24,9 @@ RSpec.describe ProxyPacRb::Rack::ProxyPacCompressor, type: :rack_test do
|
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
27
|
+
a.use Rack::Lint
|
26
28
|
a.use ProxyPacRb::Rack::ProxyPacCompressor
|
29
|
+
a.use Rack::Lint
|
27
30
|
|
28
31
|
a.new
|
29
32
|
end
|
@@ -49,7 +52,9 @@ RSpec.describe ProxyPacRb::Rack::ProxyPacCompressor, type: :rack_test do
|
|
49
52
|
end
|
50
53
|
end
|
51
54
|
|
55
|
+
a.use Rack::Lint
|
52
56
|
a.use ProxyPacRb::Rack::ProxyPacCompressor
|
57
|
+
a.use Rack::Lint
|
53
58
|
|
54
59
|
a.new
|
55
60
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'proxy_pac_rb/rack/proxy_pac_linter'
|
3
|
+
require 'rack/lint'
|
3
4
|
|
4
5
|
RSpec.describe ProxyPacRb::Rack::ProxyPacLinter, type: :rack_test do
|
5
6
|
let(:content) do
|
@@ -29,7 +30,9 @@ RSpec.describe ProxyPacRb::Rack::ProxyPacLinter, type: :rack_test do
|
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
33
|
+
a.use Rack::Lint
|
32
34
|
a.use ProxyPacRb::Rack::ProxyPacLinter
|
35
|
+
a.use Rack::Lint
|
33
36
|
|
34
37
|
a.new
|
35
38
|
end
|
@@ -55,7 +58,9 @@ RSpec.describe ProxyPacRb::Rack::ProxyPacLinter, type: :rack_test do
|
|
55
58
|
end
|
56
59
|
end
|
57
60
|
|
61
|
+
a.use Rack::Lint
|
58
62
|
a.use ProxyPacRb::Rack::ProxyPacLinter
|
63
|
+
a.use Rack::Lint
|
59
64
|
|
60
65
|
a.new
|
61
66
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -8,7 +8,7 @@ SimpleCov.start
|
|
8
8
|
|
9
9
|
# Pull in all of the gems including those in the `test` group
|
10
10
|
require 'bundler'
|
11
|
-
Bundler.require :default, :test, :development
|
11
|
+
Bundler.require :default, :test, :development, :debug
|
12
12
|
|
13
13
|
# Loading support files
|
14
14
|
Dir.glob(::File.expand_path('../support/*.rb', __FILE__)).each { |f| require_relative f }
|
data/spec/support/rack_test.rb
CHANGED
data/spec/support/rspec.rb
CHANGED