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.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -0
  3. data/.travis.yml +3 -2
  4. data/Gemfile +4 -3
  5. data/README.md +12 -13
  6. data/Rakefile +1 -0
  7. data/bin/pprb +1 -0
  8. data/features/step_definitions.rb +1 -0
  9. data/features/support/aruba.rb +1 -0
  10. data/features/support/env.rb +1 -0
  11. data/features/support/reporting.rb +1 -0
  12. data/lib/proxy_pac_rb.rb +1 -0
  13. data/lib/proxy_pac_rb/basic_configuration.rb +2 -1
  14. data/lib/proxy_pac_rb/cli/compress.rb +1 -0
  15. data/lib/proxy_pac_rb/cli/compress_proxy_pac.rb +1 -0
  16. data/lib/proxy_pac_rb/cli/find.rb +1 -0
  17. data/lib/proxy_pac_rb/cli/find_proxy.rb +1 -0
  18. data/lib/proxy_pac_rb/cli/init.rb +1 -0
  19. data/lib/proxy_pac_rb/cli/init_proxy_pac.rb +1 -0
  20. data/lib/proxy_pac_rb/cli/lint.rb +1 -0
  21. data/lib/proxy_pac_rb/cli/lint_proxy_pac.rb +1 -0
  22. data/lib/proxy_pac_rb/cli/runner.rb +1 -0
  23. data/lib/proxy_pac_rb/cli/shared.rb +1 -0
  24. data/lib/proxy_pac_rb/cli/show.rb +1 -0
  25. data/lib/proxy_pac_rb/cli_validator.rb +1 -0
  26. data/lib/proxy_pac_rb/code_configuration.rb +1 -0
  27. data/lib/proxy_pac_rb/encoding.rb +2 -1
  28. data/lib/proxy_pac_rb/environment.rb +19 -15
  29. data/lib/proxy_pac_rb/errors.rb +1 -0
  30. data/lib/proxy_pac_rb/exceptions.rb +1 -0
  31. data/lib/proxy_pac_rb/javascript.rb +1 -0
  32. data/lib/proxy_pac_rb/javascript_compiler.rb +3 -2
  33. data/lib/proxy_pac_rb/main.rb +1 -0
  34. data/lib/proxy_pac_rb/parser.rb +1 -0
  35. data/lib/proxy_pac_rb/proxy_pac_compressor.rb +1 -0
  36. data/lib/proxy_pac_rb/proxy_pac_dumper.rb +2 -1
  37. data/lib/proxy_pac_rb/proxy_pac_file.rb +5 -4
  38. data/lib/proxy_pac_rb/proxy_pac_js.rb +1 -0
  39. data/lib/proxy_pac_rb/proxy_pac_linter.rb +2 -1
  40. data/lib/proxy_pac_rb/proxy_pac_loader.rb +2 -1
  41. data/lib/proxy_pac_rb/proxy_pac_parser.rb +1 -0
  42. data/lib/proxy_pac_rb/rack/proxy_pac_compressor.rb +3 -1
  43. data/lib/proxy_pac_rb/rack/proxy_pac_linter.rb +3 -1
  44. data/lib/proxy_pac_rb/rspec.rb +1 -0
  45. data/lib/proxy_pac_rb/rspec/helpers.rb +1 -0
  46. data/lib/proxy_pac_rb/rspec/matchers/base_matcher.rb +5 -4
  47. data/lib/proxy_pac_rb/rspec/matchers/proxy.rb +1 -0
  48. data/lib/proxy_pac_rb/rspec/matchers/url.rb +1 -0
  49. data/lib/proxy_pac_rb/runtime.rb +6 -5
  50. data/lib/proxy_pac_rb/runtimes.rb +4 -3
  51. data/lib/proxy_pac_rb/runtimes/rubyracer.rb +2 -1
  52. data/lib/proxy_pac_rb/runtimes/rubyrhino.rb +1 -0
  53. data/lib/proxy_pac_rb/version.rb +2 -1
  54. data/proxy_pac_rb.gemspec +1 -2
  55. data/script/config.ru +1 -0
  56. data/script/console +1 -0
  57. data/spec/api/proxy_pac_compressor_spec.rb +1 -0
  58. data/spec/api/proxy_pac_dumper_spec.rb +1 -0
  59. data/spec/api/proxy_pac_file_spec.rb +1 -0
  60. data/spec/api/proxy_pac_linter_spec.rb +1 -0
  61. data/spec/api/proxy_pac_loader_spec.rb +1 -0
  62. data/spec/api/proxy_pac_parser_spec.rb +1 -0
  63. data/spec/basic_configuration_spec.rb +1 -0
  64. data/spec/code_configuration_spec.rb +1 -0
  65. data/spec/environment_spec.rb +2 -3
  66. data/spec/parser_spec.rb +1 -0
  67. data/spec/rack/proxy_pac_compressor_spec.rb +1 -0
  68. data/spec/rack/proxy_pac_linter_spec.rb +1 -0
  69. data/spec/rspec/compare_proxy_pac_files_spec.rb +1 -0
  70. data/spec/rspec/parse_proxy_pac_spec.rb +1 -0
  71. data/spec/rspec/readability_spec.rb +1 -0
  72. data/spec/rspec/rspec_spec.rb +1 -0
  73. data/spec/rspec/validitiy_spec.rb +1 -0
  74. data/spec/rspec_integration_spec_helper.rb +1 -0
  75. data/spec/spec_helper.rb +1 -0
  76. data/spec/support/aruba.rb +1 -0
  77. data/spec/support/matchers/file.rb +3 -2
  78. data/spec/support/matchers/option.rb +3 -2
  79. data/spec/support/rack_test.rb +1 -0
  80. data/spec/support/reporting.rb +1 -0
  81. data/spec/support/rspec.rb +1 -0
  82. data/spec/support/shared_examples/configuration.rb +1 -0
  83. data/spec/support/shared_examples/loader.rb +1 -0
  84. data/spec/support/strip.rb +1 -0
  85. data/spec/support/webmock.rb +1 -0
  86. data/templates/build/middleman/config.rb +1 -0
  87. data/templates/default/Gemfile +1 -0
  88. data/templates/default/Rakefile +1 -0
  89. data/templates/test_framework/rspec/spec_helper.rb +1 -0
  90. data/templates/test_framework/rspec/support/aruba.rb +1 -0
  91. data/templates/test_framework/rspec/support/proxy_pac_rb.rb +1 -0
  92. data/templates/test_framework/rspec/support/rspec.rb +1 -0
  93. metadata +11 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9c609f5450ae3c5d31bde4b270ab0a72c53f7ab9
