proxy_pac_rb 0.5.5 → 0.5.6
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 +9 -0
- data/features/compress_proxy_pac.feature +20 -5
- data/lib/proxy_pac_rb/proxy_pac_compressor.rb +12 -2
- data/lib/proxy_pac_rb/rack/proxy_pac_compressor.rb +10 -3
- data/lib/proxy_pac_rb/version.rb +1 -1
- 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: b33fc126af83093153453784723da4d61a84a23a
|
4
|
+
data.tar.gz: 5c3ee9be7e90cb02a6ed77dc9065bc2eb216f2e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 359b6d1a1d1dec1e12e685994428bd3c14ce819b69ab9fd1899677be3d76b7a97e543969d5a576b63c33408d1818367a42725d3291d54dadc1c278098100f68b
|
7
|
+
data.tar.gz: f45e51dc273febb09de45b60be681b3b8cb07c3115b1a12aaf9c85cb31ba58793edcd687855b8a20e36c321c784afa20d86ea0eee01657c87983f9239bdb54c6
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -173,6 +173,15 @@ require 'proxy_pac_rb/rack/proxy_pac_compressor'
|
|
173
173
|
use ProxyPacRb::Rack::ProxyPacCompressor
|
174
174
|
```
|
175
175
|
|
176
|
+
If you need to change some settings, please pass it a `options`-parameter.
|
177
|
+
Please see the (`uglifier`)[https://github.com/lautis/uglifier] for more
|
178
|
+
information about this.
|
179
|
+
|
180
|
+
```ruby
|
181
|
+
require 'proxy_pac_rb/rack/proxy_pac_compressor'
|
182
|
+
use ProxyPacRb::Rack::ProxyPacCompressor.new(options: {})
|
183
|
+
```
|
184
|
+
|
176
185
|
#### Using "rack"-middleware with "middleman"
|
177
186
|
|
178
187
|
If you want to use the `rack`-middleware with `middleman` look at the following
|
@@ -8,26 +8,32 @@ Feature: Compress proxy pac
|
|
8
8
|
Given a file named "proxy.pac.in" with:
|
9
9
|
"""
|
10
10
|
function FindProxyForURL(url, host) {
|
11
|
+
// comment
|
11
12
|
return 'PROXY localhost:3128';
|
12
13
|
}
|
13
14
|
"""
|
14
15
|
When I successfully run `pprb compress pac_file -p proxy.pac.in`
|
15
16
|
Then the file "proxy.pac" should contain:
|
16
17
|
"""
|
17
|
-
function FindProxyForURL(){
|
18
|
+
function FindProxyForURL() {
|
19
|
+
return "PROXY localhost:3128";
|
20
|
+
}
|
18
21
|
"""
|
19
22
|
|
20
23
|
Scenario: Existing proxy.pac
|
21
24
|
Given a file named "proxy.pac" with:
|
22
25
|
"""
|
23
26
|
function FindProxyForURL(url, host) {
|
27
|
+
// comment
|
24
28
|
return 'PROXY localhost:3128';
|
25
29
|
}
|
26
30
|
"""
|
27
31
|
When I successfully run `pprb compress pac_file -p proxy.pac`
|
28
32
|
Then the file "proxy.pac.out" should contain:
|
29
33
|
"""
|
30
|
-
function FindProxyForURL(){
|
34
|
+
function FindProxyForURL() {
|
35
|
+
return "PROXY localhost:3128";
|
36
|
+
}
|
31
37
|
"""
|
32
38
|
|
33
39
|
Scenario: Checks for valid proxy pac
|
@@ -48,31 +54,40 @@ Feature: Compress proxy pac
|
|
48
54
|
Given a file named "proxy1.pac.in" with:
|
49
55
|
"""
|
50
56
|
function FindProxyForURL(url, host) {
|
57
|
+
// comment
|
51
58
|
return 'PROXY localhost:3128';
|
52
59
|
}
|
53
60
|
"""
|
54
61
|
And a file named "proxy2.pac.in" with:
|
55
62
|
"""
|
56
63
|
function FindProxyForURL(url, host) {
|
64
|
+
// comment
|
57
65
|
return 'PROXY localhost:3128';
|
58
66
|
}
|
59
67
|
"""
|
60
68
|
And a file named "proxy3.pac" with:
|
61
69
|
"""
|
62
70
|
function FindProxyForURL(url, host) {
|
71
|
+
// comment
|
63
72
|
return 'PROXY localhost:3128';
|
64
73
|
}
|
65
74
|
"""
|
66
75
|
When I successfully run `pprb compress pac_file -p proxy1.pac.in proxy2.pac.in proxy3.pac`
|
67
76
|
Then the file "proxy1.pac" should contain:
|
68
77
|
"""
|
69
|
-
function FindProxyForURL(){
|
78
|
+
function FindProxyForURL() {
|
79
|
+
return "PROXY localhost:3128";
|
80
|
+
}
|
70
81
|
"""
|
71
82
|
And the file "proxy2.pac" should contain:
|
72
83
|
"""
|
73
|
-
function FindProxyForURL(){
|
84
|
+
function FindProxyForURL() {
|
85
|
+
return "PROXY localhost:3128";
|
86
|
+
}
|
74
87
|
"""
|
75
88
|
And the file "proxy3.pac.out" should contain:
|
76
89
|
"""
|
77
|
-
function FindProxyForURL(){
|
90
|
+
function FindProxyForURL() {
|
91
|
+
return "PROXY localhost:3128";
|
92
|
+
}
|
78
93
|
"""
|
@@ -2,8 +2,14 @@
|
|
2
2
|
module ProxyPacRb
|
3
3
|
# Compress javascript files
|
4
4
|
class ProxyPacCompressor
|
5
|
-
|
6
|
-
|
5
|
+
private
|
6
|
+
|
7
|
+
attr_reader :options
|
8
|
+
|
9
|
+
public
|
10
|
+
|
11
|
+
def initialize(
|
12
|
+
options: {
|
7
13
|
output: {
|
8
14
|
# ascii_only: true, # Escape non-ASCII characters
|
9
15
|
# comments: :copyright, # Preserve comments (:all, :jsdoc, :copyright, :none, Regexp (see below))
|
@@ -55,7 +61,11 @@ module ProxyPacRb
|
|
55
61
|
# keep_fnames: true # Preserve function names
|
56
62
|
}
|
57
63
|
}
|
64
|
+
)
|
65
|
+
@options = options
|
66
|
+
end
|
58
67
|
|
68
|
+
def compress(proxy_pac)
|
59
69
|
proxy_pac.content = Uglifier.new(options).compile(proxy_pac.content)
|
60
70
|
end
|
61
71
|
end
|
@@ -20,16 +20,23 @@ module ProxyPacRb
|
|
20
20
|
class ProxyPacCompressor
|
21
21
|
private
|
22
22
|
|
23
|
-
attr_reader :compressor, :loader, :enabled
|
23
|
+
attr_reader :compressor, :loader, :enabled, :options
|
24
24
|
|
25
25
|
public
|
26
26
|
|
27
27
|
def initialize(
|
28
28
|
app,
|
29
|
-
enabled: true
|
29
|
+
enabled: true,
|
30
|
+
options: nil
|
30
31
|
)
|
31
32
|
@app = app
|
32
|
-
|
33
|
+
|
34
|
+
@compressor = if options.blank?
|
35
|
+
ProxyPacRb::ProxyPacCompressor.new
|
36
|
+
else
|
37
|
+
ProxyPacRb::ProxyPacCompressor.new(options: options)
|
38
|
+
end
|
39
|
+
|
33
40
|
@loader = ProxyPacRb::ProxyPacLoader.new
|
34
41
|
@enabled = enabled
|
35
42
|
end
|
data/lib/proxy_pac_rb/version.rb
CHANGED