Sha256: 030b1abd35e761c91d76262d7483396b6d095739f295299c5976e43f46305162

Contents?: true

Size: 1.23 KB

Versions: 160

Compression:

Stored size: 1.23 KB

Contents

require 'i18n'
require 'pact_broker/api/pact_broker_urls'

I18n.config.load_path << File.expand_path("../locale/en.yml", __FILE__)

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

    extend self

    # 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
    def message(key, options={})
      ::I18n.t(key, options.merge(:scope => :pact_broker))
    end

    def validation_message key, options = {}
      message('errors.validation.' + key, options)
    end

    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

    private

    def pacticipants_url base_url
      PactBroker::Api::PactBrokerUrls.pacticipants_url base_url
    end
  end
end

Version data entries

160 entries across 160 versions & 1 rubygems

Version Path
pact_broker-2.65.0 lib/pact_broker/messages.rb
pact_broker-2.64.0 lib/pact_broker/messages.rb
pact_broker-2.63.0 lib/pact_broker/messages.rb
pact_broker-2.62.0 lib/pact_broker/messages.rb
pact_broker-2.61.0 lib/pact_broker/messages.rb
pact_broker-2.60.1 lib/pact_broker/messages.rb
pact_broker-2.60.0 lib/pact_broker/messages.rb
pact_broker-2.59.2 lib/pact_broker/messages.rb
pact_broker-2.59.1 lib/pact_broker/messages.rb
pact_broker-2.59.0 lib/pact_broker/messages.rb
pact_broker-2.58.3 lib/pact_broker/messages.rb
pact_broker-2.58.2 lib/pact_broker/messages.rb
pact_broker-2.58.0 lib/pact_broker/messages.rb
pact_broker-2.57.0 lib/pact_broker/messages.rb
pact_broker-2.56.1 lib/pact_broker/messages.rb
pact_broker-2.56.0 lib/pact_broker/messages.rb
pact_broker-2.55.0 lib/pact_broker/messages.rb
pact_broker-2.54.0 lib/pact_broker/messages.rb
pact_broker-2.53.0 lib/pact_broker/messages.rb
pact_broker-2.52.2 lib/pact_broker/messages.rb