Class: ChocBomb::Tools::Feed
- Inherits:
-
Object
- Object
- ChocBomb::Tools::Feed
- Defined in:
- lib/chocbomb/tools/feed.rb
Instance Attribute Summary collapse
-
#chocbomb ⇒ Object
Returns the value of attribute chocbomb.
Class Method Summary collapse
- .make_appcast(cb) ⇒ Object
- .make_dmg_symlink(cb) ⇒ Object
- .make_index_redirect(cb) ⇒ Object
- .make_release_notes(cb) ⇒ Object
Instance Method Summary collapse
-
#initialize(cb) ⇒ Feed
constructor
A new instance of Feed.
- #make_appcast ⇒ Object
- #make_dmg_symlink ⇒ Object
- #make_index_redirect ⇒ Object
- #make_release_notes ⇒ Object
- #release_notes_content ⇒ Object
- #release_notes_html ⇒ Object
Constructor Details
#initialize(cb) ⇒ Feed
Returns a new instance of Feed.
8 9 10 |
# File 'lib/chocbomb/tools/feed.rb', line 8 def initialize(cb) @chocbomb = cb end |
Instance Attribute Details
#chocbomb ⇒ Object
Returns the value of attribute chocbomb.
7 8 9 |
# File 'lib/chocbomb/tools/feed.rb', line 7 def chocbomb @chocbomb end |
Class Method Details
.make_appcast(cb) ⇒ Object
12 13 14 |
# File 'lib/chocbomb/tools/feed.rb', line 12 def self.make_appcast(cb) self.new(cb).make_appcast end |
.make_dmg_symlink(cb) ⇒ Object
16 17 18 |
# File 'lib/chocbomb/tools/feed.rb', line 16 def self.make_dmg_symlink(cb) self.new(cb).make_dmg_symlink end |
.make_index_redirect(cb) ⇒ Object
20 21 22 |
# File 'lib/chocbomb/tools/feed.rb', line 20 def self.make_index_redirect(cb) self.new(cb).make_index_redirect end |
.make_release_notes(cb) ⇒ Object
24 25 26 |
# File 'lib/chocbomb/tools/feed.rb', line 24 def self.make_release_notes(cb) self.new(cb).make_release_notes end |
Instance Method Details
#make_appcast ⇒ Object
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 57 58 59 60 61 62 63 64 |
# File 'lib/chocbomb/tools/feed.rb', line 28 def make_appcast dsa_signature = `openssl dgst -sha1 -binary < "#{chocbomb.pkg}" | openssl dgst -dss1 -sign "#{chocbomb.private_key}" | openssl enc -base64` FileUtils.mkdir_p(chocbomb.build_path) appcast = File.open("#{chocbomb.build_path}/#{chocbomb.appcast_filename}", 'w') do |f| xml = Builder::XmlMarkup.new(:indent => 2) xml.instruct! xml_string = xml.rss('xmlns:atom' => "http://www.w3.org/2005/Atom", 'xmlns:sparkle' => "http://www.andymatuschak.org/xml-namespaces/sparkle", :version => "2.0") do xml.channel do xml.title(chocbomb.name) xml.tag! "sparkle:minimumSystemVersion", chocbomb.minimum_osx_version unless chocbomb.minimum_osx_version.nil? xml.description("#{chocbomb.name} updates") xml.link(chocbomb.base_url) xml.language('en') xml.pubDate( Time.now.strftime("%a, %d %b %Y %H:%M:%S %z") ) # xml.lastBuildDate(Time.now.rfc822) xml.atom(:link, :href => "#{chocbomb.base_url}/#{chocbomb.appcast_filename}", :rel => "self", :type => "application/rss+xml") xml.item do xml.title("#{chocbomb.name} #{chocbomb.version}") xml.tag! "sparkle:releaseNotesLink", "#{chocbomb.base_url}/#{chocbomb.release_notes}" xml.pubDate Time.now.strftime("%a, %d %b %Y %H:%M:%S %z") xml.guid("#{chocbomb.name}-#{chocbomb.version}", :isPermaLink => "false") xml.enclosure(:url => "#{chocbomb.base_url}/#{chocbomb.pkg_name}", :length => "#{File.size(chocbomb.pkg)}", :type => "application/dmg", :"sparkle:version" => chocbomb.version, :"sparkle:dsaSignature" => dsa_signature) end end end f << xml_string end end |
#make_dmg_symlink ⇒ Object
66 67 68 69 70 71 72 73 |
# File 'lib/chocbomb/tools/feed.rb', line 66 def make_dmg_symlink if chocbomb.pkg_name != chocbomb.versionless_pkg_name FileUtils.chdir(chocbomb.build_path) do `rm '#{chocbomb.versionless_pkg_name}'` `ln -s '#{chocbomb.pkg_name}' '#{chocbomb.versionless_pkg_name}'` end end end |
#make_index_redirect ⇒ Object
75 76 77 78 79 |
# File 'lib/chocbomb/tools/feed.rb', line 75 def make_index_redirect File.open("#{chocbomb.build_path}/index.php", 'w') do |f| f << %Q{<?php header("Location: #{chocbomb.pkg_relative_url}"); ?>} end end |
#make_release_notes ⇒ Object
81 82 83 84 85 86 87 88 |
# File 'lib/chocbomb/tools/feed.rb', line 81 def make_release_notes if File.exist?(chocbomb.release_notes_template) File.open("#{chocbomb.build_path}/#{chocbomb.release_notes}", "w") do |f| template = File.read(chocbomb.release_notes_template) f << ERB.new(template).result(binding) end end end |
#release_notes_content ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/chocbomb/tools/feed.rb', line 90 def release_notes_content if File.exists?("release_notes.txt") File.read("release_notes.txt") else <<-TEXTILE.gsub(/^ /, '') h1. #{version} #{Date.today} h2. Another awesome release! TEXTILE end end |
#release_notes_html ⇒ Object
102 103 104 |
# File 'lib/chocbomb/tools/feed.rb', line 102 def release_notes_html RedCloth.new(release_notes_content).to_html end |