concord_cacher 0.1.8 → 0.1.9

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.1.8') do |p|
9
+ Echoe.new('concord_cacher', '0.1.9') 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.1.8"
5
+ s.version = "0.1.9"
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"]
@@ -88,7 +88,7 @@ class ::Concord::Resource
88
88
  f.flush
89
89
  end
90
90
  write_property_map(self.cache_dir + self.local_filename + ".hdrs", self.headers) if self.class.cache_headers
91
- ::Concord::Resource.map(self.url, self.local_filename) if self.class.create_map
91
+ ::Concord::Resource.map(self.uri_str, self.local_filename) if self.class.create_map
92
92
  end
93
93
 
94
94
  # Reserving the file will prohibit any further references to this same file to be skipped, this avoiding endlessly recursing references
@@ -105,7 +105,7 @@ class ::Concord::Resource
105
105
  end
106
106
 
107
107
  def load
108
- open(self.uri.scheme == 'file' ? self.uri.path : self.uri.to_s) do |r|
108
+ open(self.uri_str) do |r|
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
@@ -134,6 +134,11 @@ class ::Concord::Resource
134
134
  self.content = processed_lines.join("\n")
135
135
  end
136
136
 
137
+ def uri_str
138
+ return nil unless self.uri
139
+ self.uri.scheme == 'file' ? self.uri.path : self.uri.to_s
140
+ end
141
+
137
142
  def always_skip?
138
143
  return (self.url.length < 1) || ALWAYS_SKIP_REGEXES.detect{|r| r.match(self.url) }
139
144
  end
@@ -235,7 +240,7 @@ class ::Concord::Resource
235
240
  end
236
241
 
237
242
  def _recurse(resource)
238
- puts "recursively parsing '#{resource.uri.to_s}'" if self.class.debug
243
+ puts "recursively parsing '#{resource.uri_str}'" if self.class.debug
239
244
  _try(resource, lambda {
240
245
  resource.reserve # touch the file so that we know not to try to re-process the file we're currently processing
241
246
  resource.process
@@ -253,7 +258,7 @@ class ::Concord::Resource
253
258
  begin
254
259
  lam.call
255
260
  rescue => e
256
- self.class.error(self.url,"Problem getting or writing file: #{resource.uri.to_s}, Error: #{e}")
261
+ self.class.error(self.url,"Problem getting or writing file: #{resource.uri_str}, Error: #{e}")
257
262
  print 'X' if self.class.verbose
258
263
  resource.release
259
264
  throw :nextResource
@@ -230,4 +230,26 @@ describe 'Java Proxy Cacher' do
230
230
  end
231
231
 
232
232
  end
233
+
234
+ describe 'url map' do
235
+ it 'should always use absolute urls as keys' do
236
+ data_dir = File.join(@spec_root, 'data')
237
+ expected_entries = []
238
+ expected_entries << {:val => '836ba09d9d7288cf735f555e7a9b9b314ad2f6ef', :key => File.expand_path('element_reference.otml',data_dir)}
239
+ expected_entries << {:val => '20e89b62dda582d80e1832050f4998d64c801c03', :key => 'http://www.concord.org/~aunger/'}
240
+ expected_entries << {:val => '4e9576a56db3d142113b8905d7aa93e31c9f441b', :key => 'http://portal.concord.org/images/icons/chart_bar.png'}
241
+ expected_entries << {:val => '41f082b7e69a399679a47acfdcd7e7a204e49745', :key => 'http://portal.concord.org/images/icons/chart_pie.png'}
242
+ expected_entries << {:val => 'cbe7ac86926fd3b8aa8659842a1d8c299d8966a7', :key => File.expand_path('resources/text.txt',data_dir)}
243
+ expected_entries << {:val => '8f0ebcb45d7ba71a541d4781329f4a6900c7ee65', :key => File.expand_path('resources/delete.png',data_dir)}
244
+ expected_entries << {:val => 'd1cea238486aeeba9215d56bf71efc243754fe48', :key => File.expand_path('resources/chart_line.png',data_dir)}
245
+
246
+ cache('element_reference.otml')
247
+
248
+ url_map_content = File.read(File.expand_path('url_map.xml', @cache))
249
+
250
+ expected_entries.each do |e|
251
+ url_map_content.should match(Regexp.new("<entry key='#{e[:key]}'>#{e[:val]}</entry>"))
252
+ end
253
+ end
254
+ end
233
255
  end
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
- - 8
9
- version: 0.1.8
8
+ - 9
9
+ version: 0.1.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - Aaron Unger
metadata.gz.sig CHANGED
@@ -1,2 +1,4 @@
1
- s�ü�x
2
- �������#�c-?��t
1
+ ��x��K��\��M7_=?-�2^
2
+ 0�O8���l�6|�O��((�� 3x)���z�/��nRb����Z�o6��7M#V��+�H�ǖ���ZT;'6����.uH"�`�*�߲�9���6S\c����|W���A��g]�Q�� ���_XW'B�.�1N��w<%Nq��=m O[�%��[;B�)�4֌� ��{i���T
3
+
4
+ �k:� �K{vN��G�&������<���&kȉ��(�[�u