4
- data.tar.gz: 33697253051d84fcdafbeffbd5fcdba85e1314f9
3
+ metadata.gz: a0794209d07fae2f81954cf207260f5327eced23
4
+ data.tar.gz: 2dd5a036c784b5da8928feecdb4088b92c09b8b7
5
5
  SHA512:
6
- metadata.gz: b2cff58a27319e27abe84babaa3248d616ce823e56603ddc7ec4021f68ed95affa495b3e83de04387e0b9372f02e2c99e0604322bac95b03b22e1802d4abc4c1
7
- data.tar.gz: a5cf9842df03b58684e6da48dbf6f697602a1043a242c02b1da8f7e2c9ddace76e12ae80ae5cae0e4a794cd28e81571dfee809417e570cdee0b6f6cbcaa96afd
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
@@ -4,6 +4,7 @@ env:
4
4
  language: ruby
5
5
  bundler_args: --without development debug profile
6
6
  rvm:
7
- - 2.1.7
8
- - 2.2.3
7
+ - 2.1.10
8
+ - 2.2.5
9
+ - 2.3.1
9
10
  script: script/test
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
- # Important needs to come first
195
- # See Warning above for a full explanation
196
- require 'proxy_pac_rb/rack/proxy_pac_linter'
197
- use ProxyPacRb::Rack::ProxyPacLinter
198
-
199
- require 'proxy_pac_rb/rack/proxy_pac_compressor'
200
- use ProxyPacRb::Rack::ProxyPacCompressor
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
- page "*.pac", content_type: 'application/x-ns-proxy-autoconfig'
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.to_s, content_type: 'text/plain')
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
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env rake
2
+ # frozen_string_literal: true
2
3
 
