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.79.1 lib/pact_broker/messages.rb
pact_broker-2.79.0 lib/pact_broker/messages.rb
pact_broker-2.78.1 lib/pact_broker/messages.rb
pact_broker-2.78.0 lib/pact_broker/messages.rb
pact_broker-2.77.0 lib/pact_broker/messages.rb
pact_broker-2.76.2 lib/pact_broker/messages.rb
pact_broker-2.76.1 lib/pact_broker/messages.rb
pact_broker-2.76.0 lib/pact_broker/messages.rb
pact_broker-2.75.0 lib/pact_broker/messages.rb
pact_broker-2.74.1 lib/pact_broker/messages.rb
pact_broker-2.74.0 lib/pact_broker/messages.rb
pact_broker-2.73.0 lib/pact_broker/messages.rb
pact_broker-2.72.0 lib/pact_broker/messages.rb
pact_broker-2.71.0 lib/pact_broker/messages.rb
pact_broker-2.70.0 lib/pact_broker/messages.rb
pact_broker-2.69.0 lib/pact_broker/messages.rb
pact_broker-2.68.1 lib/pact_broker/messages.rb
pact_broker-2.68.0 lib/pact_broker/messages.rb
pact_broker-2.67.0 lib/pact_broker/messages.rb
pact_broker-2.66.0 lib/pact_broker/messages.rb