Class: Slackware::ChangeLog
- Inherits:
-
Object
- Object
- Slackware::ChangeLog
- Defined in:
- lib/slackware/changelog.rb,
lib/slackware/changelog/rss.rb
Overview
The class for parsing a Slackware standard ChangeLog.txt
Defined Under Namespace
Constant Summary collapse
- ABBR_DAYNAMES =
yanked from
Date %w(Sun Mon Tue Wed Thu Fri Sat)- ABBR_MONTHNAMES =
%w(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)- RE_DATE =
/^(#{re_daynames}\s+#{re_monthnames}\s+\d+\s+\d{2}:\d{2}:\d{2}\s\w+\s+\d+)$/- RE_CHANGELOG_BREAK =
This break has been the same as long as I can find
/^\+--------------------------\+$/- RE_PACKAGE_ENTRY =
combine them
Regexp.union(re_package_entry0, re_package_entry1, re_package_entry2)
- RE_SECURITY_FIX =
(* Security fix *)
/\(\*\s+security\s+fix\s+\*\)/i- IMAGE_URL =
or maybe “
” "http://connie.slackware.com/~msimons/slackware/grfx/shared/bluepiSW.jpg"
Class Method Summary collapse
- .parse(file) ⇒ Object (also: open)
- .re_changelog_break ⇒ Object
-
.re_date ⇒ Object
for hacks sake, make these usbable elsewhere.
- .re_package_entry ⇒ Object
- .re_security_fix ⇒ Object
Instance Method Summary collapse
-
#entries ⇒ Object
All entries in this Slackware::ChangeLog.
- #file ⇒ Object
-
#initialize(file = nil) ⇒ ChangeLog
constructor
A new instance of ChangeLog.
- #inspect ⇒ Object
-
#latest ⇒ Object
Returns the latest update in the set.
- #parse(opts = {:file => nil, :data => nil}) ⇒ Object
-
#pkgs_added ⇒ Object
All packages added in this Slackware::ChangeLog.
-
#pkgs_rebuilt ⇒ Object
All packages rebuilt in this Slackware::ChangeLog.
-
#pkgs_removed ⇒ Object
All packages removed in this Slackware::ChangeLog.
-
#pkgs_upgraded ⇒ Object
All packages upgraded in this Slackware::ChangeLog.
-
#security ⇒ Object
All security in this Slackware::ChangeLog.
- #sort ⇒ Object
-
#to_rss(opts = {}) ⇒ Object
optscan include * :arch - basically ‘64’ or ‘32’ * :version - 13.1, 13.2, current, etc. - #updates ⇒ Object
Constructor Details
#initialize(file = nil) ⇒ ChangeLog
Returns a new instance of ChangeLog.
131 132 133 134 135 |
# File 'lib/slackware/changelog.rb', line 131 def initialize(file = nil) @file = file @strio = StringIO.new @updates = Array.new end |
Class Method Details
.parse(file) ⇒ Object Also known as: open
200 201 202 203 |
# File 'lib/slackware/changelog.rb', line 200 def parse(file) cl = ChangeLog.new(file) return cl.parse() end |
.re_changelog_break ⇒ Object
60 |
# File 'lib/slackware/changelog.rb', line 60 def self::re_changelog_break ; RE_CHANGELOG_BREAK ; end |
.re_date ⇒ Object
for hacks sake, make these usbable elsewhere
59 |
# File 'lib/slackware/changelog.rb', line 59 def self::re_date ; RE_DATE ; end |
.re_package_entry ⇒ Object
61 |
# File 'lib/slackware/changelog.rb', line 61 def self::re_package_entry ; RE_PACKAGE_ENTRY ; end |
.re_security_fix ⇒ Object
62 |
# File 'lib/slackware/changelog.rb', line 62 def self::re_security_fix ; RE_SECURITY_FIX ; end |
Instance Method Details
#entries ⇒ Object
All entries in this Slackware::ChangeLog
Returns an Array of Slackware::ChangeLog::Entry
151 152 153 |
# File 'lib/slackware/changelog.rb', line 151 def entries @updates.map {|u| u.entries.map {|e| e } }.flatten end |
#file ⇒ Object
137 |
# File 'lib/slackware/changelog.rb', line 137 def file; @file; end |
#inspect ⇒ Object
207 208 209 |
# File 'lib/slackware/changelog.rb', line 207 def inspect "#<%s:0x%x @file=%s, %d @updates, %d @entries>" % [self.class.name, self.object_id.abs, self.file || '""', self.updates.count || 0, self.entries.count || 0] end |
#latest ⇒ Object
Returns the latest update in the set
141 142 143 |
# File 'lib/slackware/changelog.rb', line 141 def latest sort().last end |
#parse(opts = {:file => nil, :data => nil}) ⇒ Object
189 190 191 192 193 194 195 196 |
# File 'lib/slackware/changelog.rb', line 189 def parse(opts = {:file => nil, :data => nil}) if not(opts[:file].nil?) @updates = parse_this_file(opts[:file]).updates elsif not(@file.nil?) @updates = parse_this_file(@file).updates end return self end |
#pkgs_added ⇒ Object
All packages added in this Slackware::ChangeLog
Returns an Array of Slackware::ChangeLog::Entry
172 173 174 |
# File 'lib/slackware/changelog.rb', line 172 def pkgs_added @updates.map {|u| u.entries.select {|e| e if e.action == "Added" } }.flatten end |
#pkgs_rebuilt ⇒ Object
All packages rebuilt in this Slackware::ChangeLog
Returns an Array of Slackware::ChangeLog::Entry
186 187 188 |
# File 'lib/slackware/changelog.rb', line 186 def pkgs_rebuilt @updates.map {|u| u.entries.select {|e| e if e.action == "Rebuilt" } }.flatten end |
#pkgs_removed ⇒ Object
All packages removed in this Slackware::ChangeLog
Returns an Array of Slackware::ChangeLog::Entry
165 166 167 |
# File 'lib/slackware/changelog.rb', line 165 def pkgs_removed @updates.map {|u| u.entries.select {|e| e if e.action == "Removed" } }.flatten end |
#pkgs_upgraded ⇒ Object
All packages upgraded in this Slackware::ChangeLog
Returns an Array of Slackware::ChangeLog::Entry
179 180 181 |
# File 'lib/slackware/changelog.rb', line 179 def pkgs_upgraded @updates.map {|u| u.entries.select {|e| e if e.action == "Upgraded" } }.flatten end |
#security ⇒ Object
All security in this Slackware::ChangeLog
Returns an Array of Slackware::ChangeLog::Entry
158 159 160 |
# File 'lib/slackware/changelog.rb', line 158 def security @updates.map {|u| u.entries.select {|e| e if e.security } }.flatten end |
#sort ⇒ Object
144 145 146 |
# File 'lib/slackware/changelog.rb', line 144 def sort @updates.sort {|x,y| x.date <=> y.date } end |
#to_rss(opts = {}) ⇒ Object
opts can include
* :arch - basically '64' or '32'
* :version - 13.1, 13.2, current, etc.
* :url - the URL web link to the ChangeLog.txt
* :image_url - the URL for the loge used in the RSS feed
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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/slackware/changelog/rss.rb', line 35 def to_rss(opts = {}) version = "2.0" # ["0.9", "1.0", "2.0"] content = RSS::Maker.make(version) do |m| if (opts[:title]) m.channel.title = opts[:title] else added_title = "slackware#{opts[:arch]}" if opts[:version] added_title += "-#{opts[:version]}" end m.channel.title = "#{added_title} ChangeLog.txt" end if (opts[:url]) m.channel.link = "%s#slackagg" % [opts[:url]] else m.channel.link = "http://www.slackware.com/#slackagg" end if (opts[:description]) m.channel.description = opts[:description] else m.channel.description = "a parsed ChangeLog.txt, is an extendable ChangeLog.txt" end if opts[:image_url] m.channel.logo = opts[:image_url] else m.channel.logo = IMAGE_URL end if (opts[:noimage]) else image = m.image if opts[:image_url] image.url = opts[:image_url] else image.url = IMAGE_URL end image.title = "Slackware Linux" image.width = "144" image.height = "144" end m.items.do_sort = true # sort items by date @updates.each {|update| i = m.items.new_item # Add a plug to the title of the update, if it includes a security fix # set this here, so we don't have to .map again down below security_count = update.security.length if (security_count > 0) i.title = "%s (* Security fix *)" % [update.date.utc.to_s] else i.title = update.date.utc.to_s end if opts[:url] i.link = "%s#%s" % [opts[:url], update.date.to_i] else i.link = "http://slackware.com/#slackagg#%s" % [update.date.to_i] end i.date = update.date i.description = "" if (update.entries.count > 0) if (security_count > 0) i.description = i.description + "%d new update(s), %d security update(s)\n\n" % [update.entries.count, security_count] else i.description = i.description + "%d new update(s)\n\n" % [update.entries.count] end end i.description = i.description + "<pre><blockquote>\n" unless (update.notes.empty?) i.description = i.description + update.notes + "\n\n" end if (update.entries.count > 0) update.entries.each {|entry| if (entry.notes.empty?) i.description = i.description + sprintf("%s/%s:\s%s\n", entry.section, entry.package, entry.action) else i.description = i.description + sprintf("%s/%s:\s%s\n\s\s%s\n", entry.section, entry.package, entry.action, entry.notes) end } end i.description = i.description + "</blockquote></pre>\n" #i.description.gsub!(/\n/, "<br/>\n") } end return content end |
#updates ⇒ Object
138 |
# File 'lib/slackware/changelog.rb', line 138 def updates; @updates; end |