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 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.4') do |p|
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"
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{concord_cacher}
5
- s.version = "0.0.4"
5
+ s.version = "0.0.5"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Aaron Unger"]
@@ -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
- ALWAYS_SKIP_REGEX = /^(mailto|jres)/i # (resourceFile =~ /^mailto/) || (resourceFile =~ /^jres/)
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 ( ((match = URL_REGEX.match(line)) && (! match_indexes.include?(match.begin(1)))) ||
111
- ((match = SRC_REGEX.match(line)) && (! match_indexes.include?(match.begin(1)))) ||
112
- (/.*\.nlogo/.match(short_filename) && (match = NLOGO_REGEX.match(line)) && (! match_indexes.include?(match.begin(1)))) )
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 correctly download resources referenced from within mw model files'
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
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 4
9
- version: 0.0.4
8
+ - 5
9
+ version: 0.0.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Aaron Unger
metadata.gz.sig CHANGED
@@ -1 +1 @@
1
- �m�ύi^|��$NbP�L���eZE��sʞ�/]�g�w�ޖ�K�N�bX h)���ABp���tX%r7�W[1\��-_Ծ�@Ds����2��1`�e�$p�=�8�I���f��.��
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&[z1*t���͵��W�qWqo��әv^�e��f�\��S�SˮJ_�p��o~Ņ;b����=S�[�렳�� ��<|AK