3
4
  # require 'bundler'
4
5
  # Bundler.require :default, :test, :development
data/bin/pprb CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: utf-8
3
+ # frozen_string_literal: true
3
4
  $LOAD_PATH << File.expand_path('../../lib', __FILE__)
4
5
 
5
6
  require 'proxy_pac_rb'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  Given(/^a proxy\.pac named "([^"]*)" does not exist$/) do |name|
2
3
  FileUtils.rm_rf expand_path("#{name}.pac")
3
4
  end
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  require 'aruba/cucumber'
3
4
 
4
5
  Aruba.configure do |config|
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  require 'aruba/cucumber'
3
4
 
4
5
  require 'simplecov'
@@ -1,2 +1,3 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  require 'active_support/core_ext/kernel/reporting'
data/lib/proxy_pac_rb.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'active_support/core_ext/object/blank'
2
3
  require 'active_support/core_ext/string/strip'
3
4
  require 'active_support/core_ext/string/filters'
@@ -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
- fail NotImplementedError, %(Unknown option "#{name}") unless option? name
81
+ raise NotImplementedError, %(Unknown option "#{name}") unless option? name
81
82
 
82
83
  local_options[name]
83
84
  end
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  module ProxyPacRb
3
4
  module Cli
4
5
  # Compress things
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  module ProxyPacRb
3
4
  module Cli
4
5
  # Compress proxy pac
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  module ProxyPacRb
3
4
  module Cli
4
5
  # Find things
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  module ProxyPacRb
3
4
  module Cli
4
5
  # Find proxy for url
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ProxyPacRb
2
3
  module Cli
3
4
  # Lint things
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ProxyPacRb
2
3
  module Cli
3
4
  # Find proxy for url
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ProxyPacRb
2
3
  module Cli
3
4
  # Lint things
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ProxyPacRb
2
3
  module Cli
3
4
  # Find proxy for url
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  module ProxyPacRb
3
4
  # Commandline parsing
4
5
  module Cli
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  module ProxyPacRb
3
4
  module Cli
4
5
  # Shared methods for all cli commands
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  module ProxyPacRb
3
4
  module Cli
4
5
  # Show things
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ProxyPacRb
2
3
  # Validator for commandline options
3
4
  class CliValidator
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ProxyPacRb
2
3
  # Configure ProxyPacRb
3
4
  class CodeConfiguration < BasicConfiguration
@@ -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
- fail ::Encoding::UndefinedConversionError, "Could not encode ASCII-8BIT data #{string.dump} as UTF-8"
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
- fail ArgumentError, '<base ip> needs to be defined' if base_ip.nil? || base_ip.empty?
59
- fail ArgumentError, '<mask> needs to be defined' if mask.nil? || mask.empty?
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
- string << "\n\n"
105
- string << javascript_function_templates.my_ip_address_template(client_ip)
108
+ str << "\n"
109
+ str << javascript_function_templates.my_ip_address_template(client_ip)
106
110
  end
107
111
 
108
112
  if time
109
- string << javascript_function_templates.time_variables
110
- string << "\n\n"
111
- string << javascript_function_templates.week_day_range_template(time)
112
- string << "\n\n"
113
- string << javascript_function_templates.week_day_range_template(time)
114
- string << "\n\n"
115
- string << javascript_function_templates.date_range_template(time)
116
- string << "\n\n"
117
- string << javascript_function_templates.time_range_template(time)
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
- string
124
+ str.join("\n")
121
125
  end
