Class: Xezat::Cygchangelog
- Inherits:
-
Object
- Object
- Xezat::Cygchangelog
- Defined in:
- lib/xezat/cygchangelog.rb
Overview
package の changelog を管理するクラス
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(str = '') ⇒ Cygchangelog
constructor
A new instance of Cygchangelog.
- #key?(key) ⇒ Boolean
Constructor Details
#initialize(str = '') ⇒ Cygchangelog
Returns a new instance of Cygchangelog.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/xezat/cygchangelog.rb', line 6 def initialize(str = '') @changelogs = str.empty? ? {} : nil version = nil str.each_line do |line| line.rstrip! if /^Port Notes:$/ === line @changelogs = {} else unless @changelogs.nil? if match_data = /^----- version (.+) -----$/.match(line) version = match_data[1].intern else if match_data = /^(.+)$/.match(line) raise ReadmeSyntaxException, "Version missing" if version.nil? if @changelogs.key?(version) @changelogs[version] << $/ << match_data[1] else @changelogs[version] = match_data[1] end end end end end end end |
Instance Method Details
#[](key) ⇒ Object
32 33 34 |
# File 'lib/xezat/cygchangelog.rb', line 32 def [](key) @changelogs[key] end |
#[]=(key, value) ⇒ Object
36 37 38 |
# File 'lib/xezat/cygchangelog.rb', line 36 def []=(key, value) @changelogs[key] = value end |
#each(&block) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/xezat/cygchangelog.rb', line 44 def each(&block) @changelogs.sort do |a, b| -(Cygversion.new(a[0].to_s) <=> Cygversion.new(b[0].to_s)) end.each do |k, v| block.call(k, v) end end |
#key?(key) ⇒ Boolean
40 41 42 |
# File 'lib/xezat/cygchangelog.rb', line 40 def key?(key) @changelogs.key?(key) end |