concord_cacher 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest CHANGED
@@ -1,6 +1,7 @@
1
1
  Manifest
2
2
  README.textile
3
3
  Rakefile
4
+ concord_cacher.gemspec
4
5
  lib/concord/cacher.rb
5
6
  lib/concord/diy_local_cacher.rb
6
7
  lib/concord/filename_generators.rb
@@ -70,6 +71,8 @@ spec/data/resources/statesofmatter/waterZoom.gif
70
71
  spec/data/resources/text.txt
71
72
  spec/data/standard_uri.otml
72
73
  spec/data/url_with_space.otml
74
+ spec/data/xml_entities.otml
73
75
  spec/diy_local_cacher_spec.rb
74
76
  spec/helpers/cache_helper.rb
75
77
  spec/java_proxy_cacher_spec.rb
78
+ xml_entities.otml
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.1.7') do |p|
9
+ Echoe.new('concord_cacher', '0.1.8') 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,16 +2,16 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{concord_cacher}
5
- s.version = "0.1.7"
5
+ s.version = "0.1.8"
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
  s.cert_chain = ["/Users/aunger/gem-public_cert.pem"]
10
- s.date = %q{2010-04-06}
10
+ s.date = %q{2010-04-08}
11
11
  s.description = %q{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.}
12
12
  s.email = %q{aunger @nospam@ concord.org}
13
13
  s.extra_rdoc_files = ["README.textile", "lib/concord/cacher.rb", "lib/concord/diy_local_cacher.rb", "lib/concord/filename_generators.rb", "lib/concord/filename_generators/default_generator.rb", "lib/concord/filename_generators/diy_generator.rb", "lib/concord/filename_generators/java_proxy_generator.rb", "lib/concord/helper.rb", "lib/concord/java_proxy_cacher.rb", "lib/concord/resource.rb", "lib/concord_cacher.rb"]