122
126
  end
123
127
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ProxyPacRb
2
3
  # Raised if proxy pac is invalid
3
4
  class LinterError < StandardError; end
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  module ProxyPacRb
3
4
  module Exceptions
4
5
  # raise on error
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  module ProxyPacRb
3
4
  # Parse Proxy pac to file system
4
5
  class Javascript
@@ -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
- fail Exceptions::RuntimeUnavailable, "#{runtime.name} is unavailable on this system" unless runtime.available?
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
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  # Main
3
4
  module ProxyPacRb
4
5
  @debug_mode = false
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  module ProxyPacRb
3
4
  # Proxy Pac parser
4
5
  #
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  module ProxyPacRb
3
4
  # Compress javascript files
4
5
  class ProxyPacCompressor
@@ -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
- fail Errno::ENOENT, "Both paths \"#{path.gsub(/#{in_extension}*$/, '') + in_extension}\" and \"#{path}\" do not exist."
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
- fail ProxyPacInvalidError, "The proxy.pac \"#{source}\" is not readable: #{message}. Stopping here." unless readable?
57
- fail ProxyPacInvalidError, "The proxy.pac \"#{source}\" is not valid: #{message}. Stopping here." unless valid?
58
- fail 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?
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
- fail UrlInvalidError, 'url is missing host' unless uri.host
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
  # Javascript-Methods for evaluation of proxy.pac
4
5
  class ProxyPacJs
@@ -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
- fail LinterError, message unless proxy_pac.content.to_s.include?('FindProxyForURL')
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
- fail StandardError
59
+ raise StandardError
59
60
  end
60
61
 
61
62
  def suitable_for?(proxy_pac)
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  module ProxyPacRb
3
4
  # Parse Proxy pac to file system
4
5
  class ProxyPacParser
@@ -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
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'proxy_pac_rb'
2
3
  require 'rspec'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ProxyPacRb
2
3
  module Rspec
3
4
  # Helpers for proxy.pac tests
@@ -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 = EnglishPhrasing.split_words(self.class.matcher_name)
58
- desc << EnglishPhrasing.list(@expected) if defined?(@expected)
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
- fail "#{self.class.name} needs to supply#{ivar_list}"
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
- alias_method :present_ivars, :instance_variables
125
+ alias present_ivars instance_variables
125
126
  end
126
127
 
127
128
  # @private
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'proxy_pac_rb'
2
3
 
3
4
  module ProxyPacRb
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'proxy_pac_rb'
2
3
 
3
4
  RSpec::Matchers.define :be_downloaded_via do |expected|
@@ -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
- fail NotImplementedError
21
+ raise NotImplementedError
21
22
  end
22
23
 
23
24
  def eval(_source, _options = {})
24
- fail NotImplementedError
25
+ raise NotImplementedError
25
26
  end
26
27
 
27
28
  def call(_properties, *_args)
28
- fail NotImplementedError
29
+ raise NotImplementedError
29
30
  end
30
31
  end
31
32
 
32
33
  def name
