proxy_pac_rb 0.5.1 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 588a9ba9887581a9fa61028cd10121cb6f8623c1
4
- data.tar.gz: 87af23d999bf290bc75cccf41b7500e7917e117a
3
+ metadata.gz: 714eabb362c0c081f97351723504e7067707d2ad
4
+ data.tar.gz: 4982228289a0c4fd793f2367d9e8cdfeed087e96
5
5
  SHA512:
6
- metadata.gz: 056f01d2d8f7533ab40363884e302d962751e348533b8c3bb508569046dbfcce3ed0f2536b937c9af66f82981b599334678e443673df364cf6a23c11be4f003e
7
- data.tar.gz: f01a4f9e1069b045f959e0d5871e3f6e7c1213b0d55bb49c0bec1d46a9e12e05802fa5368428c6747d8fbe010313256778eb564bfa99aa7f61a9f0d1615d5971
6
+ metadata.gz: 123bfc62237965a88097c3e60d7ff877f1ddb442804988a3dc5e2911ca6f3b004a5c2a19831b20c6b220fd702e6dab7b6253ef60497c9860dcbd6e4bfaa6de90
7
+ data.tar.gz: 2de9d79fe35a031cece8d0942c658bb83210efeab64088fe859a437531f00b65cc649d90f2452b8783521611159148129fe1729cd2157771bda367e3e4370ea3
data/Gemfile CHANGED
@@ -16,12 +16,12 @@ end
16
16
 
17
17
  group :development, :test do
18
18
  gem 'activesupport', '~> 4.0.0', require: false
19
- gem 'aruba', require: false
19
+ gem 'aruba', require: false, git: 'https://github.com/cucumber/aruba'
20
20
  gem 'awesome_print', require: 'ap'
21
21
  gem 'bundler', '~> 1.3', require: false
22
22
  gem 'command_exec', require: false
23
23
  gem 'coveralls', require: false
24
- gem 'cucumber', require: false
24
+ gem 'cucumber', require: false, git: 'https://github.com/cucumber/cucumber'
25
25
  gem 'erubis'
26
26
  gem 'fedux_org-stdlib', '~>0.7.25', require: false
27
27
  gem 'filegen'
data/Gemfile.lock CHANGED
@@ -1,7 +1,28 @@
1
+ GIT
2
+ remote: https://github.com/cucumber/aruba
3
+ revision: 9e9b45d7d0d4ec93df0d81b0ba37b6efe03021d5
4
+ specs:
5
+ aruba (0.6.2)
6
+ childprocess (>= 0.3.6)
7
+ cucumber (>= 1.1.1)
8
+ rspec-expectations (>= 2.7.0)
9
+
10
+ GIT
11
+ remote: https://github.com/cucumber/cucumber
12
+ revision: 9d11cb7e10ed72b7dd72ba7aaafaccbb8e018da0
13
+ specs:
14
+ cucumber (2.0.0)
15
+ builder (>= 2.1.2)
16
+ cucumber-core (~> 1.1.3)
17
+ diff-lcs (>= 1.1.3)
18
+ gherkin (~> 2.12)
19
+ multi_json (>= 1.7.5, < 2.0)
20
+ multi_test (>= 0.1.2)
21
+
1
22
  PATH
2
23
  remote: .
3
24
  specs:
4
- proxy_pac_rb (0.5.0)
25
+ proxy_pac_rb (0.5.1)
5
26
  activesupport
6
27
  addressable
7
28
  uglifier
@@ -16,10 +37,6 @@ GEM
16
37
  thread_safe (~> 0.1)
17
38
  tzinfo (~> 0.3.37)
18
39
  addressable (2.3.8)
19
- aruba (0.6.2)
20
- childprocess (>= 0.3.6)
21
- cucumber (>= 1.1.1)
22
- rspec-expectations (>= 2.7.0)
23
40
  ast (2.0.0)
24
41
  astrolabe (1.3.0)
25
42
  parser (>= 2.2.0.pre.3, < 3.0)
@@ -30,7 +47,7 @@ GEM
30
47
  builder (3.2.2)
31
48
  byebug (4.0.5)
32
49
  columnize (= 0.9.0)
33
- childprocess (0.5.5)
50
+ childprocess (0.5.6)
34
51
  ffi (~> 1.0, >= 1.0.11)
35
52
  coderay (1.1.0)
36
53
  columnize (0.9.0)
@@ -46,13 +63,6 @@ GEM
46
63
  thor (~> 0.19.1)
47
64
  crack (0.4.2)
48
65
  safe_yaml (~> 1.0.0)
49
- cucumber (2.0.0)
50
- builder (>= 2.1.2)
51
- cucumber-core (~> 1.1.3)
52
- diff-lcs (>= 1.1.3)
53
- gherkin (~> 2.12)
54
- multi_json (>= 1.7.5, < 2.0)
55
- multi_test (>= 0.1.2)
56
66
  cucumber-core (1.1.3)
57
67
  gherkin (~> 2.12.0)
58
68
  debug_inspector (0.0.2)
@@ -201,13 +211,13 @@ PLATFORMS
201
211
 
202
212
  DEPENDENCIES
203
213
  activesupport (~> 4.0.0)
204
- aruba
214
+ aruba!
205
215
  awesome_print
206
216
  bundler (~> 1.3)
207
217
  byebug
208
218
  command_exec
209
219
  coveralls
