proxy_pac_rb 0.5.5 → 0.5.6

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: ec2d9d48dce9055e2b40cfc6ff6ae7b8b4d0f9fa
4
- data.tar.gz: 526ab26ebd8911c35f6ce2e2417fb930736429a9
3
+ metadata.gz: b33fc126af83093153453784723da4d61a84a23a
4
+ data.tar.gz: 5c3ee9be7e90cb02a6ed77dc9065bc2eb216f2e3
5
5
  SHA512:
6
- metadata.gz: 88be14c2eac3c8c009ea60a7e3ed98988ad6ff67d032ce3b31ad2be82be963527377f5c7e81b21c50e353510002c926130550cc435e2e3d8d9138d942dbc2beb
7
- data.tar.gz: 194deaf969cc4710ff34a3ff7c37b02ed7d70fb83de4693dfbb8623495759ab320edf0437149fa4b370543ebe7df841b7d7f73ba51e482f91d8fbdff7bfa9abf
6
+ metadata.gz: 359b6d1a1d1dec1e12e685994428bd3c14ce819b69ab9fd1899677be3d76b7a97e543969d5a576b63c33408d1818367a42725d3291d54dadc1c278098100f68b
7
+ data.tar.gz: f45e51dc273febb09de45b60be681b3b8cb07c3115b1a12aaf9c85cb31ba58793edcd687855b8a20e36c321c784afa20d86ea0eee01657c87983f9239bdb54c6
data/Gemfile.lock CHANGED
@@ -22,7 +22,7 @@ GIT
22
22
  PATH
23
23
  remote: .
24
24
  specs:
25
- proxy_pac_rb (0.5.4)
25
+ proxy_pac_rb (0.5.5)
26
26
  activesupport (~> 4.2.0)
27
27
  addressable (~> 2.3.8)
28
28
  uglifier (~> 2.7.1)
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(){return"PROXY localhost:3128"}
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(){return"PROXY localhost:3128"}
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(){return"PROXY localhost:3128"}
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(){return"PROXY localhost:3128"}
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(){return"PROXY localhost:3128"}
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
- def compress(proxy_pac)
6
- options = {
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
- @compressor = ProxyPacRb::ProxyPacCompressor.new
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
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
  # ProxyPacRb
3
3
  module ProxyPacRb
4
- VERSION = '0.5.5'
4
+ VERSION = '0.5.6'
5
5
  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.5.5
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dennis Günnewig