rubroxy 0.1.1 → 0.1.2

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: dacda13e6588517e47fe078c64f2c686386b29b1
4
- data.tar.gz: 1846c163cefa0eb6abb3d223c99f62302abea16d
3
+ metadata.gz: ab93edcac22cc9df6aaa24ecb577dbd0f73dd52d
4
+ data.tar.gz: ddddc791cc4293d8195ea58cdb7437c228cee660
5
5
  SHA512:
6
- metadata.gz: 73436602f6f7416e4fba7052fc32f636444cba7f1605ad7a95592e52e140832fec7cdd36e7691319ab9b672695eaf28bdbf75cbd69ebd30be2396f890c1718c2
7
- data.tar.gz: 46013cc3ed1d2a60fb8e7da52cac4fe64518851c5c7847c2510b3efe07ada231e850753d39e18caa638484fdffb44ddda365bd03f35df8d5c369a1737f249772
6
+ metadata.gz: f6835b39c4e16e6a673d0802054e055ab257c8457020a19e1b16920005dbcae443983617ac70a4fa03c6527c3c2553c773f327e13601a611e29d561b6de31e45
7
+ data.tar.gz: 70963a7eaf0dc52fa305a426ef7c0799151361083c0115e7cf3a3185e21b7629e3e8019d76e51206ba21cc1786b2766f00bda85eebc2034c04163b4c2f763614
checksums.yaml.gz.sig ADDED
Binary file
data/README.md CHANGED
@@ -13,14 +13,14 @@ This can also be used as part of tests without any external scripts or dependenc
13
13
  ```
14
14
  require 'rubroxy'
15
15
 
16
- proxy = Proxy.new('localhost', 8080, 0)
16
+ proxy = Rubroxy::Proxy.new('localhost', 8080, 0)
17
17
  proxy.start_server
18
18
  ```
19
19
 
20
20
  To filter responses and edit if needed, do something like the following:
21
21
 