210
- cucumber
220
+ cucumber!
211
221
  erubis
212
222
  fedux_org-stdlib (~> 0.7.25)
213
223
  filegen
@@ -16,9 +16,11 @@ module ProxyPacRb
16
16
  def compile(content:, environment:)
17
17
  fail Exceptions::RuntimeUnavailable, "#{runtime.name} is unavailable on this system" unless runtime.available?
18
18
 
19
- environment.prepare(content)
19
+ proxy_pac_content = content.to_s.dup
20
20
 
21
- context = runtime.compile(content)
21
+ environment.prepare(proxy_pac_content)
22
+
23
+ context = runtime.compile(proxy_pac_content)
22
24
  context.include environment
23
25
 
24
26
  Javascript.new(context)
@@ -3,8 +3,7 @@ module ProxyPacRb
3
3
  class ProxyPacFile
4
4
  include Comparable
5
5
 
6
- attr_accessor :valid, :type, :message, :readable, :javascript, :parsable, :source
7
- attr_writer :content
6
+ attr_accessor :valid, :type, :message, :readable, :javascript, :parsable, :source, :content
8
7
 
9
8
  def initialize(source:)
10
9
  if source.is_a? ProxyPacFile
@@ -28,12 +27,6 @@ module ProxyPacRb
28
27
  !@content.nil?
29
28
  end
30
29
 
31
- def content
32
- return nil if @content.nil?
33
-
34
- @content.dup
35
- end
36
-
37
30
  def <=>(other)
38
31
  content <=> other.content
39
32
  end
@@ -66,9 +59,35 @@ module ProxyPacRb
66
59
  end
67
60
 
68
61
  uri = Addressable::URI.heuristic_parse(url)
62
+
63
+ if hostname?(url)
64
+ uri.scheme = 'http'
65
+ uri.path = '/'
66
+ uri.host = url
67
+ end
68
+
69
69
  fail UrlInvalidError, 'url is missing host' unless uri.host
70
70
 
71
71
  javascript.FindProxyForURL(uri.to_s, uri.host)
72
72
  end
73
+
74
+ private
75
+
76
+ def hostname?(name)
77
+ %r{
78
+ \A
79
+ (
80
+ (
81
+ [a-zA-Z0-9]
82
+ | [a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9]
83
+ )\.
84
+ )*
85
+ (
86
+ [A-Za-z0-9]
87
+ | [A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9]
88
+ )
89
+ \Z
90
+ }x === name
91
+ end
73
92
  end
74
93
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
  # ProxyPacRb
3
3
  module ProxyPacRb
4
- VERSION = '0.5.1'
4
+ VERSION = '0.5.2'
5
5
  end
@@ -34,7 +34,7 @@ RSpec.describe ProxyPacDumper do
34
34
 
35
35
  context 'when proxy pac is string' do
36
36
  before :each do
37
- in_current_dir do
37
+ in_current_directory do
38
38
  dumper.dump(proxy_pac, type: :string)
39
39
  end
40
40
  end
@@ -51,13 +51,13 @@ RSpec.describe ProxyPacDumper do
51
51
  end
52
52
 
53
53
  before :each do
54
- in_current_dir do
54
+ in_current_directory do
55
55
  dumper.dump(proxy_pac, type: :template)
56
56
  end
57
57
  end
58
58
 
59
59
  around :example do |example|
60
- in_current_dir { example.call }
60
+ in_current_directory { example.call }
61
61
  end
62
62
 
63
63
  it { expect(destination).to be_existing_file }
@@ -87,4 +87,30 @@ RSpec.describe ProxyPacFile do
87
87
  it { expect(proxy_pac).to be_readable }
88
88
  end
89
89
  end
90
+
91
+ describe '#find' do
92
+ before :each do
93
+ proxy_pac.readable = true
94
+ proxy_pac.valid = true
95
+ proxy_pac.content = source
96
+
97
+ parser = ProxyPacParser.new
98
+ parser.parse(proxy_pac)
99
+ end
100
+
101
+ context 'when ip is used as url' do
102
+ let(:url) { '127.0.0.1' }
103
+ it { expect(proxy_pac.find(url)).to eq 'DIRECT' }
104
+ end
105
+
106
+ context 'when plain host is used as url' do
107
+ let(:url) { 'localhost' }
108
+ it { expect(proxy_pac.find(url)).to eq 'DIRECT' }
109
+ end
110
+
111
+ context 'when fqdn is used as url' do
112
+ let(:url) { 'localhost.localdomain' }
113
+ it { expect(proxy_pac.find(url)).to eq 'DIRECT' }
114
+ end
115
+ end
90
116
  end
@@ -11,7 +11,7 @@ RSpec.describe 'Readability', type: :proxy_pac do
11
11
  end
12
12
 
13
13
  context 'when is file' do
14
- let(:root_path) { current_dir }
14
+ let(:root_path) { current_directory }
15
15
 
16
16
  subject { 'proxy.pac' }
17
17
 
@@ -17,7 +17,7 @@ end
17
17
  RSpec.configure do |c|
18
18
  c.include SpecHelper::Aruba
19
19
  c.before :each do
20
- clean_current_dir
20
+ clean_current_directory
21
21
  restore_env
22
22
  end
23
23
  end
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.5.1
4
+ version: 0.5.2
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-04-08 00:00:00.000000000 Z
11
+ date: 2015-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable