Sha256: 0a346df8056854c05dbcc3ffbf8db2ff974cff6fc4e62d4b491f6d5e0467bd25

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

module Badger
  class Badger < Array
    attr_reader :github_slug, :owner

    def initialize url
      @url = url
    end

    def github_slug
      @github_slug ||= Badger.slug_extract @url
    end

    def owner
      @owner ||= github_slug.split('/')[0]
    end

    def add service
      if service == 'issues'
        self << Badger.badge('Github Issues', "http://githubbadges.herokuapp.com/#{github_slug}/issues", "https://github.com/#{github_slug}/issues")
      elsif service == 'pulls'
        self << Badger.badge('Pending Pull-Requests', "http://githubbadges.herokuapp.com/#{github_slug}/pulls", "https://github.com/#{github_slug}/pulls")
      else
        self << Service.badge(service, github_slug)
      end
      self.delete nil
    end

    def license type
      self << License.badge(type, owner)
      self.delete nil
    end

    def rubygem name
      self << Rubygem.badge(name)
    end

    def bonus
      self.uniq!
      self << Bonus.badge(self)
    end

    def badge_type type
      Config.instance.config['badge_type'] = type
    end

    def to_s
      self.uniq!

      s = ''
      self.each do |badge|
        s << badge
        s << "\n"
      end

      s
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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