14
- s.files = ["Manifest", "README.textile", "Rakefile", "lib/concord/cacher.rb", "lib/concord/diy_local_cacher.rb", "lib/concord/filename_generators.rb", "lib/concord/filename_generators/default_generator.rb", "lib/concord/filename_generators/diy_generator.rb", "lib/concord/filename_generators/java_proxy_generator.rb", "lib/concord/helper.rb", "lib/concord/java_proxy_cacher.rb", "lib/concord/resource.rb", "lib/concord_cacher.rb", "spec/data/always_skip.otml", "spec/data/bad_url.otml", "spec/data/codebase.otml", "spec/data/element_reference.otml", "spec/data/empty.otml", "spec/data/empty_url.otml", "spec/data/mw_model_absolute.otml", "spec/data/mw_model_relative.otml", "spec/data/nlogo_absolute.otml", "spec/data/nlogo_relative.otml", "spec/data/recursion.otml", "spec/data/recursive_loop.otml", "spec/data/resources/chart_line.png", "spec/data/resources/delete.png", "spec/data/resources/loop1.otml", "spec/data/resources/loop2.otml", "spec/data/resources/nlogo/SpaceRescue.Practice1.nlogo", "spec/data/resources/recurse1.otml", "spec/data/resources/recurse2.otml", "spec/data/resources/statesofmatter/bench.gif", "spec/data/resources/statesofmatter/downHighlightMol1.gif", "spec/data/resources/statesofmatter/downHighlightMol2.gif", "spec/data/resources/statesofmatter/eightBall.gif", "spec/data/resources/statesofmatter/eightBall.html", "spec/data/resources/statesofmatter/eightBall.mml", "spec/data/resources/statesofmatter/eightBallZoom.gif", "spec/data/resources/statesofmatter/gold.gif", "spec/data/resources/statesofmatter/gold.html", "spec/data/resources/statesofmatter/gold.mml", "spec/data/resources/statesofmatter/goldZoom.gif", "spec/data/resources/statesofmatter/helium.gif", "spec/data/resources/statesofmatter/helium.html", "spec/data/resources/statesofmatter/helium.mml", "spec/data/resources/statesofmatter/heliumZoom.gif", "spec/data/resources/statesofmatter/hydrogen.gif", "spec/data/resources/statesofmatter/hydrogen.html", "spec/data/resources/statesofmatter/hydrogen.mml", "spec/data/resources/statesofmatter/hydrogenZoom.gif", "spec/data/resources/statesofmatter/rootBeer.gif", "spec/data/resources/statesofmatter/rootBeer.html", "spec/data/resources/statesofmatter/rootBeer.mml", "spec/data/resources/statesofmatter/rootBeerZoom.gif", "spec/data/resources/statesofmatter/statesOfMatter$0.mml", "spec/data/resources/statesofmatter/statesOfMatter.cml", "spec/data/resources/statesofmatter/statesOfMatterPage1$0.mml", "spec/data/resources/statesofmatter/statesOfMatterPage1.cml", "spec/data/resources/statesofmatter/unknown.gif", "spec/data/resources/statesofmatter/unknown.html", "spec/data/resources/statesofmatter/unknown.mml", "spec/data/resources/statesofmatter/unknownZoom.gif", "spec/data/resources/statesofmatter/upHighlightMol1.gif", "spec/data/resources/statesofmatter/upHighlightMol2.gif", "spec/data/resources/statesofmatter/water.gif", "spec/data/resources/statesofmatter/water.html", "spec/data/resources/statesofmatter/water.mml", "spec/data/resources/statesofmatter/waterZoom.gif", "spec/data/resources/text.txt", "spec/data/standard_uri.otml", "spec/data/url_with_space.otml", "spec/diy_local_cacher_spec.rb", "spec/helpers/cache_helper.rb", "spec/java_proxy_cacher_spec.rb", "concord_cacher.gemspec"]
14
+ s.files = ["Manifest", "README.textile", "Rakefile", "concord_cacher.gemspec", "lib/concord/cacher.rb", "lib/concord/diy_local_cacher.rb", "lib/concord/filename_generators.rb", "lib/concord/filename_generators/default_generator.rb", "lib/concord/filename_generators/diy_generator.rb", "lib/concord/filename_generators/java_proxy_generator.rb", "lib/concord/helper.rb", "lib/concord/java_proxy_cacher.rb", "lib/concord/resource.rb", "lib/concord_cacher.rb", "spec/data/always_skip.otml", "spec/data/bad_url.otml", "spec/data/codebase.otml", "spec/data/element_reference.otml", "spec/data/empty.otml", "spec/data/empty_url.otml", "spec/data/mw_model_absolute.otml", "spec/data/mw_model_relative.otml", "spec/data/nlogo_absolute.otml", "spec/data/nlogo_relative.otml", "spec/data/recursion.otml", "spec/data/recursive_loop.otml", "spec/data/resources/chart_line.png", "spec/data/resources/delete.png", "spec/data/resources/loop1.otml", "spec/data/resources/loop2.otml", "spec/data/resources/nlogo/SpaceRescue.Practice1.nlogo", "spec/data/resources/recurse1.otml", "spec/data/resources/recurse2.otml", "spec/data/resources/statesofmatter/bench.gif", "spec/data/resources/statesofmatter/downHighlightMol1.gif", "spec/data/resources/statesofmatter/downHighlightMol2.gif", "spec/data/resources/statesofmatter/eightBall.gif", "spec/data/resources/statesofmatter/eightBall.html", "spec/data/resources/statesofmatter/eightBall.mml", "spec/data/resources/statesofmatter/eightBallZoom.gif", "spec/data/resources/statesofmatter/gold.gif", "spec/data/resources/statesofmatter/gold.html", "spec/data/resources/statesofmatter/gold.mml", "spec/data/resources/statesofmatter/goldZoom.gif", "spec/data/resources/statesofmatter/helium.gif", "spec/data/resources/statesofmatter/helium.html", "spec/data/resources/statesofmatter/helium.mml", "spec/data/resources/statesofmatter/heliumZoom.gif", "spec/data/resources/statesofmatter/hydrogen.gif", "spec/data/resources/statesofmatter/hydrogen.html", "spec/data/resources/statesofmatter/hydrogen.mml", "spec/data/resources/statesofmatter/hydrogenZoom.gif", "spec/data/resources/statesofmatter/rootBeer.gif", "spec/data/resources/statesofmatter/rootBeer.html", "spec/data/resources/statesofmatter/rootBeer.mml", "spec/data/resources/statesofmatter/rootBeerZoom.gif", "spec/data/resources/statesofmatter/statesOfMatter$0.mml", "spec/data/resources/statesofmatter/statesOfMatter.cml", "spec/data/resources/statesofmatter/statesOfMatterPage1$0.mml", "spec/data/resources/statesofmatter/statesOfMatterPage1.cml", "spec/data/resources/statesofmatter/unknown.gif", "spec/data/resources/statesofmatter/unknown.html", "spec/data/resources/statesofmatter/unknown.mml", "spec/data/resources/statesofmatter/unknownZoom.gif", "spec/data/resources/statesofmatter/upHighlightMol1.gif", "spec/data/resources/statesofmatter/upHighlightMol2.gif", "spec/data/resources/statesofmatter/water.gif", "spec/data/resources/statesofmatter/water.html", "spec/data/resources/statesofmatter/water.mml", "spec/data/resources/statesofmatter/waterZoom.gif", "spec/data/resources/text.txt", "spec/data/standard_uri.otml", "spec/data/url_with_space.otml", "spec/data/xml_entities.otml", "spec/diy_local_cacher_spec.rb", "spec/helpers/cache_helper.rb", "spec/java_proxy_cacher_spec.rb", "xml_entities.otml"]
15
15
  s.homepage = %q{http://github.com/psndcsrv/concord_cacher}
16
16
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Concord_cacher", "--main", "README.textile"]
17
17
  s.require_paths = ["lib"]
@@ -109,7 +109,7 @@ class ::Concord::Resource
109
109
  self.headers = r.respond_to?("meta") ? r.meta : {}
110
110
  self.headers['_http_version'] = "HTTP/1.1 #{r.respond_to?("status") ? r.status.join(" ") : "200 OK"}"
111
111
  self.content = r.read
112
- self.remove_codebase
112
+ self.remove_codebase if self.class.rewrite_urls
113
113
  end
114
114
  end
115
115
 
@@ -179,6 +179,7 @@ class ::Concord::Resource
179
179
  end
180
180
 
181
181
  def _process_line(line)
182
+ orig_line = line
182
183
  line = CGI.unescapeHTML(line)
183
184
  match_indexes = []
184
185
  while ( match = _line_matches(line) ) && (! match_indexes.include?(match.begin(1)))
@@ -189,10 +190,10 @@ class ::Concord::Resource
189
190
  resource.cache_dir = self.cache_dir
190
191
  catch :nextResource do
191
192
  _handle_resource(resource)
192
- line.sub!(resource.url,resource.local_filename.to_s) if self.class.rewrite_urls
193
+ orig_line.sub!(resource.url,resource.local_filename.to_s) if self.class.rewrite_urls
193
194
  end
194
195
  end
195
- return line
196
+ return orig_line
196
197
  end
197
198
 
198
199
  def _handle_resource(resource)
@@ -0,0 +1,12 @@
1
+ <otrunk id="6b230c1d-8816-4ef3-9c7a-b84a0da0b35f">
2
+ <imports>
3
+ <import class="org.concord.otrunk.OTSystem" />
4
+ </imports>
5
+ <objects>
6
+ <OTSystem local_id="system">
7
+ <root>
8
+ <OTText text="&lt;img src=&quot;http://portal.concord.org/images/icons/chart_line.png&quot; /&gt;" />
9
+ </root>
10
+ </OTSystem>
11
+ </objects>
12
+ </otrunk>
@@ -318,4 +318,23 @@ describe 'DIY Local Cacher' do
318
318
  it 'should only recurse html files once'
319
319
  it 'should recurse otml,cml,mml and nlogo files forever'
320
320
  end
321
+
322
+ describe 'special cases' do
323
+ it 'should not unencode xml entities that are not part of a url' do
324
+ expected_files = []
325
+ expected_files << "hash.otml" # xml_entities.otml
326
+ expected_files << filename_for("http://portal.concord.org/images/icons/chart_line.png")
327
+
328
+ cache('xml_entities.otml', :activity => mockup('xml_entities.otml'))
329
+
330
+ cache_size.should == 2
331
+ expected_files.each do |f|
332
+ exists?(f)
333
+ end
334
+
335
+ file_content = File.read(File.join(@cache,'hash.otml'))
336
+
337
+ file_content.should match(Regexp.new("<OTText text=\"&lt;img src=&quot;#{filename_for("http://portal.concord.org/images/icons/chart_line.png")}&quot; /&gt;\" />"))
338
+ end
339
+ end
321
340
  end
@@ -207,4 +207,27 @@ describe 'Java Proxy Cacher' do
207
207
  it 'should only recurse html files once'
208
208
  it 'should recurse otml,cml,mml and nlogo files forever'
209
209
  end
210
+
211
+ describe 'special cases' do
212
+ it 'should not unencode xml entities that are not part of a url' do
213
+ expected_files = []
214
+ expected_files << "b3dd880c1368ff9ed70cba3df3b81cd04bf77bdf" # xml_entities.otml
215
+ expected_files << 'd1cea238486aeeba9215d56bf71efc243754fe48' # resources/chart_line.png
216
+ expected_files << expected_files.collect{|f| f+".hdrs" } # headers for each file
217
+ expected_files.flatten!
218
+ expected_files << 'url_map.xml'
219
+
220
+ cache('xml_entities.otml')
221
+
222
+ cache_size.should == 5
223
+ expected_files.each do |f|
224
+ exists?(f)
225
+ end
226
+
227
+ file_content = File.read(File.join(@cache,'b3dd880c1368ff9ed70cba3df3b81cd04bf77bdf'))
228
+
229
+ file_content.should match(Regexp.new('<OTText text="&lt;img src=&quot;http://portal.concord.org/images/icons/chart_line.png&quot; /&gt;" />'))
230
+ end
231
+
232
+ end
210
233
  end
data/xml_entities.otml ADDED
@@ -0,0 +1,12 @@
1
+ <otrunk id="6b230c1d-8816-4ef3-9c7a-b84a0da0b35f">
2
+ <imports>
3
+ <import class="org.concord.otrunk.OTSystem" />
4
+ </imports>
5
+ <objects>
6
+ <OTSystem local_id="system">
7
+ <root>
8
+ <OTText text="<img src="http://portal.concord.org/images/icons/chart_line.png" />" />
9
+ </root>
10
+ </OTSystem>
11
+ </objects>
12
+ </otrunk>
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
  - 1
8
- - 7
9
- version: 0.1.7
8
+ - 8
9
+ version: 0.1.8
10
10
  platform: ruby
11
11
  authors:
12
12
  - Aaron Unger
@@ -35,7 +35,7 @@ cert_chain:
35
35
  8kT2T2VF
36
36
  -----END CERTIFICATE-----
37
37
 
38
- date: 2010-04-06 00:00:00 -04:00
38
+ date: 2010-04-08 00:00:00 -04:00
39
39
  default_executable:
40
40
  dependencies: []
41
41
 
@@ -61,6 +61,7 @@ files:
61
61
  - Manifest
62
62
  - README.textile
63
63
  - Rakefile
64
+ - concord_cacher.gemspec
64
65
  - lib/concord/cacher.rb
65
66
  - lib/concord/diy_local_cacher.rb
66
67
  - lib/concord/filename_generators.rb
@@ -130,10 +131,11 @@ files:
130
131
  - spec/data/resources/text.txt
131
132
  - spec/data/standard_uri.otml
132
133
  - spec/data/url_with_space.otml
134
+ - spec/data/xml_entities.otml
133
135
  - spec/diy_local_cacher_spec.rb
134
136
  - spec/helpers/cache_helper.rb
135
137
  - spec/java_proxy_cacher_spec.rb
136
- - concord_cacher.gemspec
138
+ - xml_entities.otml
137
139
  has_rdoc: true
138
140
  homepage: http://github.com/psndcsrv/concord_cacher
139
141
  licenses: []
metadata.gz.sig CHANGED
Binary file