Sha256: 90f992aecfb7810e956c7f7f078ef7922720c98e1285d731779a92d178e346e6

Contents?: true

Size: 1.06 KB

Versions: 24

Compression:

Stored size: 1.06 KB

Contents

format do
  # turn off autodetection of uri's
  def chunk_list
    :references
  end
end

# format :html do
#   def pointer_items args
#     card.item_names(context: :raw).map do |iname|
#       wrap_item iname, args
#     end
#   end
# end#

format :email_text do
  def email_addresses context
    context ||= self
    card.item_names(context: context.name).map do |name|
      # FIXME: context is processed twice here because pointers absolutize
      # item_names by default while other types can return relative names.
      # That's poor default behavior and should be fixed!
      name = name.to_name.absolute context
      email_address?(name) ? name : email_address_from_card(name, context)
    end.flatten.compact.join(", ")
  end

  def email_address? string
    string =~ /.+@.+\..+/
  end

  def email_address_from_card name, context
    card = Card.fetch name
    card.account&.email || email_addresses_from_card_content(card, context)
  end

  def email_addresses_from_card_content card, context
    subformat(card).contextual_content(context).split(/[,\n]/)
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
card-mod-email-0.18.1 set/abstract/email_field.rb
card-mod-email-0.18.0 set/abstract/email_field.rb
card-mod-email-0.17.0 set/abstract/email_field.rb
card-mod-email-0.16.0 set/abstract/email_field.rb
card-mod-email-0.15.6 set/abstract/email_field.rb
card-mod-email-0.15.5 set/abstract/email_field.rb
card-mod-email-0.15.4 set/abstract/email_field.rb
card-mod-email-0.15.3 set/abstract/email_field.rb
card-mod-email-0.15.2.pre1 set/abstract/email_field.rb
card-mod-email-0.15.1.1 set/abstract/email_field.rb
card-mod-email-0.15.1 set/abstract/email_field.rb
card-mod-email-0.15.0 set/abstract/email_field.rb
card-mod-email-0.14.2 set/abstract/email_field.rb
card-mod-email-0.14.1 set/abstract/email_field.rb
card-mod-email-0.14.0 set/abstract/email_field.rb
card-mod-email-0.13.4 set/abstract/email_field.rb
card-mod-email-0.13.3 set/abstract/email_field.rb
card-mod-email-0.13.2 set/abstract/email_field.rb
card-mod-email-0.13.1 set/abstract/email_field.rb
card-mod-email-0.13.0 set/abstract/email_field.rb