lib/motion/project/appcast.rb in motion-sparkle-0.0.3 vs lib/motion/project/appcast.rb in motion-sparkle-0.0.4

- old
+ new

@@ -17,22 +17,21 @@ appcast_file = File.open("#{sparkle_release_path}/#{appcast.feed_filename}", 'w') do |f| xml_string = '' doc = REXML::Formatters::Pretty.new doc.write(appcast_xml, xml_string) f << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" - f << xml_string + f << xml_string f << "\n" end if appcast_file App.info "Create", "./#{sparkle_release_path}/#{appcast.feed_filename}" else App.info "Fail", "./#{sparkle_release_path}/#{appcast.feed_filename} not created" end end def appcast_xml - base_url = appcast.base_url rss = REXML::Element.new 'rss' rss.attributes['xmlns:atom'] = "http://www.w3.org/2005/Atom" rss.attributes['xmlns:sparkle'] = "http://www.andymatuschak.org/xml-namespaces/sparkle" rss.attributes['xmlns:version'] = "2.0" rss.attributes['xmlns:dc'] = "http://purl.org/dc/elements/1.1/" @@ -50,13 +49,13 @@ item.add_element('title').text = "#{@config.name} #{@config.version}" item.add_element('pubDate').text = Time.now.strftime("%a, %d %b %Y %H:%M:%S %z") guid = item.add_element('guid') guid.text = "#{@config.name}-#{@config.version}" guid.attributes['isPermaLink'] = false - item.add_element('sparkle:releaseNotesLink').text = "#{base_url}/#{appcast.notes_filename}" + item.add_element('sparkle:releaseNotesLink').text = "#{appcast.notes_url}/#{appcast.notes_filename}" enclosure = item.add_element('enclosure') - enclosure.attributes['url'] = "#{base_url}/#{@package_file}" + enclosure.attributes['url'] = "#{appcast.package_url}/#{@package_file}" enclosure.attributes['length'] = "#{@package_size}" enclosure.attributes['type'] = "application/octet-stream" enclosure.attributes['sparkle:version'] = @config.version enclosure.attributes['sparkle:dsaSignature'] = @package_signature rss @@ -86,21 +85,39 @@ release_notes_content end class Appcast - attr_accessor :base_url, :feed_filename, :notes_filename, :package_filename + attr_accessor :base_url, + :feed_base_url, + :feed_filename, + :notes_base_url, + :notes_filename, + :package_base_url, + :package_filename def initialize + @feed_base_url = nil @feed_filename = 'releases.xml' + @notes_base_url = nil @notes_filename = 'release_notes.html' + @package_base_url = nil @package_filename = nil @base_url = nil end - def full_feed_url - "#{base_url}/#{feed_filename}" + def feed_url + "#{feed_base_url || base_url}/#{feed_filename}" end + + def notes_url + "#{notes_base_url || base_url}/#{notes_filename}" + end + + def package_url + "#{package_base_url || base_url}/#{package_filename}" + end + end end end