33
- fail NotImplementedError
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
- fail NotImplementedError
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
- fail(RuntimeUnavailableError, 'Could not find a JavaScript runtime. ' \
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
- fail RuntimeUnavailableError, "#{ENV['JS_RUNTIME']} runtime is not defined" unless runtime
24
- fail RuntimeUnavailableError, "#{runtime.name} runtime is not available on this system" unless runtime.available?
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
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ProxyPacRb
2
3
  # Ruby Racer Runtime
3
4
  class RubyRacerRuntime < Runtime
@@ -91,7 +92,7 @@ module ProxyPacRb
91
92
  end
92
93
 
93
94
  if exception
94
- fail exception
95
+ raise exception
95
96
  else
96
97
  result
97
98
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ProxyPacRb
2
3
  # Ruby Rhine Runtime
3
4
  class RubyRhinoRuntime < Runtime
@@ -1,5 +1,6 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  # ProxyPacRb
3
4
  module ProxyPacRb
4
- VERSION = '0.9.1'
5
+ VERSION = '1.0.0'
5
6
  end
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
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'bundler'
4
5
  Bundler.require :default, :test, :development
data/script/console CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  $LOAD_PATH << ::File.expand_path('../../lib', __FILE__)
4
5
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe ProxyPacCompressor do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe ProxyPacDumper, type: :aruba do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe ProxyPacFile do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe ProxyPacLinter do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe ProxyPacLoader, type: :aruba do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe ProxyPacParser do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe ProxyPacRb::BasicConfiguration do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe ProxyPacRb::CodeConfiguration do
@@ -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
@@ -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::Parser, type: :aruba do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
  require 'proxy_pac_rb/rack/proxy_pac_compressor'
3
4
  require 'rack/lint'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
  require 'proxy_pac_rb/rack/proxy_pac_linter'
3
4
  require 'rack/lint'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
  require 'proxy_pac_rb/rspec'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
  require 'proxy_pac_rb/rspec'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
  require 'proxy_pac_rb/rspec'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  RSpec.describe ProxyPacRb, type: :proxy_pac do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
  require 'proxy_pac_rb/rspec'
3
4
 
@@ -1,2 +1,3 @@
1
+ # frozen_string_literal: true
1
2
  require_relative 'spec_helper'
2
3
  require 'proxy_pac_rb/rspec'
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
4
  $LOAD_PATH << ::File.expand_path('../../lib', __FILE__)
4
5
 
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  require 'aruba/rspec'
3
4
 
4
5
  Aruba.configure do |config|
@@ -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("expected that file \"%s\" exists", actual)
6
+ format('expected that file "%s" exists', actual)
6
7
  end
7
8
 
8
9
  failure_message_when_negated do |actual|
9
- format("expected that file \"%s\" does not exist", actual)
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("expected that \"%s\" is a valid option", actual)
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("expected that \"%s\" is not a valid option", actual)
12
+ format('expected that "%s" is not a valid option', actual)
12
13
  end
13
14
  end
14
15
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rack/test'
2
3
 
3
4
  RSpec.configure do |config|
@@ -1 +1,2 @@
1
+ # frozen_string_literal: true
1
2
  require 'fedux_org_stdlib/core_ext/kernel/reporting'
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  RSpec.configure do |config|
3
4
  config.filter_run :focus
4
5
  config.run_all_when_everything_filtered = true
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  RSpec.shared_examples 'a basic configuration' do
2
3
  subject(:config) do
3
4
  Class.new(described_class) do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  RSpec.shared_examples 'a loadable proxy.pac' do
2
3
  it { loader.load(proxy_pac) }
3
4
  end
@@ -1,2 +1,3 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  require 'active_support/core_ext/string/strip'
@@ -1 +1,2 @@
1
+ # frozen_string_literal: true
1
2
  require 'webmock/rspec'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'proxy_pac_rb/rack/proxy_pac_linter'
2
3
  use ProxyPacRb::Rack::ProxyPacLinter
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  source 'https://rubygems.org'
2
3
 
3
4
  gem 'proxy_pac_rb'
@@ -1 +1,2 @@
1
+ # frozen_string_literal: true
1
2
  # Place your tasks here
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  $LOAD_PATH << File.expand_path('../../lib', __FILE__)
3
4
 
4
5
  # Pull in all of the gems including those in the `test` group
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  require 'aruba/api'
3
4
  require 'aruba/reporting'
4
5
 
@@ -1 +1,2 @@
1
+ # frozen_string_literal: true
1
2
  require 'proxy_pac_rb/rspec'
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
2
3
  RSpec.configure do |config|
3
4
  config.filter_run :focus
4
5
  config.run_all_when_everything_filtered = true
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.9.1
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: 2015-11-11 00:00:00.000000000 Z
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
- "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
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.4.5.1
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