Class: Milestoner::Syndication::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/milestoner/syndication/builder.rb

Overview

Builds feed in Atom format. :reek:DataClump

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client: RSS::Maker, view: Views::Milestones::Show.new) ⇒ Builder

Returns a new instance of Builder.



23
24
25
26
27
# File 'lib/milestoner/syndication/builder.rb', line 23

def initialize(client: RSS::Maker, view: Views::Milestones::Show.new, **)
  super(**)
  @client = client
  @view = view
end

Class Method Details

.authors_for(tags) ⇒ Object



17
18
19
20
21
# File 'lib/milestoner/syndication/builder.rb', line 17

def self.authors_for tags
  tags.flat_map { |tag| tag.commits.map(&:author) }
      .then { |users| users.any? ? users : tags.map(&:author) }
      .uniq
end

Instance Method Details

#call(tags) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/milestoner/syndication/builder.rb', line 29

def call tags
  return Failure "No tags or commits." if tags.empty?

  Success build_feed(tags).to_s
rescue NoMethodError, RSS::Error => error
  Failure "#{self.class}: #{error.message.capitalize}."
end