proxy_pac_rb 0.4.0 → 0.4.2

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: d05d71f53826be61244e2e77515be5da29fe969c
4
- data.tar.gz: 53df642fa1b82e2a39555c1f64c88eeb190e29e7
3
+ metadata.gz: 1965713a0aecec2df86db7b6b214469d6b8b19a3
4
+ data.tar.gz: d74100e8339ad216ee5ab2d2d06036478e56a59d
5
5
  SHA512:
6
- metadata.gz: ade07d2859ebeb2fa132c91a7151853e2c1d378536cb3343e8c16d81e84e474c31d89210cbefa4fff2a41993ebc9f36e45a2af3fdcc00caeea74ef74d81ca98b
7
- data.tar.gz: 9e2368de26bb4e74125025bde77e5d3e8396a7b4aa3f8827a2ad1a29dc5f4c3d6fe48ca9666a65753f75eb3a36050d63610dd6d93cc92a9777865b649d808fc7
6
+ metadata.gz: e88fc56a91184d502bbfdaa926ec0baba657051d77b788cabbc3d8ca91c893bdec5edeffb8a5ee07f5d6b2062e1e9e639492a1a866b3ec1a5522ad101d101c01
7
+ data.tar.gz: 64ce7df70bf552e6f5c8702960a35fb7f2f6ef8aaff9911c4f7d4bd97cb6dc8b446ac3277ff4a193ba3db831eef9f463a90867574425114e73e74a1b8e35923c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- proxy_pac_rb (0.3.8)
4
+ proxy_pac_rb (0.4.1)
5
5
  activesupport
6
6
  addressable
7
7
  uglifier
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
- *Compressor Middleware*
96
+ *Warning*
96
97
 
97
- ```ruby
98
- require 'proxy_pac_rb/rack/proxy_pac_compressor'
99
- use ProxyPacRb::Rack::ProxyPacCompressor
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 weekdayRange() {
28
- function getDay(weekday) {
29
- if (weekday in wdays) {
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 dateRange() {
58
- function getMonth(name) {
59
- if (name in months) {
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 = [body].flatten.each_with_object('') { |e, a| a << e.to_s }
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 = [body].flatten.each_with_object('') { |e, a| a << e.to_s }
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
- if proxy_pac.valid?
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']
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
  # ProxyPacRb
3
3
  module ProxyPacRb
4
- VERSION = '0.4.0'
4
+ VERSION = '0.4.2'
5
5
  end
@@ -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 }
@@ -1 +1,5 @@
1
1
  require 'rack/test'
2
+
3
+ RSpec.configure do |config|
4
+ config.include Rack::Test::Methods, type: :rack_test
5
+ end
@@ -17,6 +17,4 @@ RSpec.configure do |config|
17
17
  mocks.syntax = :expect
18
18
  mocks.verify_partial_doubles = true
19
19
  end
20
-
21
- config.include Rack::Test::Methods, type: :rack_test
22
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proxy_pac_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dennis Günnewig