Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

enable setting explicit XML source url

  • Loading branch information...
commit c4e1ed075c0c1576385b6f87186cd3578af12273 1 parent 9c34e96
@mislav authored
Showing with 16 additions and 5 deletions.
  1. +16 −5 models.rb
View
21 models.rb
@@ -73,11 +73,15 @@ def make_pretty
def needs_fetch?
entry.fetcher_version.nil? or
entry.fetcher_version < RfcFetcher.version or
- entry.updated_at.to_time < RFC.last_modified
+ needs_rerender?
end
- def fetch_and_render
- fetcher = RfcFetcher.new self.id
+ def needs_rerender?
+ entry.body and entry.updated_at.to_time < RFC.last_modified
+ end
+
+ def fetch_and_render xml_url = entry.xml_source
+ fetcher = RfcFetcher.new self.id, xml_url
entry.xml_source = fetcher.xml_url
entry.fetcher_version = fetcher.version
@@ -90,6 +94,12 @@ def fetch_and_render
end
end
+ # Bypass discovery process by explicitly seting a known XML location
+ def set_xml_source xml_url
+ fetch_and_render xml_url
+ entry.save
+ end
+
# used in the RFC HTML generation phase
def href_resolver
->(xref) { "/#{xref}" if xref =~ /^RFC\d+$/ }
@@ -166,8 +176,9 @@ def version() 1 end
attr_reader :title, :path
- def initialize doc_id
+ def initialize doc_id, known_url = nil
@doc_id = doc_id.to_s.downcase
+ @xml_url = known_url unless known_url.nil?
end
def version() self.class.version end
@@ -185,7 +196,7 @@ def fetch
@path = File.join self.class.download_dir, @doc_id + '.xml'
unless File.exist? @path
FileUtils.mkdir_p File.dirname(@path)
- system 'curl', '--silent', xml_url.to_s, '-o', @path
+ system 'curl', '-L', '--silent', xml_url.to_s, '-o', @path
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.