Class: Travis::CLI::Repos
- Inherits:
-
ApiCommand
- Object
- Command
- ApiCommand
- Travis::CLI::Repos
- Defined in:
- lib/travis/cli/repos.rb
Constant Summary
Constants inherited from Command
Command::DAY, Command::HOUR, Command::MINUTE, Command::WEEK
Constants included from Tools::Assets
Instance Attribute Summary
Attributes inherited from ApiCommand
Attributes inherited from Command
#arguments, #config, #debug, #force_interactive, #formatter, #input, #output
Instance Method Summary collapse
Methods inherited from ApiCommand
#authenticate, #detected_endpoint?, #endpoint_config, #enterprise?, #initialize, #pro?, #setup, #sync
Methods included from Travis::Client::Methods
#access_token, #access_token=, #account, #accounts, #api_endpoint, #api_endpoint=, #artifact, #broadcasts, #build, #cancel, #explicit_api_endpoint?, #github_auth, #hooks, #job, #lint, #listen, #logout, #regenerate_token, #remove_token, #repo, #repos, #restart, #user
Methods inherited from Command
abstract, abstract?, #check_completion, #check_ruby, #check_version, command_name, #command_name, #debug?, description, #error, #execute, #help, #info, #initialize, #last_check, #on_signal, #parse, #say, #setup, skip, subcommands, #terminal, #time, #usage, #usage_for, #warn, #write_to
Methods included from Tools::Assets
Methods included from Parser
Constructor Details
This class inherits a constructor from Travis::CLI::ApiCommand
Instance Method Details
#attributes(repo) ⇒ Object
45 46 47 |
# File 'lib/travis/cli/repos.rb', line 45 def attributes(repo) { 'active' => repo.active?, 'admin' => repo.admin?, 'push' => repo.push?, 'pull' => repo.pull? } end |
#match?(string) ⇒ Boolean
49 50 51 52 53 54 55 |
# File 'lib/travis/cli/repos.rb', line 49 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 ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/travis/cli/repos.rb', line 30 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? || (repo.active? == active) next false unless owner.nil? || (repo.owner_name == owner) next false unless name.nil? || (repo.name == name) next false unless admin.nil? || (repo.admin? == admin) true end end end |
#run ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/travis/cli/repos.rb', line 17 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 |