Sha256: a765cbcc878d56de95b6a662b29b498696e06698af20609442f56c5fd89603dc

Contents?: true

Size: 797 Bytes

Versions: 3

Compression:

Stored size: 797 Bytes

Contents

module Badger
  class Service
    def self.badge name, github_slug
      return nil unless params = Config.instance.services[name]
      params = Config.instance.services[name]

      scheme = params['scheme'] ||= 'http'
      case params['offers_svg']
        when true
          base_url = '%s://%s' % [
              scheme,
              params['url_path']
          ]
        else
          base_url = 'http://%s/%s' % [
              Config.instance.config['badge_service'],
              params['badge_slug']
          ]
      end

      badge_url = '%s/%s' % [
          base_url,
          github_slug
      ]
      target_url = 'https://%s/%s' % [
          params['url_path'],
          github_slug
      ]

      Badger.badge params['alt_text'], badge_url, target_url
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
badgerbadgerbadger-0.10.1 lib/badger/service.rb
badgerbadgerbadger-0.10.0 lib/badger/service.rb
badgerbadgerbadger-0.9.0 lib/badger/service.rb