Module: Bwkfanboy::Generator
Instance Method Summary collapse
-
#atom(data) ⇒ Object
- data
-
a hash; see Plugin#pack for the exact format.
- #unpack(stream) ⇒ Object
Instance Method Details
#atom(data) ⇒ Object
- data
-
a hash; see Plugin#pack for the exact format.
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 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/bwkfanboy/generator.rb', line 31 def atom data raise GeneratorException, 'unpacked input is nil' unless data feed = RSS::Maker.make("atom") { |maker| maker.channel.id = data['channel']['id'] maker.channel.updated = data['channel']['updated'] maker.channel. = data['channel']['author'] maker.channel.title = data['channel']['title'] maker.channel.links.new_link {|i| i.href = data['channel']['link'] i.rel = 'alternate' i.type = 'text/html' # eh } maker.items.do_sort = true data['x_entries'].each { |i| maker.items.new_item do |item| item.links.new_link {|k| k.href = i['link'] k.rel = 'alternate' k.type = 'text/html' # only to make happy crappy pr2nntp gateway } item.title = i['title'] item. = i['author'] item.updated = i['updated'] item.content.type = data['channel']['x_entries_content_type'] case item.content.type when 'text' item.content.content = i['content'] when 'html' item.content.content = i['content'] else item.content.xhtml = i['content'] end end } } feed rescue raise GeneratorException, $!.to_s end |
#unpack(stream) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/bwkfanboy/generator.rb', line 22 def unpack stream p = MessagePack::Unpacker.new stream p.each {|i| return i } # p.first or p[0] Messagepack doesn't implement return nil rescue EOFError return nil end |