class HornOfPlenty::Adapters::Github::Parsers::Card
Attributes
raw[RW]
Public Class Methods
new(raw:)
click to toggle source
# File lib/horn_of_plenty/adapters/github/parsers/card.rb, line 17 def initialize(raw:) self.raw = raw end
to_model(raw_item)
click to toggle source
# File lib/horn_of_plenty/adapters/github/parsers/card.rb, line 81 def self.to_model(raw_item) return NullObjects::Card.instance unless raw_item Models::Card.from_parser(parser: new(raw: raw_item)) end
Public Instance Methods
content_id()
click to toggle source
# File lib/horn_of_plenty/adapters/github/parsers/card.rb, line 53 def content_id @content_id ||= parse_text(raw, 'content_url') do |url| url.match(%r{\A.*/(\d+)\z})[1] end end
content_type()
click to toggle source
# File lib/horn_of_plenty/adapters/github/parsers/card.rb, line 39 def content_type @content_type ||= parse_text(raw, 'content_url', yield_if_nil: true) do |url| if url CoreExt::String.singularize( CoreExt::String.camelize(url.match(%r{\A.*/(.*?)/\d+\z})[1]), ) else 'Note' end end end
created_at()
click to toggle source
# File lib/horn_of_plenty/adapters/github/parsers/card.rb, line 73 def created_at @created_at ||= parse_time(raw, 'created_at') end
description()
click to toggle source
# File lib/horn_of_plenty/adapters/github/parsers/card.rb, line 65 def description @description ||= parse_text(raw, 'note') do |note| match = note.delete("\r").match(/\A.*?(?:\n)+(.*)/m) match[1] if match end end
id()
click to toggle source
# File lib/horn_of_plenty/adapters/github/parsers/card.rb, line 21 def id @id ||= parse_text(raw, 'id') end
lane_id()
click to toggle source
# File lib/horn_of_plenty/adapters/github/parsers/card.rb, line 25 def lane_id @lane_id ||= parse_text(raw, 'column_url') do |url| url.match(%r{\A.*/(\d+)\z})[1] end end
repository()
click to toggle source
# File lib/horn_of_plenty/adapters/github/parsers/card.rb, line 31 def repository @repository ||= parse_text(raw, 'column_url') do |url| repo_name = url.match(%r{\A.*/repos/((?:[^/]+/){2}).*\z})[1] repo_name && repo_name[0..-2] end end
title()
click to toggle source
# File lib/horn_of_plenty/adapters/github/parsers/card.rb, line 59 def title @title ||= parse_text(raw, 'note') do |note| note.delete("\r").match(/\A(.*)$/)[1] end end
updated_at()
click to toggle source
# File lib/horn_of_plenty/adapters/github/parsers/card.rb, line 77 def updated_at @updated_at ||= parse_time(raw, 'updated_at') end