Class: RIM::Manifest::RepoReader
- Inherits:
-
Object
- Object
- RIM::Manifest::RepoReader
- Defined in:
- lib/rim/manifest/repo_reader.rb
Overview
Reader for the original Google Repo manifest
Instance Method Summary collapse
Instance Method Details
#read(file) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rim/manifest/repo_reader.rb', line 10 def read(file) manifest = Manifest.new File.open(file) do |f| doc = Nokogiri::XML::Document.parse(f) remote_by_name = {} defaults = nil doc.xpath("/manifest/default").each do |d| raise "duplicate default setting" if defaults defaults = { :revision => d.attr("revision"), :remote => d.attr("remote") } end doc.xpath("/manifest/remote").each do |r| name = r.attr("name") raise "remote without a name" unless name rem = Remote.new( :fetch_url => r.attr("fetch"), :review_url => r.attr("review") ) raise "conflicting remote name #{name}" if remote_by_name[name] remote_by_name[name] = rem end doc.xpath("/manifest/project").each do |p| remote = p.attr("remote") remote ||= defaults[:remote] if remote raise "remote #{remote} not found" unless remote_by_name[remote] else raise "no remote specified and no default remote either" end revision = p.attr("revision") revision ||= defaults[:revision] if !revision raise "no revision specified and no default revision either" end mod = Module.new( :remote_path => p.attr("name"), :local_path => p.attr("path"), :revision => revision, :remote => remote_by_name[remote] ) manifest.add_module(mod) end end manifest end |