22
22
  ```
23
- proxy = Proxy.new('localhost', 8080, 0)
23
+ proxy = Rubroxy::Proxy.new('localhost', 8080, 0)
24
24
 
25
25
  # Creates a proc object with the logic provided in the code block
26
26
  handler = proc do |req, res|
@@ -0,0 +1,46 @@
1
+ module Rubroxy
2
+ module Handler
3
+ # Captures URLs, stores the results in a hash as the handler
4
+ # Proc object is called.
5
+ class URLCapture
6
+ attr_accessor :collection
7
+
8
+ # Creates a new URLCapture object. Sets up the hash to store URLs
9
+ #
10
+ # @return [Hash]
11
+ def initialize
12
+ setup_collection
13
+ end
14
+
15
+ # Writes to the URL collection. It attempts to find the key matching the
16
+ # URL captured and increments the value if found. If not, it will create
17
+ # a new key value pair.
18
+ #
19
+ # @param url [String] the url captured by the handler Proc
20
+ # @return [Hash]
21
+ def write(url)
22
+ if @collection[:uris].key?(url)
23
+ @collection[:uris][url] += 1
24
+ else
25
+ @collection[:uris].merge!(url => 1)
26
+ end
27
+ end
28
+
29
+ # Clears the objects URL hash.
30
+ #
31
+ # @return [Hash]
32
+ def clear
33
+ setup_collection
34
+ end
35
+
36
+ private
37
+
38
+ # Called by public methods to setup the correct hash structure.
39
+ #
40
+ # @return [Hash]
41
+ def setup_collection
42
+ @collection = { uris: {} }
43
+ end
44
+ end
45
+ end
46
+ end
@@ -1,40 +1,42 @@
1
+ module Rubroxy
1
2
  # Main class of the proxy object, includes control methods
2
- class Proxy
3
- attr_accessor :server
3
+ class Proxy
4
+ attr_accessor :server
4
5
 
5
- # Creates the proxy object, defines logging levels and host:port
6
- #
7
- # @param host [String] Hostname of the proxy (eg: localhost, 127.0.0.1 etc)
8
- # @param port [Integer] The expected port number (eg: 8080)
9
- # @param logger_level [Integer] Sets the detail of the logger included.
10
- # @return [Proxy]
11
- def initialize(host, port, logger_level = 1)
12
- logger = Logger.new($stderr)
13
- logger.level = logger_level
14
- access_log = [] if logger.level == 3
15
- @server = WEBrick::HTTPProxyServer.new(Port: port,
16
- Logger: logger,
17
- AccessLog: access_log,
18
- BindAddress: host)
19
- end
6
+ # Creates the proxy object, defines logging levels and host:port
7
+ #
8
+ # @param host [String] Hostname of the proxy (eg: localhost, 127.0.0.1 etc)
9
+ # @param port [Integer] The expected port number (eg: 8080)
10
+ # @param logger_level [Integer] Sets the detail of the logger included.
11
+ # @return [Proxy]
12
+ def initialize(host, port, logger_level = 1)
13
+ logger = Logger.new($stderr)
14
+ logger.level = logger_level
15
+ access_log = [] if logger.level == 3
16
+ @server = WEBrick::HTTPProxyServer.new(Port: port,
17
+ Logger: logger,
18
+ AccessLog: access_log,
19
+ BindAddress: host)
20
+ end
20
21
 
21
- # Adds a Proc object to the Proxy server
22
- #
23
- # @param handler [Proc] The proc object to be passed into the server config
24
- def add_rules(handler)
25
- @server.config[:ProxyContentHandler] = handler
26
- end
22
+ # Adds a Proc object to the Proxy server
23
+ #
24
+ # @param handler [Proc] The proc object to be passed into the server config
25
+ def add_rules(handler)
26
+ @server.config[:ProxyContentHandler] = handler
27
+ end
27
28
 
28
- # Starts the server process, including traps for process termination
29
- def start_server
30
- Signal.trap('INT') { stop_server }
31
- Signal.trap('TERM') { stop_server }
29
+ # Starts the server process, including traps for process termination
30
+ def start_server
31
+ Signal.trap('INT') { stop_server }
32
+ Signal.trap('TERM') { stop_server }
32
33
 
33
- @server.start
34
- end
34
+ @server.start
35
+ end
35
36
 
36
- # Shuts down the proxy server
37
- def stop_server
38
- @server.shutdown
37
+ # Shuts down the proxy server
38
+ def stop_server
39
+ @server.shutdown
40
+ end
39
41
  end
40
42
  end
@@ -1,4 +1,4 @@
1
1
  #:nodoc:
2
2
  module Rubroxy
3
- VERSION = '0.1.1'
3
+ VERSION = '0.1.2'
4
4
  end
data/lib/rubroxy.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  require 'webrick'
2
2
  require 'webrick/httpproxy'
3
3
  require 'logger'
4
- require 'rubroxy/proxy_core.rb'
4
+ require 'pry'
5
+ require 'require_all'
6
+ require_all 'lib/rubroxy'
data.tar.gz.sig ADDED
@@ -0,0 +1,3 @@
1
+ a�H�9[@EU�¥�id���nJ�4��>1H�^��({ou^Ukn.�f�8�z�^�h�HEbV�f����ǰC+öY���&
2
+ Ãc `T���d�pi�!,y�qd�a������nM�/�u��t�T�x� Gj��b� ���ӯ�X�k1��r��%��j΂d�"; '�rG�����l0�
3
+ ���;�a�[B a%���@��vd�(ͶPkd;��'ܐ.L�P��V/�V#���Ǯ�g��U)��>i�
metadata CHANGED
@@ -1,14 +1,36 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubroxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Prescott
8
8
  autorequire:
9
9
  bindir: bin
10
- cert_chain: []
11
- date: 2016-06-08 00:00:00.000000000 Z
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDgDCCAmigAwIBAgIBATANBgkqhkiG9w0BAQUFADBDMRcwFQYDVQQDDA5qYW1l
14
+ cy5wcmVzY290dDETMBEGCgmSJomT8ixkARkWA2l0djETMBEGCgmSJomT8ixkARkW
15
+ A2NvbTAeFw0xNjA2MDgxMjQ5MjlaFw0xNzA2MDgxMjQ5MjlaMEMxFzAVBgNVBAMM
16
+ DmphbWVzLnByZXNjb3R0MRMwEQYKCZImiZPyLGQBGRYDaXR2MRMwEQYKCZImiZPy
17
+ LGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxw+qWVku
18
+ dPd2ZRkIIWDZI+mzq0O9FvnAf7bsHQNUyVXD0Tp35vWTA4uMZ7KHK086LfBMEhR3
19
+ 2JP9zR/TSvU/4lOYnzCn+p5y78wEsriYimBshWb5kvvJSe9qw2cNZ6C4RsILVjvi
20
+ cQs+IBAQCEkiA7yO7A18PYEWbXi2aWCUyIzjO6K7i1ImUtHrw3xEdklCtXaxF2cu
21
+ eWdcehwjDa+gGSMVlRF5xWNwOjXmP+b/Ue6wN1AWKgWOBZ2au5jxOkQMc7vs7Fop
22
+ On8jLmsAx0hjUXxkbjHJOH4ibnsUG/59lahR7Z81N7SDvuJV2XeF9siINjPPUjVc
23
+ pUViO3oPue9/JQIDAQABo38wfTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNV
24
+ HQ4EFgQUmVNnNk3e+xHCzwEBO4s51h1sElUwIQYDVR0RBBowGIEWamFtZXMucHJl
25
+ c2NvdHRAaXR2LmNvbTAhBgNVHRIEGjAYgRZqYW1lcy5wcmVzY290dEBpdHYuY29t
26
+ MA0GCSqGSIb3DQEBBQUAA4IBAQAT/5x5FISP0g3Lolph1Dxe91cAMdWpPnuS9cGj
27
+ pV5lvSLemJg91DDEq0xiW9j2RmS7hAqgr4OEHrvfaJ23L+d8h3e5c5N1TU/uBDzD
28
+ 3A5ksLJKJ3BgqahibgHTc60wVSHeiojcv0EEMI4RuXcfvupkekymquzhPTIAf/b/
29
+ qamACLst9BoPyfQ8GDyXJargT91lkpztE4E8kmND/465JyOBg7Px6Mc3K2ufNTKm
30
+ CniA6SAR8CxOQNwqzuOOYt9V1Yj3ihCdfWFkEMcsc7dmbOhsey2gifTPMgRusJVe
31
+ RV//y3nv21WEIgu0Q4GCMxWCCBIpq3otjDMoofmjM8R7TCfK
32
+ -----END CERTIFICATE-----
33
+ date: 2016-06-30 00:00:00.000000000 Z
12
34
  dependencies:
13
35
  - !ruby/object:Gem::Dependency
14
36
  name: webrick
@@ -50,6 +72,26 @@ dependencies:
50
72
  - - ">="
51
73
  - !ruby/object:Gem::Version
52
74
  version: 1.2.8
75
+ - !ruby/object:Gem::Dependency
76
+ name: require_all
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '1.3'
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: 1.3.3
85
+ type: :runtime
86
+ prerelease: false
87
+ version_requirements: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: '1.3'
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: 1.3.3
53
95
  - !ruby/object:Gem::Dependency
54
96
  name: rspec
55
97
  requirement: !ruby/object:Gem::Requirement
@@ -70,6 +112,46 @@ dependencies:
70
112
  - - ">="
71
113
  - !ruby/object:Gem::Version
72
114
  version: 3.4.0
115
+ - !ruby/object:Gem::Dependency
116
+ name: pry
117
+ requirement: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - "~>"
120
+ - !ruby/object:Gem::Version
121
+ version: '0.10'
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: 0.10.3
125
+ type: :development
126
+ prerelease: false
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '0.10'
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: 0.10.3
135
+ - !ruby/object:Gem::Dependency
136
+ name: httparty
137
+ requirement: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - "~>"
140
+ - !ruby/object:Gem::Version
141
+ version: '0.13'
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: 0.13.7
145
+ type: :development
146
+ prerelease: false
147
+ version_requirements: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - "~>"
150
+ - !ruby/object:Gem::Version
151
+ version: '0.13'
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: 0.13.7
73
155
  description: A simple ruby built proxy
74
156
  email: james.prescott@itv.com
75
157
  executables: []
@@ -79,11 +161,12 @@ files:
79
161
  - LICENSE.md
80
162
  - README.md
81
163
  - lib/rubroxy.rb
164
+ - lib/rubroxy/handlers/url_capture.rb
82
165
  - lib/rubroxy/proxy_core.rb
83
166
  - lib/rubroxy/version.rb
84
167
  homepage: https://github.com/ITV/rubroxy
85
168
  licenses:
86
- - GPL-3.0
169
+ - ITVPL
87
170
  metadata: {}
88
171
  post_install_message:
89
172
  rdoc_options: []
metadata.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ `�y��;$���N넵���pu���n���E�ފ�a�%�2���n6 Hv�a-�i�+s��w�2�����=���-3��+� �D5��i�:a,P_�b���|��rU�s����-^�.��E�0��X~{.aIf��
2
+ ��-�[Ӳ�ƭ{���9Q:#D�J.<�96+K���"�{�u�D�$�d~y�_n'��16�z�Ř`�ͣgl��5�|�v�(��|�8�(x���J~�"Nw��z��c�����}