module PactBroker::Messages

Provides an interface to the I18n library specifically for the PactBroker's messages.

Public Instance Methods

message(key, options={}) click to toggle source

Interpolates an internationalized string. @param [String] key the name of the string to interpolate @param [Hash] options options to pass to I18n, including

variables to interpolate.

@return [String] the interpolated string

# File lib/pact_broker/messages.rb, line 18
def message(key, options={})
  ::I18n.t(key, { :scope => :pact_broker }.merge(options))
end
pluralize(word, count) click to toggle source
# File lib/pact_broker/messages.rb, line 35
def pluralize(word, count)
  if count == 1
    word
  else
    if word.end_with?("y")
      word.chomp("y") + "ies"
    else
      word + "s"
    end
  end
end
potential_duplicate_pacticipant_message(new_name, potential_duplicate_pacticipants, base_url) click to toggle source
# File lib/pact_broker/messages.rb, line 26
def potential_duplicate_pacticipant_message new_name, potential_duplicate_pacticipants, base_url
  existing_names = potential_duplicate_pacticipants.
    collect{ | p | "* #{p.name}"  }.join("\n")
  message("errors.duplicate_pacticipant",
    new_name: new_name,
    existing_names: existing_names,
    create_pacticipant_url: pacticipants_url(base_url))
end
validation_message(key, options = {}) click to toggle source
# File lib/pact_broker/messages.rb, line 22
def validation_message key, options = {}
  message("errors.validation." + key, options)
end

Private Instance Methods

pacticipants_url(base_url) click to toggle source
# File lib/pact_broker/messages.rb, line 49
def pacticipants_url base_url
  PactBroker::Api::PactBrokerUrls.pacticipants_url base_url
end