class Travis::CLI::Repos

Public Instance Methods

attributes(repo) click to toggle source
# File lib/travis/cli/repos.rb, line 41
def attributes(repo)
  { "active" => repo.active?, "admin" => repo.admin?, "push" => repo.push?, "pull" => repo.pull? }
end
match?(string) click to toggle source
# File lib/travis/cli/repos.rb, line 45
def match?(string)
  return true if match.nil?
  flags = File::FNM_PATHNAME | File::FNM_DOTMATCH
  flags |= File::FNM_EXTGLOB if defined? File::FNM_EXTGLOB
  File.fnmatch?(match, string, flags)
end
repositories() click to toggle source
# File lib/travis/cli/repos.rb, line 27
def repositories
  @repositories ||= begin
    repos = session.hooks.concat(user.repositories).uniq
    session.preload(repos).sort_by(&:slug).select do |repo|
      next false unless match? repo.slug
      next false unless active.nil? or repo.active?    == active
      next false unless owner.nil?  or repo.owner_name == owner
      next false unless name.nil?   or repo.name       == name
      next false unless admin.nil?  or repo.admin?     == admin
      true
    end
  end
end
run() click to toggle source
# File lib/travis/cli/repos.rb, line 15
def run
  repositories.each do |repo|
    next say(repo.slug) unless interactive?
    state_color = repo.active? ? :green : :yellow
    say color(repo.slug, [:bold, state_color]) + " "
    say color("(" << attributes(repo).map { |n,v| "#{n}: #{v ? "yes" : "no"}" }.join(", ") << ")", state_color)
    description = repo.description.lines.first.chomp unless repo.description.to_s.empty?
    say "Description: #{description || "???"}"
    empty_line unless repo == repositories.last
  end
end