concord_cacher 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/concord_cacher.gemspec +1 -1
- data/lib/concord/cacher.rb +14 -6
- data/spec/diy_local_cacher_spec.rb +20 -2
- data/spec/java_proxy_cacher_spec.rb +2 -0
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +1 -1
data/Rakefile
CHANGED
@@ -6,7 +6,7 @@ require 'spec/rake/spectask'
|
|
6
6
|
require './lib/concord_cacher.rb'
|
7
7
|
|
8
8
|
require 'echoe'
|
9
|
-
Echoe.new('concord_cacher', '0.0.
|
9
|
+
Echoe.new('concord_cacher', '0.0.5') do |p|
|
10
10
|
p.description = "concord_cacher provides support for locally caching a resource and all referenced resources in multiple different ways. It is intended for using with other Concord Consortium projects and not necessarily for outside projects."
|
11
11
|
p.summary = "Support for locally caching a resource and all referenced resources in multiple different ways"
|
12
12
|
p.url = "http://github.com/psndcsrv/concord_cacher"
|
data/concord_cacher.gemspec
CHANGED
data/lib/concord/cacher.rb
CHANGED
@@ -9,9 +9,10 @@ class ::Concord::Cacher
|
|
9
9
|
# scan for anything that matches (http://[^'"]+)
|
10
10
|
URL_REGEX = /(http[s]?:\/\/[^'"]+)/i
|
11
11
|
# the imageBytes can be referenced by a OTImage object
|
12
|
-
SRC_REGEX = /(?:src|href|imageBytes)[ ]?=[ ]?['"]([^'"]+)/i
|
12
|
+
SRC_REGEX = /(?:src|href|imageBytes|authoredDataURL)[ ]?=[ ]?['"]([^'"]+)/i
|
13
13
|
NLOGO_REGEX = /import-drawing "([^"]+)"/i
|
14
|
-
|
14
|
+
MW_REGEX = /<resource>(.*?mml)<\/resource>/
|
15
|
+
ALWAYS_SKIP_REGEX = /^(mailto|jres)/i
|
15
16
|
RECURSE_ONCE_REGEX = /html$/i # (resourceFile =~ /otml$/ || resourceFile =~ /html/)
|
16
17
|
RECURSE_FOREVER_REGEX = /(otml|cml|mml|nlogo)$/i
|
17
18
|
|
@@ -107,13 +108,20 @@ class ::Concord::Cacher
|
|
107
108
|
lines.each do |line|
|
108
109
|
line = CGI.unescapeHTML(line)
|
109
110
|
match_indexes = []
|
110
|
-
while (
|
111
|
-
|
112
|
-
|
111
|
+
while (
|
112
|
+
( match = (
|
113
|
+
URL_REGEX.match(line) ||
|
114
|
+
SRC_REGEX.match(line) ||
|
115
|
+
(/.*\.nlogo/.match(short_filename) ? NLOGO_REGEX.match(line) : nil) ||
|
116
|
+
(/.*\.(:?cml|mml)/.match(short_filename) ? MW_REGEX.match(line) : nil)
|
117
|
+
)
|
118
|
+
) && (! match_indexes.include?(match.begin(1)))
|
119
|
+
)
|
113
120
|
print "\nMatched url: #{match[1]}: " if DEBUG
|
114
121
|
match_indexes << match.begin(1)
|
115
122
|
# get the resource from that location, save it locally
|
116
|
-
match_url = match[1].gsub(/\s+/,"").gsub(/[
|
123
|
+
# match_url = match[1].gsub(/\s+/,"").gsub(/[\?\#&;=\+,<>"\{\}\|\\\^\[\]].*$/,"")
|
124
|
+
match_url = match[1]
|
117
125
|
# puts("pre: #{match[1]}, post: #{match_url}") if DEBUG
|
118
126
|
begin
|
119
127
|
resource_url = URI.parse(CGI.unescapeHTML(match_url))
|
@@ -20,18 +20,21 @@ OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
|
|
20
20
|
|
21
21
|
SPEC_ROOT = File.expand_path(File.dirname(__FILE__))
|
22
22
|
|
23
|
+
$\ = "<br/>\n"
|
24
|
+
|
23
25
|
describe 'DIY Local Cacher' do
|
24
26
|
include CacheHelper
|
25
27
|
|
26
28
|
before(:each) do
|
27
29
|
@klass = Concord::DiyLocalCacher
|
28
30
|
@cache = File.join(SPEC_ROOT, '..', 'tmp','diy_local')
|
31
|
+
rm_rf(@cache)
|
29
32
|
mkdir_p(@cache)
|
30
33
|
@cache += '/'
|
31
34
|
end
|
32
35
|
|
33
36
|
after(:each) do
|
34
|
-
rm_rf(@cache)
|
37
|
+
# rm_rf(@cache)
|
35
38
|
end
|
36
39
|
|
37
40
|
def mockup(file)
|
@@ -249,7 +252,22 @@ describe 'DIY Local Cacher' do
|
|
249
252
|
end
|
250
253
|
|
251
254
|
describe 'embedded mw files' do
|
252
|
-
it 'should
|
255
|
+
it 'should download absolute referenced cml files'
|
256
|
+
it 'should download relative referenced cml files'
|
257
|
+
|
258
|
+
it 'should correctly download mmls referenced from within mw cml files' do
|
259
|
+
expected_files = []
|
260
|
+
expected_files << filename_for('http://otrunk.concord.org/examples/LOOPS/models/statesofmatter/statesOfMatterPage1$0.mml')
|
261
|
+
|
262
|
+
cache('mw_model.otml', :activity => mockup('mw_model.otml'), :verbose => true)
|
263
|
+
|
264
|
+
expected_files.each do |f|
|
265
|
+
exists?(f)
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
it 'should correctly download images referenced from within mw cml files'
|
270
|
+
it 'should correctly download images referenced from within mml files'
|
253
271
|
end
|
254
272
|
|
255
273
|
describe 'never cache' do
|
@@ -88,12 +88,14 @@ describe 'Java Proxy Cacher' do
|
|
88
88
|
end
|
89
89
|
|
90
90
|
it 'should handle an empty root url gracefully' do
|
91
|
+
pending do
|
91
92
|
lambda {
|
92
93
|
cache('')
|
93
94
|
}.should_not raise_error
|
94
95
|
|
95
96
|
cache_size.should == 1
|
96
97
|
end
|
98
|
+
end
|
97
99
|
end
|
98
100
|
|
99
101
|
describe 'standard uri syntax' do
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
@@ -1 +1 @@
|
|
1
|
-
�m
|
1
|
+
).�9���xA�_�K=#�O��<өX���u�4O�"�v���=�6;'��z�,�� ���BI������$6Z!j*1�f-�m�D�Ȯ$S2�e[��_�"�w����g�N3¯��a��D� ;N�zTQ��↹�ֆ;��c}aAN&[�z�1*t���͵��W�qWqo��әv^�e��f�\��S�SˮJ_�p��o~Ņ;b����=S�[�렳����<|AK
|