remote_partial 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/README.rdoc +8 -0
- data/lib/remote_partial/partial.rb +0 -5
- data/lib/remote_partial/resource_manager.rb +15 -2
- data/lib/remote_partial/version.rb +5 -1
- data/test/log/test.log +64 -0
- data/test/test_helper.rb +2 -1
- data/test/unit/remote_partial/resource_manager_test.rb +22 -3
- metadata +6 -12
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZGRkMzFiMGIyMmIzZWQ3YWU5NGJmMmE3ZjIxMzhmYmZiMTIyNGUxZQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YTdlMWYzYzM5NTJlZWFjNDcyZWJlMTlhZDNjNGFkZWFmOTFkYWUyNw==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YWE2ZjNmZTU2YjMwYzA4NzUwN2YxYWI1ZDJiNDE2OTU1ODM3ZjNkYThhYzRi
|
10
|
+
ZDQzYzIxZTVjMmYxMWQwNGZlNjMwZTI2NTJjMjIyYjQzMDMzNmNhMTdkOTNk
|
11
|
+
NGQ0MTUyZjc4ZTZhM2UyZjA5NThhOTA0OGFhYzE2NjdhNjg2MjY=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NTVkZGNiZTgxZDRhNTA1MWRkNjlkZmUxZDJlN2E4ZWU2NzU1M2M3MTA5NGQw
|
14
|
+
NjgzMjc1ODhjNjVkNmZhOTM2MmMzYzBlZTVjNDRjNDZkNTM3YWI4YzM4NDE2
|
15
|
+
N2QyMTA1ODhjZWMzMTY1ZGNjYzhkN2RiNzVkY2VlYTcxMWEyNzk=
|
data/README.rdoc
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
{<img src="https://codeclimate.com/github/warwickshire/remote_partial.png" />}[https://codeclimate.com/github/warwickshire/remote_partial]
|
2
|
+
{<img src="https://badge.fury.io/rb/remote_partial.png" alt="Gem Version" />}[http://badge.fury.io/rb/remote_partial]
|
2
3
|
= RemotePartial
|
3
4
|
|
4
5
|
Remote Partial allows partials to be created from remote content.
|
@@ -129,6 +130,13 @@ of the stale_at time:
|
|
129
130
|
|
130
131
|
rake remote_partial:force_update
|
131
132
|
|
133
|
+
== Connection via a proxy
|
134
|
+
|
135
|
+
RemotePartial can be modified to connect to the remote source via a proxy. To
|
136
|
+
do this set the environment variable http_proxy to the proxy url:
|
137
|
+
|
138
|
+
ENV['http_proxy'] = "http://proxy.example.com:8080"
|
139
|
+
|
132
140
|
== Problems grabbing content
|
133
141
|
|
134
142
|
If remote partial is unable to retrieve remote content, the problem will be
|
@@ -12,7 +12,7 @@ module RemotePartial
|
|
12
12
|
|
13
13
|
def self.get_raw(url)
|
14
14
|
response = get_response(url)
|
15
|
-
|
15
|
+
|
16
16
|
case response.code.to_i
|
17
17
|
when ok_response_codes
|
18
18
|
return response.body
|
@@ -27,7 +27,8 @@ module RemotePartial
|
|
27
27
|
|
28
28
|
def self.get_response(url)
|
29
29
|
uri = URI.parse(url)
|
30
|
-
|
30
|
+
|
31
|
+
http = Net::HTTP.new(*connection_settings(uri))
|
31
32
|
|
32
33
|
if uri.port == 443
|
33
34
|
http.use_ssl = true
|
@@ -38,6 +39,10 @@ module RemotePartial
|
|
38
39
|
http.request(request)
|
39
40
|
end
|
40
41
|
|
42
|
+
def self.connection_settings(uri)
|
43
|
+
[uri.host, uri.port] + proxy_settings
|
44
|
+
end
|
45
|
+
|
41
46
|
def initialize(url, criteria = nil, &output_modifier)
|
42
47
|
@url = url
|
43
48
|
@criteria = criteria
|
@@ -56,6 +61,7 @@ module RemotePartial
|
|
56
61
|
end
|
57
62
|
|
58
63
|
private
|
64
|
+
|
59
65
|
def get_whole_page
|
60
66
|
self.class.get_raw(@url).force_encoding(encoding).gsub(windows_bom_text, "")
|
61
67
|
end
|
@@ -93,5 +99,12 @@ module RemotePartial
|
|
93
99
|
300..399
|
94
100
|
end
|
95
101
|
|
102
|
+
def self.proxy_settings
|
103
|
+
return [] unless ENV['http_proxy']
|
104
|
+
proxy = URI.parse(ENV['http_proxy'])
|
105
|
+
[proxy.host, proxy.port, proxy.user, proxy.password]
|
106
|
+
end
|
107
|
+
|
108
|
+
|
96
109
|
end
|
97
110
|
end
|
@@ -1,10 +1,14 @@
|
|
1
1
|
module RemotePartial
|
2
|
-
VERSION = "0.7.
|
2
|
+
VERSION = "0.7.2"
|
3
3
|
end
|
4
4
|
|
5
5
|
# History
|
6
6
|
# =======
|
7
7
|
#
|
8
|
+
# 0.7.2 Adds facility to direct HTTP through proxy
|
9
|
+
# ------------------------------------------------
|
10
|
+
#
|
11
|
+
#
|
8
12
|
# 0.7.1 Ensures code works in standalone mode
|
9
13
|
# -------------------------------------------
|
10
14
|
# An additional require statement to load all the required libraries when not
|
data/test/log/test.log
CHANGED
@@ -69,3 +69,67 @@ I, [2013-08-27T14:59:07.213269 #5477] INFO -- : Preparing to test logging via a
|
|
69
69
|
W, [2013-08-27T14:59:07.222037 #5477] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<Net::HTTPBadRequest 400 readbody=true>
|
70
70
|
I, [2013-08-27T14:59:07.238897 #5477] INFO -- : Preparing to test logging via assert_log_entry_added
|
71
71
|
W, [2013-08-27T14:59:07.244542 #5477] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<Net::HTTPBadRequest 400 readbody=true>
|
72
|
+
I, [2013-11-25T15:55:13.694737 #12223] INFO -- : Preparing to test logging via assert_log_entry_added
|
73
|
+
W, [2013-11-25T15:55:13.715204 #12223] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<Net::HTTPBadRequest 400 readbody=true>
|
74
|
+
I, [2013-11-25T15:55:13.730608 #12223] INFO -- : Preparing to test logging via assert_log_entry_added
|
75
|
+
W, [2013-11-25T15:55:13.740418 #12223] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<Net::HTTPBadRequest 400 readbody=true>
|
76
|
+
I, [2013-11-25T15:56:19.302859 #12229] INFO -- : Preparing to test logging via assert_log_entry_added
|
77
|
+
W, [2013-11-25T15:56:19.324652 #12229] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<Net::HTTPBadRequest 400 readbody=true>
|
78
|
+
I, [2013-11-25T15:56:19.333622 #12229] INFO -- : Preparing to test logging via assert_log_entry_added
|
79
|
+
W, [2013-11-25T15:56:19.344817 #12229] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<Net::HTTPBadRequest 400 readbody=true>
|
80
|
+
I, [2013-11-25T16:02:55.740992 #12342] INFO -- : Preparing to test logging via assert_log_entry_added
|
81
|
+
W, [2013-11-25T16:02:55.747786 #12342] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<Net::HTTPBadRequest 400 readbody=true>
|
82
|
+
I, [2013-11-25T16:02:55.752866 #12342] INFO -- : Preparing to test logging via assert_log_entry_added
|
83
|
+
W, [2013-11-25T16:02:55.762047 #12342] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<Net::HTTPBadRequest 400 readbody=true>
|
84
|
+
I, [2013-11-25T16:03:38.466504 #12348] INFO -- : Preparing to test logging via assert_log_entry_added
|
85
|
+
W, [2013-11-25T16:03:38.483789 #12348] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<Net::HTTPBadRequest 400 readbody=true>
|
86
|
+
I, [2013-11-25T16:03:38.546129 #12348] INFO -- : Preparing to test logging via assert_log_entry_added
|
87
|
+
W, [2013-11-25T16:03:38.554017 #12348] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<Net::HTTPBadRequest 400 readbody=true>
|
88
|
+
I, [2013-11-25T16:14:54.344239 #12475] INFO -- : Preparing to test logging via assert_log_entry_added
|
89
|
+
W, [2013-11-25T16:14:54.354949 #12475] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<Net::HTTPBadRequest 400 readbody=true>
|
90
|
+
I, [2013-11-25T16:14:54.359362 #12475] INFO -- : Preparing to test logging via assert_log_entry_added
|
91
|
+
W, [2013-11-25T16:14:54.365191 #12475] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<Net::HTTPBadRequest 400 readbody=true>
|
92
|
+
W, [2013-11-25T16:23:49.503888 #12497] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<NoMethodError: undefined method `empty?' for nil:NilClass>
|
93
|
+
I, [2013-11-25T16:23:49.549467 #12497] INFO -- : Preparing to test logging via assert_log_entry_added
|
94
|
+
W, [2013-11-25T16:23:49.553579 #12497] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<NoMethodError: undefined method `empty?' for nil:NilClass>
|
95
|
+
W, [2013-11-25T16:23:49.563744 #12497] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<NoMethodError: undefined method `empty?' for nil:NilClass>
|
96
|
+
W, [2013-11-25T16:23:49.574069 #12497] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<NoMethodError: undefined method `empty?' for nil:NilClass>
|
97
|
+
I, [2013-11-25T16:23:49.598483 #12497] INFO -- : Preparing to test logging via assert_log_entry_added
|
98
|
+
W, [2013-11-25T16:23:49.603408 #12497] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<NoMethodError: undefined method `empty?' for nil:NilClass>
|
99
|
+
I, [2013-11-25T16:24:33.065466 #12503] INFO -- : Preparing to test logging via assert_log_entry_added
|
100
|
+
W, [2013-11-25T16:24:33.073027 #12503] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<Net::HTTPBadRequest 400 readbody=true>
|
101
|
+
I, [2013-11-25T16:24:33.101628 #12503] INFO -- : Preparing to test logging via assert_log_entry_added
|
102
|
+
W, [2013-11-25T16:24:33.107203 #12503] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<Net::HTTPBadRequest 400 readbody=true>
|
103
|
+
I, [2013-11-25T16:26:42.668122 #12511] INFO -- : Preparing to test logging via assert_log_entry_added
|
104
|
+
W, [2013-11-25T16:26:42.678779 #12511] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<Net::HTTPBadRequest 400 readbody=true>
|
105
|
+
I, [2013-11-25T16:26:42.737853 #12511] INFO -- : Preparing to test logging via assert_log_entry_added
|
106
|
+
W, [2013-11-25T16:26:42.743935 #12511] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<Net::HTTPBadRequest 400 readbody=true>
|
107
|
+
I, [2013-11-25T16:31:23.698494 #12521] INFO -- : Preparing to test logging via assert_log_entry_added
|
108
|
+
W, [2013-11-25T16:31:23.718245 #12521] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<Net::HTTPBadRequest 400 readbody=true>
|
109
|
+
I, [2013-11-25T16:31:23.788483 #12521] INFO -- : Preparing to test logging via assert_log_entry_added
|
110
|
+
W, [2013-11-25T16:31:23.794937 #12521] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<Net::HTTPBadRequest 400 readbody=true>
|
111
|
+
I, [2013-11-25T16:31:36.780488 #12533] INFO -- : Preparing to test logging via assert_log_entry_added
|
112
|
+
W, [2013-11-25T16:31:36.797683 #12533] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<Net::HTTPBadRequest 400 readbody=true>
|
113
|
+
I, [2013-11-25T16:31:36.823695 #12533] INFO -- : Preparing to test logging via assert_log_entry_added
|
114
|
+
W, [2013-11-25T16:31:36.829005 #12533] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<Net::HTTPBadRequest 400 readbody=true>
|
115
|
+
I, [2013-11-25T16:36:16.478166 #12590] INFO -- : Preparing to test logging via assert_log_entry_added
|
116
|
+
W, [2013-11-25T16:36:16.490172 #12590] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<TypeError: can't convert nil into Array>
|
117
|
+
I, [2013-11-25T16:36:16.521695 #12590] INFO -- : Preparing to test logging via assert_log_entry_added
|
118
|
+
W, [2013-11-25T16:36:16.528342 #12590] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<TypeError: can't convert nil into Array>
|
119
|
+
W, [2013-11-25T16:36:16.536018 #12590] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<TypeError: can't convert nil into Array>
|
120
|
+
W, [2013-11-25T16:36:16.547377 #12590] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<TypeError: can't convert nil into Array>
|
121
|
+
W, [2013-11-25T16:36:16.558226 #12590] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<TypeError: can't convert nil into Array>
|
122
|
+
W, [2013-11-25T16:36:16.739345 #12590] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<TypeError: can't convert nil into Array>
|
123
|
+
W, [2013-11-25T16:36:16.743663 #12590] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<TypeError: can't convert nil into Array>
|
124
|
+
I, [2013-11-25T16:37:06.900239 #12596] INFO -- : Preparing to test logging via assert_log_entry_added
|
125
|
+
W, [2013-11-25T16:37:06.917849 #12596] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<Net::HTTPBadRequest 400 readbody=true>
|
126
|
+
I, [2013-11-25T16:37:06.966460 #12596] INFO -- : Preparing to test logging via assert_log_entry_added
|
127
|
+
W, [2013-11-25T16:37:06.972528 #12596] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<Net::HTTPBadRequest 400 readbody=true>
|
128
|
+
I, [2013-11-25T16:37:37.683340 #12603] INFO -- : Preparing to test logging via assert_log_entry_added
|
129
|
+
W, [2013-11-25T16:37:37.694820 #12603] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<Net::HTTPBadRequest 400 readbody=true>
|
130
|
+
I, [2013-11-25T16:37:37.716183 #12603] INFO -- : Preparing to test logging via assert_log_entry_added
|
131
|
+
W, [2013-11-25T16:37:37.722940 #12603] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<Net::HTTPBadRequest 400 readbody=true>
|
132
|
+
I, [2013-11-26T08:04:39.077014 #3428] INFO -- : Preparing to test logging via assert_log_entry_added
|
133
|
+
W, [2013-11-26T08:04:39.115809 #3428] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<Net::HTTPBadRequest 400 readbody=true>
|
134
|
+
I, [2013-11-26T08:04:39.198116 #3428] INFO -- : Preparing to test logging via assert_log_entry_added
|
135
|
+
W, [2013-11-26T08:04:39.207608 #3428] WARN -- : Unable to retrieve remote partial at http://www.warwickshire.gov.uk: #<Net::HTTPBadRequest 400 readbody=true>
|
data/test/test_helper.rb
CHANGED
@@ -69,7 +69,7 @@ module RemotePartial
|
|
69
69
|
assert_equal_ignoring_cr(@body, File.read(@path))
|
70
70
|
end
|
71
71
|
|
72
|
-
def test_connection_failure
|
72
|
+
def test_connection_failure
|
73
73
|
enable_mock_connection_failure @url
|
74
74
|
assert_raises RemotePartialRetrivalError do
|
75
75
|
ResourceManager.new(@url, 'body').html
|
@@ -83,6 +83,27 @@ module RemotePartial
|
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
|
+
def test_http_proxy_environment_variable_not_set
|
87
|
+
ENV.delete('http_proxy')
|
88
|
+
uri = URI.parse @url
|
89
|
+
settings = ResourceManager.connection_settings(uri)
|
90
|
+
assert_equal([uri.host, uri.port], settings)
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_http_proxy_environment_variable_without_credentials
|
94
|
+
ENV['http_proxy'] = "http://10.10.10.254:8080"
|
95
|
+
uri = URI.parse @url
|
96
|
+
settings = ResourceManager.connection_settings(uri)
|
97
|
+
assert_equal([uri.host, uri.port, '10.10.10.254', 8080, nil, nil], settings)
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_http_proxy_environment_variable_with_credentials
|
101
|
+
ENV['http_proxy'] = "http://fred:daphne@10.10.10.254:8080"
|
102
|
+
uri = URI.parse @url
|
103
|
+
settings = ResourceManager.connection_settings(uri)
|
104
|
+
assert_equal([uri.host, uri.port, '10.10.10.254', 8080, 'fred', 'daphne'], settings)
|
105
|
+
end
|
106
|
+
|
86
107
|
def raw_content
|
87
108
|
Net::HTTP.get(URI(@url))
|
88
109
|
end
|
@@ -91,7 +112,5 @@ module RemotePartial
|
|
91
112
|
Nokogiri::HTML(raw_content)
|
92
113
|
end
|
93
114
|
|
94
|
-
|
95
|
-
|
96
115
|
end
|
97
116
|
end
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: remote_partial
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
5
|
-
prerelease:
|
4
|
+
version: 0.7.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Rob Nichols
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-11-26 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: nokogiri
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ! '>='
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ! '>='
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: hashie
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ! '>='
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,14 +34,13 @@ dependencies:
|
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ! '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
description: ! "RemotePartial comprises:\n a system to grab content from a remote
|
47
42
|
page and copy that content into partials;\n a process to allow content to be regularly
|
48
|
-
updated
|
43
|
+
updated.\"\n"
|
49
44
|
email:
|
50
45
|
- rob@undervale.co.uk
|
51
46
|
executables: []
|
@@ -76,27 +71,26 @@ files:
|
|
76
71
|
homepage: https://github.com/warwickshire/remote_partial
|
77
72
|
licenses:
|
78
73
|
- MIT-LICENSE
|
74
|
+
metadata: {}
|
79
75
|
post_install_message:
|
80
76
|
rdoc_options: []
|
81
77
|
require_paths:
|
82
78
|
- lib
|
83
79
|
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
-
none: false
|
85
80
|
requirements:
|
86
81
|
- - ! '>='
|
87
82
|
- !ruby/object:Gem::Version
|
88
83
|
version: '0'
|
89
84
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
-
none: false
|
91
85
|
requirements:
|
92
86
|
- - ! '>='
|
93
87
|
- !ruby/object:Gem::Version
|
94
88
|
version: '0'
|
95
89
|
requirements: []
|
96
90
|
rubyforge_project:
|
97
|
-
rubygems_version: 1.
|
91
|
+
rubygems_version: 2.1.10
|
98
92
|
signing_key:
|
99
|
-
specification_version:
|
93
|
+
specification_version: 4
|
100
94
|
summary: RemotePartial adds the facility to grab content from remote sites and add
|
101
95
|
them as partials to the host app.
|
102
96
|
test_files:
|