local_pac 0.1.11 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +13 -0
- data/README.DEVELOPER.md +18 -0
- data/README.md +9 -1
- data/app/assets/fonts/open-sans/Apache License Version 2.txt +53 -0
- data/app/assets/fonts/open-sans/OpenSans-Bold-webfont.eot +0 -0
- data/app/assets/fonts/open-sans/OpenSans-Bold-webfont.svg +251 -0
- data/app/assets/fonts/open-sans/OpenSans-Bold-webfont.ttf +0 -0
- data/app/assets/fonts/open-sans/OpenSans-Bold-webfont.woff +0 -0
- data/app/assets/fonts/open-sans/OpenSans-BoldItalic-webfont.eot +0 -0
- data/app/assets/fonts/open-sans/OpenSans-BoldItalic-webfont.svg +251 -0
- data/app/assets/fonts/open-sans/OpenSans-BoldItalic-webfont.ttf +0 -0
- data/app/assets/fonts/open-sans/OpenSans-BoldItalic-webfont.woff +0 -0
- data/app/assets/fonts/open-sans/OpenSans-ExtraBold-webfont.eot +0 -0
- data/app/assets/fonts/open-sans/OpenSans-ExtraBold-webfont.svg +251 -0
- data/app/assets/fonts/open-sans/OpenSans-ExtraBold-webfont.ttf +0 -0
- data/app/assets/fonts/open-sans/OpenSans-ExtraBold-webfont.woff +0 -0
- data/app/assets/fonts/open-sans/OpenSans-ExtraBoldItalic-webfont.eot +0 -0
- data/app/assets/fonts/open-sans/OpenSans-ExtraBoldItalic-webfont.svg +251 -0
- data/app/assets/fonts/open-sans/OpenSans-ExtraBoldItalic-webfont.ttf +0 -0
- data/app/assets/fonts/open-sans/OpenSans-ExtraBoldItalic-webfont.woff +0 -0
- data/app/assets/fonts/open-sans/OpenSans-Italic-webfont.eot +0 -0
- data/app/assets/fonts/open-sans/OpenSans-Italic-webfont.svg +251 -0
- data/app/assets/fonts/open-sans/OpenSans-Italic-webfont.ttf +0 -0
- data/app/assets/fonts/open-sans/OpenSans-Italic-webfont.woff +0 -0
- data/app/assets/fonts/open-sans/OpenSans-Light-webfont.eot +0 -0
- data/app/assets/fonts/open-sans/OpenSans-Light-webfont.svg +252 -0
- data/app/assets/fonts/open-sans/OpenSans-Light-webfont.ttf +0 -0
- data/app/assets/fonts/open-sans/OpenSans-Light-webfont.woff +0 -0
- data/app/assets/fonts/open-sans/OpenSans-LightItalic-webfont.eot +0 -0
- data/app/assets/fonts/open-sans/OpenSans-LightItalic-webfont.svg +252 -0
- data/app/assets/fonts/open-sans/OpenSans-LightItalic-webfont.ttf +0 -0
- data/app/assets/fonts/open-sans/OpenSans-LightItalic-webfont.woff +0 -0
- data/app/assets/fonts/open-sans/OpenSans-Regular-webfont.eot +0 -0
- data/app/assets/fonts/open-sans/OpenSans-Regular-webfont.svg +252 -0
- data/app/assets/fonts/open-sans/OpenSans-Regular-webfont.ttf +0 -0
- data/app/assets/fonts/open-sans/OpenSans-Regular-webfont.woff +0 -0
- data/app/assets/fonts/open-sans/OpenSans-Semibold-webfont.eot +0 -0
- data/app/assets/fonts/open-sans/OpenSans-Semibold-webfont.svg +251 -0
- data/app/assets/fonts/open-sans/OpenSans-Semibold-webfont.ttf +0 -0
- data/app/assets/fonts/open-sans/OpenSans-Semibold-webfont.woff +0 -0
- data/app/assets/fonts/open-sans/OpenSans-SemiboldItalic-webfont.eot +0 -0
- data/app/assets/fonts/open-sans/OpenSans-SemiboldItalic-webfont.svg +251 -0
- data/app/assets/fonts/open-sans/OpenSans-SemiboldItalic-webfont.ttf +0 -0
- data/app/assets/fonts/open-sans/OpenSans-SemiboldItalic-webfont.woff +0 -0
- data/app/assets/javascripts/application.js +17 -0
- data/app/assets/javascripts/jquery-min.js +4 -0
- data/app/assets/stylesheets/application.css.scss +139 -0
- data/app/assets/stylesheets/open-sans.css.scss +109 -0
- data/app/controllers/application_controller.rb +90 -0
- data/app/controllers/assets_controller.rb +64 -0
- data/app/controllers/file_serve_controller.rb +22 -0
- data/app/controllers/lookup_controller.rb +34 -0
- data/app/locales/de.yml +2 -0
- data/app/locales/en.yml +31 -0
- data/{features/show_known_pacfiles.feature → app/public/favicon.ico} +0 -0
- data/app/views/application.haml +10 -0
- data/app/views/error.haml +6 -0
- data/app/views/form.haml +11 -0
- data/app/views/lookup.haml +3 -0
- data/app/views/lookup_result.haml +19 -0
- data/bin/local_pac +47 -27
- data/config.ru +24 -3
- data/features/fetch_proxy_pac.feature +1 -1
- data/features/initializer.feature +0 -1
- data/features/{show_config.feature → show_status.feature} +2 -2
- data/features/step_definitions.rb +14 -0
- data/features/support/env.rb +1 -0
- data/files/config.yaml +1 -0
- data/files/example-config.erb +16 -0
- data/lib/local_pac/{logger.rb → access_logger.rb} +1 -1
- data/lib/local_pac/actions/create_directory.rb +2 -2
- data/lib/local_pac/actions/create_file.rb +2 -2
- data/lib/local_pac/actions/create_output.rb +36 -0
- data/lib/local_pac/config.rb +15 -5
- data/lib/local_pac/exceptions.rb +12 -0
- data/lib/local_pac/initializer.rb +10 -1
- data/lib/local_pac/main.rb +39 -2
- data/lib/local_pac/null_access_logger.rb +6 -0
- data/lib/local_pac/proxy_pac/html_data.rb +17 -0
- data/lib/local_pac/proxy_pac/html_div_style.rb +48 -0
- data/lib/local_pac/proxy_pac/html_table_style.rb +57 -0
- data/lib/local_pac/proxy_pac/pac_engine.rb +28 -0
- data/lib/local_pac/proxy_pac/pac_parser.rb +33 -0
- data/lib/local_pac/proxy_pac/pac_result.rb +49 -0
- data/lib/local_pac/proxy_pac/pac_result_html_stylist.rb +34 -0
- data/lib/local_pac/proxy_pac/result.rb +40 -0
- data/lib/local_pac/proxy_pac/result_parser.rb +49 -0
- data/lib/local_pac/router.rb +7 -0
- data/lib/local_pac/server.rb +28 -0
- data/lib/local_pac/spec_helper_file_server.rb +1 -1
- data/lib/local_pac/ui_logger.rb +0 -1
- data/lib/local_pac/version.rb +1 -1
- data/lib/local_pac.rb +15 -4
- data/local_pac.gemspec +10 -0
- data/script/console +14 -0
- data/share/archlinux/PKGBUILD +4 -4
- data/spec/actions/create_directory_spec.rb +1 -1
- data/spec/actions/create_file_spec.rb +0 -2
- data/spec/actions/create_output_spec.rb +46 -0
- data/spec/config_spec.rb +11 -0
- data/spec/features/fetch_proxy_pac_spec.rb +49 -14
- data/spec/features/lookup_proxy_spec.rb +102 -0
- data/spec/initializer_spec.rb +7 -2
- data/spec/proxy_pac/html_div_style_spec.rb +45 -0
- data/spec/proxy_pac/html_table_style_spec.rb +54 -0
- data/spec/proxy_pac/pac_engine_spec.rb +33 -0
- data/spec/proxy_pac/pac_parser_spec.rb +32 -0
- data/spec/proxy_pac/pac_result_html_stylist_spec.rb +36 -0
- data/spec/proxy_pac/pac_result_spec.rb +54 -0
- data/spec/proxy_pac_result_parser_spec.rb +15 -0
- data/spec/server_spec.rb +18 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/spec_helper_features.rb +3 -0
- data/spec/support/capybara.rb +6 -0
- metadata +264 -8
- data/lib/local_pac/file_server.rb +0 -37
@@ -0,0 +1,57 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module LocalPac
|
3
|
+
module ProxyPac
|
4
|
+
class HTMLTableStyle
|
5
|
+
private
|
6
|
+
|
7
|
+
attr_reader :data, :main_container_css_class, :element_container_css_class
|
8
|
+
|
9
|
+
public
|
10
|
+
|
11
|
+
def initialize(options = {})
|
12
|
+
@main_container_css_class = options.fetch(:main_container_css_class)
|
13
|
+
@element_container_css_class = options.fetch(:element_container_css_class)
|
14
|
+
@data = []
|
15
|
+
rescue KeyError => e
|
16
|
+
raise ArgumentError, e.message
|
17
|
+
end
|
18
|
+
|
19
|
+
def add_data(data)
|
20
|
+
@data << data
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_s
|
24
|
+
header_row = data.reduce([]) do |memo, element|
|
25
|
+
if element.header
|
26
|
+
memo << ' <th>'
|
27
|
+
memo << " <span class=\"#{element.header_css_class}\">" if element.header_css_class
|
28
|
+
memo << " #{element.header}"
|
29
|
+
memo << ' </span>' if element.header_css_class
|
30
|
+
memo << ' </th>'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
data_row = data.reduce([]) do |memo, element|
|
35
|
+
memo << ' <td>'
|
36
|
+
memo << " <span class=\"#{element.element_css_class}\">" if element.element_css_class
|
37
|
+
memo << " #{element.element}"
|
38
|
+
memo << ' </span>' if element.element_css_class
|
39
|
+
memo << ' </td>'
|
40
|
+
|
41
|
+
memo
|
42
|
+
end
|
43
|
+
|
44
|
+
content = ["<table class=\"#{main_container_css_class}\">"]
|
45
|
+
content << " <tr class=\"#{element_container_css_class}\">"
|
46
|
+
content.concat header_row
|
47
|
+
content << ' </tr>'
|
48
|
+
content << " <tr class=\"#{element_container_css_class}\">"
|
49
|
+
content.concat data_row
|
50
|
+
content << ' </tr>'
|
51
|
+
content << '</table>'
|
52
|
+
|
53
|
+
content.join("\n")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module LocalPac
|
3
|
+
module ProxyPac
|
4
|
+
class PACEngine
|
5
|
+
private
|
6
|
+
|
7
|
+
attr_reader :engine, :file
|
8
|
+
|
9
|
+
public
|
10
|
+
|
11
|
+
def initialize(options = {})
|
12
|
+
@file = options.fetch(:file)
|
13
|
+
@engine = PAC
|
14
|
+
rescue KeyError
|
15
|
+
fail ArgumentError, ":file-option is missing"
|
16
|
+
end
|
17
|
+
|
18
|
+
def find(uri)
|
19
|
+
e = engine.source(file.content)
|
20
|
+
e.find(uri)
|
21
|
+
rescue V8::Error, PAC::ProgramError => err
|
22
|
+
error_id = LocalPac.error_id
|
23
|
+
LocalPac.ui_logger.fatal "Error id \"#{error_id}\": An V8::Error occured. This can happen if compiling a proxy.pac fails. The V8::Error-message was: #{err.message}."
|
24
|
+
fail Exceptions::PacFileInvalid, error_id
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module LocalPac
|
3
|
+
module ProxyPac
|
4
|
+
class PacParser
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
attr_reader :engine, :file, :result_generator, :stylist
|
9
|
+
|
10
|
+
public
|
11
|
+
|
12
|
+
def initialize(options = {})
|
13
|
+
@file = options.fetch(:file)
|
14
|
+
@engine = options.fetch(:engine, PACEngine.new(file: @file))
|
15
|
+
@result_generator = options.fetch(:result_generator, PacResult)
|
16
|
+
@stylist = options.fetch(:stylist, PacResultHtmlStylist.new)
|
17
|
+
rescue KeyError => e
|
18
|
+
fail ArgumentError, "Argument is missing: #{e.message}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def find(uri)
|
22
|
+
uri = Addressable::URI.heuristic_parse(uri)
|
23
|
+
|
24
|
+
raise Exceptions::GivenUrlInvalid, uri unless uri.host
|
25
|
+
|
26
|
+
result = result_generator.new(engine.find(uri))
|
27
|
+
stylist.style_me(result)
|
28
|
+
|
29
|
+
result
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module LocalPac
|
3
|
+
module ProxyPac
|
4
|
+
class PacResult
|
5
|
+
|
6
|
+
attr_accessor :styled_content
|
7
|
+
attr_reader :verbatim_content, :proxy, :proxy_port, :request_type
|
8
|
+
|
9
|
+
def initialize(verbatim_content)
|
10
|
+
@verbatim_content = verbatim_content
|
11
|
+
|
12
|
+
parsed_content = parse(verbatim_content) || {}
|
13
|
+
|
14
|
+
@proxy = parsed_content[:proxy]
|
15
|
+
@proxy_port = parsed_content[:proxy_port]
|
16
|
+
@request_type = parsed_content[:request_type]
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def parse(string)
|
22
|
+
regex.match(string)
|
23
|
+
end
|
24
|
+
|
25
|
+
def regex
|
26
|
+
%r{
|
27
|
+
\A
|
28
|
+
"?
|
29
|
+
(?<request_type>
|
30
|
+
[A-Z]+
|
31
|
+
)
|
32
|
+
(?:
|
33
|
+
\s+
|
34
|
+
(?<proxy>
|
35
|
+
[0-9]{1,3}(:?\.[0-9]{1,3}){3}
|
36
|
+
)
|
37
|
+
(?:
|
38
|
+
:
|
39
|
+
(?<proxy_port>[0-9]+)
|
40
|
+
)?
|
41
|
+
)?
|
42
|
+
;?
|
43
|
+
"?
|
44
|
+
\Z
|
45
|
+
}x
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module LocalPac
|
2
|
+
module ProxyPac
|
3
|
+
class PacResultHtmlStylist
|
4
|
+
attr_reader :class_proxy_port, :class_proxy, :class_request_type, :class_unimportant, :class_main_container, :class_element_container, :class_header, :html_style, :html_data
|
5
|
+
|
6
|
+
def initialize(options = {})
|
7
|
+
@class_main_container = options.fetch(:class_main_container, 'lp_main_container')
|
8
|
+
@class_element_container = options.fetch(:class_element_container, 'lp_element_container')
|
9
|
+
@class_request_type = options.fetch(:class_request_type, 'lp_request_type')
|
10
|
+
@class_proxy = options.fetch(:class_proxy, 'lp_proxy')
|
11
|
+
@class_proxy_port = options.fetch(:class_proxy_port, 'lp_proxy_port')
|
12
|
+
@class_unimportant = options.fetch(:class_unimportant, 'lp_unimportant')
|
13
|
+
@class_header = options.fetch(:class_header, 'lp_header')
|
14
|
+
#@html_style = options.fetch(:html_style, HTMLTableStyle.new(main_container_class: class_main_container, element_container_class: class_element_container))
|
15
|
+
@html_style = options.fetch(:html_style, HTMLDivStyle.new(main_container_css_class: class_main_container, element_container_css_class: class_element_container))
|
16
|
+
@html_data = options.fetch(:html_styler, HTMLData)
|
17
|
+
end
|
18
|
+
|
19
|
+
def style_me(result)
|
20
|
+
html_style.add_data(html_data.new(element: result.request_type, element_css_class: class_request_type, header: I18n.t('models.data.request_type'), header_css_class: class_header ))
|
21
|
+
|
22
|
+
if result.proxy
|
23
|
+
html_style.add_data(html_data.new(element: result.proxy, element_css_class: class_proxy, header: I18n.t('models.data.proxy'), header_css_class: class_header ))
|
24
|
+
end
|
25
|
+
|
26
|
+
if result.proxy_port
|
27
|
+
html_style.add_data(html_data.new(element: result.proxy_port, element_css_class: class_request_type, header: I18n.t('models.data.proxy_port'), header_css_class: class_header ))
|
28
|
+
end
|
29
|
+
|
30
|
+
result.styled_content = html_style.to_s
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module LocalPac
|
3
|
+
module ProxyPac
|
4
|
+
class Result
|
5
|
+
private
|
6
|
+
|
7
|
+
attr_writer :is_nil
|
8
|
+
|
9
|
+
public
|
10
|
+
|
11
|
+
attr_accessor :content, :styled_content
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
@is_nil = true
|
15
|
+
end
|
16
|
+
|
17
|
+
def nil?
|
18
|
+
is_nil == nil
|
19
|
+
end
|
20
|
+
|
21
|
+
def proxy=(val)
|
22
|
+
is_nil = false
|
23
|
+
|
24
|
+
@proxy = val
|
25
|
+
end
|
26
|
+
|
27
|
+
def proxy_port=(val)
|
28
|
+
is_nil = false
|
29
|
+
|
30
|
+
@proxy_port = val
|
31
|
+
end
|
32
|
+
|
33
|
+
def request_type=(val)
|
34
|
+
is_nil = false
|
35
|
+
|
36
|
+
@request_type = val
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module LocalPac
|
3
|
+
module ProxyPac
|
4
|
+
class ResultParser
|
5
|
+
class PacResultHtmlStylist
|
6
|
+
attr_reader :class_proxy_port, :class_proxy, :class_proxy_port
|
7
|
+
|
8
|
+
def initialize(options = {})
|
9
|
+
@class_request_type = options.fetch(:class_request_type, 'lp_request_type')
|
10
|
+
@class_proxy = options.fetch(:class_proxy, 'lp_proxy')
|
11
|
+
@class_proxy_port = options.fetch(:class_proxy_port, 'lp_proxy_port')
|
12
|
+
end
|
13
|
+
|
14
|
+
def style_me(result)
|
15
|
+
styled_result = []
|
16
|
+
|
17
|
+
styled_result << span(result.request_type, class_request_type) if result.request_type
|
18
|
+
styled_result << " " if result.proxy || result.proxy_port
|
19
|
+
styled_result << span(result.proxy, class_proxy) if result.proxy
|
20
|
+
|
21
|
+
if result.proxy_port
|
22
|
+
styled_result << ':'
|
23
|
+
styled_result << span(result.proxy_port, class_proxy_port)
|
24
|
+
end
|
25
|
+
|
26
|
+
result.styled_content = styled_content.join
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def span(content, css_class)
|
32
|
+
"<span class=\"#{css_class}\">#{content}</span>"
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
def parse(string)
|
38
|
+
regex.match(string)
|
39
|
+
result = PacResult.new(string)
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def regex
|
45
|
+
%q{"(?<type>[A-Z]+)\s+(?:(?<host>[0-9]{1,3}(:?\.[0-9]{1,3}){3}):(?<port>[0-9]+))?;?"}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# encoding:utf-8
|
2
|
+
module LocalPac
|
3
|
+
class Server
|
4
|
+
attr_reader :port, :host, :path, :environment
|
5
|
+
|
6
|
+
def initialize(listen, environment = 'development')
|
7
|
+
uri = URI.parse(listen)
|
8
|
+
|
9
|
+
@port = uri.port
|
10
|
+
@host = uri.host
|
11
|
+
@environment = environment
|
12
|
+
rescue => e
|
13
|
+
fail Exceptions::ServerListenStatementInvalid, "I cannot parse the listen statement: #{listen}. It is invalid: #{e.message}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def start
|
17
|
+
cmd = []
|
18
|
+
cmd << 'rackup'
|
19
|
+
cmd << "-E #{environment}"
|
20
|
+
cmd << "-P #{LocalPac.config.pid_file}"
|
21
|
+
cmd << "-o #{host}"
|
22
|
+
cmd << "-p #{port}"
|
23
|
+
cmd << File.expand_path('../../../config.ru', __FILE__)
|
24
|
+
|
25
|
+
exec(cmd.join(" "))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/local_pac/ui_logger.rb
CHANGED
data/lib/local_pac/version.rb
CHANGED
data/lib/local_pac.rb
CHANGED
@@ -8,23 +8,26 @@ require 'psych'
|
|
8
8
|
require 'erb'
|
9
9
|
require 'thread'
|
10
10
|
require 'open3'
|
11
|
+
require 'addressable/uri'
|
12
|
+
require 'securerandom'
|
11
13
|
require 'fedux_org/stdlib/filesystem'
|
12
14
|
|
13
15
|
require 'active_support/cache'
|
14
16
|
require 'active_support/core_ext/string/inflections'
|
15
17
|
|
18
|
+
require 'local_pac/exceptions'
|
16
19
|
require 'local_pac/main'
|
17
|
-
require 'local_pac/
|
20
|
+
require 'local_pac/access_logger'
|
21
|
+
require 'local_pac/null_access_logger'
|
18
22
|
require 'local_pac/ui_logger'
|
19
23
|
|
20
|
-
LocalPac.ui_logger.level = Logger::UNKNOWN
|
24
|
+
LocalPac.ui_logger.level = ::Logger::UNKNOWN
|
21
25
|
|
22
26
|
require 'local_pac/git'
|
23
27
|
require 'local_pac/git_file'
|
24
28
|
require 'local_pac/git_repository'
|
25
29
|
require 'local_pac/config'
|
26
30
|
require 'local_pac/runner'
|
27
|
-
require 'local_pac/exceptions'
|
28
31
|
require 'local_pac/erb_generator'
|
29
32
|
require 'local_pac/data'
|
30
33
|
require 'local_pac/version'
|
@@ -35,8 +38,16 @@ require 'local_pac/template_repository'
|
|
35
38
|
require 'local_pac/template_file'
|
36
39
|
require 'local_pac/pac_file_validator'
|
37
40
|
require 'local_pac/actions/create_repository'
|
41
|
+
require 'local_pac/actions/create_output'
|
38
42
|
require 'local_pac/actions/create_directory'
|
39
43
|
require 'local_pac/actions/create_file'
|
40
44
|
require 'local_pac/initializer'
|
41
45
|
require 'local_pac/local_storage'
|
42
|
-
require 'local_pac/
|
46
|
+
require 'local_pac/server'
|
47
|
+
require 'local_pac/proxy_pac/html_table_style'
|
48
|
+
require 'local_pac/proxy_pac/html_div_style'
|
49
|
+
require 'local_pac/proxy_pac/html_data'
|
50
|
+
require 'local_pac/proxy_pac/pac_result_html_stylist'
|
51
|
+
require 'local_pac/proxy_pac/pac_engine'
|
52
|
+
require 'local_pac/proxy_pac/pac_result'
|
53
|
+
require 'local_pac/proxy_pac/pac_parser'
|
data/local_pac.gemspec
CHANGED
@@ -26,6 +26,16 @@ EOS
|
|
26
26
|
spec.add_runtime_dependency 'uglifier'
|
27
27
|
spec.add_runtime_dependency 'therubyracer'
|
28
28
|
spec.add_runtime_dependency 'pac'
|
29
|
+
spec.add_runtime_dependency 'haml'
|
30
|
+
spec.add_runtime_dependency 'sass'
|
29
31
|
spec.add_runtime_dependency 'git_hook-pre_receive', '~>0.1.0'
|
30
32
|
spec.add_runtime_dependency 'fedux_org-stdlib'
|
33
|
+
spec.add_runtime_dependency 'bootstrap-sass'
|
34
|
+
spec.add_runtime_dependency 'sprockets'
|
35
|
+
spec.add_runtime_dependency 'sprockets-helpers'
|
36
|
+
spec.add_runtime_dependency 'sprockets-sass'
|
37
|
+
spec.add_runtime_dependency 'compass'
|
38
|
+
spec.add_runtime_dependency 'addressable'
|
39
|
+
spec.add_runtime_dependency 'i18n'
|
40
|
+
spec.add_runtime_dependency 'rack-contrib'
|
31
41
|
end
|
data/script/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$LOAD_PATH << File.expand_path('../../lib', __FILE__)
|
4
|
+
|
5
|
+
# Pull in all of the gems including those in the `test` group
|
6
|
+
require 'bundler'
|
7
|
+
Bundler.require :default, :test, :development
|
8
|
+
|
9
|
+
require 'irb'
|
10
|
+
require 'irb/completion'
|
11
|
+
require 'local_pac'
|
12
|
+
|
13
|
+
ARGV.clear
|
14
|
+
IRB.start
|
data/share/archlinux/PKGBUILD
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Maintainer: Max Meyer <dev@fedux.org>
|
2
2
|
pkgname=local_pac
|
3
|
-
pkgver=0.1.
|
4
|
-
pkgrel=
|
3
|
+
pkgver=0.1.11
|
4
|
+
pkgrel=2
|
5
5
|
pkgdesc="local pacfile serving server"
|
6
6
|
arch=(i686 x86_64)
|
7
7
|
url="https://github.com/dg-vrnetze/${pkgname}"
|
@@ -11,7 +11,7 @@ install=${pkgname}.install
|
|
11
11
|
makedepends=(rubygems filegen)
|
12
12
|
source=(http://gems.rubyforge.org/gems/$pkgname-$pkgver.gem)
|
13
13
|
noextract=($pkgname-$pkgver.gem)
|
14
|
-
sha256sums=('
|
14
|
+
sha256sums=('cc2695dd44527e942a1d4cc3370480e1fbb44ff2eb3a050fe8714e371178ac39')
|
15
15
|
|
16
16
|
package() {
|
17
17
|
cd "$srcdir"
|
@@ -34,7 +34,7 @@ package() {
|
|
34
34
|
|
35
35
|
msg "Starting download of gems. Don't get alert that the download takes a lot of time. Since rubygems 2.2.0 a new algorithm to resolve dependencies is used. Upgrade to > 2.2.0 via sudo /usr/bin/gem update --system to improve performance."
|
36
36
|
|
37
|
-
GEM_HOME="${pkgdir}${_library_dir}" GEM_ROOT="${pkgdir}${_library_dir}" GEM_PATH="${pkgdir}${_library_dir}" /usr/bin/gem install --env-shebang --wrappers --no-ri --no-rdoc --install-dir ${pkgdir}${_library_dir} $pkgname
|
37
|
+
GEM_HOME="${pkgdir}${_library_dir}" GEM_ROOT="${pkgdir}${_library_dir}" GEM_PATH="${pkgdir}${_library_dir}" /usr/bin/gem install --env-shebang --wrappers --no-ri --no-rdoc --no-prerelease --install-dir ${pkgdir}${_library_dir} $pkgname puma
|
38
38
|
|
39
39
|
install -D -m 644 ${pkgdir}${_share_dir}/archlinux/config.yaml ${pkgdir}${_examples_dir}/config.yaml.example
|
40
40
|
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Actions::CreateOutput do
|
5
|
+
context '#initialize' do
|
6
|
+
it 'requires template, data and output' do
|
7
|
+
output = double('IO')
|
8
|
+
repository = double('TemplateRepository')
|
9
|
+
data = double('Data')
|
10
|
+
|
11
|
+
engine_klass = Class.new do
|
12
|
+
def initialize(data)
|
13
|
+
end
|
14
|
+
|
15
|
+
def compile(template, destination)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
Actions::CreateOutput.new(:template, output, data, engine_klass, repository)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context '#run' do
|
24
|
+
it 'runs the action' do
|
25
|
+
output = double('$stdout')
|
26
|
+
|
27
|
+
repository = double('TemplateRepository')
|
28
|
+
expect(repository).to receive(:find).with(:template)
|
29
|
+
|
30
|
+
data = double('Data')
|
31
|
+
|
32
|
+
engine_klass = Class.new do
|
33
|
+
def initialize(data)
|
34
|
+
end
|
35
|
+
|
36
|
+
def compile(template, destination)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
silence(:stderr) do
|
41
|
+
Actions::CreateOutput.new(:template, output, data, engine_klass, repository).run
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
data/spec/config_spec.rb
CHANGED
@@ -110,4 +110,15 @@ describe LocalPac::Config do
|
|
110
110
|
expect(config.to_s).to include File.join('.local', 'share', 'local_pac', 'run', 'pid')
|
111
111
|
end
|
112
112
|
end
|
113
|
+
|
114
|
+
context '#lock' do
|
115
|
+
it 'raises and exception if changed afterward' do
|
116
|
+
config = LocalPac::Config.new(config_file)
|
117
|
+
config.lock
|
118
|
+
|
119
|
+
expect {
|
120
|
+
config.local_storage = 'asdf'
|
121
|
+
}.to raise_error RuntimeError
|
122
|
+
end
|
123
|
+
end
|
113
124
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'spec_helper_features'
|
2
3
|
|
3
|
-
describe 'Fetch proxy pac' do
|
4
|
+
describe 'Fetch proxy pac', :type => :feature do
|
4
5
|
context '/v1/pac' do
|
5
6
|
let(:valid_pac_file) do <<-EOS.strip_heredoc.chomp
|
6
7
|
function FindProxyForURL(url, host) {
|
@@ -13,14 +14,14 @@ describe 'Fetch proxy pac' do
|
|
13
14
|
|
14
15
|
let(:git_repo) { 'git_repo' }
|
15
16
|
|
16
|
-
before
|
17
|
+
before :each do
|
17
18
|
git_init(git_repo)
|
18
19
|
create_file(File.join(git_repo, 'file.pac'), valid_pac_file)
|
19
20
|
git_add(git_repo, 'file.pac')
|
20
21
|
git_commit(git_repo)
|
21
22
|
end
|
22
23
|
|
23
|
-
|
24
|
+
before :each do
|
24
25
|
config = Class.new do
|
25
26
|
include FeduxOrg::Stdlib::Filesystem
|
26
27
|
|
@@ -33,30 +34,64 @@ describe 'Fetch proxy pac' do
|
|
33
34
|
end
|
34
35
|
end.new
|
35
36
|
|
36
|
-
LocalPac.config
|
37
|
-
LocalPac::
|
37
|
+
LocalPac.config = config
|
38
|
+
Capybara.app = LocalPac::App::FileServeController
|
38
39
|
end
|
39
40
|
|
40
|
-
it 'finds an existing proxy pac' do
|
41
|
-
|
42
|
-
expect(
|
41
|
+
it 'finds an existing proxy pac', :focus do
|
42
|
+
visit('/file.pac')
|
43
|
+
expect(page).to have_content('function FindProxyForURL(){return"DIRECT"}')
|
43
44
|
end
|
44
45
|
|
45
|
-
it 'exits with 404 if file does not exist' do
|
46
|
-
|
47
|
-
expect(
|
46
|
+
it 'exits with 404 if file does not exist', :focus do
|
47
|
+
visit('/does_not_exist.pac')
|
48
|
+
expect(page.status_code).to eq(404)
|
48
49
|
end
|
49
50
|
|
50
|
-
it 'compresses data for transit if requested' do
|
51
|
+
it 'compresses data for transit if requested', :focus do
|
52
|
+
def app
|
53
|
+
config = Class.new do
|
54
|
+
include FeduxOrg::Stdlib::Filesystem
|
55
|
+
|
56
|
+
def root_directory
|
57
|
+
File.expand_path('../../../', __FILE__)
|
58
|
+
end
|
59
|
+
|
60
|
+
def local_storage
|
61
|
+
File.join(working_directory, 'git_repo', '.git')
|
62
|
+
end
|
63
|
+
end.new
|
64
|
+
|
65
|
+
LocalPac.config = config
|
66
|
+
LocalPac::App::FileServeController
|
67
|
+
end
|
68
|
+
|
51
69
|
['deflate','gzip', 'deflate,gzip','gzip,deflate'].each do|compression_method|
|
52
|
-
response = get('/
|
70
|
+
response = get('/file.pac', {}, { 'HTTP_ACCEPT_ENCODING' => compression_method })
|
53
71
|
expect(response.headers['Content-Encoding']).to be
|
54
72
|
end
|
55
73
|
end
|
56
74
|
|
57
75
|
it 'does not compresses data for transit if not requested' do
|
76
|
+
def app
|
77
|
+
config = Class.new do
|
78
|
+
include FeduxOrg::Stdlib::Filesystem
|
79
|
+
|
80
|
+
def root_directory
|
81
|
+
File.expand_path('../../../', __FILE__)
|
82
|
+
end
|
83
|
+
|
84
|
+
def local_storage
|
85
|
+
File.join(working_directory, 'git_repo', '.git')
|
86
|
+
end
|
87
|
+
end.new
|
88
|
+
|
89
|
+
LocalPac.config = config
|
90
|
+
LocalPac::App::FileServeController
|
91
|
+
end
|
92
|
+
|
58
93
|
['deflate','gzip', 'deflate,gzip','gzip,deflate'].each do|compression_method|
|
59
|
-
response = get('/
|
94
|
+
response = get('/does_not_exist.pac')
|
60
95
|
expect(response.headers['Content-Encoding']).not_to be
|
61
96
|
end
|
62
97
|
end
|